Search in sources :

Example 46 with CheckBox

use of android.widget.CheckBox in project XPrivacy by M66B.

the class ActivitySettings method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.settings);
    setSupportActionBar((Toolbar) findViewById(R.id.widgetToolbar));
    setTitle(R.string.menu_settings);
    userId = Util.getUserId(Process.myUid());
    final Bundle extras = getIntent().getExtras();
    if (extras != null && extras.containsKey(cUid))
        uid = extras.getInt(cUid);
    else
        uid = userId;
    // Reference controls
    TextView tvInfo = (TextView) findViewById(R.id.tvInfo);
    cbNotify = (CheckBox) findViewById(R.id.cbNotify);
    cbOnDemand = (CheckBox) findViewById(R.id.cbOnDemand);
    cbBlacklist = (CheckBox) findViewById(R.id.cbBlacklist);
    cbUsage = (CheckBox) findViewById(R.id.cbUsage);
    cbParameters = (CheckBox) findViewById(R.id.cbParameters);
    cbValues = (CheckBox) findViewById(R.id.cbValues);
    cbLog = (CheckBox) findViewById(R.id.cbLog);
    CheckBox cbExpert = (CheckBox) findViewById(R.id.cbExpert);
    cbSystem = (CheckBox) findViewById(R.id.cbSystem);
    cbExperimental = (CheckBox) findViewById(R.id.cbExperimental);
    cbHttps = (CheckBox) findViewById(R.id.cbHttps);
    cbAOSP = (CheckBox) findViewById(R.id.cbAOSP);
    LinearLayout llConfidence = (LinearLayout) findViewById(R.id.llConfidence);
    etConfidence = (EditText) findViewById(R.id.etConfidence);
    etQuirks = (EditText) findViewById(R.id.etQuirks);
    btnFlush = (Button) findViewById(R.id.btnFlush);
    btnClearDb = (Button) findViewById(R.id.btnClearDb);
    cbRandom = (CheckBox) findViewById(R.id.cbRandom);
    Button btnRandom = (Button) findViewById(R.id.btnRandom);
    Button btnClear = (Button) findViewById(R.id.btnClear);
    etSerial = (EditText) findViewById(R.id.etSerial);
    etLat = (EditText) findViewById(R.id.etLat);
    etLon = (EditText) findViewById(R.id.etLon);
    etAlt = (EditText) findViewById(R.id.etAlt);
    etSearch = (EditText) findViewById(R.id.etSearch);
    Button btnSearch = (Button) findViewById(R.id.btnSearch);
    etMac = (EditText) findViewById(R.id.etMac);
    etIP = (EditText) findViewById(R.id.etIP);
    etImei = (EditText) findViewById(R.id.etImei);
    etPhone = (EditText) findViewById(R.id.etPhone);
    etId = (EditText) findViewById(R.id.etId);
    etGsfId = (EditText) findViewById(R.id.etGsfId);
    etAdId = (EditText) findViewById(R.id.etAdId);
    etMcc = (EditText) findViewById(R.id.etMcc);
    etMnc = (EditText) findViewById(R.id.etMnc);
    etCountry = (EditText) findViewById(R.id.etCountry);
    etOperator = (EditText) findViewById(R.id.etOperator);
    etIccId = (EditText) findViewById(R.id.etIccId);
    etCid = (EditText) findViewById(R.id.etCid);
    etLac = (EditText) findViewById(R.id.etLac);
    etSubscriber = (EditText) findViewById(R.id.etSubscriber);
    etSSID = (EditText) findViewById(R.id.etSSID);
    etUa = (EditText) findViewById(R.id.etUa);
    cbSerial = (CheckBox) findViewById(R.id.cbSerial);
    cbLat = (CheckBox) findViewById(R.id.cbLat);
    cbLon = (CheckBox) findViewById(R.id.cbLon);
    cbAlt = (CheckBox) findViewById(R.id.cbAlt);
    cbMac = (CheckBox) findViewById(R.id.cbMac);
    cbImei = (CheckBox) findViewById(R.id.cbImei);
    cbPhone = (CheckBox) findViewById(R.id.cbPhone);
    cbId = (CheckBox) findViewById(R.id.cbId);
    cbGsfId = (CheckBox) findViewById(R.id.cbGsfId);
    cbAdId = (CheckBox) findViewById(R.id.cbAdId);
    cbCountry = (CheckBox) findViewById(R.id.cbCountry);
    cbSubscriber = (CheckBox) findViewById(R.id.cbSubscriber);
    cbSSID = (CheckBox) findViewById(R.id.cbSSID);
    // Listen for changes
    cbParameters.setOnCheckedChangeListener(this);
    cbValues.setOnCheckedChangeListener(this);
    cbExpert.setOnCheckedChangeListener(this);
    cbSerial.setOnCheckedChangeListener(this);
    cbLat.setOnCheckedChangeListener(this);
    cbLon.setOnCheckedChangeListener(this);
    cbAlt.setOnCheckedChangeListener(this);
    cbMac.setOnCheckedChangeListener(this);
    cbImei.setOnCheckedChangeListener(this);
    cbPhone.setOnCheckedChangeListener(this);
    cbId.setOnCheckedChangeListener(this);
    cbGsfId.setOnCheckedChangeListener(this);
    cbAdId.setOnCheckedChangeListener(this);
    cbCountry.setOnCheckedChangeListener(this);
    cbSubscriber.setOnCheckedChangeListener(this);
    cbSSID.setOnCheckedChangeListener(this);
    // Get current values
    boolean usage = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingUsage, true);
    boolean parameters = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingParameters, false);
    boolean values = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingValues, false);
    boolean log = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingLog, false);
    boolean components = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingSystem, false);
    boolean experimental = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingExperimental, false);
    boolean https = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingHttps, true);
    boolean aosp = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingAOSPMode, false);
    String confidence = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingConfidence, "");
    // Get quirks
    boolean freeze = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingFreeze, false);
    boolean resolve = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingResolve, false);
    boolean noresolve = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingNoResolve, false);
    boolean permman = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingPermMan, false);
    boolean iwall = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingIntentWall, false);
    boolean safemode = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingSafeMode, false);
    boolean test = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingTestVersions, false);
    boolean updates = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingUpdates, false);
    boolean odsystem = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingOnDemandSystem, false);
    boolean wnomod = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingWhitelistNoModify, false);
    boolean nousage = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingNoUsageData, false);
    List<String> listQuirks = new ArrayList<String>();
    if (freeze)
        listQuirks.add("freeze");
    if (resolve)
        listQuirks.add("resolve");
    if (noresolve)
        listQuirks.add("noresolve");
    if (permman)
        listQuirks.add("permman");
    if (iwall)
        listQuirks.add("iwall");
    if (safemode)
        listQuirks.add("safemode");
    if (test)
        listQuirks.add("test");
    if (updates)
        listQuirks.add("updates");
    if (odsystem)
        listQuirks.add("odsystem");
    if (wnomod)
        listQuirks.add("wnomod");
    if (nousage)
        listQuirks.add("nousage");
    Collections.sort(listQuirks);
    String quirks = TextUtils.join(",", listQuirks.toArray());
    expert = (components || experimental || !https || aosp || !"".equals(confidence) || listQuirks.size() > 0);
    // Application specific
    boolean notify = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingNotify, true);
    boolean ondemand = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingOnDemand, uid == userId);
    boolean blacklist = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingBlacklist, false);
    boolean enabled = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingRestricted, true);
    // Common
    boolean random = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingRandom, false);
    String serial = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingSerial, "");
    String lat = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingLatitude, "");
    String lon = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingLongitude, "");
    String alt = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingAltitude, "");
    String mac = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingMac, "");
    String imei = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingImei, "");
    String phone = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingPhone, "");
    String id = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingId, "");
    String gsfid = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingGsfId, "");
    String adid = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingAdId, "");
    String country = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingCountry, "");
    String subscriber = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingSubscriber, "");
    String ssid = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingSSID, "");
    // Set current values
    if (uid == userId) {
        // Global settings
        tvInfo.setVisibility(View.GONE);
        cbUsage.setChecked(usage);
        cbParameters.setChecked(parameters);
        cbValues.setChecked(values);
        if (userId == 0)
            cbLog.setChecked(log);
        else {
            cbLog.setVisibility(View.GONE);
            btnFlush.setVisibility(View.GONE);
            btnClearDb.setVisibility(View.GONE);
        }
        cbExpert.setChecked(expert);
        if (PrivacyManager.cVersion3 && (!Util.isSELinuxEnforced() || "true".equals(Util.getXOption("ignoreselinux"))))
            cbAOSP.setVisibility(View.VISIBLE);
        if (expert) {
            cbSystem.setChecked(components);
            cbExperimental.setChecked(experimental);
            cbHttps.setChecked(https);
            cbAOSP.setChecked(aosp);
            etConfidence.setText(confidence);
            etQuirks.setText(quirks);
        } else {
            cbSystem.setEnabled(false);
            cbExperimental.setEnabled(false);
            cbHttps.setEnabled(false);
            cbHttps.setChecked(true);
            cbAOSP.setEnabled(false);
            cbAOSP.setChecked(false);
            etConfidence.setEnabled(false);
            etQuirks.setEnabled(false);
            btnFlush.setEnabled(false);
            btnClearDb.setEnabled(false);
        }
    } else {
        // Display application names
        ApplicationInfoEx appInfo = new ApplicationInfoEx(this, uid);
        getSupportActionBar().setSubtitle(TextUtils.join(",  ", appInfo.getApplicationName()));
        // Disable global settings
        cbUsage.setVisibility(View.GONE);
        cbParameters.setVisibility(View.GONE);
        cbValues.setVisibility(View.GONE);
        cbLog.setVisibility(View.GONE);
        cbSystem.setVisibility(View.GONE);
        cbExperimental.setVisibility(View.GONE);
        cbHttps.setVisibility(View.GONE);
        cbAOSP.setVisibility(View.GONE);
        llConfidence.setVisibility(View.GONE);
        btnFlush.setVisibility(View.GONE);
        btnClearDb.setVisibility(View.GONE);
        cbExpert.setChecked(expert);
        if (expert)
            etQuirks.setText(quirks);
        else
            etQuirks.setEnabled(false);
    }
    boolean gnotify = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingNotify, true);
    if (uid == userId || gnotify)
        cbNotify.setChecked(notify);
    else
        cbNotify.setVisibility(View.GONE);
    isApp = PrivacyManager.isApplication(uid);
    odSystem = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemandSystem, false);
    boolean gondemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true);
    if (uid == userId || ((isApp || odSystem) && gondemand)) {
        cbOnDemand.setChecked(ondemand);
        cbOnDemand.setEnabled(enabled);
    } else
        cbOnDemand.setVisibility(View.GONE);
    String blFileName = Environment.getExternalStorageDirectory().getPath() + "/.xprivacy/blacklist";
    if (uid == userId || !new File(blFileName).exists())
        cbBlacklist.setVisibility(View.GONE);
    else
        cbBlacklist.setChecked(blacklist);
    // Common
    cbRandom.setChecked(random);
    // Set randomize on access check boxes
    cbSerial.setChecked(serial.equals(PrivacyManager.cValueRandom));
    cbLat.setChecked(lat.equals(PrivacyManager.cValueRandom));
    cbLon.setChecked(lon.equals(PrivacyManager.cValueRandom));
    cbAlt.setChecked(alt.equals(PrivacyManager.cValueRandom));
    cbMac.setChecked(mac.equals(PrivacyManager.cValueRandom));
    cbImei.setChecked(imei.equals(PrivacyManager.cValueRandom));
    cbPhone.setChecked(phone.equals(PrivacyManager.cValueRandom));
    cbId.setChecked(id.equals(PrivacyManager.cValueRandom));
    cbGsfId.setChecked(gsfid.equals(PrivacyManager.cValueRandom));
    cbAdId.setChecked(adid.equals(PrivacyManager.cValueRandom));
    cbCountry.setChecked(country.equals(PrivacyManager.cValueRandom));
    cbSubscriber.setChecked(subscriber.equals(PrivacyManager.cValueRandom));
    cbSSID.setChecked(ssid.equals(PrivacyManager.cValueRandom));
    // Set fake values
    etSerial.setText(cbSerial.isChecked() ? "" : serial);
    etLat.setText(cbLat.isChecked() ? "" : lat);
    etLon.setText(cbLon.isChecked() ? "" : lon);
    etAlt.setText(cbAlt.isChecked() ? "" : alt);
    etMac.setText(cbMac.isChecked() ? "" : mac);
    etImei.setText(cbImei.isChecked() ? "" : imei);
    etPhone.setText(cbPhone.isChecked() ? "" : phone);
    etId.setText(cbId.isChecked() ? "" : id);
    etGsfId.setText(cbGsfId.isChecked() ? "" : gsfid);
    etAdId.setText(cbAdId.isChecked() ? "" : adid);
    etCountry.setText(cbCountry.isChecked() ? "" : country);
    etSubscriber.setText(cbSubscriber.isChecked() ? "" : subscriber);
    etSSID.setText(cbSSID.isChecked() ? "" : ssid);
    etSerial.setEnabled(!cbSerial.isChecked());
    etLat.setEnabled(!cbLat.isChecked());
    etLon.setEnabled(!cbLon.isChecked());
    etAlt.setEnabled(!cbAlt.isChecked());
    etSearch.setEnabled(Geocoder.isPresent());
    btnSearch.setEnabled(Geocoder.isPresent());
    etMac.setEnabled(!cbMac.isChecked());
    etImei.setEnabled(!cbImei.isChecked());
    etPhone.setEnabled(!cbPhone.isChecked());
    etId.setEnabled(!cbId.isChecked());
    etGsfId.setEnabled(!cbGsfId.isChecked());
    etAdId.setEnabled(!cbAdId.isChecked());
    etCountry.setEnabled(!cbCountry.isChecked());
    etSubscriber.setEnabled(!cbSubscriber.isChecked());
    etSSID.setEnabled(!cbSSID.isChecked());
    etIP.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingIP, ""));
    etMcc.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingMcc, ""));
    etMnc.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingMnc, ""));
    etOperator.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingOperator, ""));
    etIccId.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingIccId, ""));
    etCid.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingCid, ""));
    etLac.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingLac, ""));
    etUa.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingUa, ""));
    btnFlush.setOnClickListener(this);
    btnClearDb.setOnClickListener(this);
    btnRandom.setOnClickListener(this);
    btnClear.setOnClickListener(this);
    btnSearch.setOnClickListener(this);
}
Also used : Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) Bundle(android.os.Bundle) CheckBox(android.widget.CheckBox) ArrayList(java.util.ArrayList) TextView(android.widget.TextView) File(java.io.File) LinearLayout(android.widget.LinearLayout)

Example 47 with CheckBox

use of android.widget.CheckBox in project XPrivacy by M66B.

the class ActivitySettings method clear.

private void clear() {
    final EditText[] edits = new EditText[] { etSerial, etLat, etLon, etAlt, etMac, etIP, etImei, etPhone, etId, etGsfId, etAdId, etMcc, etMnc, etCountry, etOperator, etIccId, etCid, etLac, etSubscriber, etSSID, etUa };
    final CheckBox[] boxes = new CheckBox[] { cbSerial, cbLat, cbLon, cbAlt, cbMac, cbImei, cbPhone, cbId, cbGsfId, cbAdId, cbCountry, cbSubscriber, cbSSID };
    for (EditText edit : edits) edit.setText("");
    etSearch.setText("");
    for (CheckBox box : boxes) box.setChecked(false);
}
Also used : EditText(android.widget.EditText) CheckBox(android.widget.CheckBox)

Example 48 with CheckBox

use of android.widget.CheckBox in project XPrivacy by M66B.

the class ActivityMain method optionFilter.

@SuppressLint("InflateParams")
private void optionFilter() {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.filters, null);
    final CheckBox cbFUsed = (CheckBox) view.findViewById(R.id.cbFUsed);
    final CheckBox cbFInternet = (CheckBox) view.findViewById(R.id.cbFInternet);
    final CheckBox cbFPermission = (CheckBox) view.findViewById(R.id.cbFPermission);
    final CheckBox cbFRestriction = (CheckBox) view.findViewById(R.id.cbFRestriction);
    final CheckBox cbFRestrictionNot = (CheckBox) view.findViewById(R.id.cbFRestrictionNot);
    final CheckBox cbFOnDemand = (CheckBox) view.findViewById(R.id.cbFOnDemand);
    final CheckBox cbFOnDemandNot = (CheckBox) view.findViewById(R.id.cbFOnDemandNot);
    final CheckBox cbFUser = (CheckBox) view.findViewById(R.id.cbFUser);
    final CheckBox cbFSystem = (CheckBox) view.findViewById(R.id.cbFSystem);
    final Button btnDefault = (Button) view.findViewById(R.id.btnDefault);
    // Get settings
    final int userId = Util.getUserId(Process.myUid());
    boolean fUsed = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFUsed, false);
    boolean fInternet = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFInternet, false);
    boolean fPermission = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFPermission, true);
    boolean fRestriction = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFRestriction, false);
    boolean fRestrictionNot = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFRestrictionNot, false);
    boolean fOnDemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFOnDemand, false);
    boolean fOnDemandNot = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFOnDemandNot, false);
    boolean fUser = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFUser, true);
    boolean fSystem = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFSystem, false);
    boolean ondemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true);
    // Setup checkboxes
    cbFUsed.setChecked(fUsed);
    cbFInternet.setChecked(fInternet);
    cbFPermission.setChecked(fPermission);
    cbFRestriction.setChecked(fRestriction);
    cbFRestrictionNot.setChecked(fRestrictionNot);
    cbFOnDemand.setChecked(fOnDemand && ondemand);
    cbFOnDemandNot.setChecked(fOnDemandNot && ondemand);
    cbFUser.setChecked(fUser);
    cbFSystem.setChecked(fSystem);
    cbFRestrictionNot.setEnabled(fRestriction);
    cbFOnDemand.setEnabled(ondemand);
    cbFOnDemandNot.setEnabled(fOnDemand && ondemand);
    // Manage user/system filter exclusivity
    OnCheckedChangeListener checkListener = new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (buttonView == cbFUser) {
                if (isChecked)
                    cbFSystem.setChecked(false);
            } else if (buttonView == cbFSystem) {
                if (isChecked)
                    cbFUser.setChecked(false);
            } else if (buttonView == cbFRestriction)
                cbFRestrictionNot.setEnabled(cbFRestriction.isChecked());
            else if (buttonView == cbFOnDemand)
                cbFOnDemandNot.setEnabled(cbFOnDemand.isChecked());
        }
    };
    cbFUser.setOnCheckedChangeListener(checkListener);
    cbFSystem.setOnCheckedChangeListener(checkListener);
    cbFRestriction.setOnCheckedChangeListener(checkListener);
    cbFOnDemand.setOnCheckedChangeListener(checkListener);
    // Clear button
    btnDefault.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            cbFUsed.setChecked(false);
            cbFInternet.setChecked(false);
            cbFPermission.setChecked(true);
            cbFRestriction.setChecked(false);
            cbFRestrictionNot.setChecked(false);
            cbFOnDemand.setChecked(false);
            cbFOnDemandNot.setChecked(false);
            cbFUser.setChecked(true);
            cbFSystem.setChecked(false);
        }
    });
    // Build dialog
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityMain.this);
    alertDialogBuilder.setTitle(R.string.menu_filter);
    alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher));
    alertDialogBuilder.setView(view);
    alertDialogBuilder.setPositiveButton(ActivityMain.this.getString(android.R.string.ok), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFUsed, Boolean.toString(cbFUsed.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFInternet, Boolean.toString(cbFInternet.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFRestriction, Boolean.toString(cbFRestriction.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFRestrictionNot, Boolean.toString(cbFRestrictionNot.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFPermission, Boolean.toString(cbFPermission.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFOnDemand, Boolean.toString(cbFOnDemand.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFOnDemandNot, Boolean.toString(cbFOnDemandNot.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFUser, Boolean.toString(cbFUser.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFSystem, Boolean.toString(cbFSystem.isChecked()));
            invalidateOptionsMenu();
            applyFilter();
        }
    });
    alertDialogBuilder.setNegativeButton(ActivityMain.this.getString(android.R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    // Show dialog
    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) DialogInterface(android.content.DialogInterface) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) WebView(android.webkit.WebView) TextView(android.widget.TextView) ListView(android.widget.ListView) SearchView(android.widget.SearchView) ScrollView(android.widget.ScrollView) ExpandableListView(android.widget.ExpandableListView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) CheckBox(android.widget.CheckBox) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.view.View.OnClickListener) CompoundButton(android.widget.CompoundButton) SuppressLint(android.annotation.SuppressLint)

Example 49 with CheckBox

use of android.widget.CheckBox in project FloatingStickies by MohammadAdib.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext());
    boolean key = prefs.getBoolean("key", false);
    if (!key) {
        setContentView(R.layout.tutorial);
        final ImageView iv1 = (ImageView) findViewById(R.id.imageView1);
        final ImageView iv2 = (ImageView) findViewById(R.id.imageView2);
        final ImageView iv3 = (ImageView) findViewById(R.id.imageView3);
        final ImageView iv4 = (ImageView) findViewById(R.id.done);
        final CheckBox cb = (CheckBox) findViewById(R.id.checkBox);
        final Animation anim1 = AnimationUtils.loadAnimation(this, R.anim.show);
        final Animation anim2 = AnimationUtils.loadAnimation(this, R.anim.show);
        final Animation anim3 = AnimationUtils.loadAnimation(this, R.anim.show);
        final Animation anim4 = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
        final Animation anim5 = AnimationUtils.loadAnimation(this, android.R.anim.fade_out);
        final Animation anim6 = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
        anim1.setDuration(500);
        anim2.setDuration(500);
        anim3.setDuration(500);
        anim1.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                iv1.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                iv2.startAnimation(anim2);
            }
        });
        anim2.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                iv2.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                iv3.startAnimation(anim3);
            }
        });
        anim3.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                iv3.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                iv4.startAnimation(anim4);
                iv4.setOnTouchListener(MainActivity.this);
            }
        });
        anim4.setDuration(1000);
        anim4.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                iv4.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                iv4.startAnimation(anim5);
            }
        });
        anim5.setDuration(1000);
        anim5.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                iv4.startAnimation(anim4);
            }
        });
        iv1.startAnimation(anim1);
        cb.startAnimation(anim6);
    } else {
        finish();
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) CheckBox(android.widget.CheckBox) Animation(android.view.animation.Animation) ImageView(android.widget.ImageView) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 50 with CheckBox

use of android.widget.CheckBox in project material-dialogs by afollestad.

the class MaterialDialog method onItemSelected.

@Override
public boolean onItemSelected(MaterialDialog dialog, View view, int position, CharSequence text, boolean longPress) {
    if (!view.isEnabled()) {
        return false;
    }
    if (listType == null || listType == ListType.REGULAR) {
        // Default adapter, non choice mode
        if (builder.autoDismiss) {
            // If auto dismiss is enabled, dismiss the dialog when a list item is selected
            dismiss();
        }
        if (!longPress && builder.listCallback != null) {
            builder.listCallback.onSelection(this, view, position, builder.items.get(position));
        }
        if (longPress && builder.listLongCallback != null) {
            return builder.listLongCallback.onLongSelection(this, view, position, builder.items.get(position));
        }
    } else {
        // Default adapter, choice mode
        if (listType == ListType.MULTI) {
            final CheckBox cb = (CheckBox) view.findViewById(R.id.md_control);
            if (!cb.isEnabled()) {
                return false;
            }
            final boolean shouldBeChecked = !selectedIndicesList.contains(position);
            if (shouldBeChecked) {
                // Add the selection to the states first so the callback includes it (when alwaysCallMultiChoiceCallback)
                selectedIndicesList.add(position);
                if (builder.alwaysCallMultiChoiceCallback) {
                    // If the checkbox wasn't previously selected, and the callback returns true, add it to the states and check it
                    if (sendMultiChoiceCallback()) {
                        cb.setChecked(true);
                    } else {
                        // The callback cancelled selection, remove it from the states
                        selectedIndicesList.remove(Integer.valueOf(position));
                    }
                } else {
                    // The callback was not used to check if selection is allowed, just select it
                    cb.setChecked(true);
                }
            } else {
                // Remove the selection from the states first so the callback does not include it (when alwaysCallMultiChoiceCallback)
                selectedIndicesList.remove(Integer.valueOf(position));
                if (builder.alwaysCallMultiChoiceCallback) {
                    // If the checkbox was previously selected, and the callback returns true, remove it from the states and uncheck it
                    if (sendMultiChoiceCallback()) {
                        cb.setChecked(false);
                    } else {
                        // The callback cancelled unselection, re-add it to the states
                        selectedIndicesList.add(position);
                    }
                } else {
                    // The callback was not used to check if the unselection is allowed, just uncheck it
                    cb.setChecked(false);
                }
            }
        } else if (listType == ListType.SINGLE) {
            final RadioButton radio = (RadioButton) view.findViewById(R.id.md_control);
            if (!radio.isEnabled()) {
                return false;
            }
            boolean allowSelection = true;
            final int oldSelected = builder.selectedIndex;
            if (builder.autoDismiss && builder.positiveText == null) {
                // If auto dismiss is enabled, and no action button is visible to approve the selection, dismiss the dialog
                dismiss();
                // Don't allow the selection to be updated since the dialog is being dismissed anyways
                allowSelection = false;
                // Update selected index and send callback
                builder.selectedIndex = position;
                sendSingleChoiceCallback(view);
            } else if (builder.alwaysCallSingleChoiceCallback) {
                // Temporarily set the new index so the callback uses the right one
                builder.selectedIndex = position;
                // Only allow the radio button to be checked if the callback returns true
                allowSelection = sendSingleChoiceCallback(view);
                // Restore the old selected index, so the state is updated below
                builder.selectedIndex = oldSelected;
            }
            // Update the checked states
            if (allowSelection) {
                builder.selectedIndex = position;
                radio.setChecked(true);
                builder.adapter.notifyItemChanged(oldSelected);
                builder.adapter.notifyItemChanged(position);
            }
        }
    }
    return true;
}
Also used : CheckBox(android.widget.CheckBox) RadioButton(android.widget.RadioButton)

Aggregations

CheckBox (android.widget.CheckBox)197 View (android.view.View)102 TextView (android.widget.TextView)78 CompoundButton (android.widget.CompoundButton)51 Button (android.widget.Button)48 ImageView (android.widget.ImageView)32 Intent (android.content.Intent)30 EditText (android.widget.EditText)30 LayoutInflater (android.view.LayoutInflater)25 AdapterView (android.widget.AdapterView)25 DialogInterface (android.content.DialogInterface)21 ListView (android.widget.ListView)20 SuppressLint (android.annotation.SuppressLint)19 RadioButton (android.widget.RadioButton)19 AlertDialog (android.app.AlertDialog)17 Paint (android.graphics.Paint)14 Bundle (android.os.Bundle)12 ViewGroup (android.view.ViewGroup)12 GridLayout (android.widget.GridLayout)12 LinearLayout (android.widget.LinearLayout)12