1package com.android.launcher3.testing;
2
3import android.app.Activity;
4import android.content.SharedPreferences;
5import android.os.Bundle;
6import android.view.View;
7
8import com.android.launcher3.Launcher;
9import com.android.launcher3.LauncherAppState;
10import com.android.launcher3.Utilities;
11import com.android.launcher3.util.TestingUtils;
12
13public class ToggleWeightWatcher extends Activity {
14
15    @Override
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