mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 22:09:30 +00:00
Set background refresh setting
This commit is contained in:
parent
b600306d79
commit
32eed6322f
@ -6,6 +6,7 @@ import android.content.DialogInterface;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceFragment;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.design.widget.BottomNavigationView;
|
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.ConversationsListFragment;
|
||||||
import org.communiquons.android.comunic.client.ui.fragments.FriendsListFragment;
|
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.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.UpdateConversationFragment;
|
||||||
import org.communiquons.android.comunic.client.ui.fragments.UserInfosFragment;
|
import org.communiquons.android.comunic.client.ui.fragments.UserInfosFragment;
|
||||||
import org.communiquons.android.comunic.client.ui.fragments.UserPageFragment;
|
import org.communiquons.android.comunic.client.ui.fragments.UserPageFragment;
|
||||||
@ -162,6 +164,12 @@ public class MainActivity extends AppCompatActivity
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//To open settings fragment
|
||||||
|
if(id == R.id.action_settings){
|
||||||
|
openSettingsFragment();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//Check for logout request
|
//Check for logout request
|
||||||
if(id == R.id.action_logout){
|
if(id == R.id.action_logout){
|
||||||
confirmUserLogout();
|
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
|
* Open notifications fragment
|
||||||
*/
|
*/
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,11 @@
|
|||||||
android:id="@+id/action_friends_list"
|
android:id="@+id/action_friends_list"
|
||||||
android:title="@string/main_menu_friends_list" />
|
android:title="@string/main_menu_friends_list" />
|
||||||
|
|
||||||
|
<!-- Settings -->
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_settings"
|
||||||
|
android:title="@string/action_settings"/>
|
||||||
|
|
||||||
<!-- Sign out -->
|
<!-- Sign out -->
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_logout"
|
android:id="@+id/action_logout"
|
||||||
|
@ -143,4 +143,8 @@
|
|||||||
<string name="popup_editpost_confirm">Edit</string>
|
<string name="popup_editpost_confirm">Edit</string>
|
||||||
<string name="edit_post_content_hint">New content for the post</string>
|
<string name="edit_post_content_hint">New content for the post</string>
|
||||||
<string name="err_update_post_content">An error occurred while trying to update the content of the post!</string>
|
<string name="err_update_post_content">An error occurred while trying to update the content of the post!</string>
|
||||||
|
<string name="action_settings">Settings</string>
|
||||||
|
<string name="fragment_settings_title">Settings</string>
|
||||||
|
<string name="preference_background_notif_title">Background notifications refresh</string>
|
||||||
|
<string name="preference_background_notif_summary">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.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
11
app/src/main/res/xml/app_preferences.xml
Normal file
11
app/src/main/res/xml/app_preferences.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<!-- Enable and / or disable notification service -->
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="enable_background_notification_refresh"
|
||||||
|
android:title="@string/preference_background_notif_title"
|
||||||
|
android:summary="@string/preference_background_notif_summary"/>
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user