Search in sources :

Example 86 with RadioButton

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

the class SubscriptionsFilterDialog method showDialog.

public static void showDialog(Context context) {
    SubscriptionsFilter subscriptionsFilter = UserPreferences.getSubscriptionsFilter();
    final Set<String> filterValues = new HashSet<>(Arrays.asList(subscriptionsFilter.getValues()));
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(context.getString(R.string.pref_filter_feed_title));
    LayoutInflater inflater = LayoutInflater.from(context);
    View layout = inflater.inflate(R.layout.filter_dialog, null, false);
    LinearLayout rows = layout.findViewById(R.id.filter_rows);
    builder.setView(layout);
    for (SubscriptionsFilterGroup item : SubscriptionsFilterGroup.values()) {
        RecursiveRadioGroup row = (RecursiveRadioGroup) inflater.inflate(R.layout.filter_dialog_row, null);
        RadioButton filter1 = row.findViewById(R.id.filter_dialog_radioButton1);
        RadioButton filter2 = row.findViewById(R.id.filter_dialog_radioButton2);
        filter1.setText(item.values[0].displayName);
        filter1.setTag(item.values[0].filterId);
        if (item.values.length == 2) {
            filter2.setText(item.values[1].displayName);
            filter2.setTag(item.values[1].filterId);
        } else {
            filter2.setVisibility(View.GONE);
        }
        rows.addView(row);
    }
    for (String filterId : filterValues) {
        if (!TextUtils.isEmpty(filterId)) {
            ((RadioButton) layout.findViewWithTag(filterId)).setChecked(true);
        }
    }
    builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> {
        filterValues.clear();
        for (int i = 0; i < rows.getChildCount(); i++) {
            if (!(rows.getChildAt(i) instanceof RecursiveRadioGroup)) {
                continue;
            }
            RecursiveRadioGroup group = (RecursiveRadioGroup) rows.getChildAt(i);
            if (group.getCheckedButton() != null) {
                String tag = (String) group.getCheckedButton().getTag();
                if (tag != null) {
                    // Clear buttons use no tag
                    filterValues.add((String) group.getCheckedButton().getTag());
                }
            }
        }
        updateFilter(filterValues);
    });
    builder.setNegativeButton(R.string.cancel_label, null);
    builder.show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) SubscriptionsFilterGroup(de.danoeh.antennapod.core.feed.SubscriptionsFilterGroup) RadioButton(android.widget.RadioButton) View(android.view.View) LayoutInflater(android.view.LayoutInflater) RecursiveRadioGroup(de.danoeh.antennapod.ui.common.RecursiveRadioGroup) SubscriptionsFilter(de.danoeh.antennapod.core.feed.SubscriptionsFilter) LinearLayout(android.widget.LinearLayout) HashSet(java.util.HashSet)

Example 87 with RadioButton

use of android.widget.RadioButton in project coursera-android by aporter.

the class SamplerActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    // 
    final ImageButton button = (ImageButton) findViewById(R.id.button);
    button.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // Show Toast message
            Toast.makeText(SamplerActivity.this, "Beep Bop", Toast.LENGTH_SHORT).show();
        }
    });
    final EditText edittext = (EditText) findViewById(R.id.edittext);
    edittext.setOnKeyListener(new OnKeyListener() {

        public boolean onKey(View v, int keyCode, KeyEvent event) {
            // If the event is a key-down event on the "Done" button
            if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                // Show Toast message
                Toast.makeText(SamplerActivity.this, edittext.getText(), Toast.LENGTH_SHORT).show();
                return true;
            }
            return false;
        }
    });
    final CheckBox checkbox = (CheckBox) findViewById(R.id.checkbox);
    checkbox.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // Show Toast message indicating the CheckBox's Checked state
            if (((CheckBox) v).isChecked()) {
                Toast.makeText(SamplerActivity.this, "CheckBox checked", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(SamplerActivity.this, "CheckBox not checked", Toast.LENGTH_SHORT).show();
            }
        }
    });
    final RadioButton radio_red = (RadioButton) findViewById(R.id.radio_red);
    final RadioButton radio_blue = (RadioButton) findViewById(R.id.radio_blue);
    radio_red.setOnClickListener(radio_listener);
    radio_blue.setOnClickListener(radio_listener);
    final ToggleButton togglebutton = (ToggleButton) findViewById(R.id.togglebutton);
    togglebutton.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // Perform action on clicks
            if (togglebutton.isChecked()) {
                Toast.makeText(SamplerActivity.this, "ToggleButton checked", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(SamplerActivity.this, "ToggleButton not checked", Toast.LENGTH_SHORT).show();
            }
        }
    });
    final RatingBar ratingbar = (RatingBar) findViewById(R.id.ratingbar);
    ratingbar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {

        public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
            Toast.makeText(SamplerActivity.this, "New Rating: " + rating, Toast.LENGTH_SHORT).show();
        }
    });
}
Also used : EditText(android.widget.EditText) ToggleButton(android.widget.ToggleButton) OnRatingBarChangeListener(android.widget.RatingBar.OnRatingBarChangeListener) RadioButton(android.widget.RadioButton) View(android.view.View) RatingBar(android.widget.RatingBar) KeyEvent(android.view.KeyEvent) ImageButton(android.widget.ImageButton) CheckBox(android.widget.CheckBox) OnClickListener(android.view.View.OnClickListener) OnKeyListener(android.view.View.OnKeyListener)

Example 88 with RadioButton

use of android.widget.RadioButton in project ride-read-android by Ride-Read.

the class MineEditMessageActivity method onSelectSex.

public void onSelectSex(View v) {
    final AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.show();
    Window window = alertDialog.getWindow();
    View mView = LayoutInflater.from(this).inflate(R.layout.mine_editmsg_selectsex_layout, null);
    RadioGroup group = (RadioGroup) mView.findViewById(R.id.mine_editmsg_sex_radiogroup);
    final RadioButton maleBtn = (RadioButton) mView.findViewById(R.id.mine_editmsg_sex_radiomale);
    final RadioButton femaleBtn = (RadioButton) mView.findViewById(R.id.mine_editmsg_sex_radiofemale);
    String defaultSex = editmsgSex.getText().toString().trim();
    if (defaultSex != null && !defaultSex.isEmpty()) {
        if (defaultSex.equals("男")) {
            maleBtn.setChecked(true);
        } else {
            femaleBtn.setChecked(true);
        }
    }
    window.setContentView(mView);
    maleBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            maleBtn.setChecked(true);
            editmsgSex.setText("男");
            alertDialog.cancel();
        }
    });
    femaleBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            femaleBtn.setChecked(true);
            editmsgSex.setText("女");
            alertDialog.cancel();
        }
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Window(android.view.Window) RadioGroup(android.widget.RadioGroup) RadioButton(android.widget.RadioButton) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View) TextView(android.widget.TextView)

Example 89 with RadioButton

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

the class ActivityShare method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Check privacy service client
    if (!PrivacyService.checkClient())
        return;
    // Get data
    int userId = Util.getUserId(Process.myUid());
    final Bundle extras = getIntent().getExtras();
    final String action = getIntent().getAction();
    final int[] uids = (extras != null && extras.containsKey(cUidList) ? extras.getIntArray(cUidList) : new int[0]);
    final String restrictionName = (extras != null ? extras.getString(cRestriction) : null);
    int choice = (extras != null && extras.containsKey(cChoice) ? extras.getInt(cChoice) : -1);
    if (action.equals(ACTION_EXPORT))
        mFileName = (extras != null && extras.containsKey(cFileName) ? extras.getString(cFileName) : null);
    // License check
    if (action.equals(ACTION_IMPORT) || action.equals(ACTION_EXPORT)) {
        if (!Util.isProEnabled() && Util.hasProLicense(this) == null) {
            Util.viewUri(this, ActivityMain.cProUri);
            finish();
            return;
        }
    } else if (action.equals(ACTION_FETCH) || (action.equals(ACTION_TOGGLE) && uids.length > 1)) {
        if (Util.hasProLicense(this) == null) {
            Util.viewUri(this, ActivityMain.cProUri);
            finish();
            return;
        }
    }
    // Registration check
    if (action.equals(ACTION_SUBMIT) && !registerDevice(this)) {
        finish();
        return;
    }
    // Check whether we need a user interface
    if (extras != null && extras.containsKey(cInteractive) && extras.getBoolean(cInteractive, false))
        mInteractive = true;
    // Set layout
    setContentView(R.layout.sharelist);
    setSupportActionBar((Toolbar) findViewById(R.id.widgetToolbar));
    // Reference controls
    final TextView tvDescription = (TextView) findViewById(R.id.tvDescription);
    final ScrollView svToggle = (ScrollView) findViewById(R.id.svToggle);
    final RadioGroup rgToggle = (RadioGroup) findViewById(R.id.rgToggle);
    final Spinner spRestriction = (Spinner) findViewById(R.id.spRestriction);
    RadioButton rbClear = (RadioButton) findViewById(R.id.rbClear);
    RadioButton rbTemplateFull = (RadioButton) findViewById(R.id.rbTemplateFull);
    RadioButton rbODEnable = (RadioButton) findViewById(R.id.rbEnableOndemand);
    RadioButton rbODDisable = (RadioButton) findViewById(R.id.rbDisableOndemand);
    final Spinner spTemplate = (Spinner) findViewById(R.id.spTemplate);
    final CheckBox cbClear = (CheckBox) findViewById(R.id.cbClear);
    final Button btnOk = (Button) findViewById(R.id.btnOk);
    final Button btnCancel = (Button) findViewById(R.id.btnCancel);
    // Set title
    if (action.equals(ACTION_TOGGLE)) {
        mActionId = R.string.menu_toggle;
        getSupportActionBar().setSubtitle(R.string.menu_toggle);
    } else if (action.equals(ACTION_IMPORT)) {
        mActionId = R.string.menu_import;
        getSupportActionBar().setSubtitle(R.string.menu_import);
    } else if (action.equals(ACTION_EXPORT)) {
        mActionId = R.string.menu_export;
        getSupportActionBar().setSubtitle(R.string.menu_export);
    } else if (action.equals(ACTION_FETCH)) {
        mActionId = R.string.menu_fetch;
        getSupportActionBar().setSubtitle(R.string.menu_fetch);
    } else if (action.equals(ACTION_SUBMIT)) {
        mActionId = R.string.menu_submit;
        getSupportActionBar().setSubtitle(R.string.menu_submit);
    } else {
        finish();
        return;
    }
    // Get localized restriction name
    List<String> listRestrictionName = new ArrayList<String>(PrivacyManager.getRestrictions(this).navigableKeySet());
    listRestrictionName.add(0, getString(R.string.menu_all));
    // Build restriction adapter
    SpinnerAdapter saRestriction = new SpinnerAdapter(this, android.R.layout.simple_spinner_item);
    saRestriction.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    saRestriction.addAll(listRestrictionName);
    // Setup restriction spinner
    int pos = 0;
    if (restrictionName != null)
        for (String restriction : PrivacyManager.getRestrictions(this).values()) {
            pos++;
            if (restrictionName.equals(restriction))
                break;
        }
    spRestriction.setAdapter(saRestriction);
    spRestriction.setSelection(pos);
    // Build template adapter
    SpinnerAdapter spAdapter = new SpinnerAdapter(this, android.R.layout.simple_spinner_item);
    spAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    String defaultName = PrivacyManager.getSetting(userId, Meta.cTypeTemplateName, "0", getString(R.string.title_default));
    spAdapter.add(defaultName);
    for (int i = 1; i <= 4; i++) {
        String alternateName = PrivacyManager.getSetting(userId, Meta.cTypeTemplateName, Integer.toString(i), getString(R.string.title_alternate) + " " + i);
        spAdapter.add(alternateName);
    }
    spTemplate.setAdapter(spAdapter);
    // Build application list
    AppListTask appListTask = new AppListTask();
    appListTask.executeOnExecutor(mExecutor, uids);
    // Import/export filename
    if (action.equals(ACTION_EXPORT) || action.equals(ACTION_IMPORT)) {
        // Check for availability of sharing intent
        Intent file = new Intent(Intent.ACTION_GET_CONTENT);
        file.setType("file/*");
        boolean hasIntent = Util.isIntentAvailable(ActivityShare.this, file);
        // Get file name
        if (mFileName == null)
            if (action.equals(ACTION_EXPORT)) {
                String packageName = null;
                if (uids.length == 1)
                    try {
                        ApplicationInfoEx appInfo = new ApplicationInfoEx(this, uids[0]);
                        packageName = appInfo.getPackageName().get(0);
                    } catch (Throwable ex) {
                        Util.bug(null, ex);
                    }
                mFileName = getFileName(this, hasIntent, packageName);
            } else
                mFileName = (hasIntent ? null : getFileName(this, false, null));
        if (mFileName == null)
            fileChooser();
        else
            showFileName();
        if (action.equals(ACTION_IMPORT))
            cbClear.setVisibility(View.VISIBLE);
    } else if (action.equals(ACTION_FETCH)) {
        tvDescription.setText(getBaseURL());
        cbClear.setVisibility(View.VISIBLE);
    } else if (action.equals(ACTION_TOGGLE)) {
        tvDescription.setVisibility(View.GONE);
        spRestriction.setVisibility(View.VISIBLE);
        svToggle.setVisibility(View.VISIBLE);
        // Listen for radio button
        rgToggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                btnOk.setEnabled(checkedId >= 0);
                spRestriction.setVisibility(checkedId == R.id.rbEnableOndemand || checkedId == R.id.rbDisableOndemand ? View.GONE : View.VISIBLE);
                spTemplate.setVisibility(checkedId == R.id.rbTemplateCategory || checkedId == R.id.rbTemplateFull || checkedId == R.id.rbTemplateMergeSet || checkedId == R.id.rbTemplateMergeReset ? View.VISIBLE : View.GONE);
            }
        });
        boolean ondemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true);
        rbODEnable.setVisibility(ondemand ? View.VISIBLE : View.GONE);
        rbODDisable.setVisibility(ondemand ? View.VISIBLE : View.GONE);
        if (choice == CHOICE_CLEAR)
            rbClear.setChecked(true);
        else if (choice == CHOICE_TEMPLATE)
            rbTemplateFull.setChecked(true);
    } else
        tvDescription.setText(getBaseURL());
    if (mInteractive) {
        // (showFileName does this for export/import)
        if (action.equals(ACTION_SUBMIT) || action.equals(ACTION_FETCH))
            btnOk.setEnabled(true);
        // Listen for ok
        btnOk.setOnClickListener(new Button.OnClickListener() {

            @Override
            public void onClick(View v) {
                btnOk.setEnabled(false);
                // Toggle
                if (action.equals(ACTION_TOGGLE)) {
                    mRunning = true;
                    for (int i = 0; i < rgToggle.getChildCount(); i++) ((RadioButton) rgToggle.getChildAt(i)).setEnabled(false);
                    int pos = spRestriction.getSelectedItemPosition();
                    String restrictionName = (pos == 0 ? null : (String) PrivacyManager.getRestrictions(ActivityShare.this).values().toArray()[pos - 1]);
                    new ToggleTask().executeOnExecutor(mExecutor, restrictionName);
                // Import
                } else if (action.equals(ACTION_IMPORT)) {
                    mRunning = true;
                    cbClear.setEnabled(false);
                    new ImportTask().executeOnExecutor(mExecutor, new File(mFileName), cbClear.isChecked());
                } else // Export
                if (action.equals(ACTION_EXPORT)) {
                    mRunning = true;
                    new ExportTask().executeOnExecutor(mExecutor, new File(mFileName));
                // Fetch
                } else if (action.equals(ACTION_FETCH)) {
                    if (uids.length > 0) {
                        mRunning = true;
                        cbClear.setEnabled(false);
                        new FetchTask().executeOnExecutor(mExecutor, cbClear.isChecked());
                    }
                } else // Submit
                if (action.equals(ACTION_SUBMIT)) {
                    if (uids.length > 0) {
                        if (uids.length <= cSubmitLimit) {
                            mRunning = true;
                            new SubmitTask().executeOnExecutor(mExecutor);
                        } else {
                            String message = getString(R.string.msg_limit, cSubmitLimit + 1);
                            Toast.makeText(ActivityShare.this, message, Toast.LENGTH_LONG).show();
                            btnOk.setEnabled(false);
                        }
                    }
                }
            }
        });
    } else
        btnOk.setEnabled(false);
    // Listen for cancel
    btnCancel.setOnClickListener(new Button.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mRunning) {
                mAbort = true;
                Toast.makeText(ActivityShare.this, getString(R.string.msg_abort), Toast.LENGTH_LONG).show();
            } else
                finish();
        }
    });
}
Also used : RadioGroup(android.widget.RadioGroup) Spinner(android.widget.Spinner) ArrayList(java.util.ArrayList) RadioButton(android.widget.RadioButton) Button(android.widget.Button) TextView(android.widget.TextView) OnCheckedChangeListener(android.widget.RadioGroup.OnCheckedChangeListener) Bundle(android.os.Bundle) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) RadioButton(android.widget.RadioButton) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) ScrollView(android.widget.ScrollView) SuppressLint(android.annotation.SuppressLint) ScrollView(android.widget.ScrollView) CheckBox(android.widget.CheckBox) File(java.io.File)

Example 90 with RadioButton

use of android.widget.RadioButton in project Gadgetbridge by Freeyourgadget.

the class TimePicker method initGraphics.

private void initGraphics(Context context) {
    int w = (int) (((WindowManager) context.getApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth() * 0.8);
    height = w;
    width = w;
    radius = (int) (w * 0.06);
    radius1 = 0;
    radius2 = (int) (radius * 2.3);
    radius3 = (int) (radius2 * 2.15);
    int offset = (int) (w * 0.1);
    radius1 += offset;
    radius2 += offset;
    radius3 += offset;
    pickerView = new ImageView(context);
    pickerBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    pickerCanvas = new Canvas(pickerBitmap);
    drawClock();
    LinearLayout layout = new LinearLayout(context);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.addView(pickerView);
    CheckBox box = new CheckBox(context);
    box.setText("Respect silent mode");
    box.setChecked(settings.getRespectSilentMode());
    box.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            settings.setRespectSilentMode(b);
        }
    });
    layout.addView(box);
    RadioGroup group = new RadioGroup(context);
    for (PlayNotificationRequest.VibrationType vibe : PlayNotificationRequest.VibrationType.values()) {
        RadioButton button = new RadioButton(context);
        button.setText(vibe.toString());
        button.setId(vibe.getValue());
        group.addView(button);
    }
    group.check(settings.getVibration().getValue());
    group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup radioGroup, int i) {
            settings.setVibration(PlayNotificationRequest.VibrationType.fromValue((byte) i));
            if (TimePicker.this.vibrationListener != null)
                TimePicker.this.vibrationListener.onVibrationSet(settings);
        }
    });
    ScrollView scrollView = new ScrollView(context);
    scrollView.addView(group);
    layout.addView(scrollView);
    setView(layout);
    setNegativeButton("cancel", null);
    setPositiveButton("ok", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            if (finishListener == null)
                return;
            finishListener.onFinish(true, settings);
        }
    });
    setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialogInterface) {
            if (finishListener == null)
                return;
            finishListener.onFinish(false, settings);
        }
    });
    setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialogInterface) {
            if (finishListener == null)
                return;
            finishListener.onFinish(false, settings);
        }
    });
    dialog = show();
    pickerView.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            handleTouch(dialog, motionEvent);
            return true;
        }
    });
}
Also used : RadioGroup(android.widget.RadioGroup) DialogInterface(android.content.DialogInterface) Canvas(android.graphics.Canvas) RadioButton(android.widget.RadioButton) ImageView(android.widget.ImageView) ScrollView(android.widget.ScrollView) View(android.view.View) Paint(android.graphics.Paint) WindowManager(android.view.WindowManager) MotionEvent(android.view.MotionEvent) ScrollView(android.widget.ScrollView) CheckBox(android.widget.CheckBox) PlayNotificationRequest(nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.PlayNotificationRequest) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout) CompoundButton(android.widget.CompoundButton)

Aggregations

RadioButton (android.widget.RadioButton)198 View (android.view.View)100 TextView (android.widget.TextView)69 RadioGroup (android.widget.RadioGroup)43 Button (android.widget.Button)38 Intent (android.content.Intent)36 CheckBox (android.widget.CheckBox)28 EditText (android.widget.EditText)26 ImageView (android.widget.ImageView)21 CompoundButton (android.widget.CompoundButton)19 LayoutInflater (android.view.LayoutInflater)18 ViewGroup (android.view.ViewGroup)18 LinearLayout (android.widget.LinearLayout)17 Bundle (android.os.Bundle)16 AdapterView (android.widget.AdapterView)15 DialogInterface (android.content.DialogInterface)14 Context (android.content.Context)10 ScrollView (android.widget.ScrollView)10 ArrayList (java.util.ArrayList)10 SharedPreferences (android.content.SharedPreferences)9