use of android.support.v7.preference.TwoStatePreference in project android_packages_apps_Settings by DirtyUnicorns.
the class BadgingNotificationPreferenceControllerTest method updateState_preferenceSetUncheckedWhenSettingIsOff.
@Test
public void updateState_preferenceSetUncheckedWhenSettingIsOff() {
final TwoStatePreference preference = mock(TwoStatePreference.class);
final Context context = ShadowApplication.getInstance().getApplicationContext();
Settings.Secure.putInt(context.getContentResolver(), NOTIFICATION_BADGING, 0);
mController = new BadgingNotificationPreferenceController(context);
mController.updateState(preference);
verify(preference).setChecked(false);
}
use of android.support.v7.preference.TwoStatePreference in project android_packages_apps_Settings by DirtyUnicorns.
the class AssistFlashScreenPreferenceController method updatePreference.
private void updatePreference() {
if (mPreference == null || !(mPreference instanceof TwoStatePreference)) {
return;
}
if (isAvailable()) {
if (mScreen.findPreference(getPreferenceKey()) == null) {
// add it if it's not on scree
mScreen.addPreference(mPreference);
}
} else {
mScreen.removePreference(mPreference);
}
ComponentName assistant = getCurrentAssist();
boolean isContextChecked = AssistContextPreferenceController.isChecked(mContext);
mPreference.setEnabled(isContextChecked && isPreInstalledAssistant(assistant));
((TwoStatePreference) mPreference).setChecked(willShowFlash(assistant));
}
use of android.support.v7.preference.TwoStatePreference in project MaxLock by Maxr1998.
the class MaxLockPreferenceFragment method onPreferenceTreeClick.
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
if (preference.getKey() == null) {
return false;
}
switch(screen) {
case MAIN:
switch(preference.getKey()) {
case Common.ML_IMPLEMENTATION:
AlertDialog implementation = new AlertDialog.Builder(getContext()).setTitle(preference.getTitle()).setView(MLImplementation.createImplementationDialog(getContext())).setNegativeButton(android.R.string.ok, null).setOnDismissListener(dialog -> updateImplementationStatus()).create();
implementation.show();
return true;
case Common.LOCKING_TYPE_SETTINGS:
launchFragment(this, Screen.TYPE.getScreen(), true);
return true;
case Common.LOCKING_UI_SETTINGS:
launchFragment(this, Screen.UI.getScreen(), true);
return true;
case Common.LOCKING_OPTIONS:
launchFragment(this, Screen.OPTIONS.getScreen(), true);
return true;
case Common.IMOD_OPTIONS:
launchFragment(this, Screen.IMOD.getScreen(), true);
return true;
case Common.CHOOSE_APPS:
launchFragment(this, new AppListFragment(), true);
return true;
case Common.HIDE_APP_FROM_LAUNCHER:
TwoStatePreference hideApp = (TwoStatePreference) preference;
if (hideApp.isChecked()) {
Toast.makeText(getActivity(), R.string.reboot_required, Toast.LENGTH_SHORT).show();
ComponentName componentName = new ComponentName(getActivity(), "de.Maxr1998.xposed.maxlock.Main");
getActivity().getPackageManager().setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
} else {
ComponentName componentName = new ComponentName(getActivity(), "de.Maxr1998.xposed.maxlock.Main");
getActivity().getPackageManager().setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
}
return true;
case Common.USE_DARK_STYLE:
case Common.USE_AMOLED_BLACK:
case Common.ENABLE_PRO:
getActivity().recreate();
return true;
case Common.ABOUT:
launchFragment(this, Screen.ABOUT.getScreen(), true);
return true;
case Common.DONATE:
startActivity(new Intent(getActivity(), DonateActivity.class));
return true;
case Common.UNINSTALL:
if (!((SettingsActivity) getActivity()).isDeviceAdminActive()) {
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, ((SettingsActivity) getActivity()).deviceAdmin);
startActivity(intent);
} else {
((SettingsActivity) getActivity()).getDevicePolicyManager().removeActiveAdmin(((SettingsActivity) getActivity()).deviceAdmin);
preference.setTitle(R.string.pref_prevent_uninstall);
preference.setSummary(R.string.pref_prevent_uninstall_summary);
Intent uninstall = new Intent(Intent.ACTION_DELETE);
uninstall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
uninstall.setData(Uri.parse("package:de.Maxr1998.xposed.maxlock"));
startActivity(uninstall);
}
return true;
case Common.SEND_FEEDBACK:
File tempDirectory = new File(getActivity().getCacheDir(), "feedback-cache");
try {
// Obtain data
FileUtils.copyDirectoryToDirectory(new File(Util.dataDir(getActivity()), "shared_prefs"), tempDirectory);
FileUtils.writeStringToFile(new File(tempDirectory, "device-info.txt"), "App Version: " + BuildConfig.VERSION_NAME + "\n\n" + "Device: " + Build.MANUFACTURER + " " + Build.MODEL + " (" + Build.PRODUCT + ")\n" + "API: " + SDK_INT + ", Fingerprint: " + Build.FINGERPRINT, Charset.forName("UTF-8"));
Process process = Runtime.getRuntime().exec("logcat -d");
FileUtils.copyInputStreamToFile(process.getInputStream(), new File(tempDirectory, "logcat.txt"));
try {
String xposedDir = SDK_INT >= Build.VERSION_CODES.N ? "/data/user_de/0/" + Common.XPOSED_PACKAGE_NAME : getActivity().getPackageManager().getApplicationInfo(Common.XPOSED_PACKAGE_NAME, 0).dataDir;
File xposedLog = new File(xposedDir + "/log", "error.log");
if (xposedLog.exists())
FileUtils.copyFileToDirectory(xposedLog, tempDirectory);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
// Create zip
File zipFile = new File(getActivity().getCacheDir() + File.separator + "export", "report.zip");
zipFile.getParentFile().mkdir();
FileUtils.deleteQuietly(zipFile);
ZipOutputStream stream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)));
Util.writeDirectoryToZip(tempDirectory, stream);
stream.close();
FileUtils.deleteQuietly(tempDirectory);
Util.checkForStoragePermission(this, BUG_REPORT_STORAGE_PERMISSION_REQUEST_CODE, R.string.dialog_storage_permission_bug_report);
} catch (IOException e) {
e.printStackTrace();
}
return true;
}
break;
case TYPE:
switch(preference.getKey()) {
case Common.LOCKING_TYPE_PASSWORD:
Util.setPassword(getActivity(), null);
return true;
case Common.LOCKING_TYPE_PIN:
LockSetupFragment lsp = new LockSetupFragment();
Bundle b1 = new Bundle(1);
b1.putString(Common.LOCKING_TYPE, Common.LOCKING_TYPE_PIN);
lsp.setArguments(b1);
launchFragment(this, lsp, false);
return true;
case Common.LOCKING_TYPE_KNOCK_CODE:
LockSetupFragment lsk = new LockSetupFragment();
Bundle b2 = new Bundle(1);
b2.putString(Common.LOCKING_TYPE, Common.LOCKING_TYPE_KNOCK_CODE);
lsk.setArguments(b2);
launchFragment(this, lsk, false);
return true;
case Common.LOCKING_TYPE_PATTERN:
Intent intent = new Intent(LockPatternActivity.ACTION_CREATE_PATTERN, null, getActivity(), LockPatternActivity.class);
startActivityForResult(intent, KUtil.getPatternCode(-1));
return true;
}
break;
case OPTIONS:
switch(preference.getKey()) {
case Common.VIEW_LOGS:
launchFragment(this, new LogViewerFragment(), false);
return true;
}
break;
case ABOUT:
switch(preference.getKey()) {
case Common.SHOW_CHANGELOG:
showChangelog();
return true;
case Common.VISIT_WEBSITE:
CustomTabsIntent devWebsite = new CustomTabsIntent.Builder(((SettingsActivity) getActivity()).getSession()).setShowTitle(true).enableUrlBarHiding().setToolbarColor(Color.parseColor("#ffc107")).build();
devWebsite.launchUrl(getActivity(), Common.MAXR1998_URI);
return true;
case Common.TECHNOSPARKS_PROFILE:
CustomTabsIntent technosparksSite = new CustomTabsIntent.Builder(((SettingsActivity) getActivity()).getSession()).setShowTitle(true).enableUrlBarHiding().setToolbarColor(Color.parseColor("#6d993f")).build();
technosparksSite.launchUrl(getActivity(), Common.TECHNO_SPARKS_URI);
return true;
}
break;
}
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
use of android.support.v7.preference.TwoStatePreference in project android_packages_apps_Settings by crdroidandroid.
the class GesturePreferenceControllerTest method updateState_preferenceSetCheckedWhenSettingIsOn.
@Test
public void updateState_preferenceSetCheckedWhenSettingIsOn() {
// Mock a TwoStatePreference
final TwoStatePreference preference = mock(TwoStatePreference.class);
// Set the setting to be enabled.
mController.mIsPrefEnabled = true;
// Run through updateState
mController.updateState(preference);
// Verify pref is checked (as setting is enabled).
verify(preference).setChecked(true);
}
use of android.support.v7.preference.TwoStatePreference in project android_packages_apps_Settings by crdroidandroid.
the class GesturePreferenceControllerTest method updateState_preferenceSetUncheckedWhenSettingIsOff.
@Test
public void updateState_preferenceSetUncheckedWhenSettingIsOff() {
// Mock a TwoStatePreference
final TwoStatePreference preference = mock(TwoStatePreference.class);
// Set the setting to be disabled.
mController.mIsPrefEnabled = false;
// Run through updateState
mController.updateState(preference);
// Verify pref is unchecked (as setting is disabled).
verify(preference).setChecked(false);
}
Aggregations