final
This commit is contained in:
parent
84a4ad3bfe
commit
d2354ce685
@ -1,9 +1,11 @@
|
|||||||
package com.amine.myterio.app;
|
package com.amine.myterio.app;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.Window;
|
||||||
import com.melnykov.fab.FloatingActionButton;
|
import com.melnykov.fab.FloatingActionButton;
|
||||||
|
|
||||||
|
|
||||||
@ -34,7 +36,14 @@ public class DetailsActivity extends AppCompatActivity {
|
|||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
|
|
||||||
//noinspection SimplifiableIfStatement
|
//noinspection SimplifiableIfStatement
|
||||||
if (id == R.id.action_settings) {
|
if (id == R.id.action_about) {
|
||||||
|
final Dialog dialog = new Dialog(this);
|
||||||
|
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
dialog.setCancelable(true);
|
||||||
|
|
||||||
|
// Content of the dialog
|
||||||
|
dialog.setContentView(R.layout.activity_more);
|
||||||
|
dialog.show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (id == android.R.id.home) {
|
if (id == android.R.id.home) {
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
package com.amine.myterio.app;
|
package com.amine.myterio.app;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.Window;
|
||||||
|
import com.amine.myterio.app.config.Config;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
@ -12,6 +17,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
Config.country = Locale.getDefault().getLanguage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -29,7 +35,14 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
|
|
||||||
//noinspection SimplifiableIfStatement
|
//noinspection SimplifiableIfStatement
|
||||||
if (id == R.id.action_settings) {
|
if (id == R.id.action_about) {
|
||||||
|
final Dialog dialog = new Dialog(this);
|
||||||
|
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
dialog.setCancelable(true);
|
||||||
|
|
||||||
|
// Content of the dialog
|
||||||
|
dialog.setContentView(R.layout.activity_more);
|
||||||
|
dialog.show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package com.amine.myterio.app;
|
package com.amine.myterio.app;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.Window;
|
||||||
|
|
||||||
|
|
||||||
public class SearchActivity extends AppCompatActivity {
|
public class SearchActivity extends AppCompatActivity {
|
||||||
@ -31,7 +33,14 @@ public class SearchActivity extends AppCompatActivity {
|
|||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
|
|
||||||
//noinspection SimplifiableIfStatement
|
//noinspection SimplifiableIfStatement
|
||||||
if (id == R.id.action_settings) {
|
if (id == R.id.action_about) {
|
||||||
|
final Dialog dialog = new Dialog(this);
|
||||||
|
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
dialog.setCancelable(true);
|
||||||
|
|
||||||
|
// Content of the dialog
|
||||||
|
dialog.setContentView(R.layout.activity_more);
|
||||||
|
dialog.show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,19 +2,16 @@ package com.amine.myterio.app.fragments;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.telephony.TelephonyManager;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import com.amine.myterio.app.R;
|
import com.amine.myterio.app.R;
|
||||||
import com.amine.myterio.app.SearchActivity;
|
import com.amine.myterio.app.SearchActivity;
|
||||||
import com.amine.myterio.app.adapters.CitiesAdapter;
|
import com.amine.myterio.app.adapters.CitiesAdapter;
|
||||||
import com.amine.myterio.app.config.Config;
|
|
||||||
import com.amine.myterio.app.db.CityDAO;
|
import com.amine.myterio.app.db.CityDAO;
|
||||||
import com.amine.myterio.app.model.City;
|
import com.amine.myterio.app.model.City;
|
||||||
import com.melnykov.fab.FloatingActionButton;
|
import com.melnykov.fab.FloatingActionButton;
|
||||||
@ -48,9 +45,7 @@ public class CitiesListFragment extends Fragment {
|
|||||||
handleView();
|
handleView();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleView() {
|
public void handleView() {
|
||||||
saveUserCountry();
|
|
||||||
|
|
||||||
RecyclerView.LayoutManager layoutManager;
|
RecyclerView.LayoutManager layoutManager;
|
||||||
layoutManager = new LinearLayoutManager(mActivity);
|
layoutManager = new LinearLayoutManager(mActivity);
|
||||||
|
|
||||||
@ -75,12 +70,4 @@ public class CitiesListFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void saveUserCountry() {
|
|
||||||
TelephonyManager tm = (TelephonyManager) mActivity.getSystemService(Context.TELEPHONY_SERVICE);
|
|
||||||
Config.country = tm.getSimCountryIso().toLowerCase();
|
|
||||||
if (Config.country == null || Config.country.equals("") || Config.country.isEmpty())
|
|
||||||
Config.country = mActivity.getResources().getConfiguration().locale.getCountry().toLowerCase();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.amine.myterio.app.fragments;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
@ -139,9 +140,32 @@ public class DetailsFragment extends Fragment {
|
|||||||
if (isFav) {
|
if (isFav) {
|
||||||
dao.deleteCity(f[0].getCity());
|
dao.deleteCity(f[0].getCity());
|
||||||
fab.setImageResource(R.mipmap.ic_favorite_black_24dp);
|
fab.setImageResource(R.mipmap.ic_favorite_black_24dp);
|
||||||
|
if (((getActivity().getResources().getConfiguration().screenLayout &
|
||||||
|
Configuration.SCREENLAYOUT_SIZE_MASK) ==
|
||||||
|
Configuration.SCREENLAYOUT_SIZE_LARGE) || ((getActivity().getResources().getConfiguration().screenLayout &
|
||||||
|
Configuration.SCREENLAYOUT_SIZE_MASK) ==
|
||||||
|
Configuration.SCREENLAYOUT_SIZE_XLARGE) || ((getActivity().getResources().getConfiguration().screenLayout &
|
||||||
|
Configuration.SCREENLAYOUT_SIZE_MASK) ==
|
||||||
|
4)) {
|
||||||
|
CitiesListFragment f = (CitiesListFragment) getFragmentManager().findFragmentByTag("cities_list_frag");
|
||||||
|
if (f != null)
|
||||||
|
f.handleView();
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
dao.insertCity(f[0].getCity());
|
dao.insertCity(f[0].getCity());
|
||||||
fab.setImageResource(R.mipmap.ic_favorite_border_black_24dp);
|
fab.setImageResource(R.mipmap.ic_favorite_border_black_24dp);
|
||||||
|
if (((getActivity().getResources().getConfiguration().screenLayout &
|
||||||
|
Configuration.SCREENLAYOUT_SIZE_MASK) ==
|
||||||
|
Configuration.SCREENLAYOUT_SIZE_LARGE) || ((getActivity().getResources().getConfiguration().screenLayout &
|
||||||
|
Configuration.SCREENLAYOUT_SIZE_MASK) ==
|
||||||
|
Configuration.SCREENLAYOUT_SIZE_XLARGE) || ((getActivity().getResources().getConfiguration().screenLayout &
|
||||||
|
Configuration.SCREENLAYOUT_SIZE_MASK) ==
|
||||||
|
4)) {
|
||||||
|
CitiesListFragment f = (CitiesListFragment) getFragmentManager().findFragmentByTag("cities_list_frag");
|
||||||
|
if (f != null)
|
||||||
|
f.handleView();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:layout_weight=".4"
|
android:layout_weight=".4"
|
||||||
|
android:tag="cities_list_frag"
|
||||||
tools:layout="@layout/cities_list_fragment"/>
|
tools:layout="@layout/cities_list_fragment"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:layout_weight=".4"
|
android:layout_weight=".4"
|
||||||
|
android:tag="cities_list_frag"
|
||||||
tools:layout="@layout/cities_list_fragment"/>
|
tools:layout="@layout/cities_list_fragment"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
37
app/src/main/res/layout/activity_more.xml
Normal file
37
app/src/main/res/layout/activity_more.xml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/colorAccent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="10dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView4"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:text="@string/libraries"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
|
android:textColor="@color/colorPrimary"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView7"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:autoLink="web"
|
||||||
|
android:text="https://github.com/makovkastar/FloatingActionButton"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView8"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:autoLink="web"
|
||||||
|
android:text="http://square.github.io/retrofit/"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -3,8 +3,8 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:context="com.amine.myterio.app.DetailsActivity">
|
tools:context="com.amine.myterio.app.DetailsActivity">
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_settings"
|
android:id="@+id/action_about"
|
||||||
android:orderInCategory="100"
|
android:orderInCategory="100"
|
||||||
android:title="@string/action_settings"
|
android:title="@string/action_about"
|
||||||
app:showAsAction="never"/>
|
app:showAsAction="never"/>
|
||||||
</menu>
|
</menu>
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:context=".MainActivity">
|
tools:context=".MainActivity">
|
||||||
<item android:id="@+id/action_settings"
|
<item
|
||||||
android:title="@string/action_settings"
|
android:id="@+id/action_about"
|
||||||
android:orderInCategory="100"
|
android:orderInCategory="100"
|
||||||
|
android:title="@string/action_about"
|
||||||
app:showAsAction="never"/>
|
app:showAsAction="never"/>
|
||||||
</menu>
|
</menu>
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:context="com.amine.myterio.app.SearchActivity">
|
tools:context="com.amine.myterio.app.SearchActivity">
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_settings"
|
android:id="@+id/action_about"
|
||||||
android:orderInCategory="100"
|
android:orderInCategory="100"
|
||||||
android:title="@string/action_settings"
|
android:title="@string/action_about"
|
||||||
app:showAsAction="never"/>
|
app:showAsAction="never"/>
|
||||||
</menu>
|
</menu>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Myterio</string>
|
<string name="app_name">Myterio</string>
|
||||||
<string name="hello_world">Hello world!</string>
|
<string name="hello_world">Hello world!</string>
|
||||||
<string name="action_settings">Settings</string>
|
<string name="action_about">About</string>
|
||||||
<string name="title_activity_search">Search</string>
|
<string name="title_activity_search">Search</string>
|
||||||
<string name="title_activity_details">Details</string>
|
<string name="title_activity_details">Details</string>
|
||||||
<string name="weather_not_available">This location dosn\'t have any weather.</string>
|
<string name="weather_not_available">This location dosn\'t have any weather.</string>
|
||||||
@ -11,4 +11,5 @@
|
|||||||
<string name="message_remove_from_favs">Do you want to delete this location ?</string>
|
<string name="message_remove_from_favs">Do you want to delete this location ?</string>
|
||||||
<string name="title_remove_from_favs">Delete the location ?</string>
|
<string name="title_remove_from_favs">Delete the location ?</string>
|
||||||
<string name="country_list_error">Error while getting the countires list</string>
|
<string name="country_list_error">Error while getting the countires list</string>
|
||||||
|
<string name="libraries">Libraries</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Myterio</string>
|
<string name="app_name">Myterio</string>
|
||||||
<string name="hello_world">Hello world!</string>
|
<string name="hello_world">Hello world!</string>
|
||||||
<string name="action_settings">Paramètres</string>
|
<string name="action_about">à propos</string>
|
||||||
<string name="title_activity_search">Rechercher</string>
|
<string name="title_activity_search">Rechercher</string>
|
||||||
<string name="title_activity_details">Détails</string>
|
<string name="title_activity_details">Détails</string>
|
||||||
<string name="weather_not_available">Pas de prévisions pour cette ville.</string>
|
<string name="weather_not_available">Pas de prévisions pour cette ville.</string>
|
||||||
@ -11,4 +11,5 @@
|
|||||||
<string name="delete">Supprimer</string>
|
<string name="delete">Supprimer</string>
|
||||||
<string name="cancel">Annuler</string>
|
<string name="cancel">Annuler</string>
|
||||||
<string name="country_list_error">Erreur lors de la récupération des pays</string>
|
<string name="country_list_error">Erreur lors de la récupération des pays</string>
|
||||||
|
<string name="libraries">Librairies</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user