Search in sources :

Example 76 with CheckBox

use of android.widget.CheckBox in project orWall by EthACKdotOrg.

the class AppListAdapter method saveAdvanced.

private void saveAdvanced(AppRule appRule, View view) {
    // Update DB content
    AppRule updated = new AppRule();
    updated.setAppName(appRule.getAppName());
    updated.setPkgName(appRule.getPkgName());
    updated.setAppUID(appRule.getAppUID());
    // none
    if (!checkboxInternet.isChecked()) {
        updated.setOnionType(Constants.DB_ONION_TYPE_NONE);
    } else // Anonymity provider
    if (radioTor.isChecked()) {
        updated.setOnionType(Constants.DB_ONION_TYPE_TOR);
    } else if (radioBypass.isChecked()) {
        updated.setOnionType(Constants.DB_ONION_TYPE_BYPASS);
    }
    /*
        else
        if (radioI2p.isChecked()) {
            updated.setOnionType(Constants.DB_ONION_TYPE_I2P);
        }
*/
    updated.setLocalHost(this.checkLocalHost.isChecked());
    updated.setLocalNetwork(this.checkLocalNetwork.isChecked());
    boolean done;
    // CREATE
    if (!appRule.isStored() && !updated.isEmpty()) {
        done = natRules.addAppToRules(updated);
        if (done) {
            updated.install(this.context);
            Toast.makeText(context, context.getString(R.string.toast_new_rule), Toast.LENGTH_SHORT).show();
        }
    } else // UPDATE
    if (appRule.isStored() && !updated.isEmpty()) {
        done = natRules.update(updated);
        if (done) {
            appRule.uninstall(this.context);
            updated.install(this.context);
            Toast.makeText(context, context.getString(R.string.toast_update_rule), Toast.LENGTH_SHORT).show();
        }
    } else //DELETE
    if (appRule.isStored() && updated.isEmpty()) {
        done = natRules.removeAppFromRules(updated.getAppUID());
        if (done) {
            appRule.uninstall(this.context);
            Toast.makeText(context, context.getString(R.string.toast_remove_rule), Toast.LENGTH_SHORT).show();
        }
    } else {
        // nothing to do
        return;
    }
    if (done) {
        appRule.setOnionType(updated.getOnionType());
        appRule.setLocalHost(updated.getLocalHost());
        appRule.setLocalNetwork(updated.getLocalNetwork());
        if (appRule.isEmpty()) {
            appRule.setStored(false);
            appRule.setLabel(appRule.getAppName());
        } else {
            appRule.setStored(true);
            appRule.setLabel(appRule.getDisplay());
        }
        CheckBox checkBox = (CheckBox) view;
        checkBox.setText(appRule.getLabel());
        checkBox.setChecked(appRule.isStored());
    } else {
        // error updating database
        appRule.setOnionType(Constants.DB_ONION_TYPE_NONE);
        Toast.makeText(context, String.format(context.getString(R.string.toast_error), 3), Toast.LENGTH_SHORT).show();
    }
}
Also used : CheckBox(android.widget.CheckBox) AppRule(org.ethack.orwall.lib.AppRule)

Example 77 with CheckBox

use of android.widget.CheckBox in project AndroidChromium by JackyAndroid.

the class DataUseTabUIManager method startDataUseDialog.

/**
     * Shows a dialog with the option to cancel the navigation or continue. Also allows the user to
     * opt out of seeing this dialog again.
     *
     * @param activity Current activity.
     * @param tab The tab loading the url.
     * @param url URL that is pending.
     * @param pageTransitionType The type of transition. see
     *            {@link org.chromium.content.browser.PageTransition} for valid values.
     * @param referrerUrl URL for the referrer.
     */
private static void startDataUseDialog(final Activity activity, final Tab tab, final String url, final int pageTransitionType, final String referrerUrl) {
    View dataUseDialogView = View.inflate(activity, R.layout.data_use_dialog, null);
    final TextView textView = (TextView) dataUseDialogView.findViewById(R.id.data_use_message);
    textView.setText(getDataUseUIString(DataUseUIMessage.DATA_USE_TRACKING_ENDED_MESSAGE));
    final CheckBox checkBox = (CheckBox) dataUseDialogView.findViewById(R.id.data_use_checkbox);
    checkBox.setText(getDataUseUIString(DataUseUIMessage.DATA_USE_TRACKING_ENDED_CHECKBOX_MESSAGE));
    View learnMore = dataUseDialogView.findViewById(R.id.learn_more);
    learnMore.setOnClickListener(new android.view.View.OnClickListener() {

        @Override
        public void onClick(View v) {
            EmbedContentViewActivity.show(activity, getDataUseUIString(DataUseUIMessage.DATA_USE_LEARN_MORE_TITLE), getDataUseUIString(DataUseUIMessage.DATA_USE_LEARN_MORE_LINK_URL));
            recordDataUseUIAction(DataUsageUIAction.DIALOG_LEARN_MORE_CLICKED);
        }
    });
    new AlertDialog.Builder(activity, R.style.AlertDialogTheme).setTitle(getDataUseUIString(DataUseUIMessage.DATA_USE_TRACKING_ENDED_TITLE)).setView(dataUseDialogView).setPositiveButton(getDataUseUIString(DataUseUIMessage.DATA_USE_TRACKING_ENDED_CONTINUE), new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            setOptedOutOfDataUseDialog(activity, checkBox.isChecked());
            LoadUrlParams loadUrlParams = new LoadUrlParams(url, pageTransitionType);
            if (!TextUtils.isEmpty(referrerUrl)) {
                Referrer referrer = new Referrer(referrerUrl, Referrer.REFERRER_POLICY_ALWAYS);
                loadUrlParams.setReferrer(referrer);
            }
            tab.loadUrl(loadUrlParams);
            recordDataUseUIAction(DataUsageUIAction.DIALOG_CONTINUE_CLICKED);
            userClickedContinueOnDialogBox(tab);
        }
    }).setNegativeButton(R.string.cancel, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            setOptedOutOfDataUseDialog(activity, checkBox.isChecked());
            recordDataUseUIAction(DataUsageUIAction.DIALOG_CANCEL_CLICKED);
        }
    }).show();
    recordDataUseUIAction(DataUsageUIAction.DIALOG_SHOWN);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) TextView(android.widget.TextView) View(android.view.View) CheckBox(android.widget.CheckBox) Referrer(org.chromium.content_public.common.Referrer) OnClickListener(android.content.DialogInterface.OnClickListener) TextView(android.widget.TextView) LoadUrlParams(org.chromium.content_public.browser.LoadUrlParams)

Example 78 with CheckBox

use of android.widget.CheckBox in project wifikeyboard by IvanVolosyuk.

the class WidgetConfigure method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    if (extras != null) {
        mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
    }
    setContentView(R.layout.configure);
    final EditText editText = (EditText) findViewById(R.id.text);
    final CheckBox enabled = (CheckBox) findViewById(R.id.enabled);
    Button ok = (Button) findViewById(R.id.ok);
    Button cancel = (Button) findViewById(R.id.cancel);
    ok.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            SharedPreferences prefs = getSharedPreferences(PREFS_WIDGETS, Context.MODE_PRIVATE);
            SharedPreferences.Editor editor = prefs.edit();
            editor.putBoolean(textEnableProperty(mAppWidgetId), enabled.isChecked());
            editor.putString(textStringProperty(mAppWidgetId), editText.getText().toString());
            editor.commit();
            WidgetProvider.log(WidgetConfigure.this, "Widget " + mAppWidgetId + " configured");
            AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(WidgetConfigure.this);
            updateWidget(WidgetConfigure.this, appWidgetManager, mAppWidgetId);
            Intent resultValue = new Intent();
            resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
            setResult(RESULT_OK, resultValue);
            finish();
        }
    });
    cancel.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });
    enabled.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            editText.setEnabled(isChecked);
        }
    });
    Intent resultValue = new Intent();
    resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
    setResult(RESULT_CANCELED, resultValue);
}
Also used : EditText(android.widget.EditText) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) SharedPreferences(android.content.SharedPreferences) Bundle(android.os.Bundle) AppWidgetManager(android.appwidget.AppWidgetManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) View(android.view.View) CompoundButton(android.widget.CompoundButton) Button(android.widget.Button) CheckBox(android.widget.CheckBox) OnClickListener(android.view.View.OnClickListener) CompoundButton(android.widget.CompoundButton)

Example 79 with CheckBox

use of android.widget.CheckBox in project AntennaPod by AntennaPod.

the class AutoFlattrPreferenceDialog method newAutoFlattrPreferenceDialog.

public static void newAutoFlattrPreferenceDialog(final Activity activity, final AutoFlattrPreferenceDialogInterface callback) {
    Validate.notNull(activity);
    Validate.notNull(callback);
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    @SuppressLint("InflateParams") View view = activity.getLayoutInflater().inflate(R.layout.autoflattr_preference_dialog, null);
    final CheckBox chkAutoFlattr = (CheckBox) view.findViewById(R.id.chkAutoFlattr);
    final SeekBar skbPercent = (SeekBar) view.findViewById(R.id.skbPercent);
    final TextView txtvStatus = (TextView) view.findViewById(R.id.txtvStatus);
    chkAutoFlattr.setChecked(UserPreferences.isAutoFlattr());
    skbPercent.setEnabled(chkAutoFlattr.isChecked());
    txtvStatus.setEnabled(chkAutoFlattr.isChecked());
    final int initialValue = (int) (UserPreferences.getAutoFlattrPlayedDurationThreshold() * 100.0f);
    setStatusMsgText(activity, txtvStatus, initialValue);
    skbPercent.setProgress(initialValue);
    chkAutoFlattr.setOnClickListener(v -> {
        skbPercent.setEnabled(chkAutoFlattr.isChecked());
        txtvStatus.setEnabled(chkAutoFlattr.isChecked());
    });
    skbPercent.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            setStatusMsgText(activity, txtvStatus, progress);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    builder.setTitle(R.string.pref_auto_flattr_title).setView(view).setPositiveButton(R.string.confirm_label, (dialog, which) -> {
        float progDouble = ((float) skbPercent.getProgress()) / 100.0f;
        callback.onConfirmed(chkAutoFlattr.isChecked(), progDouble);
        dialog.dismiss();
    }).setNegativeButton(R.string.cancel_label, (dialog, which) -> {
        callback.onCancelled();
        dialog.dismiss();
    }).setCancelable(false).show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) UserPreferences(de.danoeh.antennapod.core.preferences.UserPreferences) Context(android.content.Context) SeekBar(android.widget.SeekBar) SuppressLint(android.annotation.SuppressLint) AlertDialog(android.support.v7.app.AlertDialog) TextView(android.widget.TextView) Validate(org.apache.commons.lang3.Validate) CheckBox(android.widget.CheckBox) R(de.danoeh.antennapod.R) View(android.view.View) Activity(android.app.Activity) SeekBar(android.widget.SeekBar) TextView(android.widget.TextView) View(android.view.View) SuppressLint(android.annotation.SuppressLint) CheckBox(android.widget.CheckBox) SuppressLint(android.annotation.SuppressLint) TextView(android.widget.TextView)

Example 80 with CheckBox

use of android.widget.CheckBox in project android_frameworks_base by DirtyUnicorns.

the class VectorDrawable01 method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GridLayout container = new GridLayout(this);
    container.setColumnCount(5);
    container.setBackgroundColor(0xFF888888);
    final Button[] bArray = new Button[icon.length];
    CheckBox toggle = new CheckBox(this);
    toggle.setText("Toggle");
    toggle.setChecked(true);
    toggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            ViewGroup vg = (ViewGroup) buttonView.getParent();
            for (int i = 0, count = vg.getChildCount(); i < count; i++) {
                View child = vg.getChildAt(i);
                if (child != buttonView) {
                    child.setEnabled(isChecked);
                }
            }
        }
    });
    container.addView(toggle);
    for (int i = 0; i < icon.length; i++) {
        Button button = new Button(this);
        bArray[i] = button;
        button.setWidth(200);
        button.setBackgroundResource(icon[i]);
        container.addView(button);
        VectorDrawable vd = (VectorDrawable) button.getBackground();
        vd.setAlpha((i + 1) * (0xFF / (icon.length + 1)));
    }
    setContentView(container);
}
Also used : GridLayout(android.widget.GridLayout) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) CompoundButton(android.widget.CompoundButton) Button(android.widget.Button) CheckBox(android.widget.CheckBox) ViewGroup(android.view.ViewGroup) View(android.view.View) CompoundButton(android.widget.CompoundButton) VectorDrawable(android.graphics.drawable.VectorDrawable)

Aggregations

CheckBox (android.widget.CheckBox)197 View (android.view.View)102 TextView (android.widget.TextView)78 CompoundButton (android.widget.CompoundButton)51 Button (android.widget.Button)48 ImageView (android.widget.ImageView)32 Intent (android.content.Intent)30 EditText (android.widget.EditText)30 LayoutInflater (android.view.LayoutInflater)25 AdapterView (android.widget.AdapterView)25 DialogInterface (android.content.DialogInterface)21 ListView (android.widget.ListView)20 SuppressLint (android.annotation.SuppressLint)19 RadioButton (android.widget.RadioButton)19 AlertDialog (android.app.AlertDialog)17 Paint (android.graphics.Paint)14 Bundle (android.os.Bundle)12 ViewGroup (android.view.ViewGroup)12 GridLayout (android.widget.GridLayout)12 LinearLayout (android.widget.LinearLayout)12