Search in sources :

Example 16 with Switch

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();
        }
    }
}
Also used : AppOpsManager(android.app.AppOpsManager) Switch(android.widget.Switch) AppOpEntry(com.android.settings.applications.AppOpsState.AppOpEntry)

Example 17 with Switch

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();
    }
}
Also used : AlertDialog(android.app.AlertDialog) NotificationManager(android.app.NotificationManager) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Switch(android.widget.Switch) NotificationCompat(android.support.v4.app.NotificationCompat) PendingIntent(android.app.PendingIntent)

Example 18 with Switch

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);
    }
}
Also used : Switch(android.widget.Switch) View(android.view.View) TextView(android.widget.TextView)

Example 19 with Switch

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();
}
Also used : Switch(android.widget.Switch)

Example 20 with Switch

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);
    }
}
Also used : Switch(android.widget.Switch)

Aggregations

Switch (android.widget.Switch)56 View (android.view.View)29 CompoundButton (android.widget.CompoundButton)18 TextView (android.widget.TextView)18 Context (android.content.Context)11 DialogInterface (android.content.DialogInterface)8 AlertDialog (android.app.AlertDialog)7 LayoutInflater (android.view.LayoutInflater)7 Checkable (android.widget.Checkable)7 OnCancelListener (android.content.DialogInterface.OnCancelListener)6 TypedArray (android.content.res.TypedArray)6 Drawable (android.graphics.drawable.Drawable)6 InputMethodInfo (android.view.inputmethod.InputMethodInfo)6 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)6 JSONObject (org.json.JSONObject)6 OnClickListener (android.content.DialogInterface.OnClickListener)5 Intent (android.content.Intent)5 LocaleList (android.os.LocaleList)5 ContextThemeWrapper (android.view.ContextThemeWrapper)5 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)5