diff options
author | Altaf-Mahdi <altaf.mahdi@gmail.com> | 2015-04-15 19:03:00 +0100 |
---|---|---|
committer | Adnan Begovic <adnan@cyngn.com> | 2015-10-26 16:12:35 -0700 |
commit | 8faf268f3404cb7f2a99fb952fcdc49dfbdd352a (patch) | |
tree | 6bd6bd2fae2efde825de4ebadb08e875c5cc1f4c /src/com/android/settings/profiles/SetupActionsFragment.java | |
parent | f10a82bfca8032a3e4c4c4057aa873dddf6e4c7b (diff) | |
download | packages_apps_Settings-8faf268f3404cb7f2a99fb952fcdc49dfbdd352a.zip packages_apps_Settings-8faf268f3404cb7f2a99fb952fcdc49dfbdd352a.tar.gz packages_apps_Settings-8faf268f3404cb7f2a99fb952fcdc49dfbdd352a.tar.bz2 |
Settings: enable/disable doze through Profiles (2/2)
* moved isDozeAvailable boolean to Utils so we can check for it in profiles
Change-Id: I5a768098b4ed00b28931bee58a58efa8280262a1
Diffstat (limited to 'src/com/android/settings/profiles/SetupActionsFragment.java')
-rw-r--r-- | src/com/android/settings/profiles/SetupActionsFragment.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/com/android/settings/profiles/SetupActionsFragment.java b/src/com/android/settings/profiles/SetupActionsFragment.java index c7fe6c2..c7c9680 100644 --- a/src/com/android/settings/profiles/SetupActionsFragment.java +++ b/src/com/android/settings/profiles/SetupActionsFragment.java @@ -75,6 +75,7 @@ import com.android.settings.profiles.actions.item.AirplaneModeItem; import com.android.settings.profiles.actions.item.BrightnessItem; import com.android.settings.profiles.actions.item.AppGroupItem; import com.android.settings.profiles.actions.item.ConnectionOverrideItem; +import com.android.settings.profiles.actions.item.DozeModeItem; import com.android.settings.profiles.actions.item.Header; import com.android.settings.profiles.actions.item.Item; import com.android.settings.profiles.actions.item.LockModeItem; @@ -82,6 +83,7 @@ import com.android.settings.profiles.actions.item.ProfileNameItem; import com.android.settings.profiles.actions.item.RingModeItem; import com.android.settings.profiles.actions.item.TriggerItem; import com.android.settings.profiles.actions.item.VolumeStreamItem; +import com.android.settings.Utils; import java.util.ArrayList; import java.util.List; @@ -120,6 +122,11 @@ public class SetupActionsFragment extends SettingsPreferenceFragment Profile.ExpandedDesktopMode.ENABLE, Profile.ExpandedDesktopMode.DISABLE }; + private static final int[] DOZE_MAPPING = new int[] { + Profile.DozeMode.DEFAULT, + Profile.DozeMode.ENABLE, + Profile.DozeMode.DISABLE + }; private List<Item> mItems = new ArrayList<Item>(); public static SetupActionsFragment newInstance(Profile profile, boolean newProfile) { @@ -213,6 +220,11 @@ public class SetupActionsFragment extends SettingsPreferenceFragment mItems.add(new LockModeItem(mProfile)); mItems.add(new BrightnessItem(mProfile.getBrightness())); + final Activity activity = getActivity(); + if (Utils.isDozeAvailable(activity)) { + mItems.add(new DozeModeItem(mProfile)); + } + // app groups if (SettingsActivity.showAdvancedPreferences(getActivity())) { mItems.add(new Header(getString(R.string.profile_app_group_category_title))); @@ -521,6 +533,35 @@ public class SetupActionsFragment extends SettingsPreferenceFragment builder.show(); } + private void requestDozeModeDialog() { + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + final String[] dozeEntries = + getResources().getStringArray(R.array.profile_doze_entries); + + int defaultIndex = 0; // no action + for (int i = 0; i < DOZE_MAPPING.length; i++) { + if (DOZE_MAPPING[i] == mProfile.getDozeMode()) { + defaultIndex = i; + break; + } + } + + builder.setTitle(R.string.doze_title); + builder.setSingleChoiceItems(dozeEntries, defaultIndex, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int item) { + mProfile.setDozeMode(DOZE_MAPPING[item]); + updateProfile(); + mAdapter.notifyDataSetChanged(); + dialog.dismiss(); + } + }); + + builder.setNegativeButton(android.R.string.cancel, null); + builder.show(); + } + private void requestAirplaneModeDialog(final AirplaneModeSettings setting) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final String[] connectionNames = @@ -932,6 +973,8 @@ public class SetupActionsFragment extends SettingsPreferenceFragment requestBrightnessDialog(item.getSettings()); } else if (itemAtPosition instanceof LockModeItem) { requestLockscreenModeDialog(); + } else if (itemAtPosition instanceof DozeModeItem) { + requestDozeModeDialog(); } else if (itemAtPosition instanceof RingModeItem) { RingModeItem item = (RingModeItem) itemAtPosition; requestRingModeDialog(item.getSettings()); |