Search in sources :

Example 81 with RadioButton

use of android.widget.RadioButton in project ARChon-Packager by bpear96.

the class activityInstalled method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.installed_list);
    g.setstep(0);
    // Open either file explorer
    if (selection == 1) {
        // Open file selector
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("file/*");
        startActivityForResult(intent, PICKFILE_RESULT_CODE);
    }
    if (selection == 0) {
        AsyncTask<Void, Void, Void> task = new // Start progress dialog and run task in background
        AsyncTask<Void, Void, Void>() {

            @Override
            protected void onPreExecute() {
                pd = new ProgressDialog(activityInstalled.this);
                pd.setTitle("Processing...");
                pd.setMessage("Please wait.");
                pd.setCancelable(false);
                pd.setIndeterminate(true);
                pd.show();
            }

            @Override
            protected Void doInBackground(Void... arg0) {
                // or list installed apps
                // Create TreeMap to store list of apps.
                map = new TreeMap<String, Button>();
                // This is the id of the RadioGroup we defined
                appButtonLayout = (ViewGroup) findViewById(R.id.installed_radio_group);
                // Generate list of apps installed
                List<PackageInfo> PackList = getPackageManager().getInstalledPackages(0);
                for (int i = 0; i < PackList.size(); i++) {
                    PackageInfo PackInfo = PackList.get(i);
                    if ((PackInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
                        // Do not use system apps. Only user/data apps.
                        final String AppName = PackInfo.applicationInfo.loadLabel(getPackageManager()).toString();
                        RadioButton buttonr = new RadioButton(activityInstalled.this);
                        // Set text of button to applications name
                        buttonr.setText(AppName);
                        buttonr.setId(i);
                        // Put buttons in TreeMap
                        map.put(AppName, buttonr);
                        buttonr.setOnClickListener(new // When app radio button is selected
                        View.OnClickListener() {

                            @Override
                            public void onClick(View view) {
                                ((RadioGroup) view.getParent()).check(view.getId());
                                // store AppID
                                SelectedAppId = view.getId();
                                // Store App name
                                SelectedAppName = AppName;
                                Toast.makeText(activityInstalled.this, "App selected.", Toast.LENGTH_LONG).show();
                                // Save variables for next fragment
                                // Sets global variable
                                g.setSelectedAppId(SelectedAppId);
                                g.setSelectedAppName(SelectedAppName);
                                AsyncTask<Void, Void, Void> task = new // Start progress dialog and run task in background
                                AsyncTask<Void, Void, Void>() {

                                    @Override
                                    protected void onPreExecute() {
                                        pd = new ProgressDialog(activityInstalled.this);
                                        pd.setTitle("Processing...");
                                        pd.setMessage("Please wait.");
                                        pd.setCancelable(false);
                                        pd.setIndeterminate(true);
                                        pd.show();
                                    }

                                    @Override
                                    protected Void doInBackground(Void... arg0) {
                                        pullAPk();
                                        return null;
                                    }

                                    @Override
                                    protected void onPostExecute(Void result) {
                                        if (pd != null) {
                                            pd.dismiss();
                                        }
                                    }
                                };
                                task.execute((Void[]) null);
                            }
                        });
                    }
                }
                return null;
            }

            @Override
            protected void onPostExecute(Void result) {
                if (pd != null) {
                    for (Button b : map.values()) {
                        // Add buttons in TreeMap to view.
                        appButtonLayout.addView(b);
                    }
                    pd.dismiss();
                }
            }
        };
        task.execute((Void[]) null);
    }
}
Also used : PackageInfo(android.content.pm.PackageInfo) AsyncTask(android.os.AsyncTask) Intent(android.content.Intent) RadioButton(android.widget.RadioButton) ProgressDialog(android.app.ProgressDialog) View(android.view.View) RadioButton(android.widget.RadioButton) Button(android.widget.Button)

Example 82 with RadioButton

use of android.widget.RadioButton in project NewXmPluginSDK by MiEcosystem.

the class XmRadioGroup method findRadioButton.

public RadioButton findRadioButton(ViewGroup group) {
    RadioButton resBtn = null;
    int len = group.getChildCount();
    for (int i = 0; i < len; i++) {
        if (group.getChildAt(i) instanceof RadioButton) {
            resBtn = (RadioButton) group.getChildAt(i);
        } else if (group.getChildAt(i) instanceof ViewGroup) {
            findRadioButton((ViewGroup) group.getChildAt(i));
        }
    }
    return resBtn;
}
Also used : ViewGroup(android.view.ViewGroup) RadioButton(android.widget.RadioButton)

Example 83 with RadioButton

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

the class PlaybackStatisticsFragment method selectStatisticsMode.

private void selectStatisticsMode() {
    View contentView = View.inflate(getContext(), R.layout.statistics_mode_select_dialog, null);
    AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
    builder.setView(contentView);
    builder.setTitle(R.string.statistics_mode);
    if (countAll) {
        ((RadioButton) contentView.findViewById(R.id.statistics_mode_count_all)).setChecked(true);
    } else {
        ((RadioButton) contentView.findViewById(R.id.statistics_mode_normal)).setChecked(true);
    }
    builder.setPositiveButton(android.R.string.ok, (dialog, which) -> {
        countAll = ((RadioButton) contentView.findViewById(R.id.statistics_mode_count_all)).isChecked();
        listAdapter.setCountAll(countAll);
        prefs.edit().putBoolean(PREF_COUNT_ALL, countAll).apply();
        refreshStatistics();
        getActivity().invalidateOptionsMenu();
    });
    builder.show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) RadioButton(android.widget.RadioButton) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 84 with RadioButton

use of android.widget.RadioButton in project JustAndroid by chinaltz.

the class SegmentedGroup method updateBackground.

private void updateBackground(View view) {
    if (!isInEditMode()) {
        int checked = mLayoutSelector.getSelected();
        int unchecked = mLayoutSelector.getUnselected();
        // Set text color
        ColorStateList colorStateList = new ColorStateList(new int[][] { { -android.R.attr.state_checked }, { android.R.attr.state_checked } }, new int[] { mTintColor, mCheckedTextColor });
        ((Button) view).setTextColor(colorStateList);
        // Redraw with tint color
        Drawable checkedDrawable = resources.getDrawable(checked).mutate();
        Drawable uncheckedDrawable = resources.getDrawable(unchecked).mutate();
        ((GradientDrawable) checkedDrawable).setColor(mTintColor);
        ((GradientDrawable) checkedDrawable).setStroke(mMarginDp, mTintColor);
        ((GradientDrawable) uncheckedDrawable).setStroke(mMarginDp, mTintColor);
        ((GradientDrawable) uncheckedDrawable).setColor(mUnCheckedTintColor);
        // Set proper radius
        ((GradientDrawable) checkedDrawable).setCornerRadii(mLayoutSelector.getChildRadii(view));
        ((GradientDrawable) uncheckedDrawable).setCornerRadii(mLayoutSelector.getChildRadii(view));
        GradientDrawable maskDrawable = (GradientDrawable) resources.getDrawable(unchecked).mutate();
        maskDrawable.setStroke(mMarginDp, mTintColor);
        maskDrawable.setColor(mUnCheckedTintColor);
        maskDrawable.setCornerRadii(mLayoutSelector.getChildRadii(view));
        int maskColor = Color.argb(50, Color.red(mTintColor), Color.green(mTintColor), Color.blue(mTintColor));
        maskDrawable.setColor(maskColor);
        LayerDrawable pressedDrawable = new LayerDrawable(new Drawable[] { uncheckedDrawable, maskDrawable });
        Drawable[] drawables = { uncheckedDrawable, checkedDrawable };
        TransitionDrawable transitionDrawable = new TransitionDrawable(drawables);
        if (((RadioButton) view).isChecked()) {
            transitionDrawable.reverseTransition(0);
        }
        StateListDrawable stateListDrawable = new StateListDrawable();
        stateListDrawable.addState(new int[] { -android.R.attr.state_checked, android.R.attr.state_pressed }, pressedDrawable);
        stateListDrawable.addState(StateSet.WILD_CARD, transitionDrawable);
        mDrawableMap.put(view.getId(), transitionDrawable);
        // Set button background
        if (Build.VERSION.SDK_INT >= 16) {
            view.setBackground(stateListDrawable);
        } else {
            view.setBackgroundDrawable(stateListDrawable);
        }
        super.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                TransitionDrawable current = mDrawableMap.get(checkedId);
                current.reverseTransition(200);
                if (mLastCheckId != 0) {
                    TransitionDrawable last = mDrawableMap.get(mLastCheckId);
                    if (last != null)
                        last.reverseTransition(200);
                }
                mLastCheckId = checkedId;
                if (mCheckedChangeListener != null) {
                    mCheckedChangeListener.onCheckedChanged(group, checkedId);
                }
            }
        });
    }
}
Also used : TransitionDrawable(android.graphics.drawable.TransitionDrawable) RadioGroup(android.widget.RadioGroup) LayerDrawable(android.graphics.drawable.LayerDrawable) Drawable(android.graphics.drawable.Drawable) TransitionDrawable(android.graphics.drawable.TransitionDrawable) StateListDrawable(android.graphics.drawable.StateListDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable) ColorStateList(android.content.res.ColorStateList) RadioButton(android.widget.RadioButton) StateListDrawable(android.graphics.drawable.StateListDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable) RadioButton(android.widget.RadioButton) Button(android.widget.Button) LayerDrawable(android.graphics.drawable.LayerDrawable)

Example 85 with RadioButton

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

the class FilterDialog method openDialog.

public void openDialog() {
    final Set<String> filterValues = new HashSet<>(Arrays.asList(filter.getValues()));
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(R.string.filter);
    LayoutInflater inflater = LayoutInflater.from(this.context);
    View layout = inflater.inflate(R.layout.filter_dialog, null, false);
    LinearLayout rows = layout.findViewById(R.id.filter_rows);
    builder.setView(layout);
    for (FeedItemFilterGroup item : FeedItemFilterGroup.values()) {
        RecursiveRadioGroup row = (RecursiveRadioGroup) inflater.inflate(R.layout.filter_dialog_row, null, false);
        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);
        filter2.setText(item.values[1].displayName);
        filter2.setTag(item.values[1].filterId);
        rows.addView(row);
    }
    for (String filterId : filterValues) {
        if (!TextUtils.isEmpty(filterId)) {
            RadioButton button = layout.findViewWithTag(filterId);
            if (button != null) {
                button.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.create().show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) FeedItemFilterGroup(de.danoeh.antennapod.core.feed.FeedItemFilterGroup) RadioButton(android.widget.RadioButton) View(android.view.View) LayoutInflater(android.view.LayoutInflater) RecursiveRadioGroup(de.danoeh.antennapod.ui.common.RecursiveRadioGroup) LinearLayout(android.widget.LinearLayout) HashSet(java.util.HashSet)

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