use of android.widget.RadioGroup in project RoboBinding by RoboBinding.
the class RadioGroupAddOnTest method shouldSupportMultipleOnCheckedChangeListeners.
@Test
public void shouldSupportMultipleOnCheckedChangeListeners() {
RadioGroup view = new RadioGroup(RuntimeEnvironment.application);
RadioGroupAddOn viewAddOn = new RadioGroupAddOn(view);
MockOnCheckedChangeListener listener1 = new MockOnCheckedChangeListener();
MockOnCheckedChangeListener listener2 = new MockOnCheckedChangeListener();
viewAddOn.addOnCheckedChangeListener(listener1);
viewAddOn.addOnCheckedChangeListener(listener2);
view.check(RandomValues.anyIntegerGreaterThanZero());
assertTrue(listener1.checkedChangeEventFired);
assertTrue(listener2.checkedChangeEventFired);
}
use of android.widget.RadioGroup 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();
}
});
}
use of android.widget.RadioGroup in project XPrivacy by M66B.
the class ActivityMain method optionSort.
@SuppressLint("InflateParams")
private void optionSort() {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.sort, null);
final RadioGroup rgSMode = (RadioGroup) view.findViewById(R.id.rgSMode);
final CheckBox cbSInvert = (CheckBox) view.findViewById(R.id.cbSInvert);
// Initialise controls
switch(mSortMode) {
case SORT_BY_NAME:
rgSMode.check(R.id.rbSName);
break;
case SORT_BY_UID:
rgSMode.check(R.id.rbSUid);
break;
case SORT_BY_INSTALL_TIME:
rgSMode.check(R.id.rbSInstalled);
break;
case SORT_BY_UPDATE_TIME:
rgSMode.check(R.id.rbSUpdated);
break;
case SORT_BY_MODIFY_TIME:
rgSMode.check(R.id.rbSModified);
break;
case SORT_BY_STATE:
rgSMode.check(R.id.rbSState);
break;
}
cbSInvert.setChecked(mSortInvert);
// Build dialog
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityMain.this);
alertDialogBuilder.setTitle(R.string.menu_sort);
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) {
switch(rgSMode.getCheckedRadioButtonId()) {
case R.id.rbSName:
mSortMode = SORT_BY_NAME;
break;
case R.id.rbSUid:
mSortMode = SORT_BY_UID;
break;
case R.id.rbSInstalled:
mSortMode = SORT_BY_INSTALL_TIME;
break;
case R.id.rbSUpdated:
mSortMode = SORT_BY_UPDATE_TIME;
break;
case R.id.rbSModified:
mSortMode = SORT_BY_MODIFY_TIME;
break;
case R.id.rbSState:
mSortMode = SORT_BY_STATE;
break;
}
mSortInvert = cbSInvert.isChecked();
int userId = Util.getUserId(Process.myUid());
PrivacyManager.setSetting(userId, PrivacyManager.cSettingSortMode, Integer.toString(mSortMode));
PrivacyManager.setSetting(userId, PrivacyManager.cSettingSortInverted, Boolean.toString(mSortInvert));
applySort();
}
});
alertDialogBuilder.setNegativeButton(ActivityMain.this.getString(android.R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Do nothing
}
});
// Show dialog
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
use of android.widget.RadioGroup in project uCrop by Yalantis.
the class SampleActivity method setupUI.
@SuppressWarnings("ConstantConditions")
private void setupUI() {
findViewById(R.id.button_crop).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pickFromGallery();
}
});
findViewById(R.id.button_random_image).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Random random = new Random();
int minSizePixels = 800;
int maxSizePixels = 2400;
startCropActivity(Uri.parse(String.format(Locale.getDefault(), "https://unsplash.it/%d/%d/?random", minSizePixels + random.nextInt(maxSizePixels - minSizePixels), minSizePixels + random.nextInt(maxSizePixels - minSizePixels))));
}
});
mRadioGroupAspectRatio = ((RadioGroup) findViewById(R.id.radio_group_aspect_ratio));
mRadioGroupCompressionSettings = ((RadioGroup) findViewById(R.id.radio_group_compression_settings));
mCheckBoxMaxSize = ((CheckBox) findViewById(R.id.checkbox_max_size));
mEditTextRatioX = ((EditText) findViewById(R.id.edit_text_ratio_x));
mEditTextRatioY = ((EditText) findViewById(R.id.edit_text_ratio_y));
mEditTextMaxWidth = ((EditText) findViewById(R.id.edit_text_max_width));
mEditTextMaxHeight = ((EditText) findViewById(R.id.edit_text_max_height));
mSeekBarQuality = ((SeekBar) findViewById(R.id.seekbar_quality));
mTextViewQuality = ((TextView) findViewById(R.id.text_view_quality));
mCheckBoxHideBottomControls = ((CheckBox) findViewById(R.id.checkbox_hide_bottom_controls));
mCheckBoxFreeStyleCrop = ((CheckBox) findViewById(R.id.checkbox_freestyle_crop));
mRadioGroupAspectRatio.check(R.id.radio_dynamic);
mEditTextRatioX.addTextChangedListener(mAspectRatioTextWatcher);
mEditTextRatioY.addTextChangedListener(mAspectRatioTextWatcher);
mRadioGroupCompressionSettings.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
mSeekBarQuality.setEnabled(checkedId == R.id.radio_jpeg);
}
});
mRadioGroupCompressionSettings.check(R.id.radio_jpeg);
mSeekBarQuality.setProgress(UCropActivity.DEFAULT_COMPRESS_QUALITY);
mTextViewQuality.setText(String.format(getString(R.string.format_quality_d), mSeekBarQuality.getProgress()));
mSeekBarQuality.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mTextViewQuality.setText(String.format(getString(R.string.format_quality_d), progress));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
}
use of android.widget.RadioGroup in project SlidingMenu by jfeinstein10.
the class PropertiesActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setSlidingActionBarEnabled(true);
setContentView(R.layout.properties);
// left and right modes
RadioGroup mode = (RadioGroup) findViewById(R.id.mode);
mode.check(R.id.left);
mode.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
SlidingMenu sm = getSlidingMenu();
switch(checkedId) {
case R.id.left:
sm.setMode(SlidingMenu.LEFT);
sm.setShadowDrawable(R.drawable.shadow);
break;
case R.id.right:
sm.setMode(SlidingMenu.RIGHT);
sm.setShadowDrawable(R.drawable.shadowright);
break;
case R.id.left_right:
sm.setMode(SlidingMenu.LEFT_RIGHT);
sm.setSecondaryMenu(R.layout.menu_frame_two);
getSupportFragmentManager().beginTransaction().replace(R.id.menu_frame_two, new SampleListFragment()).commit();
sm.setSecondaryShadowDrawable(R.drawable.shadowright);
sm.setShadowDrawable(R.drawable.shadow);
}
}
});
// touch mode stuff
RadioGroup touchAbove = (RadioGroup) findViewById(R.id.touch_above);
touchAbove.check(R.id.touch_above_full);
touchAbove.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch(checkedId) {
case R.id.touch_above_full:
getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
break;
case R.id.touch_above_margin:
getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
break;
case R.id.touch_above_none:
getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE);
break;
}
}
});
// scroll scale stuff
SeekBar scrollScale = (SeekBar) findViewById(R.id.scroll_scale);
scrollScale.setMax(1000);
scrollScale.setProgress(333);
scrollScale.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
getSlidingMenu().setBehindScrollScale((float) seekBar.getProgress() / seekBar.getMax());
}
});
// behind width stuff
SeekBar behindWidth = (SeekBar) findViewById(R.id.behind_width);
behindWidth.setMax(1000);
behindWidth.setProgress(750);
behindWidth.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
float percent = (float) seekBar.getProgress() / seekBar.getMax();
getSlidingMenu().setBehindWidth((int) (percent * getSlidingMenu().getWidth()));
getSlidingMenu().requestLayout();
}
});
// shadow stuff
CheckBox shadowEnabled = (CheckBox) findViewById(R.id.shadow_enabled);
shadowEnabled.setChecked(true);
shadowEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked)
getSlidingMenu().setShadowDrawable(getSlidingMenu().getMode() == SlidingMenu.LEFT ? R.drawable.shadow : R.drawable.shadowright);
else
getSlidingMenu().setShadowDrawable(null);
}
});
SeekBar shadowWidth = (SeekBar) findViewById(R.id.shadow_width);
shadowWidth.setMax(1000);
shadowWidth.setProgress(75);
shadowWidth.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
float percent = (float) seekBar.getProgress() / (float) seekBar.getMax();
int width = (int) (percent * (float) getSlidingMenu().getWidth());
getSlidingMenu().setShadowWidth(width);
getSlidingMenu().invalidate();
}
});
// fading stuff
CheckBox fadeEnabled = (CheckBox) findViewById(R.id.fade_enabled);
fadeEnabled.setChecked(true);
fadeEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
getSlidingMenu().setFadeEnabled(isChecked);
}
});
SeekBar fadeDeg = (SeekBar) findViewById(R.id.fade_degree);
fadeDeg.setMax(1000);
fadeDeg.setProgress(666);
fadeDeg.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
getSlidingMenu().setFadeDegree((float) seekBar.getProgress() / seekBar.getMax());
}
});
}
Aggregations