Search in sources :

Example 11 with CheckBox

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

the class ActivityShare method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Check privacy service client
    if (!PrivacyService.checkClient())
        return;
    // Get data
    int userId = Util.getUserId(Process.myUid());
    final Bundle extras = getIntent().getExtras();
    final String action = getIntent().getAction();
    final int[] uids = (extras != null && extras.containsKey(cUidList) ? extras.getIntArray(cUidList) : new int[0]);
    final String restrictionName = (extras != null ? extras.getString(cRestriction) : null);
    int choice = (extras != null && extras.containsKey(cChoice) ? extras.getInt(cChoice) : -1);
    if (action.equals(ACTION_EXPORT))
        mFileName = (extras != null && extras.containsKey(cFileName) ? extras.getString(cFileName) : null);
    // License check
    if (action.equals(ACTION_IMPORT) || action.equals(ACTION_EXPORT)) {
        if (!Util.isProEnabled() && Util.hasProLicense(this) == null) {
            Util.viewUri(this, ActivityMain.cProUri);
            finish();
            return;
        }
    } else if (action.equals(ACTION_FETCH) || (action.equals(ACTION_TOGGLE) && uids.length > 1)) {
        if (Util.hasProLicense(this) == null) {
            Util.viewUri(this, ActivityMain.cProUri);
            finish();
            return;
        }
    }
    // Registration check
    if (action.equals(ACTION_SUBMIT) && !registerDevice(this)) {
        finish();
        return;
    }
    // Check whether we need a user interface
    if (extras != null && extras.containsKey(cInteractive) && extras.getBoolean(cInteractive, false))
        mInteractive = true;
    // Set layout
    setContentView(R.layout.sharelist);
    setSupportActionBar((Toolbar) findViewById(R.id.widgetToolbar));
    // Reference controls
    final TextView tvDescription = (TextView) findViewById(R.id.tvDescription);
    final ScrollView svToggle = (ScrollView) findViewById(R.id.svToggle);
    final RadioGroup rgToggle = (RadioGroup) findViewById(R.id.rgToggle);
    final Spinner spRestriction = (Spinner) findViewById(R.id.spRestriction);
    RadioButton rbClear = (RadioButton) findViewById(R.id.rbClear);
    RadioButton rbTemplateFull = (RadioButton) findViewById(R.id.rbTemplateFull);
    RadioButton rbODEnable = (RadioButton) findViewById(R.id.rbEnableOndemand);
    RadioButton rbODDisable = (RadioButton) findViewById(R.id.rbDisableOndemand);
    final Spinner spTemplate = (Spinner) findViewById(R.id.spTemplate);
    final CheckBox cbClear = (CheckBox) findViewById(R.id.cbClear);
    final Button btnOk = (Button) findViewById(R.id.btnOk);
    final Button btnCancel = (Button) findViewById(R.id.btnCancel);
    // Set title
    if (action.equals(ACTION_TOGGLE)) {
        mActionId = R.string.menu_toggle;
        getSupportActionBar().setSubtitle(R.string.menu_toggle);
    } else if (action.equals(ACTION_IMPORT)) {
        mActionId = R.string.menu_import;
        getSupportActionBar().setSubtitle(R.string.menu_import);
    } else if (action.equals(ACTION_EXPORT)) {
        mActionId = R.string.menu_export;
        getSupportActionBar().setSubtitle(R.string.menu_export);
    } else if (action.equals(ACTION_FETCH)) {
        mActionId = R.string.menu_fetch;
        getSupportActionBar().setSubtitle(R.string.menu_fetch);
    } else if (action.equals(ACTION_SUBMIT)) {
        mActionId = R.string.menu_submit;
        getSupportActionBar().setSubtitle(R.string.menu_submit);
    } else {
        finish();
        return;
    }
    // Get localized restriction name
    List<String> listRestrictionName = new ArrayList<String>(PrivacyManager.getRestrictions(this).navigableKeySet());
    listRestrictionName.add(0, getString(R.string.menu_all));
    // Build restriction adapter
    SpinnerAdapter saRestriction = new SpinnerAdapter(this, android.R.layout.simple_spinner_item);
    saRestriction.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    saRestriction.addAll(listRestrictionName);
    // Setup restriction spinner
    int pos = 0;
    if (restrictionName != null)
        for (String restriction : PrivacyManager.getRestrictions(this).values()) {
            pos++;
            if (restrictionName.equals(restriction))
                break;
        }
    spRestriction.setAdapter(saRestriction);
    spRestriction.setSelection(pos);
    // Build template adapter
    SpinnerAdapter spAdapter = new SpinnerAdapter(this, android.R.layout.simple_spinner_item);
    spAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    String defaultName = PrivacyManager.getSetting(userId, Meta.cTypeTemplateName, "0", getString(R.string.title_default));
    spAdapter.add(defaultName);
    for (int i = 1; i <= 4; i++) {
        String alternateName = PrivacyManager.getSetting(userId, Meta.cTypeTemplateName, Integer.toString(i), getString(R.string.title_alternate) + " " + i);
        spAdapter.add(alternateName);
    }
    spTemplate.setAdapter(spAdapter);
    // Build application list
    AppListTask appListTask = new AppListTask();
    appListTask.executeOnExecutor(mExecutor, uids);
    // Import/export filename
    if (action.equals(ACTION_EXPORT) || action.equals(ACTION_IMPORT)) {
        // Check for availability of sharing intent
        Intent file = new Intent(Intent.ACTION_GET_CONTENT);
        file.setType("file/*");
        boolean hasIntent = Util.isIntentAvailable(ActivityShare.this, file);
        // Get file name
        if (mFileName == null)
            if (action.equals(ACTION_EXPORT)) {
                String packageName = null;
                if (uids.length == 1)
                    try {
                        ApplicationInfoEx appInfo = new ApplicationInfoEx(this, uids[0]);
                        packageName = appInfo.getPackageName().get(0);
                    } catch (Throwable ex) {
                        Util.bug(null, ex);
                    }
                mFileName = getFileName(this, hasIntent, packageName);
            } else
                mFileName = (hasIntent ? null : getFileName(this, false, null));
        if (mFileName == null)
            fileChooser();
        else
            showFileName();
        if (action.equals(ACTION_IMPORT))
            cbClear.setVisibility(View.VISIBLE);
    } else if (action.equals(ACTION_FETCH)) {
        tvDescription.setText(getBaseURL());
        cbClear.setVisibility(View.VISIBLE);
    } else if (action.equals(ACTION_TOGGLE)) {
        tvDescription.setVisibility(View.GONE);
        spRestriction.setVisibility(View.VISIBLE);
        svToggle.setVisibility(View.VISIBLE);
        // Listen for radio button
        rgToggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                btnOk.setEnabled(checkedId >= 0);
                spRestriction.setVisibility(checkedId == R.id.rbEnableOndemand || checkedId == R.id.rbDisableOndemand ? View.GONE : View.VISIBLE);
                spTemplate.setVisibility(checkedId == R.id.rbTemplateCategory || checkedId == R.id.rbTemplateFull || checkedId == R.id.rbTemplateMergeSet || checkedId == R.id.rbTemplateMergeReset ? View.VISIBLE : View.GONE);
            }
        });
        boolean ondemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true);
        rbODEnable.setVisibility(ondemand ? View.VISIBLE : View.GONE);
        rbODDisable.setVisibility(ondemand ? View.VISIBLE : View.GONE);
        if (choice == CHOICE_CLEAR)
            rbClear.setChecked(true);
        else if (choice == CHOICE_TEMPLATE)
            rbTemplateFull.setChecked(true);
    } else
        tvDescription.setText(getBaseURL());
    if (mInteractive) {
        // (showFileName does this for export/import)
        if (action.equals(ACTION_SUBMIT) || action.equals(ACTION_FETCH))
            btnOk.setEnabled(true);
        // Listen for ok
        btnOk.setOnClickListener(new Button.OnClickListener() {

            @Override
            public void onClick(View v) {
                btnOk.setEnabled(false);
                // Toggle
                if (action.equals(ACTION_TOGGLE)) {
                    mRunning = true;
                    for (int i = 0; i < rgToggle.getChildCount(); i++) ((RadioButton) rgToggle.getChildAt(i)).setEnabled(false);
                    int pos = spRestriction.getSelectedItemPosition();
                    String restrictionName = (pos == 0 ? null : (String) PrivacyManager.getRestrictions(ActivityShare.this).values().toArray()[pos - 1]);
                    new ToggleTask().executeOnExecutor(mExecutor, restrictionName);
                // Import
                } else if (action.equals(ACTION_IMPORT)) {
                    mRunning = true;
                    cbClear.setEnabled(false);
                    new ImportTask().executeOnExecutor(mExecutor, new File(mFileName), cbClear.isChecked());
                } else // Export
                if (action.equals(ACTION_EXPORT)) {
                    mRunning = true;
                    new ExportTask().executeOnExecutor(mExecutor, new File(mFileName));
                // Fetch
                } else if (action.equals(ACTION_FETCH)) {
                    if (uids.length > 0) {
                        mRunning = true;
                        cbClear.setEnabled(false);
                        new FetchTask().executeOnExecutor(mExecutor, cbClear.isChecked());
                    }
                } else // Submit
                if (action.equals(ACTION_SUBMIT)) {
                    if (uids.length > 0) {
                        if (uids.length <= cSubmitLimit) {
                            mRunning = true;
                            new SubmitTask().executeOnExecutor(mExecutor);
                        } else {
                            String message = getString(R.string.msg_limit, cSubmitLimit + 1);
                            Toast.makeText(ActivityShare.this, message, Toast.LENGTH_LONG).show();
                            btnOk.setEnabled(false);
                        }
                    }
                }
            }
        });
    } else
        btnOk.setEnabled(false);
    // Listen for cancel
    btnCancel.setOnClickListener(new Button.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mRunning) {
                mAbort = true;
                Toast.makeText(ActivityShare.this, getString(R.string.msg_abort), Toast.LENGTH_LONG).show();
            } else
                finish();
        }
    });
}
Also used : RadioGroup(android.widget.RadioGroup) Spinner(android.widget.Spinner) ArrayList(java.util.ArrayList) RadioButton(android.widget.RadioButton) Button(android.widget.Button) TextView(android.widget.TextView) OnCheckedChangeListener(android.widget.RadioGroup.OnCheckedChangeListener) Bundle(android.os.Bundle) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) RadioButton(android.widget.RadioButton) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) ScrollView(android.widget.ScrollView) SuppressLint(android.annotation.SuppressLint) ScrollView(android.widget.ScrollView) CheckBox(android.widget.CheckBox) File(java.io.File)

Example 12 with CheckBox

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

the class ActivityMain method optionSort.

@SuppressLint("InflateParams")
private void optionSort() {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.sort, null);
    final RadioGroup rgSMode = (RadioGroup) view.findViewById(R.id.rgSMode);
    final CheckBox cbSInvert = (CheckBox) view.findViewById(R.id.cbSInvert);
    // Initialise controls
    switch(mSortMode) {
        case SORT_BY_NAME:
            rgSMode.check(R.id.rbSName);
            break;
        case SORT_BY_UID:
            rgSMode.check(R.id.rbSUid);
            break;
        case SORT_BY_INSTALL_TIME:
            rgSMode.check(R.id.rbSInstalled);
            break;
        case SORT_BY_UPDATE_TIME:
            rgSMode.check(R.id.rbSUpdated);
            break;
        case SORT_BY_MODIFY_TIME:
            rgSMode.check(R.id.rbSModified);
            break;
        case SORT_BY_STATE:
            rgSMode.check(R.id.rbSState);
            break;
    }
    cbSInvert.setChecked(mSortInvert);
    // Build dialog
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityMain.this);
    alertDialogBuilder.setTitle(R.string.menu_sort);
    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) {
            switch(rgSMode.getCheckedRadioButtonId()) {
                case R.id.rbSName:
                    mSortMode = SORT_BY_NAME;
                    break;
                case R.id.rbSUid:
                    mSortMode = SORT_BY_UID;
                    break;
                case R.id.rbSInstalled:
                    mSortMode = SORT_BY_INSTALL_TIME;
                    break;
                case R.id.rbSUpdated:
                    mSortMode = SORT_BY_UPDATE_TIME;
                    break;
                case R.id.rbSModified:
                    mSortMode = SORT_BY_MODIFY_TIME;
                    break;
                case R.id.rbSState:
                    mSortMode = SORT_BY_STATE;
                    break;
            }
            mSortInvert = cbSInvert.isChecked();
            int userId = Util.getUserId(Process.myUid());
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingSortMode, Integer.toString(mSortMode));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingSortInverted, Boolean.toString(mSortInvert));
            applySort();
        }
    });
    alertDialogBuilder.setNegativeButton(ActivityMain.this.getString(android.R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
        // Do nothing
        }
    });
    // Show dialog
    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) RadioGroup(android.widget.RadioGroup) DialogInterface(android.content.DialogInterface) CheckBox(android.widget.CheckBox) LayoutInflater(android.view.LayoutInflater) 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) SuppressLint(android.annotation.SuppressLint)

Example 13 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 14 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 15 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)

Aggregations

CheckBox (android.widget.CheckBox)183 View (android.view.View)92 TextView (android.widget.TextView)69 CompoundButton (android.widget.CompoundButton)46 Button (android.widget.Button)43 ImageView (android.widget.ImageView)29 Intent (android.content.Intent)28 EditText (android.widget.EditText)27 AdapterView (android.widget.AdapterView)25 ListView (android.widget.ListView)20 LayoutInflater (android.view.LayoutInflater)19 DialogInterface (android.content.DialogInterface)16 RadioButton (android.widget.RadioButton)16 SuppressLint (android.annotation.SuppressLint)14 RemoteException (android.os.RemoteException)13 AlertDialog (android.app.AlertDialog)12 Paint (android.graphics.Paint)12 GridLayout (android.widget.GridLayout)12 Bundle (android.os.Bundle)11 ViewGroup (android.view.ViewGroup)11