Files
Flexera-Launcher/quickstep/src/com/android/launcher3/uioverrides/plugins/PluginEnablerImpl.java
T
Sunny Goyal eae0514f1a Moving Plugin and feature flags UI to androidX
> Combining both preference into a single screen
> Adding plugin preference screen so quickstep build

Change-Id: I3d2ff3ebdac3c774659e79ecb81be6f75f765eb0
2018-10-25 13:07:42 -07:00

60 lines
1.9 KiB
Java

/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package com.android.launcher3.uioverrides.plugins;
import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
import com.android.launcher3.Utilities;
import com.android.systemui.shared.plugins.PluginEnabler;
import androidx.preference.PreferenceDataStore;
public class PluginEnablerImpl extends PreferenceDataStore implements PluginEnabler {
private static final String PREFIX_PLUGIN_ENABLED = "PLUGIN_ENABLED_";
final private SharedPreferences mSharedPrefs;
public PluginEnablerImpl(Context context) {
mSharedPrefs = Utilities.getDevicePrefs(context);
}
@Override
public void setEnabled(ComponentName component, boolean enabled) {
putBoolean(pluginEnabledKey(component), enabled);
}
@Override
public boolean isEnabled(ComponentName component) {
return getBoolean(pluginEnabledKey(component), true);
}
@Override
public void putBoolean(String key, boolean value) {
mSharedPrefs.edit().putBoolean(key, value).apply();
}
@Override
public boolean getBoolean(String key, boolean defValue) {
return mSharedPrefs.getBoolean(key, defValue);
}
static String pluginEnabledKey(ComponentName cn) {
return PREFIX_PLUGIN_ENABLED + cn.flattenToString();
}
}