diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java index 4e2bfbc..7f3ca41 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java @@ -6,6 +6,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; +import android.preference.PreferenceFragment; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.design.widget.BottomNavigationView; @@ -28,6 +29,7 @@ import org.communiquons.android.comunic.client.ui.fragments.ConversationFragment import org.communiquons.android.comunic.client.ui.fragments.ConversationsListFragment; import org.communiquons.android.comunic.client.ui.fragments.FriendsListFragment; import org.communiquons.android.comunic.client.ui.fragments.NotificationsFragment; +import org.communiquons.android.comunic.client.ui.fragments.SettingsFragment; import org.communiquons.android.comunic.client.ui.fragments.UpdateConversationFragment; import org.communiquons.android.comunic.client.ui.fragments.UserInfosFragment; import org.communiquons.android.comunic.client.ui.fragments.UserPageFragment; @@ -162,6 +164,12 @@ public class MainActivity extends AppCompatActivity return true; } + //To open settings fragment + if(id == R.id.action_settings){ + openSettingsFragment(); + return true; + } + //Check for logout request if(id == R.id.action_logout){ confirmUserLogout(); @@ -271,6 +279,17 @@ public class MainActivity extends AppCompatActivity } + /** + * Open settings fragment + */ + void openSettingsFragment(){ + SettingsFragment settingsFragment = new SettingsFragment(); + FragmentTransaction transaction = getFragmentManager().beginTransaction(); + transaction.replace(R.id.main_fragment, settingsFragment); + transaction.addToBackStack(null); + transaction.commit(); + } + /** * Open notifications fragment */ diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/SettingsFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/SettingsFragment.java new file mode 100644 index 0000000..1d62c63 --- /dev/null +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/SettingsFragment.java @@ -0,0 +1,38 @@ +package org.communiquons.android.comunic.client.ui.fragments; + +import android.os.Bundle; +import android.preference.PreferenceFragment; +import android.support.annotation.Nullable; + +import org.communiquons.android.comunic.client.R; +import org.communiquons.android.comunic.client.ui.activities.MainActivity; + +/** + * Application preferences fragment + * + * @author Pierre HUBERT + * Created by pierre on 4/8/18. + */ + +public class SettingsFragment extends PreferenceFragment { + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + //Load the preferences from an XML resource + addPreferencesFromResource(R.xml.app_preferences); + } + + @Override + public void onResume() { + super.onResume(); + + //Update the title + getActivity().setTitle(R.string.fragment_settings_title); + + //Update the bottom navigation menu + ((MainActivity) getActivity()) + .setSelectedNavigationItem(R.id.main_bottom_navigation_me_view); + } +} diff --git a/app/src/main/res/menu/main_menu.xml b/app/src/main/res/menu/main_menu.xml index 0639c96..a11a666 100644 --- a/app/src/main/res/menu/main_menu.xml +++ b/app/src/main/res/menu/main_menu.xml @@ -7,6 +7,11 @@ android:id="@+id/action_friends_list" android:title="@string/main_menu_friends_list" /> + + + Edit New content for the post An error occurred while trying to update the content of the post! + Settings + Settings + Background notifications refresh + This allow you to stay informed about the latest notifications on Comunic by checking at a regular interval the existence of notifications, even if the application is closed. diff --git a/app/src/main/res/xml/app_preferences.xml b/app/src/main/res/xml/app_preferences.xml new file mode 100644 index 0000000..1c65125 --- /dev/null +++ b/app/src/main/res/xml/app_preferences.xml @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file