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 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;
}
use of android.widget.CheckBox in project android_frameworks_base by ParanoidAndroid.
the class UsbResolverActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
Parcelable targetParcelable = intent.getParcelableExtra(Intent.EXTRA_INTENT);
if (!(targetParcelable instanceof Intent)) {
Log.w("UsbResolverActivity", "Target is not an intent: " + targetParcelable);
finish();
return;
}
Intent target = (Intent) targetParcelable;
ArrayList<ResolveInfo> rList = intent.getParcelableArrayListExtra(EXTRA_RESOLVE_INFOS);
CharSequence title = getResources().getText(com.android.internal.R.string.chooseUsbActivity);
super.onCreate(savedInstanceState, target, title, null, rList, true);
CheckBox alwaysUse = (CheckBox) findViewById(com.android.internal.R.id.alwaysUse);
if (alwaysUse != null) {
if (mDevice == null) {
alwaysUse.setText(R.string.always_use_accessory);
} else {
alwaysUse.setText(R.string.always_use_device);
}
}
mDevice = (UsbDevice) target.getParcelableExtra(UsbManager.EXTRA_DEVICE);
if (mDevice != null) {
mDisconnectedReceiver = new UsbDisconnectedReceiver(this, mDevice);
} else {
mAccessory = (UsbAccessory) target.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
if (mAccessory == null) {
Log.e(TAG, "no device or accessory");
finish();
return;
}
mDisconnectedReceiver = new UsbDisconnectedReceiver(this, mAccessory);
}
}
use of android.widget.CheckBox in project android_frameworks_base by ParanoidAndroid.
the class ClientTest method onCreate.
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button addpbtn = (Button) findViewById(R.id.addpkg);
Button procbtn = (Button) findViewById(R.id.procmsg);
Button delbtn = (Button) findViewById(R.id.delpkg);
Log.v(LOG_TAG, "activity created!!");
addpbtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
EditText app_id = (EditText) findViewById(R.id.app_id);
EditText cont = (EditText) findViewById(R.id.cont);
EditText pkg = (EditText) findViewById(R.id.pkg);
EditText cls = (EditText) findViewById(R.id.cls);
RadioButton act = (RadioButton) findViewById(R.id.act);
CheckBox sig = (CheckBox) findViewById(R.id.sig);
CheckBox ftr = (CheckBox) findViewById(R.id.ftr);
try {
if (!mWapPushMan.addPackage(app_id.getText().toString(), cont.getText().toString(), pkg.getText().toString(), cls.getText().toString(), act.isChecked() ? WapPushManagerParams.APP_TYPE_ACTIVITY : WapPushManagerParams.APP_TYPE_SERVICE, sig.isChecked(), ftr.isChecked())) {
Log.w(LOG_TAG, "remote add pkg failed...");
mWapPushMan.updatePackage(app_id.getText().toString(), cont.getText().toString(), pkg.getText().toString(), cls.getText().toString(), act.isChecked() ? WapPushManagerParams.APP_TYPE_ACTIVITY : WapPushManagerParams.APP_TYPE_SERVICE, sig.isChecked(), ftr.isChecked());
}
} catch (RemoteException e) {
Log.w(LOG_TAG, "remote func failed...");
}
}
});
delbtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
EditText app_id = (EditText) findViewById(R.id.app_id);
EditText cont = (EditText) findViewById(R.id.cont);
EditText pkg = (EditText) findViewById(R.id.pkg);
EditText cls = (EditText) findViewById(R.id.cls);
try {
mWapPushMan.deletePackage(app_id.getText().toString(), cont.getText().toString(), pkg.getText().toString(), cls.getText().toString());
// delall.isChecked());
} catch (RemoteException e) {
Log.w(LOG_TAG, "remote func failed...");
}
}
});
procbtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
EditText pdu = (EditText) findViewById(R.id.pdu);
EditText app_id = (EditText) findViewById(R.id.app_id);
EditText cont = (EditText) findViewById(R.id.cont);
// wap.dispatchWapPdu(strToHex(pdu.getText().toString()));
try {
Intent intent = new Intent();
intent.putExtra("transactionId", 0);
intent.putExtra("pduType", 6);
intent.putExtra("header", HexDump.hexStringToByteArray(pdu.getText().toString()));
intent.putExtra("data", HexDump.hexStringToByteArray(pdu.getText().toString()));
mWapPushMan.processMessage(app_id.getText().toString(), cont.getText().toString(), intent);
//HexDump.hexStringToByteArray(pdu.getText().toString()), 0, 6, 5, 5);
} catch (RemoteException e) {
Log.w(LOG_TAG, "remote func failed...");
}
}
});
}
Aggregations