Search in sources :

Example 11 with CompoundButton

use of android.widget.CompoundButton in project XPrivacy by M66B.

the class PrivacyService method getOnDemandView.

@SuppressLint("InflateParams")
private View getOnDemandView(final PRestriction restriction, final Hook hook, ApplicationInfoEx appInfo, final PRestriction result, Context context, final OnDemandDialogHolder holder, final OnDemandResult oResult) throws NameNotFoundException, RemoteException {
    // Get resources
    String self = PrivacyService.class.getPackage().getName();
    Resources resources = context.getPackageManager().getResourcesForApplication(self);
    // Reference views
    final View view = LayoutInflater.from(context.createPackageContext(self, 0)).inflate(R.layout.ondemand, null);
    ImageView ivAppIcon = (ImageView) view.findViewById(R.id.ivAppIcon);
    TextView tvUid = (TextView) view.findViewById(R.id.tvUid);
    TextView tvAppName = (TextView) view.findViewById(R.id.tvAppName);
    TextView tvCategory = (TextView) view.findViewById(R.id.tvCategory);
    TextView tvFunction = (TextView) view.findViewById(R.id.tvFunction);
    TextView tvParameters = (TextView) view.findViewById(R.id.tvParameters);
    TableRow rowParameters = (TableRow) view.findViewById(R.id.rowParameters);
    TextView tvDefault = (TextView) view.findViewById(R.id.tvDefault);
    TextView tvInfoCategory = (TextView) view.findViewById(R.id.tvInfoCategory);
    final CheckBox cbExpert = (CheckBox) view.findViewById(R.id.cbExpert);
    final CheckBox cbCategory = (CheckBox) view.findViewById(R.id.cbCategory);
    final CheckBox cbOnce = (CheckBox) view.findViewById(R.id.cbOnce);
    final Spinner spOnce = (Spinner) view.findViewById(R.id.spOnce);
    final LinearLayout llWhiteList = (LinearLayout) view.findViewById(R.id.llWhiteList);
    final CheckBox cbWhitelist = (CheckBox) view.findViewById(R.id.cbWhitelist);
    final CheckBox cbWhitelistExtra1 = (CheckBox) view.findViewById(R.id.cbWhitelistExtra1);
    final CheckBox cbWhitelistExtra2 = (CheckBox) view.findViewById(R.id.cbWhitelistExtra2);
    final CheckBox cbWhitelistExtra3 = (CheckBox) view.findViewById(R.id.cbWhitelistExtra3);
    ProgressBar mProgress = (ProgressBar) view.findViewById(R.id.pbProgress);
    Button btnDeny = (Button) view.findViewById(R.id.btnDeny);
    Button btnDontKnow = (Button) view.findViewById(R.id.btnDontKnow);
    Button btnAllow = (Button) view.findViewById(R.id.btnAllow);
    final int userId = Util.getUserId(Process.myUid());
    boolean expert = getSettingBool(userId, PrivacyManager.cSettingODExpert, false);
    boolean category = getSettingBool(userId, PrivacyManager.cSettingODCategory, true);
    boolean once = getSettingBool(userId, PrivacyManager.cSettingODOnce, false);
    expert = expert || !category || once;
    final boolean whitelistDangerous = (hook != null && hook.isDangerous() && hook.whitelist() != null);
    // Set values
    if ((hook != null && hook.isDangerous()) || appInfo.isSystem())
        view.setBackgroundResource(R.color.color_dangerous_dialog);
    else
        view.setBackgroundResource(android.R.color.background_dark);
    // Application information
    ivAppIcon.setImageDrawable(appInfo.getIcon(context));
    tvUid.setText(Integer.toString(appInfo.getUid()));
    tvAppName.setText(TextUtils.join(", ", appInfo.getApplicationName()));
    // Restriction information
    int catId = resources.getIdentifier("restrict_" + restriction.restrictionName, "string", self);
    tvCategory.setText(resources.getString(catId));
    tvFunction.setText(restriction.methodName);
    if (restriction.extra == null)
        rowParameters.setVisibility(View.GONE);
    else
        tvParameters.setText(restriction.extra);
    String defaultAction = resources.getString(result.restricted ? R.string.title_deny : R.string.title_allow);
    tvDefault.setText(defaultAction);
    // Help
    int helpId = resources.getIdentifier("restrict_help_" + restriction.restrictionName, "string", self);
    tvInfoCategory.setText(resources.getString(helpId));
    // Expert mode
    cbExpert.setChecked(expert);
    if (expert) {
        for (View child : Util.getViewsByTag((ViewGroup) view, "details")) child.setVisibility(View.VISIBLE);
        for (View child : Util.getViewsByTag((ViewGroup) view, "nodetails")) child.setVisibility(View.GONE);
    }
    if (expert || whitelistDangerous)
        llWhiteList.setVisibility(View.VISIBLE);
    // Category
    cbCategory.setChecked(category);
    // Once
    cbOnce.setChecked(once);
    int osel = Integer.parseInt(getSetting(new PSetting(userId, "", PrivacyManager.cSettingODOnceDuration, "0")).value);
    spOnce.setSelection(osel);
    // Whitelisting
    if (hook != null && hook.whitelist() != null && restriction.extra != null) {
        cbWhitelist.setText(resources.getString(R.string.title_whitelist, restriction.extra));
        cbWhitelist.setVisibility(View.VISIBLE);
        String[] xextra = getXExtra(restriction, hook);
        if (xextra.length > 0) {
            cbWhitelistExtra1.setText(resources.getString(R.string.title_whitelist, xextra[0]));
            cbWhitelistExtra1.setVisibility(View.VISIBLE);
        }
        if (xextra.length > 1) {
            cbWhitelistExtra2.setText(resources.getString(R.string.title_whitelist, xextra[1]));
            cbWhitelistExtra2.setVisibility(View.VISIBLE);
        }
        if (xextra.length > 2) {
            cbWhitelistExtra3.setText(resources.getString(R.string.title_whitelist, xextra[2]));
            cbWhitelistExtra3.setVisibility(View.VISIBLE);
        }
    }
    cbExpert.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            setSettingBool(userId, "", PrivacyManager.cSettingODExpert, isChecked);
            if (!isChecked) {
                setSettingBool(userId, "", PrivacyManager.cSettingODCategory, true);
                setSettingBool(userId, "", PrivacyManager.cSettingODOnce, false);
                cbCategory.setChecked(true);
                cbOnce.setChecked(false);
                cbWhitelist.setChecked(false);
                cbWhitelistExtra1.setChecked(false);
                cbWhitelistExtra2.setChecked(false);
                cbWhitelistExtra3.setChecked(false);
            }
            for (View child : Util.getViewsByTag((ViewGroup) view, "details")) child.setVisibility(isChecked ? View.VISIBLE : View.GONE);
            for (View child : Util.getViewsByTag((ViewGroup) view, "nodetails")) child.setVisibility(isChecked ? View.GONE : View.VISIBLE);
            if (!whitelistDangerous)
                llWhiteList.setVisibility(isChecked ? View.VISIBLE : View.GONE);
        }
    });
    // Category, once and whitelist exclude each other
    cbCategory.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                cbWhitelist.setChecked(false);
                cbWhitelistExtra1.setChecked(false);
                cbWhitelistExtra2.setChecked(false);
                cbWhitelistExtra3.setChecked(false);
            }
        }
    });
    cbOnce.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                cbWhitelist.setChecked(false);
                cbWhitelistExtra1.setChecked(false);
                cbWhitelistExtra2.setChecked(false);
                cbWhitelistExtra3.setChecked(false);
            }
        }
    });
    cbWhitelist.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                cbCategory.setChecked(false);
                cbOnce.setChecked(false);
                cbWhitelistExtra1.setChecked(false);
                cbWhitelistExtra2.setChecked(false);
                cbWhitelistExtra3.setChecked(false);
            }
        }
    });
    cbWhitelistExtra1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                cbCategory.setChecked(false);
                cbOnce.setChecked(false);
                cbWhitelist.setChecked(false);
                cbWhitelistExtra2.setChecked(false);
                cbWhitelistExtra3.setChecked(false);
            }
        }
    });
    cbWhitelistExtra2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                cbCategory.setChecked(false);
                cbOnce.setChecked(false);
                cbWhitelist.setChecked(false);
                cbWhitelistExtra1.setChecked(false);
                cbWhitelistExtra3.setChecked(false);
            }
        }
    });
    cbWhitelistExtra3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                cbCategory.setChecked(false);
                cbOnce.setChecked(false);
                cbWhitelist.setChecked(false);
                cbWhitelistExtra1.setChecked(false);
                cbWhitelistExtra2.setChecked(false);
            }
        }
    });
    // Setup progress bar
    mProgress.setMax(cMaxOnDemandDialog * 20);
    mProgress.setProgress(cMaxOnDemandDialog * 20);
    btnAllow.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // Allow
            result.restricted = false;
            result.asked = true;
            if (cbWhitelist.isChecked())
                onDemandWhitelist(restriction, null, result, oResult, hook);
            else if (cbWhitelistExtra1.isChecked())
                onDemandWhitelist(restriction, getXExtra(restriction, hook)[0], result, oResult, hook);
            else if (cbWhitelistExtra2.isChecked())
                onDemandWhitelist(restriction, getXExtra(restriction, hook)[1], result, oResult, hook);
            else if (cbWhitelistExtra3.isChecked())
                onDemandWhitelist(restriction, getXExtra(restriction, hook)[2], result, oResult, hook);
            else {
                setSettingBool(userId, "", PrivacyManager.cSettingODCategory, cbCategory.isChecked());
                setSettingBool(userId, "", PrivacyManager.cSettingODOnce, cbOnce.isChecked());
                if (cbOnce.isChecked())
                    onDemandOnce(restriction, cbCategory.isChecked(), result, oResult, spOnce);
                else
                    onDemandChoice(restriction, cbCategory.isChecked(), false);
            }
            holder.latch.countDown();
        }
    });
    btnDontKnow.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // Deny once
            result.restricted = !(hook != null && hook.isDangerous());
            result.asked = true;
            onDemandOnce(restriction, false, result, oResult, spOnce);
            holder.latch.countDown();
        }
    });
    btnDeny.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            // Deny
            result.restricted = true;
            result.asked = true;
            if (cbWhitelist.isChecked())
                onDemandWhitelist(restriction, null, result, oResult, hook);
            else if (cbWhitelistExtra1.isChecked())
                onDemandWhitelist(restriction, getXExtra(restriction, hook)[0], result, oResult, hook);
            else if (cbWhitelistExtra2.isChecked())
                onDemandWhitelist(restriction, getXExtra(restriction, hook)[1], result, oResult, hook);
            else if (cbWhitelistExtra3.isChecked())
                onDemandWhitelist(restriction, getXExtra(restriction, hook)[2], result, oResult, hook);
            else {
                setSettingBool(userId, "", PrivacyManager.cSettingODCategory, cbCategory.isChecked());
                setSettingBool(userId, "", PrivacyManager.cSettingODOnce, cbOnce.isChecked());
                if (cbOnce.isChecked())
                    onDemandOnce(restriction, cbCategory.isChecked(), result, oResult, spOnce);
                else
                    onDemandChoice(restriction, cbCategory.isChecked(), true);
            }
            holder.latch.countDown();
        }
    });
    return view;
}
Also used : Spinner(android.widget.Spinner) ViewGroup(android.view.ViewGroup) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) CheckBox(android.widget.CheckBox) TableRow(android.widget.TableRow) TextView(android.widget.TextView) Resources(android.content.res.Resources) ImageView(android.widget.ImageView) ProgressBar(android.widget.ProgressBar) LinearLayout(android.widget.LinearLayout) CompoundButton(android.widget.CompoundButton) SuppressLint(android.annotation.SuppressLint)

Example 12 with CompoundButton

use of android.widget.CompoundButton in project XPrivacy by M66B.

the class ActivityMain method optionFilter.

@SuppressLint("InflateParams")
private void optionFilter() {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.filters, null);
    final CheckBox cbFUsed = (CheckBox) view.findViewById(R.id.cbFUsed);
    final CheckBox cbFInternet = (CheckBox) view.findViewById(R.id.cbFInternet);
    final CheckBox cbFPermission = (CheckBox) view.findViewById(R.id.cbFPermission);
    final CheckBox cbFRestriction = (CheckBox) view.findViewById(R.id.cbFRestriction);
    final CheckBox cbFRestrictionNot = (CheckBox) view.findViewById(R.id.cbFRestrictionNot);
    final CheckBox cbFOnDemand = (CheckBox) view.findViewById(R.id.cbFOnDemand);
    final CheckBox cbFOnDemandNot = (CheckBox) view.findViewById(R.id.cbFOnDemandNot);
    final CheckBox cbFUser = (CheckBox) view.findViewById(R.id.cbFUser);
    final CheckBox cbFSystem = (CheckBox) view.findViewById(R.id.cbFSystem);
    final Button btnDefault = (Button) view.findViewById(R.id.btnDefault);
    // Get settings
    final int userId = Util.getUserId(Process.myUid());
    boolean fUsed = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFUsed, false);
    boolean fInternet = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFInternet, false);
    boolean fPermission = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFPermission, true);
    boolean fRestriction = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFRestriction, false);
    boolean fRestrictionNot = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFRestrictionNot, false);
    boolean fOnDemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFOnDemand, false);
    boolean fOnDemandNot = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFOnDemandNot, false);
    boolean fUser = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFUser, true);
    boolean fSystem = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFSystem, false);
    boolean ondemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true);
    // Setup checkboxes
    cbFUsed.setChecked(fUsed);
    cbFInternet.setChecked(fInternet);
    cbFPermission.setChecked(fPermission);
    cbFRestriction.setChecked(fRestriction);
    cbFRestrictionNot.setChecked(fRestrictionNot);
    cbFOnDemand.setChecked(fOnDemand && ondemand);
    cbFOnDemandNot.setChecked(fOnDemandNot && ondemand);
    cbFUser.setChecked(fUser);
    cbFSystem.setChecked(fSystem);
    cbFRestrictionNot.setEnabled(fRestriction);
    cbFOnDemand.setEnabled(ondemand);
    cbFOnDemandNot.setEnabled(fOnDemand && ondemand);
    // Manage user/system filter exclusivity
    OnCheckedChangeListener checkListener = new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (buttonView == cbFUser) {
                if (isChecked)
                    cbFSystem.setChecked(false);
            } else if (buttonView == cbFSystem) {
                if (isChecked)
                    cbFUser.setChecked(false);
            } else if (buttonView == cbFRestriction)
                cbFRestrictionNot.setEnabled(cbFRestriction.isChecked());
            else if (buttonView == cbFOnDemand)
                cbFOnDemandNot.setEnabled(cbFOnDemand.isChecked());
        }
    };
    cbFUser.setOnCheckedChangeListener(checkListener);
    cbFSystem.setOnCheckedChangeListener(checkListener);
    cbFRestriction.setOnCheckedChangeListener(checkListener);
    cbFOnDemand.setOnCheckedChangeListener(checkListener);
    // Clear button
    btnDefault.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            cbFUsed.setChecked(false);
            cbFInternet.setChecked(false);
            cbFPermission.setChecked(true);
            cbFRestriction.setChecked(false);
            cbFRestrictionNot.setChecked(false);
            cbFOnDemand.setChecked(false);
            cbFOnDemandNot.setChecked(false);
            cbFUser.setChecked(true);
            cbFSystem.setChecked(false);
        }
    });
    // Build dialog
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityMain.this);
    alertDialogBuilder.setTitle(R.string.menu_filter);
    alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher));
    alertDialogBuilder.setView(view);
    alertDialogBuilder.setPositiveButton(ActivityMain.this.getString(android.R.string.ok), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFUsed, Boolean.toString(cbFUsed.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFInternet, Boolean.toString(cbFInternet.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFRestriction, Boolean.toString(cbFRestriction.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFRestrictionNot, Boolean.toString(cbFRestrictionNot.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFPermission, Boolean.toString(cbFPermission.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFOnDemand, Boolean.toString(cbFOnDemand.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFOnDemandNot, Boolean.toString(cbFOnDemandNot.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFUser, Boolean.toString(cbFUser.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFSystem, Boolean.toString(cbFSystem.isChecked()));
            invalidateOptionsMenu();
            applyFilter();
        }
    });
    alertDialogBuilder.setNegativeButton(ActivityMain.this.getString(android.R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    // Show dialog
    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) DialogInterface(android.content.DialogInterface) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) WebView(android.webkit.WebView) TextView(android.widget.TextView) ListView(android.widget.ListView) SearchView(android.widget.SearchView) ScrollView(android.widget.ScrollView) ExpandableListView(android.widget.ExpandableListView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) CheckBox(android.widget.CheckBox) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.view.View.OnClickListener) CompoundButton(android.widget.CompoundButton) SuppressLint(android.annotation.SuppressLint)

Example 13 with CompoundButton

use of android.widget.CompoundButton in project Notes by MiCode.

the class NoteEditActivity method getListItem.

private View getListItem(String item, int index) {
    View view = LayoutInflater.from(this).inflate(R.layout.note_edit_list_item, null);
    final NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text);
    edit.setTextAppearance(this, TextAppearanceResources.getTexAppearanceResource(mFontSizeId));
    CheckBox cb = ((CheckBox) view.findViewById(R.id.cb_edit_item));
    cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                edit.setPaintFlags(edit.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            } else {
                edit.setPaintFlags(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);
            }
        }
    });
    if (item.startsWith(TAG_CHECKED)) {
        cb.setChecked(true);
        edit.setPaintFlags(edit.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        item = item.substring(TAG_CHECKED.length(), item.length()).trim();
    } else if (item.startsWith(TAG_UNCHECKED)) {
        cb.setChecked(false);
        edit.setPaintFlags(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);
        item = item.substring(TAG_UNCHECKED.length(), item.length()).trim();
    }
    edit.setOnTextViewChangeListener(this);
    edit.setIndex(index);
    edit.setText(getHighlightQueryResult(item, mUserQuery));
    return view;
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) CheckBox(android.widget.CheckBox) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton)

Example 14 with CompoundButton

use of android.widget.CompoundButton in project Xposed-Tinted-Status-Bar by MohammadAG.

the class ActivitesListActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activites_list, menu);
    mSearchItem = menu.findItem(R.id.action_search);
    final SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    mSearchItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {

        @Override
        public boolean onMenuItemActionExpand(MenuItem menuItem) {
            searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

                @Override
                public boolean onQueryTextSubmit(String query) {
                    mNameFilter = query;
                    mActivityListAdapter.getFilter().filter(mNameFilter);
                    findViewById(R.id.action_search).clearFocus();
                    return false;
                }

                @Override
                public boolean onQueryTextChange(String newText) {
                    mNameFilter = newText;
                    mActivityListAdapter.getFilter().filter(mNameFilter);
                    return false;
                }
            });
            return true;
        }

        @Override
        public boolean onMenuItemActionCollapse(MenuItem menuItem) {
            mActivityListAdapter.getFilter().filter("");
            return true;
        }
    });
    MenuItem actionSwitch = menu.findItem(R.id.switch_button);
    mSwitch = (Switch) actionSwitch.getActionView().findViewById(R.id.color_switch);
    if (mSwitch != null) {
        mSwitch.setChecked(mSettingsHelper.isEnabled(mPackageName, null));
        // Toggle the visibility of the lower panel when changed
        mSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mDirty = true;
                String keyName = SettingsHelper.getKeyName(mPackageName, null, SettingsKeys.IS_ACTIVE);
                mSettingsHelper.getSharedPreferences().edit().putBoolean(keyName, isChecked).commit();
                mActivityListAdapter.notifyDataSetChanged();
            }
        });
    }
    return true;
}
Also used : SearchView(android.widget.SearchView) MenuItem(android.view.MenuItem) CompoundButton(android.widget.CompoundButton)

Example 15 with CompoundButton

use of android.widget.CompoundButton in project Xposed-Tinted-Status-Bar by MohammadAG.

the class ApplicationSettings method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.applications_settings, menu);
    MenuItem actionSwitch = menu.findItem(R.id.switch_button);
    mSwitch = (Switch) actionSwitch.getActionView().findViewById(R.id.color_switch);
    if (mSwitch != null) {
        mSwitch.setChecked(mSettingsHelper.isEnabled(mPackageName, mActivityName));
        // Toggle the visibility of the lower panel when changed
        mSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mDirty = true;
                Editor editor = mSettingsHelper.getSharedPreferences().edit();
                String keyName = SettingsHelper.getKeyName(mPackageName, mActivityName, SettingsKeys.IS_ACTIVE);
                editor.putBoolean(keyName, isChecked);
                editor.commit();
            }
        });
    }
    updateMenuEntries(getApplicationContext(), menu, mPackageName);
    return true;
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) MenuItem(android.view.MenuItem) Editor(android.content.SharedPreferences.Editor) CompoundButton(android.widget.CompoundButton)

Aggregations

CompoundButton (android.widget.CompoundButton)235 View (android.view.View)118 TextView (android.widget.TextView)95 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)60 ImageView (android.widget.ImageView)48 CheckBox (android.widget.CheckBox)42 AdapterView (android.widget.AdapterView)25 Button (android.widget.Button)22 DialogInterface (android.content.DialogInterface)21 LayoutInflater (android.view.LayoutInflater)20 OnClickListener (android.view.View.OnClickListener)18 Intent (android.content.Intent)17 SeekBar (android.widget.SeekBar)17 Switch (android.widget.Switch)17 SwitchCompat (android.support.v7.widget.SwitchCompat)15 AlertDialog (android.app.AlertDialog)13 ArrayList (java.util.ArrayList)12 Context (android.content.Context)11 OnClickListener (android.content.DialogInterface.OnClickListener)11 Cursor (android.database.Cursor)11