SetupWizard: Bring back software nav keys option
Issue-id: OPO-402 Change-Id: Id04105a48dfbb494dddc757f8fe9bcad16796937
This commit is contained in:
parent
d40d8b83c3
commit
5b276ea335
@ -18,19 +18,16 @@ package com.cyanogenmod.setupwizard.setup;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ThemeUtils;
|
||||
import android.content.res.ThemeConfig;
|
||||
import android.content.res.ThemeManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.Settings;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannableStringBuilder;
|
||||
@ -49,26 +46,20 @@ import com.cyanogenmod.setupwizard.R;
|
||||
import com.cyanogenmod.setupwizard.SetupWizardApp;
|
||||
import com.cyanogenmod.setupwizard.cmstats.SetupStats;
|
||||
import com.cyanogenmod.setupwizard.ui.SetupPageFragment;
|
||||
import com.cyanogenmod.setupwizard.ui.WebViewDialogFragment;
|
||||
import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
|
||||
import com.cyanogenmod.setupwizard.util.WhisperPushUtils;
|
||||
|
||||
import cyanogenmod.providers.CMSettings;
|
||||
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.GooglePlayServicesUtil;
|
||||
|
||||
import cyanogenmod.hardware.CMHardwareManager;
|
||||
import cyanogenmod.providers.CMSettings;
|
||||
|
||||
public class CyanogenSettingsPage extends SetupPage {
|
||||
|
||||
public static final String TAG = "CyanogenSettingsPage";
|
||||
|
||||
public static final String KEY_SEND_METRICS = "send_metrics";
|
||||
public static final String KEY_ENABLE_NAV_KEYS = "enable_nav_keys";
|
||||
public static final String DISABLE_NAV_KEYS = "disable_nav_keys";
|
||||
public static final String KEY_APPLY_DEFAULT_THEME = "apply_default_theme";
|
||||
public static final String KEY_BUTTON_BACKLIGHT = "pre_navbar_button_backlight";
|
||||
|
||||
public static final String SETTING_METRICS = "settings.cyanogen.allow_metrics";
|
||||
public static final String PRIVACY_POLICY_URI = "https://cyngn.com/oobe-legal?hideHeader=1";
|
||||
|
||||
public CyanogenSettingsPage(Context context, SetupDataCallbacks callbacks) {
|
||||
@ -100,47 +91,37 @@ public class CyanogenSettingsPage extends SetupPage {
|
||||
|
||||
private static void writeDisableNavkeysOption(Context context, boolean enabled) {
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
/*final int defaultBrightness = context.getResources().getInteger(
|
||||
com.android.internal.R.integer.config_buttonBrightnessSettingDefault);*/
|
||||
|
||||
/*Settings.Secure.putInt(context.getContentResolver(),
|
||||
Settings.Secure.DEV_FORCE_SHOW_NAVBAR, enabled ? 1 : 0);
|
||||
final CMHardwareManager hardware = CMHardwareManager.getInstance(context);
|
||||
hardware.set(CMHardwareManager.FEATURE_KEY_DISABLE, enabled);*/
|
||||
CMSettings.Secure.putInt(context.getContentResolver(),
|
||||
CMSettings.Secure.DEV_FORCE_SHOW_NAVBAR, enabled ? 1 : 0);
|
||||
CMHardwareManager hardware = CMHardwareManager.getInstance(context);
|
||||
hardware.set(CMHardwareManager.FEATURE_KEY_DISABLE, enabled);
|
||||
|
||||
/* Save/restore button timeouts to disable them in softkey mode */
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
|
||||
if (enabled) {
|
||||
int currentBrightness = CMSettings.Secure.getInt(context.getContentResolver(),
|
||||
CMSettings.Secure.BUTTON_BRIGHTNESS, 100);
|
||||
if (!prefs.contains("pre_navbar_button_backlight")) {
|
||||
editor.putInt("pre_navbar_button_backlight", currentBrightness);
|
||||
}
|
||||
CMSettings.Secure.putInt(context.getContentResolver(),
|
||||
CMSettings.Secure.BUTTON_BRIGHTNESS, 0);
|
||||
} else {
|
||||
int oldBright = prefs.getInt("pre_navbar_button_backlight", -1);
|
||||
if (oldBright != -1) {
|
||||
int currentBrightness = CMSettings.Secure.getInt(context.getContentResolver(),
|
||||
CMSettings.Secure.BUTTON_BRIGHTNESS, 100);
|
||||
int oldBright = prefs.getInt(KEY_BUTTON_BACKLIGHT,
|
||||
currentBrightness);
|
||||
CMSettings.Secure.putInt(context.getContentResolver(),
|
||||
CMSettings.Secure.BUTTON_BRIGHTNESS, oldBright);
|
||||
editor.remove("pre_navbar_button_backlight");
|
||||
}
|
||||
}
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinishSetup() {
|
||||
getCallbacks().addFinishRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (getData().containsKey(KEY_ENABLE_NAV_KEYS)) {
|
||||
if (getData().containsKey(DISABLE_NAV_KEYS)) {
|
||||
SetupStats.addEvent(SetupStats.Categories.SETTING_CHANGED,
|
||||
SetupStats.Action.ENABLE_NAV_KEYS,
|
||||
SetupStats.Label.CHECKED,
|
||||
String.valueOf(getData().getBoolean(KEY_ENABLE_NAV_KEYS)));
|
||||
writeDisableNavkeysOption(mContext, getData().getBoolean(KEY_ENABLE_NAV_KEYS));
|
||||
String.valueOf(getData().getBoolean(DISABLE_NAV_KEYS)));
|
||||
writeDisableNavkeysOption(mContext, getData().getBoolean(DISABLE_NAV_KEYS));
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -230,7 +211,7 @@ public class CyanogenSettingsPage extends SetupPage {
|
||||
public void onClick(View view) {
|
||||
boolean checked = !mNavKeys.isChecked();
|
||||
mNavKeys.setChecked(checked);
|
||||
mPage.getData().putBoolean(KEY_ENABLE_NAV_KEYS, checked);
|
||||
mPage.getData().putBoolean(DISABLE_NAV_KEYS, checked);
|
||||
}
|
||||
};
|
||||
|
||||
@ -310,11 +291,11 @@ public class CyanogenSettingsPage extends SetupPage {
|
||||
mNavKeysRow.setOnClickListener(mNavKeysClickListener);
|
||||
mNavKeys = (CheckBox) mRootView.findViewById(R.id.nav_keys_checkbox);
|
||||
boolean needsNavBar = true;
|
||||
/*try {
|
||||
try {
|
||||
IWindowManager windowManager = WindowManagerGlobal.getWindowManagerService();
|
||||
needsNavBar = windowManager.needsNavigationBar();
|
||||
} catch (RemoteException e) {
|
||||
}*/
|
||||
}
|
||||
mHideNavKeysRow = hideKeyDisabler(getActivity());
|
||||
if (mHideNavKeysRow || needsNavBar) {
|
||||
mNavKeysRow.setVisibility(View.GONE);
|
||||
@ -333,7 +314,7 @@ public class CyanogenSettingsPage extends SetupPage {
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
/*updateDisableNavkeysOption();*/
|
||||
updateDisableNavkeysOption();
|
||||
updateMetricsOption();
|
||||
updateThemeOption();
|
||||
}
|
||||
@ -362,18 +343,18 @@ public class CyanogenSettingsPage extends SetupPage {
|
||||
}
|
||||
}
|
||||
|
||||
/*private void updateDisableNavkeysOption() {
|
||||
private void updateDisableNavkeysOption() {
|
||||
if (!mHideNavKeysRow) {
|
||||
final Bundle myPageBundle = mPage.getData();
|
||||
boolean enabled = Settings.Secure.getInt(getActivity().getContentResolver(),
|
||||
Settings.Secure.DEV_FORCE_SHOW_NAVBAR, 0) != 0;
|
||||
boolean checked = myPageBundle.containsKey(KEY_ENABLE_NAV_KEYS) ?
|
||||
myPageBundle.getBoolean(KEY_ENABLE_NAV_KEYS) :
|
||||
boolean enabled = CMSettings.Secure.getInt(getActivity().getContentResolver(),
|
||||
CMSettings.Secure.DEV_FORCE_SHOW_NAVBAR, 0) != 0;
|
||||
boolean checked = myPageBundle.containsKey(DISABLE_NAV_KEYS) ?
|
||||
myPageBundle.getBoolean(DISABLE_NAV_KEYS) :
|
||||
enabled;
|
||||
mNavKeys.setChecked(checked);
|
||||
myPageBundle.putBoolean(KEY_ENABLE_NAV_KEYS, checked);
|
||||
myPageBundle.putBoolean(DISABLE_NAV_KEYS, checked);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
private static boolean hideKillSwitch() {
|
||||
return !SetupWizardUtils.hasKillSwitch();
|
||||
|
Loading…
Reference in New Issue
Block a user