use of android.widget.Switch in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AppOpsCategory method onListItemClick.
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
AppOpEntry entry = mAdapter.getItem(position);
if (entry != null) {
if (mUserControlled) {
// We treat this as tapping on the check box, toggling the app op state.
Switch sw = ((Switch) v.findViewById(R.id.op_switch));
boolean checked = !sw.isChecked();
sw.setChecked(checked);
AppOpsManager.OpEntry op = entry.getOpEntry(0);
int mode = checked ? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_IGNORED;
mState.getAppOpsManager().setMode(op.getOp(), entry.getAppEntry().getApplicationInfo().uid, entry.getAppEntry().getApplicationInfo().packageName, mode);
entry.overridePrimaryOpMode(mode);
} else {
mCurrentPkgName = entry.getAppEntry().getApplicationInfo().packageName;
startApplicationDetailsActivity();
}
}
}
use of android.widget.Switch in project orWall by EthACKdotOrg.
the class HomeFragment method toggleOrwall.
/**
* Toggle orWall status
*
* @param view View passed by onClick
*/
public void toggleOrwall(final View view) {
boolean checked = ((Switch) view).isChecked();
final Intent bgpProcess = new Intent(this.getActivity(), BackgroundProcess.class);
Intent intent = new Intent(this.getActivity(), TabbedMain.class);
final PendingIntent pintent = PendingIntent.getActivity(this.getActivity(), 0, intent, 0);
final NotificationCompat.Builder notification = new NotificationCompat.Builder(getActivity()).setAutoCancel(false).setOngoing(true).setContentIntent(pintent).setContentTitle(getString(R.string.notification_deactivated_title)).setContentText(getString(R.string.notification_deactivated_text)).setSmallIcon(R.drawable.v2);
final NotificationManager notificationManager = (NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
if (checked) {
bgpProcess.putExtra(Constants.ACTION, Constants.ACTION_ENABLE_ORWALL);
getActivity().startService(bgpProcess);
Preferences.setOrwallEnabled(getActivity(), true);
updateOptions();
Toast.makeText(this.getActivity(), getString(R.string.enabling_orwall), Toast.LENGTH_LONG).show();
notificationManager.cancel(1);
} else {
final AlertDialog.Builder alertDialog = new AlertDialog.Builder(this.getActivity());
alertDialog.setTitle(getString(R.string.disable_orwall_title));
alertDialog.setMessage(getString(R.string.disable_orwall_msg));
alertDialog.setPositiveButton(getString(R.string.alert_accept), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
bgpProcess.putExtra(Constants.ACTION, Constants.ACTION_DISABLE_ORWALL);
getActivity().startService(bgpProcess);
Preferences.setOrwallEnabled(getActivity(), false);
updateOptions();
notificationManager.notify(1, notification.build());
}
});
alertDialog.setNegativeButton(getString(R.string.alert_cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
((Switch) view).setChecked(true);
}
});
alertDialog.show();
}
}
use of android.widget.Switch in project orWall by EthACKdotOrg.
the class HomeFragment method updateOptions.
private void updateOptions() {
Switch browserStatus = (Switch) home.findViewById(R.id.browser_status);
Switch sipStatus = (Switch) home.findViewById(R.id.sip_status);
// We want to ensure we can access this setting if and only if there's a selected browser.
this.browser_uid = Long.valueOf(Preferences.getBrowserApp(getActivity()));
if (this.browser_uid != 0 && Preferences.isOrwallEnabled(getActivity())) {
browserStatus.setClickable(true);
browserStatus.setTextColor(Color.BLACK);
browserStatus.setChecked(Preferences.isBrowserEnabled(getActivity()));
browserStatus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
toggleBrowser(view);
}
});
} else {
// No selected browser, meaning we want to deactivate this option.
browserStatus.setClickable(false);
browserStatus.setTextColor(Color.GRAY);
}
// We want to ensure we can access this setting if and only if there's a selected SIP app
this.sip_uid = Long.valueOf(Preferences.getSIPApp(getActivity()));
if (this.sip_uid != 0 && Preferences.isOrwallEnabled(getActivity())) {
sipStatus.setClickable(false);
sipStatus.setTextColor(Color.BLACK);
sipStatus.setChecked(Preferences.isSIPEnabled(getActivity()));
sipStatus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean checked = ((Switch) view).isChecked();
iptables.manageSip(checked, sip_uid);
Preferences.setSIPEnabled(getActivity(), checked);
}
});
} else {
// No selected SIP app, meaning we want to deactivate this option.
sipStatus.setClickable(false);
sipStatus.setTextColor(Color.GRAY);
}
}
use of android.widget.Switch in project orWall by EthACKdotOrg.
the class HomeFragment method onResume.
@Override
public void onResume() {
super.onResume();
Switch orwallSwitch = (Switch) home.findViewById(R.id.orwall_status);
// checking true orwall status
if (Preferences.isOrwallEnabled(getActivity()) && !iptables.haveBooted()) {
Preferences.setOrwallEnabled(getActivity(), false);
orwallSwitch.setChecked(false);
}
updateOptions();
}
use of android.widget.Switch in project android_frameworks_base by DirtyUnicorns.
the class InputMethodManagerService method updateKeyboardFromSettingsLocked.
public void updateKeyboardFromSettingsLocked() {
mShowImeWithHardKeyboard = mSettings.isShowImeWithHardKeyboardEnabled();
if (mSwitchingDialog != null && mSwitchingDialogTitleView != null && mSwitchingDialog.isShowing()) {
final Switch hardKeySwitch = (Switch) mSwitchingDialogTitleView.findViewById(com.android.internal.R.id.hard_keyboard_switch);
hardKeySwitch.setChecked(mShowImeWithHardKeyboard);
}
}
Aggregations