summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDvTonder <david.vantonder@gmail.com>2012-12-14 09:47:31 -0500
committerDvTonder <david.vantonder@gmail.com>2012-12-14 09:58:52 -0500
commitccb7ab0fa5c024f8505cf922b00601bbdc33a81a (patch)
tree27569d904e931d6ff65847c152966dfc4f409741
parent33bfadb7411f3d17a193be84b711f0b89009d7e6 (diff)
downloadpackages_apps_settings-ccb7ab0fa5c024f8505cf922b00601bbdc33a81a.zip
packages_apps_settings-ccb7ab0fa5c024f8505cf922b00601bbdc33a81a.tar.gz
packages_apps_settings-ccb7ab0fa5c024f8505cf922b00601bbdc33a81a.tar.bz2
Settings: Add ability to reset Quick Settings panel to default
Change-Id: I968f8b01e82e39410d6b1fc8dacced05c011468b
-rw-r--r--res/values/strings.xml12
-rw-r--r--src/com/android/settings/cyanogenmod/QuickSettingsTiles.java58
-rw-r--r--src/com/android/settings/cyanogenmod/QuickSettingsUtil.java5
3 files changed, 53 insertions, 22 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index be672e6..1ddb803 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5033,15 +5033,9 @@
<string name="title_quick_pulldown">Quick pulldown</string>
<string name="summary_quick_pulldown">Show Quick Settings when pulling down notification bar near the right side of the screen</string>
- <!-- This exists as part of Power widget already, re-use them
- If Power widget is removed, re-enable these
- <string name="pref_ring_mode_title">Sound modes</string>
- <string name="pref_ring_mode_summary">View or change the Sound button modes</string>
- <string name="cm_sound_mode_silent">Silent</string>
- <string name="cm_sound_mode_vibrate">Vibrate</string>
- <string name="cm_sound_mode_sound">Sound</string>
- <string name="cm_sound_mode_soundVibrate">Sound + Vibrate</string>
- -->
+ <!-- Reset tiles -->
+ <string name="tiles_reset_title">Reset</string>
+ <string name="tiles_reset_message">Restore the default displayed tiles and layout?</string>
<!-- **** CYANOGENMOD ADDITIONS END **** -->
</resources>
diff --git a/src/com/android/settings/cyanogenmod/QuickSettingsTiles.java b/src/com/android/settings/cyanogenmod/QuickSettingsTiles.java
index bc89cb5..3fe3bb8 100644
--- a/src/com/android/settings/cyanogenmod/QuickSettingsTiles.java
+++ b/src/com/android/settings/cyanogenmod/QuickSettingsTiles.java
@@ -16,39 +16,34 @@
package com.android.settings.cyanogenmod;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Random;
-import java.util.zip.Inflater;
-
import android.app.AlertDialog;
import android.app.Fragment;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
-import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
-import android.widget.Button;
import android.widget.TextView;
+
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.cyanogenmod.QuickSettingsUtil.TileInfo;
+
+import java.util.ArrayList;
public class QuickSettingsTiles extends Fragment {
+ private static final int MENU_RESET = Menu.FIRST;
+
DraggableGridView mDragView;
private ViewGroup mContainer;
LayoutInflater mInflater;
@@ -151,6 +146,8 @@ public class QuickSettingsTiles extends Fragment {
builder.create().show();
}
});
+
+ setHasOptionsMenu(true);
}
@Override
@@ -161,6 +158,41 @@ public class QuickSettingsTiles extends Fragment {
}
}
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+
+ menu.add(0, MENU_RESET, 0, R.string.profile_reset_title)
+ .setIcon(R.drawable.ic_settings_backup) // use the backup icon
+ .setAlphabeticShortcut('r')
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM |
+ MenuItem.SHOW_AS_ACTION_WITH_TEXT);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case MENU_RESET:
+ resetTiles();
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ private void resetTiles() {
+ AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
+ alert.setTitle(R.string.tiles_reset_title);
+ alert.setMessage(R.string.tiles_reset_message);
+ alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ QuickSettingsUtil.resetTiles(getActivity());
+ genTiles();
+ }
+ });
+ alert.setNegativeButton(R.string.cancel, null);
+ alert.create().show();
+ }
+
@SuppressWarnings("rawtypes")
static class TileAdapter extends ArrayAdapter {
diff --git a/src/com/android/settings/cyanogenmod/QuickSettingsUtil.java b/src/com/android/settings/cyanogenmod/QuickSettingsUtil.java
index dec91bb..27102e9 100644
--- a/src/com/android/settings/cyanogenmod/QuickSettingsUtil.java
+++ b/src/com/android/settings/cyanogenmod/QuickSettingsUtil.java
@@ -164,6 +164,11 @@ public class QuickSettingsUtil {
Settings.System.QUICK_SETTINGS_TILES, tiles);
}
+ public static void resetTiles(Context context) {
+ Settings.System.putString(context.getContentResolver(),
+ Settings.System.QUICK_SETTINGS_TILES, TILES_DEFAULT);
+ }
+
public static String mergeInNewTileString(String oldString, String newString) {
ArrayList<String> oldList = getTileListFromString(oldString);
ArrayList<String> newList = getTileListFromString(newString);