diff options
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()); |