diff options
-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 bf9773ad0..2881a91e1 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; @@ -1040,14 +1043,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); } } @@ -2051,6 +2057,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; } } @@ -3460,6 +3469,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 { + +} |