mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-02 08:56:55 +00:00
> This ensures that LauncherAppState is only accessed in the presence of a valid context Bug: 33032833 Change-Id: I955e5cb022f8bd6374681ae6c0720a2666d5b750
32 lines
1.0 KiB
Java
32 lines
1.0 KiB
Java
package com.android.launcher3.testing;
|
|
|
|
import android.app.Activity;
|
|
import android.content.SharedPreferences;
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
|
|
import com.android.launcher3.Launcher;
|
|
import com.android.launcher3.LauncherAppState;
|
|
import com.android.launcher3.Utilities;
|
|
import com.android.launcher3.util.TestingUtils;
|
|
|
|
public class ToggleWeightWatcher extends Activity {
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
|
|
SharedPreferences sp = Utilities.getPrefs(this);
|
|
boolean show = sp.getBoolean(TestingUtils.SHOW_WEIGHT_WATCHER, true);
|
|
|
|
show = !show;
|
|
sp.edit().putBoolean(TestingUtils.SHOW_WEIGHT_WATCHER, show).apply();
|
|
|
|
Launcher launcher = (Launcher) LauncherAppState.getInstance(this).getModel().getCallback();
|
|
if (launcher != null && launcher.mWeightWatcher != null) {
|
|
launcher.mWeightWatcher.setVisibility(show ? View.VISIBLE : View.GONE);
|
|
}
|
|
finish();
|
|
}
|
|
}
|