use of android.widget.CheckBox in project Notes by MiCode.
the class NoteEditActivity method getListItem.
private View getListItem(String item, int index) {
View view = LayoutInflater.from(this).inflate(R.layout.note_edit_list_item, null);
final NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text);
edit.setTextAppearance(this, TextAppearanceResources.getTexAppearanceResource(mFontSizeId));
CheckBox cb = ((CheckBox) view.findViewById(R.id.cb_edit_item));
cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
edit.setPaintFlags(edit.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
} else {
edit.setPaintFlags(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);
}
}
});
if (item.startsWith(TAG_CHECKED)) {
cb.setChecked(true);
edit.setPaintFlags(edit.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
item = item.substring(TAG_CHECKED.length(), item.length()).trim();
} else if (item.startsWith(TAG_UNCHECKED)) {
cb.setChecked(false);
edit.setPaintFlags(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);
item = item.substring(TAG_UNCHECKED.length(), item.length()).trim();
}
edit.setOnTextViewChangeListener(this);
edit.setIndex(index);
edit.setText(getHighlightQueryResult(item, mUserQuery));
return view;
}
use of android.widget.CheckBox in project FloatingStickies by MohammadAdib.
the class MainActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext());
boolean key = prefs.getBoolean("key", false);
if (!key) {
setContentView(R.layout.tutorial);
final ImageView iv1 = (ImageView) findViewById(R.id.imageView1);
final ImageView iv2 = (ImageView) findViewById(R.id.imageView2);
final ImageView iv3 = (ImageView) findViewById(R.id.imageView3);
final ImageView iv4 = (ImageView) findViewById(R.id.done);
final CheckBox cb = (CheckBox) findViewById(R.id.checkBox);
final Animation anim1 = AnimationUtils.loadAnimation(this, R.anim.show);
final Animation anim2 = AnimationUtils.loadAnimation(this, R.anim.show);
final Animation anim3 = AnimationUtils.loadAnimation(this, R.anim.show);
final Animation anim4 = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
final Animation anim5 = AnimationUtils.loadAnimation(this, android.R.anim.fade_out);
final Animation anim6 = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
anim1.setDuration(500);
anim2.setDuration(500);
anim3.setDuration(500);
anim1.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
iv1.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
iv2.startAnimation(anim2);
}
});
anim2.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
iv2.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
iv3.startAnimation(anim3);
}
});
anim3.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
iv3.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
iv4.startAnimation(anim4);
iv4.setOnTouchListener(MainActivity.this);
}
});
anim4.setDuration(1000);
anim4.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
iv4.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
iv4.startAnimation(anim5);
}
});
anim5.setDuration(1000);
anim5.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
iv4.startAnimation(anim4);
}
});
iv1.startAnimation(anim1);
cb.startAnimation(anim6);
} else {
finish();
}
}
use of android.widget.CheckBox in project OpenMEAP by OpenMEAP.
the class MainActivity method createLoginFormDialog.
private Dialog createLoginFormDialog() {
Context mContext = this;
final Dialog dialog = new Dialog(mContext);
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
final View layout = inflater.inflate(R.layout.login_form, (ViewGroup) findViewById(R.id.login_form_container));
dialog.setContentView(layout);
dialog.setTitle("Authentication Prompt");
String infoText = loginFormCallback.getInfoText();
TextView infoTextView = (TextView) layout.findViewById(R.id.info);
infoTextView.setText(infoText);
Button proceedButton = (Button) layout.findViewById(R.id.proceed);
proceedButton.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
EditText passwordText = (EditText) layout.findViewById(R.id.password);
EditText usernameText = (EditText) layout.findViewById(R.id.username);
CheckBox rememberBox = (CheckBox) layout.findViewById(R.id.remember);
loginFormCallback.onProceed(usernameText.getEditableText().toString(), passwordText.getEditableText().toString(), rememberBox.isChecked());
loginFormCallback = null;
if (!rememberBox.isChecked()) {
usernameText.setText("");
passwordText.setText("");
}
dialog.dismiss();
}
});
Button cancelButton = (Button) layout.findViewById(R.id.cancel);
cancelButton.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
EditText passwordText = (EditText) layout.findViewById(R.id.password);
EditText usernameText = (EditText) layout.findViewById(R.id.username);
CheckBox rememberBox = (CheckBox) layout.findViewById(R.id.remember);
loginFormCallback.onCancel();
loginFormCallback = null;
if (!rememberBox.isChecked()) {
usernameText.setText("");
passwordText.setText("");
}
dialog.dismiss();
}
});
EditText usernameText = (EditText) layout.findViewById(R.id.username);
usernameText.requestFocus();
return dialog;
}
use of android.widget.CheckBox 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.CheckBox in project actor-platform by actorapp.
the class NotificationsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View res = inflater.inflate(R.layout.fr_settings_notifications, container, false);
res.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
// Conversation tone
final CheckBox enableTones = (CheckBox) res.findViewById(R.id.enableConversationTones);
enableTones.setChecked(messenger().isConversationTonesEnabled());
View.OnClickListener enableTonesListener = v -> {
messenger().changeConversationTonesEnabled(!messenger().isConversationTonesEnabled());
enableTones.setChecked(messenger().isConversationTonesEnabled());
};
ActorStyle style = ActorSDK.sharedActor().style;
((TextView) res.findViewById(R.id.settings_conversation_tones_title)).setTextColor(style.getTextPrimaryColor());
((TextView) res.findViewById(R.id.settings_conversation_tones_hint)).setTextColor(style.getTextSecondaryColor());
enableTones.setOnClickListener(enableTonesListener);
res.findViewById(R.id.conversationTonesCont).setOnClickListener(enableTonesListener);
// Vibration
final CheckBox enableVibration = (CheckBox) res.findViewById(R.id.enableVibration);
enableVibration.setChecked(messenger().isNotificationVibrationEnabled());
View.OnClickListener enableVibrationListener = v -> {
messenger().changeNotificationVibrationEnabled(!messenger().isNotificationVibrationEnabled());
enableVibration.setChecked(messenger().isNotificationVibrationEnabled());
};
enableVibration.setOnClickListener(enableVibrationListener);
res.findViewById(R.id.vibrationCont).setOnClickListener(enableVibrationListener);
((TextView) res.findViewById(R.id.settings_vibration_title)).setTextColor(style.getTextPrimaryColor());
((TextView) res.findViewById(R.id.settings_vibration_hint)).setTextColor(style.getTextSecondaryColor());
// Group
final CheckBox enableGroup = (CheckBox) res.findViewById(R.id.enableGroup);
enableGroup.setChecked(messenger().isGroupNotificationsEnabled());
View.OnClickListener enableGroupListener = v -> {
messenger().changeGroupNotificationsEnabled(!messenger().isGroupNotificationsEnabled());
enableGroup.setChecked(messenger().isGroupNotificationsEnabled());
};
enableGroup.setOnClickListener(enableGroupListener);
res.findViewById(R.id.groupCont).setOnClickListener(enableGroupListener);
((TextView) res.findViewById(R.id.settings_group_title)).setTextColor(style.getTextPrimaryColor());
((TextView) res.findViewById(R.id.settings_group_hint)).setTextColor(style.getTextSecondaryColor());
// Mentions
final CheckBox enableGroupMentions = (CheckBox) res.findViewById(R.id.enableGroupMentions);
enableGroupMentions.setChecked(messenger().isGroupNotificationsOnlyMentionsEnabled());
View.OnClickListener enableGroupMentionsListener = v -> {
messenger().changeGroupNotificationsOnlyMentionsEnabled(!messenger().isGroupNotificationsOnlyMentionsEnabled());
enableGroupMentions.setChecked(messenger().isGroupNotificationsOnlyMentionsEnabled());
};
enableGroupMentions.setOnClickListener(enableGroupMentionsListener);
res.findViewById(R.id.groupMentionsCont).setOnClickListener(enableGroupMentionsListener);
((TextView) res.findViewById(R.id.settings_group_mentions_title)).setTextColor(style.getTextPrimaryColor());
((TextView) res.findViewById(R.id.settings_group_mentions_hint)).setTextColor(style.getTextSecondaryColor());
// Names and messages
final CheckBox enableText = (CheckBox) res.findViewById(R.id.enableTitles);
enableText.setChecked(messenger().isShowNotificationsText());
View.OnClickListener enableTextListener = v -> {
messenger().changeShowNotificationTextEnabled(!messenger().isShowNotificationsText());
enableText.setChecked(messenger().isShowNotificationsText());
};
enableText.setOnClickListener(enableTextListener);
res.findViewById(R.id.titlesCont).setOnClickListener(enableTextListener);
((TextView) res.findViewById(R.id.settings_titles_title)).setTextColor(style.getTextPrimaryColor());
((TextView) res.findViewById(R.id.settings_titles_hint)).setTextColor(style.getTextSecondaryColor());
// Sound
View soundPickerCont = res.findViewById(R.id.soundPickerCont);
View soundPickerDivider = res.findViewById(R.id.divider);
if (messenger().isNotificationSoundEnabled()) {
ViewUtils.showViews(false, soundPickerCont, soundPickerDivider);
} else {
ViewUtils.goneViews(false, soundPickerCont, soundPickerDivider);
}
final CheckBox enableSound = (CheckBox) res.findViewById(R.id.enableSound);
enableSound.setChecked(messenger().isNotificationSoundEnabled());
View.OnClickListener enableSoundListener = v -> {
messenger().changeNotificationSoundEnabled(!messenger().isNotificationSoundEnabled());
enableSound.setChecked(messenger().isNotificationSoundEnabled());
if (messenger().isNotificationSoundEnabled()) {
ViewUtils.showViews(soundPickerCont, soundPickerDivider);
} else {
ViewUtils.goneViews(soundPickerCont, soundPickerDivider);
}
};
enableSound.setOnClickListener(enableSoundListener);
res.findViewById(R.id.soundCont).setOnClickListener(enableSoundListener);
((TextView) res.findViewById(R.id.settings_sound_title)).setTextColor(style.getTextPrimaryColor());
((TextView) res.findViewById(R.id.settings_sound_hint)).setTextColor(style.getTextSecondaryColor());
// Sound picker
View.OnClickListener soundPickerListener = v -> {
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
Uri currentSound = null;
String defaultPath = null;
Uri defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
if (defaultUri != null) {
defaultPath = defaultUri.getPath();
}
String path = messenger().getPreferences().getString("globalNotificationSound");
if (path == null) {
path = defaultPath;
}
if (path != null && !path.equals("none")) {
if (path.equals(defaultPath)) {
currentSound = defaultUri;
} else {
currentSound = Uri.parse(path);
}
}
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentSound);
startActivityForResult(intent, SOUND_PICKER_REQUEST_CODE);
};
res.findViewById(R.id.soundPickerCont).setOnClickListener(soundPickerListener);
((TextView) res.findViewById(R.id.settings_sound_picker_title)).setTextColor(style.getTextPrimaryColor());
((TextView) res.findViewById(R.id.settings_sound_picker_hint)).setTextColor(style.getTextSecondaryColor());
return res;
}
Aggregations