Java Code Examples for androidx.preference.PreferenceCategory#removePreference()

The following examples show how to use androidx.preference.PreferenceCategory#removePreference() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PreferencesCommonFragment.java    From InviZible with GNU General Public License v3.0 6 votes vote down vote up
private void manageLANDeviceAddressPreference() {

        PreferenceCategory hotspotSettingsCategory = findPreference("HOTSPOT");
        Preference localEthernetDeviceAddress = findPreference("pref_common_local_eth_device_addr");

        if (getActivity() == null || hotspotSettingsCategory == null || localEthernetDeviceAddress == null) {
            return;
        }

        if (Utils.INSTANCE.getScreenOrientation(getActivity()) == Configuration.ORIENTATION_PORTRAIT
                || !Utils.INSTANCE.isLANInterfaceExist()) {
            hotspotSettingsCategory.removePreference(localEthernetDeviceAddress);
        } else {
            String deviceIP = Utils.INSTANCE.getDeviceIP();
            String summary = String.format(getString(R.string.pref_common_local_eth_device_addr_summ), deviceIP, deviceIP);
            localEthernetDeviceAddress.setSummary(summary);
        }


    }
 
Example 2
Source File: PreferencesTorFragment.java    From InviZible with GNU General Public License v3.0 6 votes vote down vote up
private void changePreferencesForGPVersion() {
    PreferenceCategory torSettingsCategory = findPreference("tor_settings");

    if (torSettingsCategory != null) {
        ArrayList<Preference> preferences = new ArrayList<>();
        preferences.add(findPreference("AvoidDiskWrites"));
        preferences.add(findPreference("ConnectionPadding"));
        preferences.add(findPreference("ReducedConnectionPadding"));
        preferences.add(findPreference("Enable SOCKS proxy"));
        preferences.add(findPreference("Enable HTTPTunnel"));
        preferences.add(findPreference("Enable Transparent proxy"));
        preferences.add(findPreference("Enable DNS"));

        for (Preference preference : preferences) {
            if (preference != null) {
                torSettingsCategory.removePreference(preference);
            }
        }
    }

    PreferenceCategory otherCategory = findPreference("pref_tor_other");
    Preference editTorConfDirectly = findPreference("editTorConfDirectly");
    if (otherCategory != null && editTorConfDirectly != null) {
        otherCategory.removePreference(editTorConfDirectly);
    }
}
 
Example 3
Source File: SettingsFragment.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
private void setGDPR() {
  if (settingsManager.showGDPR()) {
    termsAndConditions = findPreference(TERMS_AND_CONDITIONS_PREFERENCE_KEY);
    privacyPolicy = findPreference(PRIVACY_POLICY_PREFERENCE_KEY);
  } else {
    PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference("about");
    Preference termsAndConditionsPreference = findPreference("termsConditions");
    Preference privacyPolicyPreference = findPreference("privacyPolicy");
    if (termsAndConditionsPreference != null) {
      preferenceCategory.removePreference(termsAndConditionsPreference);
    }
    if (privacyPolicyPreference != null) {
      preferenceCategory.removePreference(privacyPolicyPreference);
    }
  }
}
 
Example 4
Source File: PreferencesDNSFragment.java    From InviZible with GNU General Public License v3.0 5 votes vote down vote up
private void removePreferencesWithGPVersion() {
    PreferenceScreen dnscryptSettings = findPreference("dnscrypt_settings");

    ArrayList<PreferenceCategory> categories = new ArrayList<>();
    categories.add(findPreference("pref_dnscrypt_forwarding_rules"));
    categories.add(findPreference("pref_dnscrypt_cloaking_rules"));
    categories.add(findPreference("pref_dnscrypt_blacklist"));
    categories.add(findPreference("pref_dnscrypt_ipblacklist"));
    categories.add(findPreference("pref_dnscrypt_whitelist"));
    categories.add(findPreference("pref_dnscrypt_other"));

    for (PreferenceCategory category : categories) {
        if (dnscryptSettings != null && category != null) {
            dnscryptSettings.removePreference(category);
        }
    }

    PreferenceCategory requireServersCategory = findPreference("dnscrypt_require_servers_prop_summ");
    Preference requireNofilter = findPreference("require_nofilter");

    if (requireServersCategory != null && requireNofilter != null) {
        requireServersCategory.removePreference(requireNofilter);
    }

    PreferenceCategory queryLogCategory = findPreference("pref_dnscrypt_query_log");
    Preference ignoredQtypes = findPreference("ignored_qtypes");

    if (queryLogCategory != null && ignoredQtypes != null) {
        queryLogCategory.removePreference(ignoredQtypes);
    }
}
 
Example 5
Source File: PreferencesFastFragment.java    From InviZible with GNU General Public License v3.0 5 votes vote down vote up
private void changePreferencesWithProxyMode() {

        PreferenceCategory torSettingsCategory = findPreference("Tor Settings");

        List<Preference> preferencesList = new ArrayList<>();

        preferencesList.add(findPreference("pref_fast_all_through_tor"));
        preferencesList.add(findPreference("prefTorSiteUnlock"));
        preferencesList.add(findPreference("prefTorAppUnlock"));
        preferencesList.add(findPreference("prefTorSiteExclude"));
        preferencesList.add(findPreference("prefTorAppExclude"));
        preferencesList.add(findPreference("pref_fast_site_refresh_interval"));

        for (Preference preference : preferencesList) {
            if (preference != null) {
                if (torSettingsCategory != null) {
                    torSettingsCategory.removePreference(preference);
                }
            }
        }

        PreferenceCategory fastUpdateCategory = findPreference("fast_update");
        Preference updateThroughTor = findPreference("pref_fast through_tor_update");
        if (fastUpdateCategory != null && updateThroughTor != null) {
            fastUpdateCategory.removePreference(updateThroughTor);
        }

        PreferenceCategory fastOtherCategory = findPreference("fast_other");

        Preference blockHttp = findPreference("pref_fast_block_http");
        if (fastOtherCategory != null && blockHttp != null) {
            fastOtherCategory.removePreference(blockHttp);
        }
    }
 
Example 6
Source File: PreferencesFastFragment.java    From InviZible with GNU General Public License v3.0 5 votes vote down vote up
private void changePreferencesForGPVersion() {
    PreferenceScreen preferencesFast = findPreference("fast_preferences");
    PreferenceCategory fastUpdateCategory = findPreference("fast_update");
    if (preferencesFast != null && fastUpdateCategory != null) {
        preferencesFast.removePreference(fastUpdateCategory);
    }

    PreferenceCategory fastOtherCategory = findPreference("fast_other");

    Preference blockHttp = findPreference("pref_fast_block_http");
    if (fastOtherCategory != null && blockHttp != null) {
        fastOtherCategory.removePreference(blockHttp);
    }
}
 
Example 7
Source File: GeneralPreferenceFragment.java    From TowerCollector with Mozilla Public License 2.0 5 votes vote down vote up
private void setupUsageStatisticsAvailability() {
    boolean available = BuildConfig.ANALYTICS_AVAILABLE;
    if (!available) {
        PreferenceCategory settingsCategoryPreference = findPreference(getString(R.string.preferences_general_category_settings_key));
        SwitchPreferenceCompat trackingPreference = findPreference(getString(R.string.preferences_tracking_enabled_key));
        settingsCategoryPreference.removePreference(trackingPreference);

        // We have only one help preference so the whole category is to be removed
        PreferenceScreen generalScreenPreference = getPreferenceScreen();
        PreferenceCategory helpCategoryPreference = findPreference(getString(R.string.preferences_general_category_help_key));
        generalScreenPreference.removePreference(helpCategoryPreference);
    } else {
        setupUsageStatisticsDialog();
    }
}
 
Example 8
Source File: CollectorPreferenceFragment.java    From TowerCollector with Mozilla Public License 2.0 5 votes vote down vote up
private void setupHideCollectorNotificationAvailability() {
    boolean available = Build.VERSION.SDK_INT < Build.VERSION_CODES.O;
    if (!available) {
        PreferenceCategory settingsCategoryPreference = findPreference(getString(R.string.preferences_general_category_settings_key));
        SwitchPreferenceCompat hideCollectorNotificationPreference = findPreference(getString(R.string.preferences_hide_collector_notification_key));
        settingsCategoryPreference.removePreference(hideCollectorNotificationPreference);
    }
}
 
Example 9
Source File: AdvancedPreferenceFragment.java    From TowerCollector with Mozilla Public License 2.0 5 votes vote down vote up
private void setupErrorReportingAvailability() {
    boolean available = BuildConfig.ACRA_SETTINGS_AVAILABLE;
    if (!available) {
        PreferenceCategory settingsCategoryPreference = findPreference(getString(R.string.preferences_advanced_category_settings_key));
        SwitchPreferenceCompat errorReportingSilentPreference = findPreference(getString(R.string.preferences_error_reporting_silent_key));
        settingsCategoryPreference.removePreference(errorReportingSilentPreference);
    }
}
 
Example 10
Source File: PreferencesCommonFragment.java    From InviZible with GNU General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    if (getActivity() == null) {
        super.onCreateView(inflater, container, savedInstanceState);
    }

    getActivity().setTitle(R.string.drawer_menu_commonSettings);

    PreferenceCategory others = findPreference("common_other");
    Preference swShowNotification = findPreference("swShowNotification");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        if (others != null && swShowNotification != null) {
            others.removePreference(swShowNotification);
        }
    } else {
        if (swShowNotification != null) {
            swShowNotification.setOnPreferenceChangeListener(this);
        }
    }

    if (ModulesStatus.getInstance().getMode() == ROOT_MODE) {
        registerPreferences();
    } else {
        removePreferences();
    }

    manageLANDeviceAddressPreference();

    PreferenceCategory otherSettingsCategory = findPreference("common_other");
    Preference shellControl = findPreference("pref_common_shell_control");

    if (appVersion.startsWith("g")) {
        PreferenceCategory hotspotSettingsCategory = findPreference("HOTSPOT");
        Preference blockHTTP = findPreference("pref_common_block_http");
        if (hotspotSettingsCategory != null && blockHTTP != null) {
            hotspotSettingsCategory.removePreference(blockHTTP);
        }

        if (otherSettingsCategory != null && shellControl != null) {
            otherSettingsCategory.removePreference(shellControl);
        }

    } else if (shellControl != null){
        shellControl.setSummary(String.format(getString(R.string.pref_common_shell_control_summ), getActivity().getPackageName()));
    }

    return super.onCreateView(inflater, container, savedInstanceState);
}
 
Example 11
Source File: PreferencesFastFragment.java    From InviZible with GNU General Public License v3.0 4 votes vote down vote up
private void changePreferencesWithVPNMode(Context context) {
    Preference pref_fast_all_through_tor = findPreference("pref_fast_all_through_tor");
    if (pref_fast_all_through_tor != null) {
        //pref_fast_all_through_tor.setTitle(R.string.pref_fast_all_through_ipro);
        pref_fast_all_through_tor.setOnPreferenceChangeListener(this);
    }

    Preference pref_fast_block_http = findPreference("pref_fast_block_http");
    if (pref_fast_block_http != null) {
        pref_fast_block_http.setOnPreferenceChangeListener(this);
    }

    SharedPreferences shPref = PreferenceManager.getDefaultSharedPreferences(context);
    Preference prefTorAppUnlock = findPreference("prefTorAppUnlock");

    /*if (prefTorAppUnlock != null) {
        prefTorAppUnlock.setSummary(R.string.pref_fast_unlock_apps_with_ipro_summ);
    }*/

    if (shPref.getBoolean("pref_fast_all_through_tor", true)) {
        if (prefTorAppUnlock != null) {
            prefTorAppUnlock.setEnabled(false);
        }
    } else {
        if (prefTorAppUnlock != null) {
            prefTorAppUnlock.setEnabled(true);
        }
    }

    /*Preference prefTorAppExclude = findPreference("prefTorAppExclude");
    if (prefTorAppExclude != null) {
        prefTorAppExclude.setSummary(R.string.pref_fast_exclude_apps_from_ipro_summ);
    }*/

    PreferenceCategory torSettingsCategory = findPreference("Tor Settings");
    /*if (torSettingsCategory != null) {
        torSettingsCategory.setTitle(R.string.pref_fast_routing);
    }*/

    List<Preference> preferencesList = new ArrayList<>();

    preferencesList.add(findPreference("prefTorSiteUnlock"));
    preferencesList.add(findPreference("prefTorSiteExclude"));
    preferencesList.add(findPreference("pref_fast_site_refresh_interval"));

    for (Preference preference : preferencesList) {
        if (preference != null) {
            if (torSettingsCategory != null) {
                torSettingsCategory.removePreference(preference);
            }
        }
    }

    PreferenceCategory fastUpdateCategory = findPreference("fast_update");
    Preference updateThroughTor = findPreference("pref_fast through_tor_update");
    if (fastUpdateCategory != null && updateThroughTor != null) {
        fastUpdateCategory.removePreference(updateThroughTor);
    }
}