Search in sources :

Example 56 with CompoundButton

use of android.widget.CompoundButton in project SeriesGuide by UweTrottmann.

the class DataLiberationFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_data_liberation, container, false);
    unbinder = ButterKnife.bind(this, v);
    progressBar.setVisibility(View.GONE);
    // setup listeners
    buttonExport.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryDataLiberationAction(REQUEST_CODE_EXPORT);
        }
    });
    checkBoxImportWarning.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateImportButtonEnabledState();
        }
    });
    checkBoxShows.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateImportButtonEnabledState();
        }
    });
    checkBoxLists.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateImportButtonEnabledState();
        }
    });
    checkBoxMovies.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateImportButtonEnabledState();
        }
    });
    buttonImport.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryDataLiberationAction(REQUEST_CODE_IMPORT);
        }
    });
    // as we use Storage Access Framework in this case
    if (AndroidUtils.isKitKatOrHigher()) {
        buttonShowsExportFile.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                DataLiberationTools.selectExportFile(DataLiberationFragment.this, JsonExportTask.EXPORT_JSON_FILE_SHOWS, REQUEST_CODE_SHOWS_EXPORT_URI);
            }
        });
        buttonShowsImportFile.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                DataLiberationTools.selectImportFile(DataLiberationFragment.this, REQUEST_CODE_SHOWS_IMPORT_URI);
            }
        });
        buttonListsExportFile.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                DataLiberationTools.selectExportFile(DataLiberationFragment.this, JsonExportTask.EXPORT_JSON_FILE_LISTS, REQUEST_CODE_LISTS_EXPORT_URI);
            }
        });
        buttonListsImportFile.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                DataLiberationTools.selectImportFile(DataLiberationFragment.this, REQUEST_CODE_LISTS_IMPORT_URI);
            }
        });
        buttonMoviesExportFile.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                DataLiberationTools.selectExportFile(DataLiberationFragment.this, JsonExportTask.EXPORT_JSON_FILE_MOVIES, REQUEST_CODE_MOVIES_EXPORT_URI);
            }
        });
        buttonMoviesImportFile.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                DataLiberationTools.selectImportFile(DataLiberationFragment.this, REQUEST_CODE_MOVIES_IMPORT_URI);
            }
        });
    } else {
        buttonShowsExportFile.setVisibility(View.GONE);
        buttonShowsImportFile.setVisibility(View.GONE);
        buttonListsExportFile.setVisibility(View.GONE);
        buttonListsImportFile.setVisibility(View.GONE);
        buttonMoviesExportFile.setVisibility(View.GONE);
        buttonMoviesImportFile.setVisibility(View.GONE);
    }
    updateFileViews();
    return v;
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) OnClickListener(android.view.View.OnClickListener) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton)

Example 57 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 58 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 59 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 60 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)249 View (android.view.View)129 TextView (android.widget.TextView)102 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)63 ImageView (android.widget.ImageView)50 CheckBox (android.widget.CheckBox)45 AdapterView (android.widget.AdapterView)27 Intent (android.content.Intent)26 Button (android.widget.Button)24 DialogInterface (android.content.DialogInterface)23 LayoutInflater (android.view.LayoutInflater)23 OnClickListener (android.view.View.OnClickListener)20 Switch (android.widget.Switch)18 SeekBar (android.widget.SeekBar)17 SwitchCompat (android.support.v7.widget.SwitchCompat)15 AlertDialog (android.app.AlertDialog)14 RecyclerView (android.support.v7.widget.RecyclerView)13 ArrayList (java.util.ArrayList)13 LinearLayout (android.widget.LinearLayout)12 OnClickListener (android.content.DialogInterface.OnClickListener)11