use of android.support.v7.widget.AppCompatRadioButton in project iNaturalistAndroid by inaturalist.
the class NetworkSettings method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mHelper = new ActivityHelper(this);
final Intent intent = getIntent();
setContentView(R.layout.inat_network_settings);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setTitle(R.string.inat_network);
mNetworks = (RadioGroup) findViewById(R.id.networks);
mMoreInfo = (ViewGroup) findViewById(R.id.more_info);
if (mApp == null) {
mApp = (INaturalistApp) getApplicationContext();
}
mMoreInfo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(getString(R.string.inat_network_info_url)));
startActivity(i);
}
});
String[] networks = mApp.getINatNetworks();
String network = mApp.getInaturalistNetworkMember();
int selectedNetwork = 0;
mNetworkRadioButtons = new ArrayList<RadioButton>();
for (int i = 0; i < networks.length; i++) {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final ViewGroup customNetworkOption = (ViewGroup) inflater.inflate(R.layout.network_option, null, false);
TextView networkName = (TextView) customNetworkOption.findViewById(R.id.title);
TextView networkLocation = (TextView) customNetworkOption.findViewById(R.id.sub_title);
final AppCompatRadioButton radioButton = (AppCompatRadioButton) customNetworkOption.findViewById(R.id.radio_button);
networkName.setText(mApp.getStringResourceByName("network_" + networks[i]));
networkLocation.setText(mApp.getStringResourceByName("inat_country_name_" + networks[i]));
radioButton.setId(i);
// Set radio button color
ColorStateList colorStateList = new ColorStateList(new int[][] { new int[] { -android.R.attr.state_checked }, new int[] { android.R.attr.state_checked } }, new int[] { Color.DKGRAY, getResources().getColor(R.color.inatapptheme_color) });
radioButton.setSupportButtonTintList(colorStateList);
final int index = i;
customNetworkOption.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Uncheck all other radio buttons
for (int c = 0; c < mNetworkRadioButtons.size(); c++) {
if (c == index)
continue;
RadioButton r = mNetworkRadioButtons.get(c);
r.setChecked(false);
}
onINatNetworkRadioButtonClicked(index);
}
});
mNetworkRadioButtons.add(radioButton);
mNetworks.addView(customNetworkOption);
if (networks[i].equals(network)) {
selectedNetwork = i;
}
}
mFormerSelectedNetworkRadioButton = selectedNetwork;
mNetworkRadioButtons.get(selectedNetwork).setChecked(true);
}
use of android.support.v7.widget.AppCompatRadioButton in project GzuClassSchedule by mnnyang.
the class SettingActivity method showThemeDialog.
private void showThemeDialog() {
ScrollView scrollView = new ScrollView(this);
RadioGroup radioGroup = new RadioGroup(this);
scrollView.addView(radioGroup);
int margin = ScreenUtils.dp2px(16);
radioGroup.setPadding(margin / 2, margin, margin, margin);
for (int i = 0; i < themeColorArray.length; i++) {
AppCompatRadioButton arb = new AppCompatRadioButton(this);
RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
arb.setLayoutParams(params);
arb.setId(i);
arb.setTextColor(getResources().getColor(themeColorArray[i]));
arb.setText(themeNameArray[i]);
arb.setTextSize(16);
arb.setPadding(0, margin / 2, 0, margin / 2);
radioGroup.addView(arb);
}
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
theme = checkedId;
}
});
DialogHelper dialogHelper = new DialogHelper();
dialogHelper.showCustomDialog(this, scrollView, getString(R.string.theme_preference), new DialogListener() {
@Override
public void onPositive(DialogInterface dialog, int which) {
super.onPositive(dialog, which);
dialog.dismiss();
String key = getString(R.string.app_preference_theme);
int oldTheme = Preferences.getInt(key, 0);
if (theme != oldTheme) {
Preferences.putInt(key, theme);
ActivityUtil.finishAll();
startActivity(new Intent(app.mContext, CourseActivity.class));
}
}
});
}
use of android.support.v7.widget.AppCompatRadioButton in project GzuClassSchedule by mnnyang.
the class SettingFragment method showThemeDialog.
private void showThemeDialog() {
ScrollView scrollView = new ScrollView(getActivity());
RadioGroup radioGroup = new RadioGroup(getActivity());
scrollView.addView(radioGroup);
int margin = ScreenUtils.dp2px(16);
radioGroup.setPadding(margin / 2, margin, margin, margin);
for (int i = 0; i < themeColorArray.length; i++) {
AppCompatRadioButton arb = new AppCompatRadioButton(getActivity());
RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
arb.setLayoutParams(params);
arb.setId(i);
arb.setTextColor(getResources().getColor(themeColorArray[i]));
arb.setText(themeNameArray[i]);
arb.setTextSize(16);
arb.setPadding(0, margin / 2, 0, margin / 2);
radioGroup.addView(arb);
}
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
theme = checkedId;
}
});
DialogHelper dialogHelper = new DialogHelper();
dialogHelper.showCustomDialog(getActivity(), scrollView, getString(R.string.theme_preference), new DialogListener() {
@Override
public void onPositive(DialogInterface dialog, int which) {
super.onPositive(dialog, which);
dialog.dismiss();
String key = getString(R.string.app_preference_theme);
int oldTheme = Preferences.getInt(key, 0);
if (theme != oldTheme) {
Preferences.putInt(key, theme);
ActivityUtil.finishAll();
startActivity(new Intent(app.mContext, CourseActivity.class));
}
}
});
}
use of android.support.v7.widget.AppCompatRadioButton in project Roblu by wdavies973.
the class RMetricToUI method getBoolean.
/**
* Gets the Boolean UI card from an RBoolean reference
* @param bool RBoolean reference to be set to the UI
* @return a UI CardView
*/
public CardView getBoolean(final RBoolean bool) {
RadioGroup group = new RadioGroup(activity);
AppCompatRadioButton yes = new AppCompatRadioButton(activity);
AppCompatRadioButton no = new AppCompatRadioButton(activity);
yes.setEnabled(editable);
no.setEnabled(editable);
ColorStateList colorStateList = new ColorStateList(new int[][] { // unchecked
new int[] { -android.R.attr.state_checked }, // checked
new int[] { android.R.attr.state_checked } }, new int[] { rui.getButtons(), rui.getAccent() });
CompoundButtonCompat.setButtonTintList(yes, colorStateList);
CompoundButtonCompat.setButtonTintList(no, colorStateList);
group.setId(Utils.generateViewId());
yes.setId(Utils.generateViewId());
no.setId(Utils.generateViewId());
yes.setTextColor(rui.getText());
no.setTextColor(rui.getText());
yes.setText(R.string.yes);
no.setText(R.string.no);
final RelativeLayout layout = new RelativeLayout(activity);
final TextView observed = new TextView(activity);
// don't check either if the boolean isn't modified
yes.setChecked(bool.isValue());
yes.setHighlightColor(rui.getAccent());
no.setChecked(!bool.isValue());
no.setPadding(0, 0, 0, Utils.DPToPX(activity, 10));
no.setHighlightColor(rui.getAccent());
group.addView(yes);
group.addView(no);
no.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
layout.removeView(observed);
listener.changeMade(bool);
}
});
yes.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
layout.removeView(observed);
listener.changeMade(bool);
}
});
// Observed field
observed.setTextColor(rui.getText());
observed.setText(R.string.not_observed_yet);
observed.setTextSize(10);
observed.setPadding(observed.getPaddingLeft(), Utils.DPToPX(activity, 15), observed.getPaddingRight(), observed.getPaddingBottom());
observed.setId(Utils.generateViewId());
observed.setTag("N.O.");
observed.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!editable)
return;
layout.removeView(observed);
listener.changeMade(bool);
}
});
group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
layout.removeView(observed);
bool.setValue(((RadioButton) radioGroup.getChildAt(0)).isChecked());
listener.changeMade(bool);
}
});
TextView title = new TextView(activity);
title.setTextColor(rui.getText());
title.setText(bool.getTitle());
title.setMaxWidth(width);
title.setTextSize(20);
title.setId(Utils.generateViewId());
// observed params
RelativeLayout.LayoutParams oParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
oParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
oParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
oParams.addRule(RelativeLayout.BELOW, group.getId());
observed.setLayoutParams(oParams);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
params.addRule(RelativeLayout.CENTER_VERTICAL);
group.setLayoutParams(params);
group.setPadding(group.getPaddingLeft(), group.getPaddingTop(), Utils.DPToPX(activity, 10), group.getPaddingBottom());
params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.CENTER_VERTICAL);
title.setPadding(Utils.DPToPX(activity, 4), title.getPaddingTop(), title.getPaddingRight(), title.getPaddingBottom());
title.setLayoutParams(params);
layout.addView(title);
layout.addView(group);
if (!bool.isModified())
layout.addView(observed);
return getCard(layout);
}
use of android.support.v7.widget.AppCompatRadioButton in project GzuClassSchedule by mnnyang.
the class ShowTermDialog method showSelectTimeTermDialog.
public void showSelectTimeTermDialog(Context context, String[] times, final TimeTermCallback callback) {
if (times.length == 0) {
return;
}
View dialogView = LayoutInflater.from(context).inflate(R.layout.layout_course_time_dialog, null);
final RadioGroup rg = dialogView.findViewById(R.id.rg_course_time);
int i = 1;
for (String time : times) {
AppCompatRadioButton tempButton = new AppCompatRadioButton(context);
tempButton.setTextColor(ColorUtil.getColor(context, R.attr.colorPrimary));
tempButton.setText(time);
tempButton.setId(i);
rg.addView(tempButton, LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
i++;
}
rg.invalidate();
rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
AppCompatRadioButton arb = group.findViewById(checkedId);
System.out.println("6:" + arb);
callback.onTimeChanged(arb.getText().toString());
}
});
RadioGroup termRg = dialogView.findViewById(R.id.rg_term);
termRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
AppCompatRadioButton arb = group.findViewById(checkedId);
callback.onTermChanged(arb.getTag().toString());
}
});
AppCompatRadioButton at = (AppCompatRadioButton) rg.getChildAt(0);
if (at != null)
at.setChecked(true);
at = (AppCompatRadioButton) termRg.getChildAt(0);
if (at != null)
at.setChecked(true);
DialogHelper helper = new DialogHelper();
helper.showCustomDialog(context, dialogView, "", new DialogListener() {
@Override
public void onPositive(DialogInterface dialog, int which) {
super.onPositive(dialog, which);
dialog.dismiss();
callback.onPositive(dialog, which);
}
});
}
Aggregations