Search in sources :

Example 1 with SettingsActivity

use of de.Maxr1998.xposed.maxlock.ui.SettingsActivity in project MaxLock by Maxr1998.

the class MaxLockPreferenceFragment method onStart.

@Override
public void onStart() {
    super.onStart();
    setTitle();
    if (screen == Screen.MAIN) {
        findPreference(Common.ABOUT).setTitle(getName() + " " + BuildConfig.VERSION_NAME);
        if (prefs.getBoolean(Common.DONATED, false)) {
            Preference donate = findPreference(Common.DONATE);
            donate.setTitle(R.string.pref_donate_thanks_for_donation);
            donate.setSummary(R.string.pref_donate_again_on_pro_summary);
            Preference pro = findPreference(Common.ENABLE_PRO);
            pro.setEnabled(false);
            pro.setSummary("");
            if (!prefs.getBoolean(Common.ENABLE_PRO, false)) {
                prefs.edit().putBoolean(Common.ENABLE_PRO, true).putBoolean(Common.ENABLE_LOGGING, true).apply();
            }
        }
        if (((SettingsActivity) getActivity()).isDeviceAdminActive()) {
            Preference protectOrUninstall = findPreference(Common.UNINSTALL);
            protectOrUninstall.setTitle(R.string.pref_uninstall);
            protectOrUninstall.setSummary("");
        }
    }
    // Show Snackbars if no password and/or packages set up
    if (screen == Screen.MAIN && isFirstPane()) {
        @StringRes int stringId = 0;
        Fragment fragment = null;
        if (prefs.getString(Common.LOCKING_TYPE, "").equals("")) {
            stringId = R.string.sb_no_locking_type;
            fragment = Screen.TYPE.getScreen();
        } else if (!new File(Util.dataDir(getContext()) + "shared_prefs" + File.separator + Common.PREFS_APPS + ".xml").exists()) {
            stringId = R.string.sb_no_locked_apps;
            fragment = new AppListFragment();
        }
        if (stringId != 0 && fragment != null) {
            final Fragment copyFragment = fragment;
            snackCache = Snackbar.make(getActivity().findViewById(android.R.id.content), stringId, Snackbar.LENGTH_INDEFINITE).setAction(R.string.sb_action_setup, v -> launchFragment(this, copyFragment, true));
            snackCache.show();
        }
    }
}
Also used : Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) BuildConfig(de.Maxr1998.xposed.maxlock.BuildConfig) Uri(android.net.Uri) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) LockPatternActivity(com.haibison.android.lockpattern.LockPatternActivity) ColorDrawable(android.graphics.drawable.ColorDrawable) PreferenceScreen(android.preference.PreferenceScreen) SDK_INT(android.os.Build.VERSION.SDK_INT) VisibleForTesting(android.support.annotation.VisibleForTesting) Util(de.Maxr1998.xposed.maxlock.util.Util) PreferenceFragmentCompat(android.support.v4.preference.PreferenceFragmentCompat) CheckBox(android.widget.CheckBox) MLImplementation(de.Maxr1998.xposed.maxlock.MLImplementation) WebViewClient(android.webkit.WebViewClient) View(android.view.View) BUTTON_NEUTRAL(android.content.DialogInterface.BUTTON_NEUTRAL) WebView(android.webkit.WebView) PERMISSION_GRANTED(android.content.pm.PackageManager.PERMISSION_GRANTED) Fragment(android.support.v4.app.Fragment) ContextCompat(android.support.v4.content.ContextCompat) FileProvider.getUriForFile(android.support.v4.content.FileProvider.getUriForFile) PorterDuff(android.graphics.PorterDuff) ActivityCompat(android.support.v4.app.ActivityCompat) AppCompatActivity(android.support.v7.app.AppCompatActivity) IOUtils(org.apache.commons.io.IOUtils) ListPreference(android.preference.ListPreference) TextView(android.widget.TextView) ActivityNotFoundException(android.content.ActivityNotFoundException) Snackbar(android.support.design.widget.Snackbar) SettingsActivity(de.Maxr1998.xposed.maxlock.ui.SettingsActivity) ZipOutputStream(java.util.zip.ZipOutputStream) Context(android.content.Context) PreferenceCategory(android.preference.PreferenceCategory) Intent(android.content.Intent) CheckBoxPreference(android.preference.CheckBoxPreference) StringRes(android.support.annotation.StringRes) NonNull(android.support.annotation.NonNull) XmlRes(android.support.annotation.XmlRes) BufferedOutputStream(java.io.BufferedOutputStream) FingerprintManagerCompat(android.support.v4.hardware.fingerprint.FingerprintManagerCompat) SuppressLint(android.annotation.SuppressLint) KUtil(de.Maxr1998.xposed.maxlock.util.KUtil) Charset(java.nio.charset.Charset) DevicePolicyManager(android.app.admin.DevicePolicyManager) READ_EXTERNAL_STORAGE(android.Manifest.permission.READ_EXTERNAL_STORAGE) Toast(android.widget.Toast) Build(android.os.Build) AppListFragment(de.Maxr1998.xposed.maxlock.ui.settings.applist.AppListFragment) DialogInterface(android.content.DialogInterface) BUTTON_POSITIVE(android.content.DialogInterface.BUTTON_POSITIVE) ImplementationPreference(de.Maxr1998.xposed.maxlock.preference.ImplementationPreference) MLPreferences(de.Maxr1998.xposed.maxlock.util.MLPreferences) ComponentName(android.content.ComponentName) LayoutInflater(android.view.LayoutInflater) FileOutputStream(java.io.FileOutputStream) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) Common(de.Maxr1998.xposed.maxlock.Common) File(java.io.File) R(de.Maxr1998.xposed.maxlock.R) Color(android.graphics.Color) TimeUnit(java.util.concurrent.TimeUnit) FragmentManager(android.support.v4.app.FragmentManager) AlertDialog(android.support.v7.app.AlertDialog) SharedPreferences(android.content.SharedPreferences) TwoStatePreference(android.preference.TwoStatePreference) Preference(android.preference.Preference) Activity(android.app.Activity) FragmentTransaction(android.support.v4.app.FragmentTransaction) InputStream(java.io.InputStream) ListPreference(android.preference.ListPreference) CheckBoxPreference(android.preference.CheckBoxPreference) ImplementationPreference(de.Maxr1998.xposed.maxlock.preference.ImplementationPreference) TwoStatePreference(android.preference.TwoStatePreference) Preference(android.preference.Preference) StringRes(android.support.annotation.StringRes) AppListFragment(de.Maxr1998.xposed.maxlock.ui.settings.applist.AppListFragment) Fragment(android.support.v4.app.Fragment) AppListFragment(de.Maxr1998.xposed.maxlock.ui.settings.applist.AppListFragment) FileProvider.getUriForFile(android.support.v4.content.FileProvider.getUriForFile) File(java.io.File) SettingsActivity(de.Maxr1998.xposed.maxlock.ui.SettingsActivity) SuppressLint(android.annotation.SuppressLint)

Example 2 with SettingsActivity

use of de.Maxr1998.xposed.maxlock.ui.SettingsActivity in project MaxLock by Maxr1998.

the class MaxLockPreferenceFragment method onPreferenceTreeClick.

@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    if (preference.getKey() == null) {
        return false;
    }
    switch(screen) {
        case MAIN:
            switch(preference.getKey()) {
                case Common.ML_IMPLEMENTATION:
                    AlertDialog implementation = new AlertDialog.Builder(getContext()).setTitle(preference.getTitle()).setView(MLImplementation.createImplementationDialog(getContext())).setNegativeButton(android.R.string.ok, null).setOnDismissListener(dialog -> updateImplementationStatus()).create();
                    implementation.show();
                    return true;
                case Common.LOCKING_TYPE_SETTINGS:
                    launchFragment(this, Screen.TYPE.getScreen(), true);
                    return true;
                case Common.LOCKING_UI_SETTINGS:
                    launchFragment(this, Screen.UI.getScreen(), true);
                    return true;
                case Common.LOCKING_OPTIONS:
                    launchFragment(this, Screen.OPTIONS.getScreen(), true);
                    return true;
                case Common.IMOD_OPTIONS:
                    launchFragment(this, Screen.IMOD.getScreen(), true);
                    return true;
                case Common.CHOOSE_APPS:
                    launchFragment(this, new AppListFragment(), true);
                    return true;
                case Common.HIDE_APP_FROM_LAUNCHER:
                    TwoStatePreference hideApp = (TwoStatePreference) preference;
                    if (hideApp.isChecked()) {
                        Toast.makeText(getActivity(), R.string.reboot_required, Toast.LENGTH_SHORT).show();
                        ComponentName componentName = new ComponentName(getActivity(), "de.Maxr1998.xposed.maxlock.Main");
                        getActivity().getPackageManager().setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
                    } else {
                        ComponentName componentName = new ComponentName(getActivity(), "de.Maxr1998.xposed.maxlock.Main");
                        getActivity().getPackageManager().setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
                    }
                    return true;
                case Common.USE_DARK_STYLE:
                case Common.USE_AMOLED_BLACK:
                case Common.ENABLE_PRO:
                    getActivity().recreate();
                    return true;
                case Common.ABOUT:
                    launchFragment(this, Screen.ABOUT.getScreen(), true);
                    return true;
                case Common.DONATE:
                    startActivity(new Intent(getActivity(), DonateActivity.class));
                    return true;
                case Common.UNINSTALL:
                    if (!((SettingsActivity) getActivity()).isDeviceAdminActive()) {
                        Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
                        intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, ((SettingsActivity) getActivity()).deviceAdmin);
                        startActivity(intent);
                    } else {
                        ((SettingsActivity) getActivity()).getDevicePolicyManager().removeActiveAdmin(((SettingsActivity) getActivity()).deviceAdmin);
                        preference.setTitle(R.string.pref_prevent_uninstall);
                        preference.setSummary(R.string.pref_prevent_uninstall_summary);
                        Intent uninstall = new Intent(Intent.ACTION_DELETE);
                        uninstall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        uninstall.setData(Uri.parse("package:de.Maxr1998.xposed.maxlock"));
                        startActivity(uninstall);
                    }
                    return true;
                case Common.SEND_FEEDBACK:
                    File tempDirectory = new File(getActivity().getCacheDir(), "feedback-cache");
                    try {
                        // Obtain data
                        FileUtils.copyDirectoryToDirectory(new File(Util.dataDir(getActivity()), "shared_prefs"), tempDirectory);
                        FileUtils.writeStringToFile(new File(tempDirectory, "device-info.txt"), "App Version: " + BuildConfig.VERSION_NAME + "\n\n" + "Device: " + Build.MANUFACTURER + " " + Build.MODEL + " (" + Build.PRODUCT + ")\n" + "API: " + SDK_INT + ", Fingerprint: " + Build.FINGERPRINT, Charset.forName("UTF-8"));
                        Process process = Runtime.getRuntime().exec("logcat -d");
                        FileUtils.copyInputStreamToFile(process.getInputStream(), new File(tempDirectory, "logcat.txt"));
                        try {
                            String xposedDir = SDK_INT >= Build.VERSION_CODES.N ? "/data/user_de/0/" + Common.XPOSED_PACKAGE_NAME : getActivity().getPackageManager().getApplicationInfo(Common.XPOSED_PACKAGE_NAME, 0).dataDir;
                            File xposedLog = new File(xposedDir + "/log", "error.log");
                            if (xposedLog.exists())
                                FileUtils.copyFileToDirectory(xposedLog, tempDirectory);
                        } catch (PackageManager.NameNotFoundException e) {
                            e.printStackTrace();
                        }
                        // Create zip
                        File zipFile = new File(getActivity().getCacheDir() + File.separator + "export", "report.zip");
                        zipFile.getParentFile().mkdir();
                        FileUtils.deleteQuietly(zipFile);
                        ZipOutputStream stream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)));
                        Util.writeDirectoryToZip(tempDirectory, stream);
                        stream.close();
                        FileUtils.deleteQuietly(tempDirectory);
                        Util.checkForStoragePermission(this, BUG_REPORT_STORAGE_PERMISSION_REQUEST_CODE, R.string.dialog_storage_permission_bug_report);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    return true;
            }
            break;
        case TYPE:
            switch(preference.getKey()) {
                case Common.LOCKING_TYPE_PASSWORD:
                    Util.setPassword(getActivity(), null);
                    return true;
                case Common.LOCKING_TYPE_PIN:
                    LockSetupFragment lsp = new LockSetupFragment();
                    Bundle b1 = new Bundle(1);
                    b1.putString(Common.LOCKING_TYPE, Common.LOCKING_TYPE_PIN);
                    lsp.setArguments(b1);
                    launchFragment(this, lsp, false);
                    return true;
                case Common.LOCKING_TYPE_KNOCK_CODE:
                    LockSetupFragment lsk = new LockSetupFragment();
                    Bundle b2 = new Bundle(1);
                    b2.putString(Common.LOCKING_TYPE, Common.LOCKING_TYPE_KNOCK_CODE);
                    lsk.setArguments(b2);
                    launchFragment(this, lsk, false);
                    return true;
                case Common.LOCKING_TYPE_PATTERN:
                    Intent intent = new Intent(LockPatternActivity.ACTION_CREATE_PATTERN, null, getActivity(), LockPatternActivity.class);
                    startActivityForResult(intent, KUtil.getPatternCode(-1));
                    return true;
            }
            break;
        case OPTIONS:
            switch(preference.getKey()) {
                case Common.VIEW_LOGS:
                    launchFragment(this, new LogViewerFragment(), false);
                    return true;
            }
            break;
        case ABOUT:
            switch(preference.getKey()) {
                case Common.SHOW_CHANGELOG:
                    showChangelog();
                    return true;
                case Common.VISIT_WEBSITE:
                    CustomTabsIntent devWebsite = new CustomTabsIntent.Builder(((SettingsActivity) getActivity()).getSession()).setShowTitle(true).enableUrlBarHiding().setToolbarColor(Color.parseColor("#ffc107")).build();
                    devWebsite.launchUrl(getActivity(), Common.MAXR1998_URI);
                    return true;
                case Common.TECHNOSPARKS_PROFILE:
                    CustomTabsIntent technosparksSite = new CustomTabsIntent.Builder(((SettingsActivity) getActivity()).getSession()).setShowTitle(true).enableUrlBarHiding().setToolbarColor(Color.parseColor("#6d993f")).build();
                    technosparksSite.launchUrl(getActivity(), Common.TECHNO_SPARKS_URI);
                    return true;
            }
            break;
    }
    return super.onPreferenceTreeClick(preferenceScreen, preference);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) BuildConfig(de.Maxr1998.xposed.maxlock.BuildConfig) Uri(android.net.Uri) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) LockPatternActivity(com.haibison.android.lockpattern.LockPatternActivity) ColorDrawable(android.graphics.drawable.ColorDrawable) PreferenceScreen(android.preference.PreferenceScreen) SDK_INT(android.os.Build.VERSION.SDK_INT) VisibleForTesting(android.support.annotation.VisibleForTesting) Util(de.Maxr1998.xposed.maxlock.util.Util) PreferenceFragmentCompat(android.support.v4.preference.PreferenceFragmentCompat) CheckBox(android.widget.CheckBox) MLImplementation(de.Maxr1998.xposed.maxlock.MLImplementation) WebViewClient(android.webkit.WebViewClient) View(android.view.View) BUTTON_NEUTRAL(android.content.DialogInterface.BUTTON_NEUTRAL) WebView(android.webkit.WebView) PERMISSION_GRANTED(android.content.pm.PackageManager.PERMISSION_GRANTED) Fragment(android.support.v4.app.Fragment) ContextCompat(android.support.v4.content.ContextCompat) FileProvider.getUriForFile(android.support.v4.content.FileProvider.getUriForFile) PorterDuff(android.graphics.PorterDuff) ActivityCompat(android.support.v4.app.ActivityCompat) AppCompatActivity(android.support.v7.app.AppCompatActivity) IOUtils(org.apache.commons.io.IOUtils) ListPreference(android.preference.ListPreference) TextView(android.widget.TextView) ActivityNotFoundException(android.content.ActivityNotFoundException) Snackbar(android.support.design.widget.Snackbar) SettingsActivity(de.Maxr1998.xposed.maxlock.ui.SettingsActivity) ZipOutputStream(java.util.zip.ZipOutputStream) Context(android.content.Context) PreferenceCategory(android.preference.PreferenceCategory) Intent(android.content.Intent) CheckBoxPreference(android.preference.CheckBoxPreference) StringRes(android.support.annotation.StringRes) NonNull(android.support.annotation.NonNull) XmlRes(android.support.annotation.XmlRes) BufferedOutputStream(java.io.BufferedOutputStream) FingerprintManagerCompat(android.support.v4.hardware.fingerprint.FingerprintManagerCompat) SuppressLint(android.annotation.SuppressLint) KUtil(de.Maxr1998.xposed.maxlock.util.KUtil) Charset(java.nio.charset.Charset) DevicePolicyManager(android.app.admin.DevicePolicyManager) READ_EXTERNAL_STORAGE(android.Manifest.permission.READ_EXTERNAL_STORAGE) Toast(android.widget.Toast) Build(android.os.Build) AppListFragment(de.Maxr1998.xposed.maxlock.ui.settings.applist.AppListFragment) DialogInterface(android.content.DialogInterface) BUTTON_POSITIVE(android.content.DialogInterface.BUTTON_POSITIVE) ImplementationPreference(de.Maxr1998.xposed.maxlock.preference.ImplementationPreference) MLPreferences(de.Maxr1998.xposed.maxlock.util.MLPreferences) ComponentName(android.content.ComponentName) LayoutInflater(android.view.LayoutInflater) FileOutputStream(java.io.FileOutputStream) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) Common(de.Maxr1998.xposed.maxlock.Common) File(java.io.File) R(de.Maxr1998.xposed.maxlock.R) Color(android.graphics.Color) TimeUnit(java.util.concurrent.TimeUnit) FragmentManager(android.support.v4.app.FragmentManager) AlertDialog(android.support.v7.app.AlertDialog) SharedPreferences(android.content.SharedPreferences) TwoStatePreference(android.preference.TwoStatePreference) Preference(android.preference.Preference) Activity(android.app.Activity) FragmentTransaction(android.support.v4.app.FragmentTransaction) InputStream(java.io.InputStream) TwoStatePreference(android.preference.TwoStatePreference) Bundle(android.os.Bundle) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) Intent(android.content.Intent) IOException(java.io.IOException) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) PackageManager(android.content.pm.PackageManager) ZipOutputStream(java.util.zip.ZipOutputStream) AppListFragment(de.Maxr1998.xposed.maxlock.ui.settings.applist.AppListFragment) FileOutputStream(java.io.FileOutputStream) ComponentName(android.content.ComponentName) FileProvider.getUriForFile(android.support.v4.content.FileProvider.getUriForFile) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Example 3 with SettingsActivity

use of de.Maxr1998.xposed.maxlock.ui.SettingsActivity in project MaxLock by Maxr1998.

the class MaxLockPreferenceFragment method launchFragment.

public static void launchFragment(@NonNull Fragment fragment, @NonNull Fragment replacement, boolean fromRoot) {
    FragmentManager manager = fragment.getFragmentManager();
    if (fromRoot) {
        manager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    }
    FragmentTransaction transaction = manager.beginTransaction();
    if (manager.getBackStackEntryCount() > 0 || !((SettingsActivity) fragment.getActivity()).inLandscape())
        transaction.setCustomAnimations(R.anim.fragment_in, 0, R.anim.fragment_pop_in, R.anim.fragment_pop_out);
    transaction.replace(R.id.fragment_container, replacement).addToBackStack(null).commit();
    if (fromRoot && ((MaxLockPreferenceFragment) fragment).isFirstPane())
        SettingsActivity.showMultipaneIfInLandscape((SettingsActivity) fragment.getActivity());
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) FragmentTransaction(android.support.v4.app.FragmentTransaction) SettingsActivity(de.Maxr1998.xposed.maxlock.ui.SettingsActivity)

Example 4 with SettingsActivity

use of de.Maxr1998.xposed.maxlock.ui.SettingsActivity in project MaxLock by Maxr1998.

the class AppListFragment method onRequestPermissionsResult.

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    if (grantResults.length == 0 || grantResults[0] == PackageManager.PERMISSION_DENIED) {
        return;
    }
    final String prefsAppsName = Common.PREFS_APPS + ".xml";
    final String prefsPerAppName = Common.PREFS_KEYS_PER_APP + ".xml";
    final File prefsAppsFile = new File(Util.dataDir(getActivity()) + "shared_prefs/" + prefsAppsName);
    final File prefsPerAppFile = new File(Util.dataDir(getActivity()) + "shared_prefs/" + prefsPerAppName);
    switch(requestCode) {
        case BACKUP_STORAGE_PERMISSION_REQUEST_CODE:
            String currentBackupDirPath = Common.BACKUP_DIR + new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss", Locale.getDefault()).format(new Date(System.currentTimeMillis())) + File.separator;
            backupFile(prefsAppsFile, new File(currentBackupDirPath));
            backupFile(prefsPerAppFile, new File(currentBackupDirPath));
            if (new File(currentBackupDirPath).exists() && new File(currentBackupDirPath + prefsAppsName).exists())
                Toast.makeText(getActivity(), R.string.toast_backup_success, Toast.LENGTH_SHORT).show();
            break;
        case RESTORE_STORAGE_PERMISSION_REQUEST_CODE:
            File backupDir = new File(Common.BACKUP_DIR);
            // noinspection ResultOfMethodCallIgnored
            backupDir.mkdirs();
            List<String> list = new ArrayList<>(Arrays.asList(backupDir.list()));
            restoreAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, list);
            AlertDialog restoreDialog = new AlertDialog.Builder(getActivity()).setTitle(R.string.dialog_text_restore_list).setNegativeButton(android.R.string.cancel, null).setAdapter(restoreAdapter, (dialogInterface, i) -> {
                File restorePackagesFile = new File(Common.BACKUP_DIR + restoreAdapter.getItem(i) + File.separator + prefsAppsName);
                File restorePerAppFile = new File(Common.BACKUP_DIR + restoreAdapter.getItem(i) + File.separator + prefsPerAppName);
                try {
                    if (restorePackagesFile.exists()) {
                        FileUtils.deleteQuietly(prefsAppsFile);
                        FileUtils.copyFile(restorePackagesFile, prefsAppsFile);
                    }
                    if (restorePerAppFile.exists()) {
                        FileUtils.deleteQuietly(prefsPerAppFile);
                        FileUtils.copyFile(restorePerAppFile, prefsPerAppFile);
                    }
                } catch (IOException e) {
                    Toast.makeText(getActivity(), R.string.toast_no_files_to_restore, Toast.LENGTH_SHORT).show();
                }
                getActivity().getSharedPreferences(Common.PREFS_APPS, Context.MODE_MULTI_PROCESS);
                getActivity().getSharedPreferences(Common.PREFS_KEYS_PER_APP, Context.MODE_MULTI_PROCESS);
                Toast.makeText(getActivity(), R.string.toast_restore_success, Toast.LENGTH_SHORT).show();
                ((SettingsActivity) getActivity()).restart();
            }).show();
            restoreDialog.getListView().setOnItemLongClickListener((adapterView, view, i, l) -> {
                try {
                    FileUtils.deleteDirectory(new File(Common.BACKUP_DIR + restoreAdapter.getItem(i)));
                    restoreAdapter.remove(restoreAdapter.getItem(i));
                    restoreAdapter.notifyDataSetChanged();
                } catch (IOException e) {
                    e.printStackTrace();
                    return false;
                }
                return true;
            });
            break;
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Context(android.content.Context) Arrays(java.util.Arrays) Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) SearchView(android.support.v7.widget.SearchView) Date(java.util.Date) LockPatternActivity(com.haibison.android.lockpattern.LockPatternActivity) SimpleDateFormat(java.text.SimpleDateFormat) Intent(android.content.Intent) StringRes(android.support.annotation.StringRes) LOAD_ALL(de.Maxr1998.xposed.maxlock.ui.settings.applist.SetupAppListLoader.LOAD_ALL) NonNull(android.support.annotation.NonNull) Drawable(android.graphics.drawable.Drawable) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint) Util(de.Maxr1998.xposed.maxlock.util.Util) MenuInflater(android.view.MenuInflater) Locale(java.util.Locale) Toast(android.widget.Toast) Menu(android.view.Menu) View(android.view.View) LoaderManager(android.support.v4.app.LoaderManager) FastScrollRecyclerView(com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView) Loader(android.support.v4.content.Loader) MLPreferences(de.Maxr1998.xposed.maxlock.util.MLPreferences) LayoutInflater(android.view.LayoutInflater) Fragment(android.support.v4.app.Fragment) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) Common(de.Maxr1998.xposed.maxlock.Common) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) AppCompatActivity(android.support.v7.app.AppCompatActivity) ViewGroup(android.view.ViewGroup) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) R(de.Maxr1998.xposed.maxlock.R) ArrayAdapter(android.widget.ArrayAdapter) List(java.util.List) AlertDialog(android.support.v7.app.AlertDialog) SharedPreferences(android.content.SharedPreferences) Nullable(android.support.annotation.Nullable) ApplicationInfo(android.content.pm.ApplicationInfo) SettingsActivity(de.Maxr1998.xposed.maxlock.ui.SettingsActivity) ArrayList(java.util.ArrayList) IOException(java.io.IOException) File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 5 with SettingsActivity

use of de.Maxr1998.xposed.maxlock.ui.SettingsActivity in project MaxLock by Maxr1998.

the class SettingsActivity method showMultipaneIfInLandscape.

public static void showMultipaneIfInLandscape(SettingsActivity activity) {
    if (activity.secondFragmentContainer != null) {
        activity.secondFragmentContainer.setVisibility(View.VISIBLE);
        FragmentManager manager = activity.getSupportFragmentManager();
        Fragment secondPane = manager.findFragmentByTag(TAG_PREFERENCE_FRAGMENT_SECOND_PANE);
        if (secondPane == null) {
            secondPane = MaxLockPreferenceFragment.Screen.MAIN.getScreen();
        }
        if (!secondPane.isAdded())
            manager.beginTransaction().replace(R.id.second_fragment_container, secondPane, TAG_PREFERENCE_FRAGMENT_SECOND_PANE).commit();
    }
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) MaxLockPreferenceFragment(de.Maxr1998.xposed.maxlock.ui.settings.MaxLockPreferenceFragment) AppListFragment(de.Maxr1998.xposed.maxlock.ui.settings.applist.AppListFragment) Fragment(android.support.v4.app.Fragment)

Aggregations

Fragment (android.support.v4.app.Fragment)4 FragmentManager (android.support.v4.app.FragmentManager)4 SuppressLint (android.annotation.SuppressLint)3 Context (android.content.Context)3 Intent (android.content.Intent)3 SharedPreferences (android.content.SharedPreferences)3 PackageManager (android.content.pm.PackageManager)3 Bundle (android.os.Bundle)3 NonNull (android.support.annotation.NonNull)3 StringRes (android.support.annotation.StringRes)3 FragmentTransaction (android.support.v4.app.FragmentTransaction)3 SettingsActivity (de.Maxr1998.xposed.maxlock.ui.SettingsActivity)3 READ_EXTERNAL_STORAGE (android.Manifest.permission.READ_EXTERNAL_STORAGE)2 Activity (android.app.Activity)2 DevicePolicyManager (android.app.admin.DevicePolicyManager)2 ActivityNotFoundException (android.content.ActivityNotFoundException)2 ComponentName (android.content.ComponentName)2 DialogInterface (android.content.DialogInterface)2 BUTTON_NEUTRAL (android.content.DialogInterface.BUTTON_NEUTRAL)2 BUTTON_POSITIVE (android.content.DialogInterface.BUTTON_POSITIVE)2