use of android.widget.CheckBox in project GreenDroid by cyrilmottier.
the class SegmentedBar method addSegment.
/**
* Adds a segment to the SegmentBar. This method automatically adds a
* divider if needed.
*
* @param title The title of the segment to add.
*/
public void addSegment(String title) {
final Context context = getContext();
final LayoutInflater inflater = LayoutInflater.from(context);
/*
* First of all, we have to check whether or not we need to add a
* divider. A divider is added when there is at least one segment
*/
if (mDividerDrawable != null && getSegmentCount() > 0) {
ImageView divider = new ImageView(context);
final int width = (mDividerWidth > 0) ? mDividerWidth : mDividerDrawable.getIntrinsicWidth();
final LinearLayout.LayoutParams lp = new LayoutParams(width, LayoutParams.FILL_PARENT);
lp.setMargins(0, 0, 0, 0);
divider.setLayoutParams(lp);
divider.setBackgroundDrawable(mDividerDrawable);
addView(divider);
}
CheckBox segment = (CheckBox) inflater.inflate(R.layout.gd_segment, this, false);
segment.setText(title);
segment.setClickable(true);
segment.setFocusable(true);
segment.setOnFocusChangeListener(this);
segment.setOnCheckedChangeListener(new SegmentCheckedListener(getSegmentCount()));
segment.setOnClickListener(new SegmentClickedListener(getSegmentCount()));
addView(segment);
}
use of android.widget.CheckBox in project bee by orhanobut.
the class SettingsAdapter method createCheckBox.
private View createCheckBox(ViewGroup parent, MethodInfo methodInfo) {
final Method method = methodInfo.getMethod();
final Object instance = methodInfo.getInstance();
final Context context = parent.getContext();
View view = inflater.inflate(R.layout.item_settings_checkbox, parent, false);
((TextView) view.findViewById(R.id.title)).setText(methodInfo.getTitle());
CheckBox checkBox = (CheckBox) view.findViewById(R.id.checkbox);
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
try {
method.invoke(instance, isChecked);
} catch (Exception e) {
Log.e("Bee", e.getMessage());
}
PrefHelper.setBoolean(context, method.getName(), isChecked);
}
});
checkBox.setChecked(PrefHelper.getBoolean(context, method.getName()));
return view;
}
use of android.widget.CheckBox in project android_frameworks_base by ResurrectionRemix.
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.CheckBox in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DockService method createDialog.
private void createDialog(BluetoothDevice device, int state, int startId) {
if (mDialog != null) {
// Shouldn't normally happen
mDialog.dismiss();
mDialog = null;
}
mDevice = device;
switch(state) {
case Intent.EXTRA_DOCK_STATE_CAR:
case Intent.EXTRA_DOCK_STATE_DESK:
case Intent.EXTRA_DOCK_STATE_LE_DESK:
case Intent.EXTRA_DOCK_STATE_HE_DESK:
break;
default:
return;
}
startForeground(0, new Notification());
final AlertDialog.Builder ab = new AlertDialog.Builder(this);
View view;
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
mAudioMediaCheckbox = null;
if (device != null) {
// Device in a new dock.
boolean firstTime = !LocalBluetoothPreferences.hasDockAutoConnectSetting(this, device.getAddress());
CharSequence[] items = initBtSettings(device, state, firstTime);
ab.setTitle(getString(R.string.bluetooth_dock_settings_title));
// Profiles
ab.setMultiChoiceItems(items, mCheckedItems, mMultiClickListener);
// Remember this settings
view = inflater.inflate(R.layout.remember_dock_setting, null);
CheckBox rememberCheckbox = (CheckBox) view.findViewById(R.id.remember);
// check "Remember setting" by default if no value was saved
boolean checked = firstTime || LocalBluetoothPreferences.getDockAutoConnectSetting(this, device.getAddress());
rememberCheckbox.setChecked(checked);
rememberCheckbox.setOnCheckedChangeListener(mCheckedChangeListener);
if (DEBUG) {
Log.d(TAG, "Auto connect = " + LocalBluetoothPreferences.getDockAutoConnectSetting(this, device.getAddress()));
}
} else {
ab.setTitle(getString(R.string.bluetooth_dock_settings_title));
view = inflater.inflate(R.layout.dock_audio_media_enable_dialog, null);
mAudioMediaCheckbox = (CheckBox) view.findViewById(R.id.dock_audio_media_enable_cb);
boolean checked = Settings.Global.getInt(getContentResolver(), Settings.Global.DOCK_AUDIO_MEDIA_ENABLED, 0) == 1;
mAudioMediaCheckbox.setChecked(checked);
mAudioMediaCheckbox.setOnCheckedChangeListener(mCheckedChangeListener);
}
float pixelScaleFactor = getResources().getDisplayMetrics().density;
int viewSpacingLeft = (int) (14 * pixelScaleFactor);
int viewSpacingRight = (int) (14 * pixelScaleFactor);
ab.setView(view, viewSpacingLeft, 0, /* top */
viewSpacingRight, 0);
// Ok Button
ab.setPositiveButton(getString(android.R.string.ok), mClickListener);
mStartIdAssociatedWithDialog = startId;
mDialog = ab.create();
mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
mDialog.setOnDismissListener(mDismissListener);
mDialog.show();
}
use of android.widget.CheckBox in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SupportDisclaimerDialogFragment method onClick.
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == Dialog.BUTTON_NEGATIVE) {
MetricsLogger.action(getContext(), MetricsProto.MetricsEvent.ACTION_SUPPORT_DISCLAIMER_CANCEL);
return;
}
final Activity activity = getActivity();
final CheckBox doNotShow = (CheckBox) getDialog().findViewById(R.id.support_disclaimer_do_not_show_again);
final SupportFeatureProvider supportFeatureProvider = FeatureFactory.getFactory(activity).getSupportFeatureProvider(activity);
supportFeatureProvider.setShouldShowDisclaimerDialog(getContext(), !doNotShow.isChecked());
final Bundle bundle = getArguments();
MetricsLogger.action(activity, MetricsProto.MetricsEvent.ACTION_SUPPORT_DISCLAIMER_OK);
supportFeatureProvider.startSupport(getActivity(), (Account) bundle.getParcelable(EXTRA_ACCOUNT), bundle.getInt(EXTRA_TYPE));
}
Aggregations