use of android.widget.CompoundButton in project AndroidTraining by mixi-inc.
the class ListMenuItemView method setCheckable.
public void setCheckable(boolean checkable) {
if (!checkable && mRadioButton == null && mCheckBox == null) {
return;
}
if (mRadioButton == null) {
insertRadioButton();
}
if (mCheckBox == null) {
insertCheckBox();
}
// Depending on whether its exclusive check or not, the checkbox or
// radio button will be the one in use (and the other will be otherCompoundButton)
final CompoundButton compoundButton;
final CompoundButton otherCompoundButton;
if (mItemData.isExclusiveCheckable()) {
compoundButton = mRadioButton;
otherCompoundButton = mCheckBox;
} else {
compoundButton = mCheckBox;
otherCompoundButton = mRadioButton;
}
if (checkable) {
compoundButton.setChecked(mItemData.isChecked());
final int newVisibility = checkable ? VISIBLE : GONE;
if (compoundButton.getVisibility() != newVisibility) {
compoundButton.setVisibility(newVisibility);
}
// Make sure the other compound button isn't visible
if (otherCompoundButton.getVisibility() != GONE) {
otherCompoundButton.setVisibility(GONE);
}
} else {
mCheckBox.setVisibility(GONE);
mRadioButton.setVisibility(GONE);
}
}
use of android.widget.CompoundButton in project k-9 by k9mail.
the class AccountSetupBasics method initializeViewListeners.
private void initializeViewListeners() {
mEmailView.addTextChangedListener(this);
mPasswordView.addTextChangedListener(this);
mClientCertificateCheckBox.setOnCheckedChangeListener(this);
mClientCertificateSpinner.setOnClientCertificateChangedListener(this);
mShowPasswordCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
showPassword(isChecked);
}
});
}
use of android.widget.CompoundButton in project SeriesGuide by UweTrottmann.
the class DataLiberationFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_data_liberation, container, false);
unbinder = ButterKnife.bind(this, v);
progressBar.setVisibility(View.GONE);
// setup listeners
buttonExport.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
tryDataLiberationAction(REQUEST_CODE_EXPORT);
}
});
checkBoxImportWarning.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
updateImportButtonEnabledState();
}
});
checkBoxShows.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
updateImportButtonEnabledState();
}
});
checkBoxLists.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
updateImportButtonEnabledState();
}
});
checkBoxMovies.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
updateImportButtonEnabledState();
}
});
buttonImport.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
tryDataLiberationAction(REQUEST_CODE_IMPORT);
}
});
// as we use Storage Access Framework in this case
if (AndroidUtils.isKitKatOrHigher()) {
buttonShowsExportFile.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
DataLiberationTools.selectExportFile(DataLiberationFragment.this, JsonExportTask.EXPORT_JSON_FILE_SHOWS, REQUEST_CODE_SHOWS_EXPORT_URI);
}
});
buttonShowsImportFile.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
DataLiberationTools.selectImportFile(DataLiberationFragment.this, REQUEST_CODE_SHOWS_IMPORT_URI);
}
});
buttonListsExportFile.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
DataLiberationTools.selectExportFile(DataLiberationFragment.this, JsonExportTask.EXPORT_JSON_FILE_LISTS, REQUEST_CODE_LISTS_EXPORT_URI);
}
});
buttonListsImportFile.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
DataLiberationTools.selectImportFile(DataLiberationFragment.this, REQUEST_CODE_LISTS_IMPORT_URI);
}
});
buttonMoviesExportFile.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
DataLiberationTools.selectExportFile(DataLiberationFragment.this, JsonExportTask.EXPORT_JSON_FILE_MOVIES, REQUEST_CODE_MOVIES_EXPORT_URI);
}
});
buttonMoviesImportFile.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
DataLiberationTools.selectImportFile(DataLiberationFragment.this, REQUEST_CODE_MOVIES_IMPORT_URI);
}
});
} else {
buttonShowsExportFile.setVisibility(View.GONE);
buttonShowsImportFile.setVisibility(View.GONE);
buttonListsExportFile.setVisibility(View.GONE);
buttonListsImportFile.setVisibility(View.GONE);
buttonMoviesExportFile.setVisibility(View.GONE);
buttonMoviesImportFile.setVisibility(View.GONE);
}
updateFileViews();
return v;
}
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);
}
Aggregations