1 package com.android.launcher3.testing;
2 
3 import android.app.Activity;
4 import android.content.SharedPreferences;
5 import android.os.Bundle;
6 import android.view.View;
7 
8 import com.android.launcher3.Launcher;
9 import com.android.launcher3.LauncherAppState;
10 import com.android.launcher3.Utilities;
11 import com.android.launcher3.util.TestingUtils;
12 
13 public class ToggleWeightWatcher extends Activity {
14 
15     @Override
onCreate(Bundle savedInstanceState)16     protected void onCreate(Bundle savedInstanceState) {
17         super.onCreate(savedInstanceState);
18 
19         SharedPreferences sp = Utilities.getPrefs(this);
20         boolean show = sp.getBoolean(TestingUtils.SHOW_WEIGHT_WATCHER, true);
21 
22         show = !show;
23         sp.edit().putBoolean(TestingUtils.SHOW_WEIGHT_WATCHER, show).apply();
24 
25         Launcher launcher = (Launcher) LauncherAppState.getInstance().getModel().getCallback();
26         if (launcher != null && launcher.mWeightWatcher != null) {
27             launcher.mWeightWatcher.setVisibility(show ? View.VISIBLE : View.GONE);
28         }
29         finish();
30     }
31 }
32