use of android.widget.CheckBox in project orWall by EthACKdotOrg.
the class AppListAdapter method saveAdvanced.
private void saveAdvanced(AppRule appRule, View view) {
// Update DB content
AppRule updated = new AppRule();
updated.setAppName(appRule.getAppName());
updated.setPkgName(appRule.getPkgName());
updated.setAppUID(appRule.getAppUID());
// none
if (!checkboxInternet.isChecked()) {
updated.setOnionType(Constants.DB_ONION_TYPE_NONE);
} else // Anonymity provider
if (radioTor.isChecked()) {
updated.setOnionType(Constants.DB_ONION_TYPE_TOR);
} else if (radioBypass.isChecked()) {
updated.setOnionType(Constants.DB_ONION_TYPE_BYPASS);
}
/*
else
if (radioI2p.isChecked()) {
updated.setOnionType(Constants.DB_ONION_TYPE_I2P);
}
*/
updated.setLocalHost(this.checkLocalHost.isChecked());
updated.setLocalNetwork(this.checkLocalNetwork.isChecked());
boolean done;
// CREATE
if (!appRule.isStored() && !updated.isEmpty()) {
done = natRules.addAppToRules(updated);
if (done) {
updated.install(this.context);
Toast.makeText(context, context.getString(R.string.toast_new_rule), Toast.LENGTH_SHORT).show();
}
} else // UPDATE
if (appRule.isStored() && !updated.isEmpty()) {
done = natRules.update(updated);
if (done) {
appRule.uninstall(this.context);
updated.install(this.context);
Toast.makeText(context, context.getString(R.string.toast_update_rule), Toast.LENGTH_SHORT).show();
}
} else //DELETE
if (appRule.isStored() && updated.isEmpty()) {
done = natRules.removeAppFromRules(updated.getAppUID());
if (done) {
appRule.uninstall(this.context);
Toast.makeText(context, context.getString(R.string.toast_remove_rule), Toast.LENGTH_SHORT).show();
}
} else {
// nothing to do
return;
}
if (done) {
appRule.setOnionType(updated.getOnionType());
appRule.setLocalHost(updated.getLocalHost());
appRule.setLocalNetwork(updated.getLocalNetwork());
if (appRule.isEmpty()) {
appRule.setStored(false);
appRule.setLabel(appRule.getAppName());
} else {
appRule.setStored(true);
appRule.setLabel(appRule.getDisplay());
}
CheckBox checkBox = (CheckBox) view;
checkBox.setText(appRule.getLabel());
checkBox.setChecked(appRule.isStored());
} else {
// error updating database
appRule.setOnionType(Constants.DB_ONION_TYPE_NONE);
Toast.makeText(context, String.format(context.getString(R.string.toast_error), 3), Toast.LENGTH_SHORT).show();
}
}
use of android.widget.CheckBox in project AndroidChromium by JackyAndroid.
the class DataUseTabUIManager method startDataUseDialog.
/**
* Shows a dialog with the option to cancel the navigation or continue. Also allows the user to
* opt out of seeing this dialog again.
*
* @param activity Current activity.
* @param tab The tab loading the url.
* @param url URL that is pending.
* @param pageTransitionType The type of transition. see
* {@link org.chromium.content.browser.PageTransition} for valid values.
* @param referrerUrl URL for the referrer.
*/
private static void startDataUseDialog(final Activity activity, final Tab tab, final String url, final int pageTransitionType, final String referrerUrl) {
View dataUseDialogView = View.inflate(activity, R.layout.data_use_dialog, null);
final TextView textView = (TextView) dataUseDialogView.findViewById(R.id.data_use_message);
textView.setText(getDataUseUIString(DataUseUIMessage.DATA_USE_TRACKING_ENDED_MESSAGE));
final CheckBox checkBox = (CheckBox) dataUseDialogView.findViewById(R.id.data_use_checkbox);
checkBox.setText(getDataUseUIString(DataUseUIMessage.DATA_USE_TRACKING_ENDED_CHECKBOX_MESSAGE));
View learnMore = dataUseDialogView.findViewById(R.id.learn_more);
learnMore.setOnClickListener(new android.view.View.OnClickListener() {
@Override
public void onClick(View v) {
EmbedContentViewActivity.show(activity, getDataUseUIString(DataUseUIMessage.DATA_USE_LEARN_MORE_TITLE), getDataUseUIString(DataUseUIMessage.DATA_USE_LEARN_MORE_LINK_URL));
recordDataUseUIAction(DataUsageUIAction.DIALOG_LEARN_MORE_CLICKED);
}
});
new AlertDialog.Builder(activity, R.style.AlertDialogTheme).setTitle(getDataUseUIString(DataUseUIMessage.DATA_USE_TRACKING_ENDED_TITLE)).setView(dataUseDialogView).setPositiveButton(getDataUseUIString(DataUseUIMessage.DATA_USE_TRACKING_ENDED_CONTINUE), new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
setOptedOutOfDataUseDialog(activity, checkBox.isChecked());
LoadUrlParams loadUrlParams = new LoadUrlParams(url, pageTransitionType);
if (!TextUtils.isEmpty(referrerUrl)) {
Referrer referrer = new Referrer(referrerUrl, Referrer.REFERRER_POLICY_ALWAYS);
loadUrlParams.setReferrer(referrer);
}
tab.loadUrl(loadUrlParams);
recordDataUseUIAction(DataUsageUIAction.DIALOG_CONTINUE_CLICKED);
userClickedContinueOnDialogBox(tab);
}
}).setNegativeButton(R.string.cancel, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
setOptedOutOfDataUseDialog(activity, checkBox.isChecked());
recordDataUseUIAction(DataUsageUIAction.DIALOG_CANCEL_CLICKED);
}
}).show();
recordDataUseUIAction(DataUsageUIAction.DIALOG_SHOWN);
}
use of android.widget.CheckBox in project wifikeyboard by IvanVolosyuk.
the class WidgetConfigure method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
Bundle extras = intent.getExtras();
if (extras != null) {
mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
}
setContentView(R.layout.configure);
final EditText editText = (EditText) findViewById(R.id.text);
final CheckBox enabled = (CheckBox) findViewById(R.id.enabled);
Button ok = (Button) findViewById(R.id.ok);
Button cancel = (Button) findViewById(R.id.cancel);
ok.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
SharedPreferences prefs = getSharedPreferences(PREFS_WIDGETS, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean(textEnableProperty(mAppWidgetId), enabled.isChecked());
editor.putString(textStringProperty(mAppWidgetId), editText.getText().toString());
editor.commit();
WidgetProvider.log(WidgetConfigure.this, "Widget " + mAppWidgetId + " configured");
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(WidgetConfigure.this);
updateWidget(WidgetConfigure.this, appWidgetManager, mAppWidgetId);
Intent resultValue = new Intent();
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
setResult(RESULT_OK, resultValue);
finish();
}
});
cancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
enabled.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
editText.setEnabled(isChecked);
}
});
Intent resultValue = new Intent();
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
setResult(RESULT_CANCELED, resultValue);
}
use of android.widget.CheckBox in project AntennaPod by AntennaPod.
the class AutoFlattrPreferenceDialog method newAutoFlattrPreferenceDialog.
public static void newAutoFlattrPreferenceDialog(final Activity activity, final AutoFlattrPreferenceDialogInterface callback) {
Validate.notNull(activity);
Validate.notNull(callback);
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
@SuppressLint("InflateParams") View view = activity.getLayoutInflater().inflate(R.layout.autoflattr_preference_dialog, null);
final CheckBox chkAutoFlattr = (CheckBox) view.findViewById(R.id.chkAutoFlattr);
final SeekBar skbPercent = (SeekBar) view.findViewById(R.id.skbPercent);
final TextView txtvStatus = (TextView) view.findViewById(R.id.txtvStatus);
chkAutoFlattr.setChecked(UserPreferences.isAutoFlattr());
skbPercent.setEnabled(chkAutoFlattr.isChecked());
txtvStatus.setEnabled(chkAutoFlattr.isChecked());
final int initialValue = (int) (UserPreferences.getAutoFlattrPlayedDurationThreshold() * 100.0f);
setStatusMsgText(activity, txtvStatus, initialValue);
skbPercent.setProgress(initialValue);
chkAutoFlattr.setOnClickListener(v -> {
skbPercent.setEnabled(chkAutoFlattr.isChecked());
txtvStatus.setEnabled(chkAutoFlattr.isChecked());
});
skbPercent.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
setStatusMsgText(activity, txtvStatus, progress);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
builder.setTitle(R.string.pref_auto_flattr_title).setView(view).setPositiveButton(R.string.confirm_label, (dialog, which) -> {
float progDouble = ((float) skbPercent.getProgress()) / 100.0f;
callback.onConfirmed(chkAutoFlattr.isChecked(), progDouble);
dialog.dismiss();
}).setNegativeButton(R.string.cancel_label, (dialog, which) -> {
callback.onCancelled();
dialog.dismiss();
}).setCancelable(false).show();
}
use of android.widget.CheckBox in project android_frameworks_base by DirtyUnicorns.
the class VectorDrawable01 method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GridLayout container = new GridLayout(this);
container.setColumnCount(5);
container.setBackgroundColor(0xFF888888);
final Button[] bArray = new Button[icon.length];
CheckBox toggle = new CheckBox(this);
toggle.setText("Toggle");
toggle.setChecked(true);
toggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
ViewGroup vg = (ViewGroup) buttonView.getParent();
for (int i = 0, count = vg.getChildCount(); i < count; i++) {
View child = vg.getChildAt(i);
if (child != buttonView) {
child.setEnabled(isChecked);
}
}
}
});
container.addView(toggle);
for (int i = 0; i < icon.length; i++) {
Button button = new Button(this);
bArray[i] = button;
button.setWidth(200);
button.setBackgroundResource(icon[i]);
container.addView(button);
VectorDrawable vd = (VectorDrawable) button.getBackground();
vd.setAlpha((i + 1) * (0xFF / (icon.length + 1)));
}
setContentView(container);
}
Aggregations