use of android.widget.CompoundButton 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.CompoundButton in project GT by Tencent.
the class GTCaptureActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pi_capture);
initLayout();
tv_tcpdump_back = (TextView) findViewById(R.id.tcpdump_back_gt);
tv_tcpdump_back.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
tv_tcpdump_curFile.setText(curFilePath == null ? "" : curFilePath);
tv_tcpdump_progress.setText(curFileSize == null ? "" : curFileSize + "KB");
tv_param_switch = (TextView) findViewById(R.id.tcpdump_param_switch);
tv_param_switch.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (!switch_param) {
switch_param = true;
tv_param_title.setVisibility(View.VISIBLE);
fl_param.setVisibility(View.VISIBLE);
} else {
switch_param = false;
et_param.setText(param);
tv_param_title.setVisibility(View.GONE);
fl_param.setVisibility(View.GONE);
}
}
});
btn_param_clear = (Button) findViewById(R.id.tcpdump_param_cancel);
btn_param_clear.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
param = "";
et_param.setText(param);
}
});
et_param = (EditText) findViewById(R.id.tcpdump_param);
et_param.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
return (event.getKeyCode() == KeyEvent.KEYCODE_ENTER);
}
});
tv_switch = (TextView) findViewById(R.id.tcpdump_switch);
tv_switch.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// 获取权限过程比较耗时,交给菊花去处理
Thread t = new Thread(new ProgressRunnable());
t.start();
}
});
cb_param_switch = (GTCheckBox) findViewById(R.id.cb_param_switch);
cb_param_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
cur_param_switch_status = isChecked;
tv_param_title.setVisibility(View.VISIBLE);
fl_param.setVisibility(View.VISIBLE);
String cur_param = et_param.getText().toString();
if (cur_param.equals("") || cur_param.trim().equals("")) {
et_param.setText(default_param);
}
} else {
cur_param_switch_status = isChecked;
tv_param_title.setVisibility(View.GONE);
fl_param.setVisibility(View.GONE);
}
}
});
tcpdumpSwitchHandler = new Handler() {
public void handleMessage(Message msg) {
switch(msg.what) {
case // 启动抓包开始,控件状态置为红色,显示stop
0:
switch_tcpdump = true;
tv_switch.setBackgroundResource(R.drawable.switch_off_border);
tv_switch.setText(getString(R.string.stop));
break;
case // 抓包结束,控件状态置为绿色,显示start
1:
switch_tcpdump = false;
tv_switch.setBackgroundResource(R.drawable.switch_on_border);
tv_switch.setText(getString(R.string.start));
break;
case // 吐槽提示
2:
String message = msg.obj == null ? "" : msg.obj.toString();
WidgetUtils.openToast(message);
// 有菊花则停止菊花
dismissProDialog();
break;
case // 抓包文件发生大小变化时
3:
curFileSize = msg.obj == null ? "" : msg.obj.toString();
tv_tcpdump_progress.setText(curFileSize + "KB");
break;
case // 启动抓包完成,显示当前保存的抓包文件 TODO
4:
curFilePath = msg.obj == null ? "" : msg.obj.toString();
tv_tcpdump_curFile.setText(curFilePath == null ? "" : curFilePath);
// 停止菊花
dismissProDialog();
break;
case // 抓包之前的校验,转菊花
5:
showProDialog();
break;
}
}
};
GTCaptureEngine.getInstance().addListener(this);
}
use of android.widget.CompoundButton in project android_frameworks_base by ParanoidAndroid.
the class InputMethodManagerService method showInputMethodMenuInternal.
private void showInputMethodMenuInternal(boolean showSubtypes) {
if (DEBUG)
Slog.v(TAG, "Show switching menu");
final Context context = getUiContext();
final boolean isScreenLocked = isScreenLocked();
final String lastInputMethodId = mSettings.getSelectedInputMethod();
int lastInputMethodSubtypeId = mSettings.getSelectedInputMethodSubtypeId(lastInputMethodId);
if (DEBUG)
Slog.v(TAG, "Current IME: " + lastInputMethodId);
synchronized (mMethodMap) {
final HashMap<InputMethodInfo, List<InputMethodSubtype>> immis = getExplicitlyOrImplicitlyEnabledInputMethodsAndSubtypeListLocked();
if (immis == null || immis.size() == 0) {
return;
}
hideInputMethodMenuLocked();
final List<ImeSubtypeListItem> imList = mImListManager.getSortedInputMethodAndSubtypeList(showSubtypes, mInputShown, isScreenLocked);
if (lastInputMethodSubtypeId == NOT_A_SUBTYPE_ID) {
final InputMethodSubtype currentSubtype = getCurrentInputMethodSubtypeLocked();
if (currentSubtype != null) {
final InputMethodInfo currentImi = mMethodMap.get(mCurMethodId);
lastInputMethodSubtypeId = InputMethodUtils.getSubtypeIdFromHashCode(currentImi, currentSubtype.hashCode());
}
}
final int N = imList.size();
mIms = new InputMethodInfo[N];
mSubtypeIds = new int[N];
int checkedItem = 0;
for (int i = 0; i < N; ++i) {
final ImeSubtypeListItem item = imList.get(i);
mIms[i] = item.mImi;
mSubtypeIds[i] = item.mSubtypeId;
if (mIms[i].getId().equals(lastInputMethodId)) {
int subtypeId = mSubtypeIds[i];
if ((subtypeId == NOT_A_SUBTYPE_ID) || (lastInputMethodSubtypeId == NOT_A_SUBTYPE_ID && subtypeId == 0) || (subtypeId == lastInputMethodSubtypeId)) {
checkedItem = i;
}
}
}
final TypedArray a = context.obtainStyledAttributes(null, com.android.internal.R.styleable.DialogPreference, com.android.internal.R.attr.alertDialogStyle, 0);
mDialogBuilder = new AlertDialog.Builder(context).setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
hideInputMethodMenu();
}
}).setIcon(a.getDrawable(com.android.internal.R.styleable.DialogPreference_dialogTitle));
a.recycle();
final LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View tv = inflater.inflate(com.android.internal.R.layout.input_method_switch_dialog_title, null);
mDialogBuilder.setCustomTitle(tv);
// Setup layout for a toggle switch of the hardware keyboard
mSwitchingDialogTitleView = tv;
mSwitchingDialogTitleView.findViewById(com.android.internal.R.id.hard_keyboard_section).setVisibility(mWindowManagerService.isHardKeyboardAvailable() ? View.VISIBLE : View.GONE);
final Switch hardKeySwitch = ((Switch) mSwitchingDialogTitleView.findViewById(com.android.internal.R.id.hard_keyboard_switch));
hardKeySwitch.setChecked(mWindowManagerService.isHardKeyboardEnabled());
hardKeySwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mWindowManagerService.setHardKeyboardEnabled(isChecked);
// Ensure that the input method dialog is dismissed when changing
// the hardware keyboard state.
hideInputMethodMenu();
}
});
final ImeSubtypeListAdapter adapter = new ImeSubtypeListAdapter(context, com.android.internal.R.layout.simple_list_item_2_single_choice, imList, checkedItem);
mDialogBuilder.setSingleChoiceItems(adapter, checkedItem, new AlertDialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
synchronized (mMethodMap) {
if (mIms == null || mIms.length <= which || mSubtypeIds == null || mSubtypeIds.length <= which) {
return;
}
InputMethodInfo im = mIms[which];
int subtypeId = mSubtypeIds[which];
adapter.mCheckedItem = which;
adapter.notifyDataSetChanged();
hideInputMethodMenu();
if (im != null) {
if ((subtypeId < 0) || (subtypeId >= im.getSubtypeCount())) {
subtypeId = NOT_A_SUBTYPE_ID;
}
setInputMethodLocked(im.getId(), subtypeId);
}
}
}
});
if (showSubtypes && !isScreenLocked) {
mDialogBuilder.setPositiveButton(com.android.internal.R.string.configure_input_methods, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
showConfigureInputMethods();
}
});
}
mSwitchingDialog = mDialogBuilder.create();
mSwitchingDialog.setCanceledOnTouchOutside(true);
mSwitchingDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG);
mSwitchingDialog.getWindow().getAttributes().privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
mSwitchingDialog.getWindow().getAttributes().setTitle("Select input method");
mSwitchingDialog.show();
}
}
use of android.widget.CompoundButton in project android_frameworks_base by ParanoidAndroid.
the class TransformsAndAnimationsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.transforms_and_animations);
button1 = (Button) findViewById(R.id.button1);
button2 = (Button) findViewById(R.id.button2);
button3 = (Button) findViewById(R.id.button3);
button1a = (Button) findViewById(R.id.button1a);
button2a = (Button) findViewById(R.id.button2a);
button3a = (Button) findViewById(R.id.button3a);
button1b = (Button) findViewById(R.id.button1b);
button2b = (Button) findViewById(R.id.button2b);
button3b = (Button) findViewById(R.id.button3b);
button4 = (Button) findViewById(R.id.button4);
button5 = (Button) findViewById(R.id.button5);
button6 = (Button) findViewById(R.id.button6);
button7 = (Button) findViewById(R.id.button7);
button8 = (Button) findViewById(R.id.button8);
layersNoneCB = (CheckBox) findViewById(R.id.layersNoneCB);
layersHardwareCB = (CheckBox) findViewById(R.id.layersHwCB);
layersSoftwareCB = (CheckBox) findViewById(R.id.layersSwCB);
layersNoneCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
setLayerType(View.LAYER_TYPE_NONE);
layersHardwareCB.setChecked(false);
layersSoftwareCB.setChecked(false);
}
}
});
layersSoftwareCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
setLayerType(View.LAYER_TYPE_SOFTWARE);
layersHardwareCB.setChecked(false);
layersNoneCB.setChecked(false);
}
}
});
layersHardwareCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
setLayerType(View.LAYER_TYPE_HARDWARE);
layersNoneCB.setChecked(false);
layersSoftwareCB.setChecked(false);
}
}
});
button1a.setAlpha(.5f);
button2a.setAlpha(.5f);
button3a.setAlpha(.5f);
button3.setTranslationX(50);
button7.setTranslationX(50);
button8.setTranslationX(50);
final AlphaAnimation alphaAnim = new AlphaAnimation(1, 0);
alphaAnim.setDuration(1000);
alphaAnim.setRepeatCount(Animation.INFINITE);
alphaAnim.setRepeatMode(Animation.REVERSE);
final TranslateAnimation transAnim = new TranslateAnimation(0, -50, 0, 0);
transAnim.setDuration(1000);
transAnim.setRepeatCount(Animation.INFINITE);
transAnim.setRepeatMode(Animation.REVERSE);
getWindow().getDecorView().postDelayed(new Runnable() {
@Override
public void run() {
button1.startAnimation(alphaAnim);
button2.startAnimation(alphaAnim);
button3.startAnimation(alphaAnim);
button1a.startAnimation(alphaAnim);
button2a.startAnimation(alphaAnim);
button3a.startAnimation(alphaAnim);
button1b.startAnimation(alphaAnim);
button2b.startAnimation(alphaAnim);
button3b.startAnimation(alphaAnim);
startAnimator(button1b);
startAnimator(button2b);
startAnimator(button3b);
button7.startAnimation(transAnim);
button8.startAnimation(transAnim);
}
}, 2000);
}
use of android.widget.CompoundButton in project android_frameworks_base by ParanoidAndroid.
the class NotificationBuilderTest method setChecked.
private void setChecked(int id) {
final CompoundButton b = (CompoundButton) findViewById(id);
b.setChecked(true);
}
Aggregations