diff options
author | Adam Cohen <adamcohen@google.com> | 2013-07-19 21:42:11 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-07-19 21:42:12 +0000 |
commit | ae6f6c67a3aa78d6ebde87321a0abd191aee94e1 (patch) | |
tree | f06eff67c07a8404c597b216eae50b5b3dbbfd3c | |
parent | 1e2f465f46ded990ea30516cdb7f0fcf3280411f (diff) | |
parent | 39a06042556a90c98f55a92bda5811e7d9492d13 (diff) | |
download | android_packages_apps_Trebuchet-ae6f6c67a3aa78d6ebde87321a0abd191aee94e1.tar.gz android_packages_apps_Trebuchet-ae6f6c67a3aa78d6ebde87321a0abd191aee94e1.tar.bz2 android_packages_apps_Trebuchet-ae6f6c67a3aa78d6ebde87321a0abd191aee94e1.zip |
Merge "Adding switch to toggle Memory Overlay" into jb-ub-gel-agar
-rw-r--r-- | AndroidManifest.xml | 11 | ||||
-rw-r--r-- | res/values/strings.xml | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 39 | ||||
-rw-r--r-- | src/com/android/launcher3/ToggleWeightWatcher.java | 7 |
4 files changed, 56 insertions, 3 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 09a94aefc..b9f75cf5d 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -96,6 +96,17 @@ </activity> <activity + android:name="com.android.launcher3.ToggleWeightWatcher" + android:label="@string/toggle_weight_watcher" + android:icon="@mipmap/ic_launcher_home"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.DEFAULT" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + + <activity android:name="com.android.launcher3.WallpaperChooser" android:theme="@style/Theme.WallpaperPicker" android:label="@string/pick_wallpaper" diff --git a/res/values/strings.xml b/res/values/strings.xml index b57ae7439..052e13b3b 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -41,6 +41,8 @@ <string name="widget_adder">Widgets</string> + <string name="toggle_weight_watcher">Show Mem</string> + <!-- AppsCustomize pane --> <!-- Message to tell the user to press and hold on a widget to add it [CHAR_LIMIT=50] --> <string name="long_press_widget_to_add">Touch & hold to pick up a widget.</string> diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 9a7d42ee0..7d9ebc0b5 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -191,6 +191,8 @@ public class Launcher extends Activity private static final String TOOLBAR_VOICE_SEARCH_ICON_METADATA_NAME = "com.android.launcher.toolbar_voice_search_icon"; + public static final String SHOW_WEIGHT_WATCHER = "debug.show_mem"; + /** The different states that Launcher can be in. */ private enum State { NONE, WORKSPACE, APPS_CUSTOMIZE, APPS_CUSTOMIZE_SPRING_LOADED }; private State mState = State.WORKSPACE; @@ -221,6 +223,7 @@ public class Launcher extends Activity private View mLauncherView; private DragLayer mDragLayer; private DragController mDragController; + private View mWeightWatcher; private AppWidgetManager mAppWidgetManager; private LauncherAppWidgetHost mAppWidgetHost; @@ -1041,14 +1044,17 @@ public class Launcher extends Activity if (getResources().getBoolean(R.bool.debug_memory_enabled)) { Log.v(TAG, "adding WeightWatcher"); - final View ww = new WeightWatcher(this); - ww.setAlpha(0.5f); - ((FrameLayout) mLauncherView).addView(ww, + mWeightWatcher = new WeightWatcher(this); + mWeightWatcher.setAlpha(0.5f); + ((FrameLayout) mLauncherView).addView(mWeightWatcher, new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM) ); + + boolean show = shouldShowWeightWatcher(); + mWeightWatcher.setVisibility(show ? View.VISIBLE : View.GONE); } } @@ -2052,6 +2058,9 @@ public class Launcher extends Activity } else if (shortcutClass.equals(MemoryDumpActivity.class.getName())) { MemoryDumpActivity.startDump(this); return; + } else if (shortcutClass.equals(ToggleWeightWatcher.class.getName())) { + toggleShowWeightWatcher(); + return; } } @@ -3472,6 +3481,30 @@ public class Launcher extends Activity } } + private boolean shouldShowWeightWatcher() { + String spKey = LauncherAppState.getSharedPreferencesKey(); + SharedPreferences sp = getSharedPreferences(spKey, Context.MODE_PRIVATE); + boolean show = sp.getBoolean(SHOW_WEIGHT_WATCHER, true); + + return show; + } + + private void toggleShowWeightWatcher() { + String spKey = LauncherAppState.getSharedPreferencesKey(); + SharedPreferences sp = getSharedPreferences(spKey, Context.MODE_PRIVATE); + boolean show = sp.getBoolean(SHOW_WEIGHT_WATCHER, true); + + show = !show; + + SharedPreferences.Editor editor = sp.edit(); + editor.putBoolean(SHOW_WEIGHT_WATCHER, show); + editor.commit(); + + if (mWeightWatcher != null) { + mWeightWatcher.setVisibility(show ? View.VISIBLE : View.GONE); + } + } + /** * Bind the items start-end from the list. * diff --git a/src/com/android/launcher3/ToggleWeightWatcher.java b/src/com/android/launcher3/ToggleWeightWatcher.java new file mode 100644 index 000000000..33701a2c4 --- /dev/null +++ b/src/com/android/launcher3/ToggleWeightWatcher.java @@ -0,0 +1,7 @@ +package com.android.launcher3; + +import android.app.Activity; + +public class ToggleWeightWatcher extends Activity { + +} |