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();
}
});
}
use of android.widget.RadioButton in project JamsMusicPlayer by psaravan.
the class GooglePlayMusicFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mContext = getActivity().getApplicationContext();
mApp = (Common) mContext;
View rootView = (View) inflater.inflate(R.layout.fragment_welcome_screen_5, null);
welcomeHeader = (TextView) rootView.findViewById(R.id.welcome_header);
welcomeHeader.setTypeface(TypefaceHelper.getTypeface(getActivity(), "Roboto-Light"));
welcomeText1 = (TextView) rootView.findViewById(R.id.welcome_text_1);
welcomeText1.setTypeface(TypefaceHelper.getTypeface(getActivity(), "Roboto-Regular"));
googlePlayMusicDisclaimer = (TextView) rootView.findViewById(R.id.google_play_music_disclaimer);
googlePlayMusicDisclaimer.setTypeface(TypefaceHelper.getTypeface(getActivity(), "Roboto-Regular"));
radioGroup = (RadioGroup) rootView.findViewById(R.id.google_play_music_radio_group);
final AccountManager accountManager = AccountManager.get(getActivity().getApplicationContext());
final Account[] accounts = accountManager.getAccountsByType("com.google");
//We're adding 1 here to account (no pun intended) for the extra "Don't use Google Play Music" option.
final int size = accounts.length + 1;
final RadioButton[] radioButton = new RadioButton[size];
//Add a new radio button the group for each username.
for (int i = 0; i < size; i++) {
radioButton[i] = new RadioButton(getActivity());
radioGroup.addView(radioButton[i]);
//The first radio button will always be "Don't use Google Play Music".
if (i == 0) {
radioButton[i].setChecked(true);
radioButton[i].setText(R.string.dont_use_google_play_music);
} else {
radioButton[i].setText(accounts[i - 1].name);
}
radioButton[i].setTag(i);
radioButton[i].setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
}
radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
int radioButtonID = group.getCheckedRadioButtonId();
View radioButton = group.findViewById(radioButtonID);
int index = group.indexOfChild(radioButton);
if (index != 0) {
account = accounts[index - 1];
mApp.getSharedPreferences().edit().putString("GOOGLE_PLAY_MUSIC_ACCOUNT", account.name).commit();
AsyncGoogleMusicAuthenticationTask task = new AsyncGoogleMusicAuthenticationTask(mContext, getActivity(), true, account.name);
task.execute();
} else {
mApp.getSharedPreferences().edit().putString("GOOGLE_PLAY_MUSIC_ACCOUNT", "").commit();
mApp.getSharedPreferences().edit().putBoolean("GOOGLE_PLAY_MUSIC_ENABLED", false).commit();
}
}
});
return rootView;
}
use of android.widget.RadioButton in project JamsMusicPlayer by psaravan.
the class MusicFoldersFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mContext = getActivity().getApplicationContext();
mApp = (Common) mContext;
View rootView = (View) getActivity().getLayoutInflater().inflate(R.layout.fragment_welcome_screen_2, null);
mFoldersLayout = (RelativeLayout) rootView.findViewById(R.id.folders_fragment_holder);
if (mApp.getSharedPreferences().getInt("MUSIC_FOLDERS_SELECTION", 0) == 0) {
mFoldersLayout.setVisibility(View.INVISIBLE);
mFoldersLayout.setEnabled(false);
} else {
mFoldersLayout.setVisibility(View.VISIBLE);
mFoldersLayout.setEnabled(true);
}
mSlideInAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 2.0f, Animation.RELATIVE_TO_SELF, 0.0f);
mSlideInAnimation.setDuration(600);
mSlideInAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
mSlideInAnimation.setAnimationListener(slideInListener);
mSlideOutAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 2.0f);
mSlideOutAnimation.setDuration(600);
mSlideOutAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
mSlideOutAnimation.setAnimationListener(slideOutListener);
mChildFragmentManager = this.getChildFragmentManager();
mChildFragmentManager.beginTransaction().add(R.id.folders_fragment_holder, getMusicFoldersSelectionFragment()).commit();
mWelcomeHeader = (TextView) rootView.findViewById(R.id.welcome_header);
mWelcomeHeader.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Light"));
mMusicFoldersOptions = (RadioGroup) rootView.findViewById(R.id.music_library_welcome_radio_group);
RadioButton getAllSongsRadioButton = (RadioButton) mMusicFoldersOptions.findViewById(R.id.get_all_songs_radio);
RadioButton letMePickFoldersRadioButton = (RadioButton) mMusicFoldersOptions.findViewById(R.id.pick_folders_radio);
getAllSongsRadioButton.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
letMePickFoldersRadioButton.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
mMusicFoldersOptions.setOnCheckedChangeListener(onCheckedChangeListener);
return rootView;
}
use of android.widget.RadioButton in project PocketHub by pockethub.
the class EditIssuesFilterActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_issues_filter_edit);
labelsText = finder.find(R.id.tv_labels);
milestoneText = finder.find(R.id.tv_milestone);
assigneeText = finder.find(R.id.tv_assignee);
avatarView = finder.find(R.id.iv_avatar);
if (savedInstanceState != null) {
filter = savedInstanceState.getParcelable(EXTRA_ISSUE_FILTER);
}
if (filter == null) {
filter = getIntent().getParcelableExtra(EXTRA_ISSUE_FILTER);
}
final Repository repository = filter.getRepository();
setSupportActionBar((android.support.v7.widget.Toolbar) findViewById(R.id.toolbar));
ActionBar actionBar = getSupportActionBar();
actionBar.setTitle(R.string.filter_issues_title);
actionBar.setSubtitle(InfoUtils.createRepoId(repository));
avatars.bind(actionBar, repository.owner());
OnClickListener assigneeListener = new OnClickListener() {
@Override
public void onClick(View v) {
if (assigneeDialog == null) {
assigneeDialog = new AssigneeDialog(EditIssuesFilterActivity.this, REQUEST_ASSIGNEE, repository);
}
assigneeDialog.show(filter.getAssignee());
}
};
findViewById(R.id.tv_assignee_label).setOnClickListener(assigneeListener);
assigneeText.setOnClickListener(assigneeListener);
OnClickListener milestoneListener = new OnClickListener() {
@Override
public void onClick(View v) {
if (milestoneDialog == null) {
milestoneDialog = new MilestoneDialog(EditIssuesFilterActivity.this, REQUEST_MILESTONE, repository);
}
milestoneDialog.show(filter.getMilestone());
}
};
findViewById(R.id.tv_milestone_label).setOnClickListener(milestoneListener);
milestoneText.setOnClickListener(milestoneListener);
OnClickListener labelsListener = new OnClickListener() {
@Override
public void onClick(View v) {
if (labelsDialog == null) {
labelsDialog = new LabelsDialog(EditIssuesFilterActivity.this, REQUEST_LABELS, repository);
}
labelsDialog.show(filter.getLabels());
}
};
findViewById(R.id.tv_labels_label).setOnClickListener(labelsListener);
labelsText.setOnClickListener(labelsListener);
updateAssignee();
updateMilestone();
updateLabels();
RadioButton openButton = (RadioButton) findViewById(R.id.rb_open);
openButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
filter.setOpen(true);
}
}
});
RadioButton closedButton = (RadioButton) findViewById(R.id.rb_closed);
closedButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
filter.setOpen(false);
}
}
});
if (filter.isOpen()) {
openButton.setChecked(true);
} else {
closedButton.setChecked(true);
}
}
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();
}
});
}
Aggregations