Search in sources :

Example 11 with AlertDialog

use of android.app.AlertDialog in project XPrivacy by M66B.

the class Requirements method check.

@SuppressWarnings("unchecked")
public static void check(final ActivityBase context) {
    // Check Android version
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
        alertDialogBuilder.setTitle(R.string.app_name);
        alertDialogBuilder.setMessage(R.string.app_wrongandroid);
        alertDialogBuilder.setIcon(context.getThemed(R.attr.icon_launcher));
        alertDialogBuilder.setPositiveButton(context.getString(android.R.string.ok), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                Intent androidIntent = new Intent(Intent.ACTION_VIEW);
                androidIntent.setData(Uri.parse("https://github.com/M66B/XPrivacy#installation"));
                context.startActivity(androidIntent);
            }
        });
        AlertDialog alertDialog = alertDialogBuilder.create();
        alertDialog.show();
    }
    // Check if XPrivacy is enabled
    if (Util.isXposedEnabled()) {
        // Check privacy client
        try {
            if (PrivacyService.checkClient()) {
                List<String> listError = (List<String>) PrivacyService.getClient().check();
                if (listError.size() > 0)
                    sendSupportInfo(TextUtils.join("\r\n", listError), context);
            }
        } catch (Throwable ex) {
            sendSupportInfo(ex.toString(), context);
        }
    } else {
        // @formatter:off
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
        alertDialogBuilder.setTitle(R.string.app_name);
        alertDialogBuilder.setMessage(R.string.app_notenabled);
        alertDialogBuilder.setIcon(context.getThemed(R.attr.icon_launcher));
        alertDialogBuilder.setPositiveButton(context.getString(android.R.string.ok), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                Intent xInstallerIntent = new Intent("de.robv.android.xposed.installer.OPEN_SECTION").setPackage("de.robv.android.xposed.installer").putExtra("section", "modules").putExtra("module", context.getPackageName()).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(xInstallerIntent);
            }
        });
        // @formatter:on
        AlertDialog alertDialog = alertDialogBuilder.create();
        alertDialog.show();
    }
    // Check pro enabler
    Version version = Util.getProEnablerVersion(context);
    if (version != null && !Util.isValidProEnablerVersion(version)) {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
        alertDialogBuilder.setTitle(R.string.app_name);
        alertDialogBuilder.setMessage(R.string.app_wrongenabler);
        alertDialogBuilder.setIcon(context.getThemed(R.attr.icon_launcher));
        alertDialogBuilder.setPositiveButton(context.getString(android.R.string.ok), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                Intent storeIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName() + ".pro"));
                context.startActivity(storeIntent);
            }
        });
        AlertDialog alertDialog = alertDialogBuilder.create();
        alertDialog.show();
    }
    // Check incompatible apps
    checkCompatibility(context);
    // Check activity thread
    try {
        Class<?> clazz = Class.forName("android.app.ActivityThread", false, null);
        try {
            clazz.getDeclaredMethod("unscheduleGcIdler");
        } catch (NoSuchMethodException ex) {
            reportClass(clazz, context);
        }
    } catch (ClassNotFoundException ex) {
        sendSupportInfo(ex.toString(), context);
    }
    // Check activity thread receiver data
    try {
        Class<?> clazz = Class.forName("android.app.ActivityThread$ReceiverData", false, null);
        if (!checkField(clazz, "intent"))
            reportClass(clazz, context);
    } catch (ClassNotFoundException ex) {
        try {
            reportClass(Class.forName("android.app.ActivityThread", false, null), context);
        } catch (ClassNotFoundException exex) {
            sendSupportInfo(exex.toString(), context);
        }
    }
    // Check file utils
    try {
        Class<?> clazz = Class.forName("android.os.FileUtils", false, null);
        try {
            clazz.getDeclaredMethod("setPermissions", String.class, int.class, int.class, int.class);
        } catch (NoSuchMethodException ex) {
            reportClass(clazz, context);
        }
    } catch (ClassNotFoundException ex) {
        sendSupportInfo(ex.toString(), context);
    }
    // Check interface address
    if (!checkField(InterfaceAddress.class, "address") || !checkField(InterfaceAddress.class, "broadcastAddress") || (PrivacyService.getClient() != null && PrivacyManager.getDefacedProp(0, "InetAddress") == null))
        reportClass(InterfaceAddress.class, context);
    // Check package manager service
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
        try {
            Class<?> clazz = Class.forName("com.android.server.pm.PackageManagerService", false, null);
            try {
                try {
                    clazz.getDeclaredMethod("getPackageUid", String.class, int.class);
                } catch (NoSuchMethodException ignored) {
                    clazz.getDeclaredMethod("getPackageUid", String.class);
                }
            } catch (NoSuchMethodException ex) {
                reportClass(clazz, context);
            }
        } catch (ClassNotFoundException ex) {
            sendSupportInfo(ex.toString(), context);
        }
    // Check GPS status
    if (!checkField(GpsStatus.class, "mSatellites"))
        reportClass(GpsStatus.class, context);
    // Check service manager
    try {
        Class<?> clazz = Class.forName("android.os.ServiceManager", false, null);
        try {
            // @formatter:off
            // public static void addService(String name, IBinder service)
            // public static void addService(String name, IBinder service, boolean allowIsolated)
            // public static String[] listServices()
            // public static IBinder checkService(String name)
            // @formatter:on
            Method listServices = clazz.getDeclaredMethod("listServices");
            Method getService = clazz.getDeclaredMethod("getService", String.class);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
                clazz.getDeclaredMethod("addService", String.class, IBinder.class, boolean.class);
            else
                clazz.getDeclaredMethod("addService", String.class, IBinder.class);
            // Get services
            Map<String, String> mapService = new HashMap<String, String>();
            String[] services = (String[]) listServices.invoke(null);
            if (services != null)
                for (String service : services) if (service != null) {
                    IBinder binder = (IBinder) getService.invoke(null, service);
                    String descriptor = (binder == null ? null : binder.getInterfaceDescriptor());
                    mapService.put(service, descriptor);
                }
            if (mapService.size() > 0) {
                // Check services
                int i = 0;
                List<String> listMissing = new ArrayList<String>();
                for (String name : XBinder.cServiceName) {
                    String descriptor = XBinder.cServiceDescriptor.get(i++);
                    if (descriptor != null && !XBinder.cServiceOptional.contains(name)) {
                        // Check name
                        boolean checkDescriptor = false;
                        if (name.equals("telephony.registry")) {
                            if (mapService.containsKey(name))
                                checkDescriptor = true;
                            else if (!mapService.containsKey("telephony.msim.registry"))
                                listMissing.add(name);
                        } else if (name.equals("telephony.msim.registry")) {
                            if (mapService.containsKey(name))
                                checkDescriptor = true;
                            else if (!mapService.containsKey("telephony.registry"))
                                listMissing.add(name);
                        } else if (name.equals("bluetooth")) {
                            if (mapService.containsKey(name))
                                checkDescriptor = true;
                            else if (!mapService.containsKey("bluetooth_manager"))
                                listMissing.add(name);
                        } else if (name.equals("bluetooth_manager")) {
                            if (mapService.containsKey(name))
                                checkDescriptor = true;
                            else if (!mapService.containsKey("bluetooth"))
                                listMissing.add(name);
                        } else {
                            if (mapService.containsKey(name))
                                checkDescriptor = true;
                            else
                                listMissing.add(name);
                        }
                        // Check descriptor
                        if (checkDescriptor) {
                            String d = mapService.get(name);
                            if (d != null && !d.equals(descriptor))
                                listMissing.add(descriptor);
                        }
                    }
                }
                // Check result
                if (listMissing.size() > 0) {
                    List<String> listService = new ArrayList<String>();
                    for (String service : mapService.keySet()) listService.add(String.format("%s: %s", service, mapService.get(service)));
                    sendSupportInfo("Missing:\r\n" + TextUtils.join("\r\n", listMissing) + "\r\n\r\nAvailable:\r\n" + TextUtils.join("\r\n", listService), context);
                }
            }
        } catch (NoSuchMethodException ex) {
            reportClass(clazz, context);
        } catch (Throwable ex) {
            Util.bug(null, ex);
        }
    } catch (ClassNotFoundException ex) {
        sendSupportInfo(ex.toString(), context);
    }
    // Check wifi info
    if (!checkField(WifiInfo.class, "mSupplicantState") || !checkField(WifiInfo.class, "mBSSID") || !checkField(WifiInfo.class, "mIpAddress") || !checkField(WifiInfo.class, "mMacAddress") || !(checkField(WifiInfo.class, "mSSID") || checkField(WifiInfo.class, "mWifiSsid")))
        reportClass(WifiInfo.class, context);
    // Check mWifiSsid.octets
    if (checkField(WifiInfo.class, "mWifiSsid"))
        try {
            Class<?> clazz = Class.forName("android.net.wifi.WifiSsid", false, null);
            try {
                clazz.getDeclaredMethod("createFromAsciiEncoded", String.class);
            } catch (NoSuchMethodException ex) {
                reportClass(clazz, context);
            }
        } catch (ClassNotFoundException ex) {
            sendSupportInfo(ex.toString(), context);
        }
    // Check Inet4Address/ANY
    try {
        Inet4Address.class.getDeclaredField("ANY");
    } catch (Throwable ex) {
        reportClass(Inet4Address.class, context);
    }
    // Check context services
    checkService(context, Context.ACCOUNT_SERVICE, new String[] { "android.accounts.AccountManager", "com.intel.arkham.ExtendAccountManager", /* Asus */
    "android.privacy.surrogate.PrivacyAccountManager" });
    checkService(context, Context.ACTIVITY_SERVICE, new String[] { "android.app.ActivityManager", "android.app.ActivityManagerEx" });
    checkService(context, Context.CLIPBOARD_SERVICE, new String[] { "android.content.ClipboardManager" });
    checkService(context, Context.CONNECTIVITY_SERVICE, new String[] { "android.net.ConnectivityManager", "android.net.ConnectivityManagerEx", "android.net.MultiSimConnectivityManager", "android.privacy.surrogate.PrivacyConnectivityManager" });
    checkService(context, Context.LOCATION_SERVICE, new String[] { "android.location.LocationManager", "android.location.ZTEPrivacyLocationManager", "android.privacy.surrogate.PrivacyLocationManager" });
    Class<?> serviceClass = context.getPackageManager().getClass();
    if (!"android.app.ApplicationPackageManager".equals(serviceClass.getName()) && !"amazon.content.pm.AmazonPackageManagerImpl".equals(serviceClass.getName()))
        reportClass(serviceClass, context);
    checkService(context, Context.SENSOR_SERVICE, new String[] { "android.hardware.SensorManager", "android.hardware.SystemSensorManager" });
    checkService(context, Context.TELEPHONY_SERVICE, new String[] { "android.telephony.TelephonyManager", "android.telephony.MSimTelephonyManager", "android.telephony.MultiSimTelephonyManager", "android.telephony.ZTEPrivacyTelephonyManager", "android.telephony.ZTEPrivacyMSimTelephonyManager", "com.motorola.android.telephony.MotoTelephonyManager", "android.privacy.surrogate.PrivacyTelephonyManager" });
    checkService(context, Context.WINDOW_SERVICE, new String[] { "android.view.WindowManagerImpl", "android.view.Window$LocalWindowManager", "amazon.view.AmazonWindowManagerImpl" });
    checkService(context, Context.WIFI_SERVICE, new String[] { "android.net.wifi.WifiManager", "com.amazon.net.AmazonWifiManager", "com.amazon.android.service.AmazonWifiManager", "android.privacy.surrogate.PrivacyWifiManager" });
}
Also used : AlertDialog(android.app.AlertDialog) GpsStatus(android.location.GpsStatus) DialogInterface(android.content.DialogInterface) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IBinder(android.os.IBinder) ArrayList(java.util.ArrayList) List(java.util.List) Inet4Address(java.net.Inet4Address) InterfaceAddress(java.net.InterfaceAddress) Intent(android.content.Intent) Method(java.lang.reflect.Method) WifiInfo(android.net.wifi.WifiInfo)

Example 12 with AlertDialog

use of android.app.AlertDialog in project XPrivacy by M66B.

the class Requirements method sendSupportInfo.

public static void sendSupportInfo(final String text, final ActivityBase context) {
    Util.log(null, Log.WARN, text);
    if (Util.hasValidFingerPrint(context) && !"Genymotion".equals(Build.MANUFACTURER)) {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
        alertDialogBuilder.setTitle(R.string.app_name);
        alertDialogBuilder.setMessage(R.string.msg_support_info);
        alertDialogBuilder.setIcon(context.getThemed(R.attr.icon_launcher));
        alertDialogBuilder.setPositiveButton(context.getString(android.R.string.ok), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int _which) {
                String ourVersion = Util.getSelfVersionName(context);
                StringBuilder sb = new StringBuilder(text);
                sb.insert(0, "\r\n");
                sb.insert(0, String.format("Id: %s\r\n", Build.ID));
                sb.insert(0, String.format("Display: %s\r\n", Build.DISPLAY));
                sb.insert(0, String.format("Host: %s\r\n", Build.HOST));
                sb.insert(0, String.format("Device: %s\r\n", Build.DEVICE));
                sb.insert(0, String.format("Product: %s\r\n", Build.PRODUCT));
                sb.insert(0, String.format("Model: %s\r\n", Build.MODEL));
                sb.insert(0, String.format("Manufacturer: %s\r\n", Build.MANUFACTURER));
                sb.insert(0, String.format("Brand: %s\r\n", Build.BRAND));
                sb.insert(0, "\r\n");
                sb.insert(0, String.format("Android: %s (SDK %d)\r\n", Build.VERSION.RELEASE, Build.VERSION.SDK_INT));
                sb.insert(0, String.format("XPrivacy: %s\r\n", ourVersion));
                Intent sendEmail = new Intent(Intent.ACTION_SEND);
                sendEmail.setType("message/rfc822");
                sendEmail.putExtra(Intent.EXTRA_EMAIL, new String[] { "marcel+support@faircode.eu" });
                sendEmail.putExtra(Intent.EXTRA_SUBJECT, "XPrivacy " + ourVersion + "/" + Build.VERSION.RELEASE + " support info");
                sendEmail.putExtra(Intent.EXTRA_TEXT, sb.toString());
                try {
                    context.startActivity(sendEmail);
                } catch (Throwable ex) {
                    Util.bug(null, ex);
                }
            }
        });
        alertDialogBuilder.setNegativeButton(context.getString(android.R.string.cancel), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
            }
        });
        AlertDialog alertDialog = alertDialogBuilder.create();
        alertDialog.show();
    }
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent)

Example 13 with AlertDialog

use of android.app.AlertDialog 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 14 with AlertDialog

use of android.app.AlertDialog 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 15 with AlertDialog

use of android.app.AlertDialog in project XPrivacy by M66B.

the class ActivityMain method optionSubmit.

private void optionSubmit() {
    if (ActivityShare.registerDevice(this)) {
        int[] uid = (mAppAdapter == null ? new int[0] : mAppAdapter.getSelectedOrVisibleUid(AppListAdapter.cSelectAppNone));
        if (uid.length == 0) {
            AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
            alertDialogBuilder.setTitle(R.string.app_name);
            alertDialogBuilder.setMessage(R.string.msg_select);
            alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher));
            alertDialogBuilder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            AlertDialog alertDialog = alertDialogBuilder.create();
            alertDialog.show();
        } else if (uid.length <= ActivityShare.cSubmitLimit) {
            if (mAppAdapter != null) {
                Intent intent = new Intent(ActivityShare.ACTION_SUBMIT);
                intent.putExtra(ActivityShare.cInteractive, true);
                intent.putExtra(ActivityShare.cUidList, uid);
                startActivity(intent);
            }
        } else {
            AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
            alertDialogBuilder.setTitle(R.string.app_name);
            alertDialogBuilder.setMessage(getString(R.string.msg_limit, ActivityShare.cSubmitLimit + 1));
            alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher));
            alertDialogBuilder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            AlertDialog alertDialog = alertDialogBuilder.create();
            alertDialog.show();
        }
    }
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.view.View.OnClickListener) Intent(android.content.Intent) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint)

Aggregations

AlertDialog (android.app.AlertDialog)348 DialogInterface (android.content.DialogInterface)236 View (android.view.View)84 Intent (android.content.Intent)63 TextView (android.widget.TextView)63 EditText (android.widget.EditText)50 OnClickListener (android.content.DialogInterface.OnClickListener)34 Test (org.junit.Test)33 Context (android.content.Context)29 ListView (android.widget.ListView)28 ImageView (android.widget.ImageView)26 AdapterView (android.widget.AdapterView)25 LayoutInflater (android.view.LayoutInflater)24 SuppressLint (android.annotation.SuppressLint)23 Button (android.widget.Button)23 Activity (android.app.Activity)21 Paint (android.graphics.Paint)19 KeyEvent (android.view.KeyEvent)16 OnClickListener (android.view.View.OnClickListener)15 ArrayList (java.util.ArrayList)15