From 896978ac28b9acac8c9936e0756f07161ee936c3 Mon Sep 17 00:00:00 2001 From: aminecmi Date: Sun, 12 Jul 2015 15:49:17 +0200 Subject: [PATCH] screen and text --- .../amine/myterio/app/DetailsActivity.java | 32 +++- .../com/amine/myterio/app/MainActivity.java | 6 + .../myterio/app/adapters/CitiesAdapter.java | 38 ++++- .../com/amine/myterio/app/db/CityDAO.java | 11 ++ .../res/layout-large/activity_details.xml | 45 ++++++ .../main/res/layout-large/activity_main.xml | 25 +++ .../activity_search.xml} | 21 ++- .../main/res/layout-large/city_card_view.xml | 144 ++++++++++++++++++ app/src/main/res/layout-large/detail_item.xml | 20 +++ .../res/layout-normal/activity_details.xml | 45 ++++++ .../main/res/layout-normal/activity_main.xml | 25 +++ .../res/layout-normal/activity_search.xml | 27 ++++ .../main/res/layout-normal/city_card_view.xml | 143 +++++++++++++++++ .../main/res/layout-normal/detail_item.xml | 20 +++ .../res/layout-small/activity_details.xml | 47 ++++++ .../main/res/layout-small/activity_main.xml | 25 +++ .../main/res/layout-small/activity_search.xml | 27 ++++ .../main/res/layout-small/city_card_view.xml | 143 +++++++++++++++++ app/src/main/res/layout-small/detail_item.xml | 20 +++ .../res/layout-xlarge/activity_details.xml | 45 ++++++ .../main/res/layout-xlarge/activity_main.xml | 25 +++ .../res/layout-xlarge/activity_search.xml | 27 ++++ .../main/res/layout-xlarge/city_card_view.xml | 143 +++++++++++++++++ .../main/res/layout-xlarge/detail_item.xml | 20 +++ app/src/main/res/layout/activity_details.xml | 9 ++ app/src/main/res/values-en/strings.xml | 4 + app/src/main/res/values-small/dimens.xml | 5 + app/src/main/res/values-xlarge/dimens.xml | 5 + app/src/main/res/values/strings.xml | 4 + 29 files changed, 1143 insertions(+), 8 deletions(-) create mode 100644 app/src/main/res/layout-large/activity_details.xml create mode 100644 app/src/main/res/layout-large/activity_main.xml rename app/src/main/res/{layout/fragment_main.xml => layout-large/activity_search.xml} (50%) create mode 100644 app/src/main/res/layout-large/city_card_view.xml create mode 100644 app/src/main/res/layout-large/detail_item.xml create mode 100644 app/src/main/res/layout-normal/activity_details.xml create mode 100644 app/src/main/res/layout-normal/activity_main.xml create mode 100644 app/src/main/res/layout-normal/activity_search.xml create mode 100644 app/src/main/res/layout-normal/city_card_view.xml create mode 100644 app/src/main/res/layout-normal/detail_item.xml create mode 100644 app/src/main/res/layout-small/activity_details.xml create mode 100644 app/src/main/res/layout-small/activity_main.xml create mode 100644 app/src/main/res/layout-small/activity_search.xml create mode 100644 app/src/main/res/layout-small/city_card_view.xml create mode 100644 app/src/main/res/layout-small/detail_item.xml create mode 100644 app/src/main/res/layout-xlarge/activity_details.xml create mode 100644 app/src/main/res/layout-xlarge/activity_main.xml create mode 100644 app/src/main/res/layout-xlarge/activity_search.xml create mode 100644 app/src/main/res/layout-xlarge/city_card_view.xml create mode 100644 app/src/main/res/layout-xlarge/detail_item.xml create mode 100644 app/src/main/res/values-small/dimens.xml create mode 100644 app/src/main/res/values-xlarge/dimens.xml diff --git a/app/src/main/java/com/amine/myterio/app/DetailsActivity.java b/app/src/main/java/com/amine/myterio/app/DetailsActivity.java index 25fbc1d..a5853c7 100644 --- a/app/src/main/java/com/amine/myterio/app/DetailsActivity.java +++ b/app/src/main/java/com/amine/myterio/app/DetailsActivity.java @@ -6,6 +6,7 @@ import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.Menu; import android.view.MenuItem; +import android.view.View; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; @@ -13,14 +14,18 @@ import com.amine.myterio.app.adapters.ForecastAdapter; import com.amine.myterio.app.api.WeatherAdapters; import com.amine.myterio.app.api.WeatherApis; import com.amine.myterio.app.config.Config; +import com.amine.myterio.app.db.CityDAO; import com.amine.myterio.app.model.City; import com.amine.myterio.app.model.Forecast; +import com.melnykov.fab.FloatingActionButton; import retrofit.Callback; import retrofit.RetrofitError; import retrofit.client.Response; public class DetailsActivity extends AppCompatActivity { + static boolean isFav = true; + static FloatingActionButton fab; @Override protected void onCreate(Bundle savedInstanceState) { @@ -36,8 +41,10 @@ public class DetailsActivity extends AppCompatActivity { list.setLayoutManager(layoutManager); list.setHasFixedSize(true); - + CityDAO dao = CityDAO.getInstance(this); if (cityName != null) { + + isFav = dao.getCity(cityName) != null; WeatherApis.WeatherDailyForecastLocationApi s = adapters.getWeatherForecastLocationAdapter(); s.cityForecast(cityName, Config.country, new Callback() { @@ -70,6 +77,7 @@ public class DetailsActivity extends AppCompatActivity { } else { City city = getIntent().getExtras().getParcelable("city"); cityName = city.getName(); + isFav = dao.getCity(city.getCityIdentifier()) != null; WeatherApis.WeatherDailyForecastApi s = adapters.getWeatherForecastAdapter(); s.cityForecast(city.getCityIdentifier(), Config.country, new Callback() { @@ -86,7 +94,7 @@ public class DetailsActivity extends AppCompatActivity { }); WeatherApis.WeatherCityApi sWeather = adapters.getWeatherCityAdapter(); - sWeather.cityWeather(city.getCityIdentifier(), new Callback() { + sWeather.cityWeather(city.getCityIdentifier(), Config.country, new Callback() { @Override public void success(City c, Response response) { ImageView image = (ImageView) findViewById(R.id.weatherImage); @@ -102,6 +110,26 @@ public class DetailsActivity extends AppCompatActivity { TextView name = (TextView) findViewById(R.id.cityName); name.setText(cityName); + + fab = (FloatingActionButton) findViewById(R.id.fab); + if (isFav) { + fab.setImageResource(R.mipmap.ic_favorite_border_black_24dp); + } else { + fab.setImageResource(R.mipmap.ic_favorite_black_24dp); + } + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + CityDAO dao = CityDAO.getInstance(DetailsActivity.this); + if (DetailsActivity.isFav) { + dao.deleteCity(f[0].getCity()); + fab.setImageResource(R.mipmap.ic_favorite_black_24dp); + } else { + dao.insertCity(f[0].getCity()); + fab.setImageResource(R.mipmap.ic_favorite_border_black_24dp); + } + } + }); } diff --git a/app/src/main/java/com/amine/myterio/app/MainActivity.java b/app/src/main/java/com/amine/myterio/app/MainActivity.java index c14599c..b1b4a3d 100644 --- a/app/src/main/java/com/amine/myterio/app/MainActivity.java +++ b/app/src/main/java/com/amine/myterio/app/MainActivity.java @@ -29,6 +29,12 @@ public class MainActivity extends AppCompatActivity { handleView(); } + @Override + protected void onResume() { + super.onResume(); + handleView(); + } + private void saveUserCountry() { TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); Config.country = tm.getSimCountryIso().toLowerCase(); diff --git a/app/src/main/java/com/amine/myterio/app/adapters/CitiesAdapter.java b/app/src/main/java/com/amine/myterio/app/adapters/CitiesAdapter.java index 20fffb3..9c13ca3 100644 --- a/app/src/main/java/com/amine/myterio/app/adapters/CitiesAdapter.java +++ b/app/src/main/java/com/amine/myterio/app/adapters/CitiesAdapter.java @@ -1,7 +1,9 @@ package com.amine.myterio.app.adapters; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; +import android.support.v7.app.AlertDialog; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; @@ -14,6 +16,7 @@ import com.amine.myterio.app.R; import com.amine.myterio.app.api.WeatherAdapters; import com.amine.myterio.app.api.WeatherApis; import com.amine.myterio.app.config.Config; +import com.amine.myterio.app.db.CityDAO; import com.amine.myterio.app.model.City; import retrofit.Callback; import retrofit.RetrofitError; @@ -33,6 +36,12 @@ public class CitiesAdapter extends RecyclerView.Adapter + + + + + + + + + + diff --git a/app/src/main/res/layout-large/activity_main.xml b/app/src/main/res/layout-large/activity_main.xml new file mode 100644 index 0000000..5f346aa --- /dev/null +++ b/app/src/main/res/layout-large/activity_main.xml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/app/src/main/res/layout/fragment_main.xml b/app/src/main/res/layout-large/activity_search.xml similarity index 50% rename from app/src/main/res/layout/fragment_main.xml rename to app/src/main/res/layout-large/activity_search.xml index 6183458..5591c63 100644 --- a/app/src/main/res/layout/fragment_main.xml +++ b/app/src/main/res/layout-large/activity_search.xml @@ -2,15 +2,26 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" - android:paddingBottom="@dimen/activity_vertical_margin" - tools:context=".MainActivity$PlaceholderFragment"> + tools:context="com.amine.myterio.app.SearchActivity"> - + android:layout_height="100dp" + android:layout_alignParentEnd="true" + android:layout_alignParentRight="true" + android:layout_alignParentTop="true"/> + + diff --git a/app/src/main/res/layout-large/city_card_view.xml b/app/src/main/res/layout-large/city_card_view.xml new file mode 100644 index 0000000..3f503c7 --- /dev/null +++ b/app/src/main/res/layout-large/city_card_view.xml @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-large/detail_item.xml b/app/src/main/res/layout-large/detail_item.xml new file mode 100644 index 0000000..d1bed9d --- /dev/null +++ b/app/src/main/res/layout-large/detail_item.xml @@ -0,0 +1,20 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-normal/activity_details.xml b/app/src/main/res/layout-normal/activity_details.xml new file mode 100644 index 0000000..7ec40f4 --- /dev/null +++ b/app/src/main/res/layout-normal/activity_details.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + diff --git a/app/src/main/res/layout-normal/activity_main.xml b/app/src/main/res/layout-normal/activity_main.xml new file mode 100644 index 0000000..5f346aa --- /dev/null +++ b/app/src/main/res/layout-normal/activity_main.xml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/app/src/main/res/layout-normal/activity_search.xml b/app/src/main/res/layout-normal/activity_search.xml new file mode 100644 index 0000000..b691300 --- /dev/null +++ b/app/src/main/res/layout-normal/activity_search.xml @@ -0,0 +1,27 @@ + + + + + + + diff --git a/app/src/main/res/layout-normal/city_card_view.xml b/app/src/main/res/layout-normal/city_card_view.xml new file mode 100644 index 0000000..8056549 --- /dev/null +++ b/app/src/main/res/layout-normal/city_card_view.xml @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-normal/detail_item.xml b/app/src/main/res/layout-normal/detail_item.xml new file mode 100644 index 0000000..d1bed9d --- /dev/null +++ b/app/src/main/res/layout-normal/detail_item.xml @@ -0,0 +1,20 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-small/activity_details.xml b/app/src/main/res/layout-small/activity_details.xml new file mode 100644 index 0000000..0d8f83a --- /dev/null +++ b/app/src/main/res/layout-small/activity_details.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + diff --git a/app/src/main/res/layout-small/activity_main.xml b/app/src/main/res/layout-small/activity_main.xml new file mode 100644 index 0000000..5f346aa --- /dev/null +++ b/app/src/main/res/layout-small/activity_main.xml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/app/src/main/res/layout-small/activity_search.xml b/app/src/main/res/layout-small/activity_search.xml new file mode 100644 index 0000000..b691300 --- /dev/null +++ b/app/src/main/res/layout-small/activity_search.xml @@ -0,0 +1,27 @@ + + + + + + + diff --git a/app/src/main/res/layout-small/city_card_view.xml b/app/src/main/res/layout-small/city_card_view.xml new file mode 100644 index 0000000..918332e --- /dev/null +++ b/app/src/main/res/layout-small/city_card_view.xml @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-small/detail_item.xml b/app/src/main/res/layout-small/detail_item.xml new file mode 100644 index 0000000..d1bed9d --- /dev/null +++ b/app/src/main/res/layout-small/detail_item.xml @@ -0,0 +1,20 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-xlarge/activity_details.xml b/app/src/main/res/layout-xlarge/activity_details.xml new file mode 100644 index 0000000..7a702f1 --- /dev/null +++ b/app/src/main/res/layout-xlarge/activity_details.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + diff --git a/app/src/main/res/layout-xlarge/activity_main.xml b/app/src/main/res/layout-xlarge/activity_main.xml new file mode 100644 index 0000000..5f346aa --- /dev/null +++ b/app/src/main/res/layout-xlarge/activity_main.xml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/app/src/main/res/layout-xlarge/activity_search.xml b/app/src/main/res/layout-xlarge/activity_search.xml new file mode 100644 index 0000000..5591c63 --- /dev/null +++ b/app/src/main/res/layout-xlarge/activity_search.xml @@ -0,0 +1,27 @@ + + + + + + + diff --git a/app/src/main/res/layout-xlarge/city_card_view.xml b/app/src/main/res/layout-xlarge/city_card_view.xml new file mode 100644 index 0000000..4c18132 --- /dev/null +++ b/app/src/main/res/layout-xlarge/city_card_view.xml @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-xlarge/detail_item.xml b/app/src/main/res/layout-xlarge/detail_item.xml new file mode 100644 index 0000000..d1bed9d --- /dev/null +++ b/app/src/main/res/layout-xlarge/detail_item.xml @@ -0,0 +1,20 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_details.xml b/app/src/main/res/layout/activity_details.xml index a055687..7ec40f4 100644 --- a/app/src/main/res/layout/activity_details.xml +++ b/app/src/main/res/layout/activity_details.xml @@ -33,4 +33,13 @@ android:layout_centerHorizontal="true" android:layout_marginTop="37dp"/> + + diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index ebc8785..b46a931 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -6,4 +6,8 @@ DetailsActivity This location dosn\'t have any weather. Can\'t get the weather from the API. + Cancel + Delete + Do you want to delete this location ? + Delete the location ? diff --git a/app/src/main/res/values-small/dimens.xml b/app/src/main/res/values-small/dimens.xml new file mode 100644 index 0000000..d1273d3 --- /dev/null +++ b/app/src/main/res/values-small/dimens.xml @@ -0,0 +1,5 @@ + + + 4dp + 4dp + diff --git a/app/src/main/res/values-xlarge/dimens.xml b/app/src/main/res/values-xlarge/dimens.xml new file mode 100644 index 0000000..9f53ad0 --- /dev/null +++ b/app/src/main/res/values-xlarge/dimens.xml @@ -0,0 +1,5 @@ + + + 36dp + 36dp + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ee365a7..e137b8b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -6,4 +6,8 @@ DetailsActivity Pas de prévisions pour cette ville. Erreur lors de la récupération des prévisions + Voulez-vous vraiment supprimer cette ville ? + Supprimer la ville? + Supprimer + Annuler