use of android.widget.CheckBox 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.CheckBox in project tree-view-list-android by Polidea.
the class SimpleStandardAdapter method handleItemClick.
@Override
public void handleItemClick(final View view, final Object id) {
final Long longId = (Long) id;
final TreeNodeInfo<Long> info = getManager().getNodeInfo(longId);
if (info.isWithChildren()) {
super.handleItemClick(view, id);
} else {
final ViewGroup vg = (ViewGroup) view;
final CheckBox cb = (CheckBox) vg.findViewById(R.id.demo_list_checkbox);
cb.performClick();
}
}
use of android.widget.CheckBox in project RoboBinding by RoboBinding.
the class AbstractCompoundButtonAttributeTest method initializeViewAndListeners.
@Before
public void initializeViewAndListeners() {
view = new CheckBox(RuntimeEnvironment.application);
viewAddOn = new MockCompoundButtonAddOn(view);
}
use of android.widget.CheckBox in project RoboBinding by RoboBinding.
the class CompoundButtonAddOnTest method shouldSupportMultipleOnCheckedChangeListeners.
@Test
public void shouldSupportMultipleOnCheckedChangeListeners() {
CheckBox view = new CheckBox(RuntimeEnvironment.application);
CompoundButtonAddOn viewAddOn = new CompoundButtonAddOn(view);
MockOnCheckedChangeListener listener1 = new MockOnCheckedChangeListener();
MockOnCheckedChangeListener listener2 = new MockOnCheckedChangeListener();
viewAddOn.addOnCheckedChangeListener(listener1);
viewAddOn.addOnCheckedChangeListener(listener2);
view.setChecked(!view.isChecked());
assertTrue(listener1.checkedChangeEventFired);
assertTrue(listener2.checkedChangeEventFired);
}
use of android.widget.CheckBox in project XPrivacy by M66B.
the class PrivacyService method getOnDemandView.
@SuppressLint("InflateParams")
private View getOnDemandView(final PRestriction restriction, final Hook hook, ApplicationInfoEx appInfo, final PRestriction result, Context context, final OnDemandDialogHolder holder, final OnDemandResult oResult) throws NameNotFoundException, RemoteException {
// Get resources
String self = PrivacyService.class.getPackage().getName();
Resources resources = context.getPackageManager().getResourcesForApplication(self);
// Reference views
final View view = LayoutInflater.from(context.createPackageContext(self, 0)).inflate(R.layout.ondemand, null);
ImageView ivAppIcon = (ImageView) view.findViewById(R.id.ivAppIcon);
TextView tvUid = (TextView) view.findViewById(R.id.tvUid);
TextView tvAppName = (TextView) view.findViewById(R.id.tvAppName);
TextView tvCategory = (TextView) view.findViewById(R.id.tvCategory);
TextView tvFunction = (TextView) view.findViewById(R.id.tvFunction);
TextView tvParameters = (TextView) view.findViewById(R.id.tvParameters);
TableRow rowParameters = (TableRow) view.findViewById(R.id.rowParameters);
TextView tvDefault = (TextView) view.findViewById(R.id.tvDefault);
TextView tvInfoCategory = (TextView) view.findViewById(R.id.tvInfoCategory);
final CheckBox cbExpert = (CheckBox) view.findViewById(R.id.cbExpert);
final CheckBox cbCategory = (CheckBox) view.findViewById(R.id.cbCategory);
final CheckBox cbOnce = (CheckBox) view.findViewById(R.id.cbOnce);
final Spinner spOnce = (Spinner) view.findViewById(R.id.spOnce);
final LinearLayout llWhiteList = (LinearLayout) view.findViewById(R.id.llWhiteList);
final CheckBox cbWhitelist = (CheckBox) view.findViewById(R.id.cbWhitelist);
final CheckBox cbWhitelistExtra1 = (CheckBox) view.findViewById(R.id.cbWhitelistExtra1);
final CheckBox cbWhitelistExtra2 = (CheckBox) view.findViewById(R.id.cbWhitelistExtra2);
final CheckBox cbWhitelistExtra3 = (CheckBox) view.findViewById(R.id.cbWhitelistExtra3);
ProgressBar mProgress = (ProgressBar) view.findViewById(R.id.pbProgress);
Button btnDeny = (Button) view.findViewById(R.id.btnDeny);
Button btnDontKnow = (Button) view.findViewById(R.id.btnDontKnow);
Button btnAllow = (Button) view.findViewById(R.id.btnAllow);
final int userId = Util.getUserId(Process.myUid());
boolean expert = getSettingBool(userId, PrivacyManager.cSettingODExpert, false);
boolean category = getSettingBool(userId, PrivacyManager.cSettingODCategory, true);
boolean once = getSettingBool(userId, PrivacyManager.cSettingODOnce, false);
expert = expert || !category || once;
final boolean whitelistDangerous = (hook != null && hook.isDangerous() && hook.whitelist() != null);
// Set values
if ((hook != null && hook.isDangerous()) || appInfo.isSystem())
view.setBackgroundResource(R.color.color_dangerous_dialog);
else
view.setBackgroundResource(android.R.color.background_dark);
// Application information
ivAppIcon.setImageDrawable(appInfo.getIcon(context));
tvUid.setText(Integer.toString(appInfo.getUid()));
tvAppName.setText(TextUtils.join(", ", appInfo.getApplicationName()));
// Restriction information
int catId = resources.getIdentifier("restrict_" + restriction.restrictionName, "string", self);
tvCategory.setText(resources.getString(catId));
tvFunction.setText(restriction.methodName);
if (restriction.extra == null)
rowParameters.setVisibility(View.GONE);
else
tvParameters.setText(restriction.extra);
String defaultAction = resources.getString(result.restricted ? R.string.title_deny : R.string.title_allow);
tvDefault.setText(defaultAction);
// Help
int helpId = resources.getIdentifier("restrict_help_" + restriction.restrictionName, "string", self);
tvInfoCategory.setText(resources.getString(helpId));
// Expert mode
cbExpert.setChecked(expert);
if (expert) {
for (View child : Util.getViewsByTag((ViewGroup) view, "details")) child.setVisibility(View.VISIBLE);
for (View child : Util.getViewsByTag((ViewGroup) view, "nodetails")) child.setVisibility(View.GONE);
}
if (expert || whitelistDangerous)
llWhiteList.setVisibility(View.VISIBLE);
// Category
cbCategory.setChecked(category);
// Once
cbOnce.setChecked(once);
int osel = Integer.parseInt(getSetting(new PSetting(userId, "", PrivacyManager.cSettingODOnceDuration, "0")).value);
spOnce.setSelection(osel);
// Whitelisting
if (hook != null && hook.whitelist() != null && restriction.extra != null) {
cbWhitelist.setText(resources.getString(R.string.title_whitelist, restriction.extra));
cbWhitelist.setVisibility(View.VISIBLE);
String[] xextra = getXExtra(restriction, hook);
if (xextra.length > 0) {
cbWhitelistExtra1.setText(resources.getString(R.string.title_whitelist, xextra[0]));
cbWhitelistExtra1.setVisibility(View.VISIBLE);
}
if (xextra.length > 1) {
cbWhitelistExtra2.setText(resources.getString(R.string.title_whitelist, xextra[1]));
cbWhitelistExtra2.setVisibility(View.VISIBLE);
}
if (xextra.length > 2) {
cbWhitelistExtra3.setText(resources.getString(R.string.title_whitelist, xextra[2]));
cbWhitelistExtra3.setVisibility(View.VISIBLE);
}
}
cbExpert.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
setSettingBool(userId, "", PrivacyManager.cSettingODExpert, isChecked);
if (!isChecked) {
setSettingBool(userId, "", PrivacyManager.cSettingODCategory, true);
setSettingBool(userId, "", PrivacyManager.cSettingODOnce, false);
cbCategory.setChecked(true);
cbOnce.setChecked(false);
cbWhitelist.setChecked(false);
cbWhitelistExtra1.setChecked(false);
cbWhitelistExtra2.setChecked(false);
cbWhitelistExtra3.setChecked(false);
}
for (View child : Util.getViewsByTag((ViewGroup) view, "details")) child.setVisibility(isChecked ? View.VISIBLE : View.GONE);
for (View child : Util.getViewsByTag((ViewGroup) view, "nodetails")) child.setVisibility(isChecked ? View.GONE : View.VISIBLE);
if (!whitelistDangerous)
llWhiteList.setVisibility(isChecked ? View.VISIBLE : View.GONE);
}
});
// Category, once and whitelist exclude each other
cbCategory.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
cbWhitelist.setChecked(false);
cbWhitelistExtra1.setChecked(false);
cbWhitelistExtra2.setChecked(false);
cbWhitelistExtra3.setChecked(false);
}
}
});
cbOnce.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
cbWhitelist.setChecked(false);
cbWhitelistExtra1.setChecked(false);
cbWhitelistExtra2.setChecked(false);
cbWhitelistExtra3.setChecked(false);
}
}
});
cbWhitelist.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
cbCategory.setChecked(false);
cbOnce.setChecked(false);
cbWhitelistExtra1.setChecked(false);
cbWhitelistExtra2.setChecked(false);
cbWhitelistExtra3.setChecked(false);
}
}
});
cbWhitelistExtra1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
cbCategory.setChecked(false);
cbOnce.setChecked(false);
cbWhitelist.setChecked(false);
cbWhitelistExtra2.setChecked(false);
cbWhitelistExtra3.setChecked(false);
}
}
});
cbWhitelistExtra2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
cbCategory.setChecked(false);
cbOnce.setChecked(false);
cbWhitelist.setChecked(false);
cbWhitelistExtra1.setChecked(false);
cbWhitelistExtra3.setChecked(false);
}
}
});
cbWhitelistExtra3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
cbCategory.setChecked(false);
cbOnce.setChecked(false);
cbWhitelist.setChecked(false);
cbWhitelistExtra1.setChecked(false);
cbWhitelistExtra2.setChecked(false);
}
}
});
// Setup progress bar
mProgress.setMax(cMaxOnDemandDialog * 20);
mProgress.setProgress(cMaxOnDemandDialog * 20);
btnAllow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Allow
result.restricted = false;
result.asked = true;
if (cbWhitelist.isChecked())
onDemandWhitelist(restriction, null, result, oResult, hook);
else if (cbWhitelistExtra1.isChecked())
onDemandWhitelist(restriction, getXExtra(restriction, hook)[0], result, oResult, hook);
else if (cbWhitelistExtra2.isChecked())
onDemandWhitelist(restriction, getXExtra(restriction, hook)[1], result, oResult, hook);
else if (cbWhitelistExtra3.isChecked())
onDemandWhitelist(restriction, getXExtra(restriction, hook)[2], result, oResult, hook);
else {
setSettingBool(userId, "", PrivacyManager.cSettingODCategory, cbCategory.isChecked());
setSettingBool(userId, "", PrivacyManager.cSettingODOnce, cbOnce.isChecked());
if (cbOnce.isChecked())
onDemandOnce(restriction, cbCategory.isChecked(), result, oResult, spOnce);
else
onDemandChoice(restriction, cbCategory.isChecked(), false);
}
holder.latch.countDown();
}
});
btnDontKnow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Deny once
result.restricted = !(hook != null && hook.isDangerous());
result.asked = true;
onDemandOnce(restriction, false, result, oResult, spOnce);
holder.latch.countDown();
}
});
btnDeny.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Deny
result.restricted = true;
result.asked = true;
if (cbWhitelist.isChecked())
onDemandWhitelist(restriction, null, result, oResult, hook);
else if (cbWhitelistExtra1.isChecked())
onDemandWhitelist(restriction, getXExtra(restriction, hook)[0], result, oResult, hook);
else if (cbWhitelistExtra2.isChecked())
onDemandWhitelist(restriction, getXExtra(restriction, hook)[1], result, oResult, hook);
else if (cbWhitelistExtra3.isChecked())
onDemandWhitelist(restriction, getXExtra(restriction, hook)[2], result, oResult, hook);
else {
setSettingBool(userId, "", PrivacyManager.cSettingODCategory, cbCategory.isChecked());
setSettingBool(userId, "", PrivacyManager.cSettingODOnce, cbOnce.isChecked());
if (cbOnce.isChecked())
onDemandOnce(restriction, cbCategory.isChecked(), result, oResult, spOnce);
else
onDemandChoice(restriction, cbCategory.isChecked(), true);
}
holder.latch.countDown();
}
});
return view;
}
Aggregations