androidx.preference.PreferenceScreen Java Examples

The following examples show how to use androidx.preference.PreferenceScreen. 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: BasePreferenceFragmentCompat.java    From GotoSleep with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
    return new PreferenceGroupAdapter(preferenceScreen) {
        @SuppressLint("RestrictedApi")
        @Override
        public void onBindViewHolder(PreferenceViewHolder holder, int position) {
            super.onBindViewHolder(holder, position);
            Preference preference = getItem(position);
            if (preference instanceof PreferenceCategory)
                setZeroPaddingToLayoutChildren(holder.itemView);
            else {
                View iconFrame = holder.itemView.findViewById(R.id.icon_frame);
                if (iconFrame != null) {
                    iconFrame.setVisibility(preference.getIcon() == null ? View.GONE : View.VISIBLE);
                }
            }
        }
    };
}
 
Example #2
Source File: BasePreferenceFragment.java    From ColorPicker with Apache License 2.0 6 votes vote down vote up
@Override protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
  return new PreferenceGroupAdapter(preferenceScreen) {
    @SuppressLint("RestrictedApi") @Override public void onBindViewHolder(PreferenceViewHolder holder, int position) {
      super.onBindViewHolder(holder, position);
      Preference preference = getItem(position);
      if (preference instanceof PreferenceCategory) {
        setZeroPaddingToLayoutChildren(holder.itemView);
      } else {
        View iconFrame = holder.itemView.findViewById(R.id.icon_frame);
        if (iconFrame != null) {
          iconFrame.setVisibility(preference.getIcon() == null ? View.GONE : View.VISIBLE);
        }
      }
    }
  };
}
 
Example #3
Source File: EnabledApplicationsPreferenceFragment.java    From an2linuxclient with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onSharedPreferenceChanged(SharedPreferences sp, String key) {
    boolean newSettingsValue = sp.getBoolean(key, false);
    String prefEnableDisableAllKey = getString(R.string.preference_enable_disable_all_applications);
    if (key.equals(prefEnableDisableAllKey)) {
        final PreferenceScreen prefScreen = findPreference(getString(R.string.enabled_apps_pref_screen));
        for (int i = 1; i < prefScreen.getPreferenceCount(); i++) {
            ((CheckBoxPreference) (prefScreen.getPreference(i))).setChecked(newSettingsValue);
        }
    }

    // If newSettingsValue == false, clear it from SharedPreferences file to save up some space.
    // Since AN2Linux will default to false if the setting is not found.
    if (!newSettingsValue) {
        sp.edit().remove(key).apply();
    }
}
 
Example #4
Source File: EnabledApplicationsPreferenceFragment.java    From an2linuxclient with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    EnabledApplicationsViewModel viewModel = ViewModelProviders.of(getActivity()).get(EnabledApplicationsViewModel.class);
    viewModel.getFilteredCheckBoxPrefsData().observe(getViewLifecycleOwner(), checkBoxPreferencesData -> {
        setPreferencesFromResource(R.xml.enabled_applications_preferences, null);
        PreferenceScreen prefScreen = (PreferenceScreen) findPreference(getString(R.string.enabled_apps_pref_screen));
        for (CheckBoxPreferenceData checkBoxPreferenceData : checkBoxPreferencesData) {
            CheckBoxPreference c = new CheckBoxPreference(getPreferenceScreen().getContext());
            c.setKey(checkBoxPreferenceData.key);
            c.setTitle(checkBoxPreferenceData.title);
            c.setSummary(checkBoxPreferenceData.summary);
            c.setIcon(checkBoxPreferenceData.icon);
            prefScreen.addPreference(c);
        }
    });
}
 
Example #5
Source File: DeveloperPreferences.java    From commcare-android with Apache License 2.0 6 votes vote down vote up
private void hideOrShowDangerousSettings() {
    Preference[] onScreenPrefs = getOnScreenPrefs();
    if (!GlobalPrivilegesManager.isAdvancedSettingsAccessEnabled() && !BuildConfig.DEBUG) {
        // Dangerous privileges should not be showing
        PreferenceScreen prefScreen = getPreferenceScreen();
        for (Preference p : onScreenPrefs) {
            if (p != null && !WHITELISTED_DEVELOPER_PREF_KEYS.contains(p.getKey())) {
                prefScreen.removePreference(p);
            }
        }
    } else {
        // Dangerous privileges should be showing
        if (onScreenPrefs.length == WHITELISTED_DEVELOPER_PREF_KEYS.size()) {
            // If we're currently showing only white-listed prefs, reset
            reset();
        }
    }
}
 
Example #6
Source File: SettingsFragment.java    From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
    return new PreferenceGroupAdapter(preferenceScreen) {
        @SuppressLint("RestrictedApi")
        @Override
        public void onBindViewHolder(PreferenceViewHolder holder, int position) {
            super.onBindViewHolder(holder, position);
            Preference preference = getItem(position);
            if (preference instanceof PreferenceCategory)
                setZeroPaddingToLayoutChildren(holder.itemView);
            else {
                View iconFrame = holder.itemView.findViewById(R.id.icon_frame);
                if (iconFrame != null) {
                    iconFrame.setVisibility(preference.getIcon() == null ? View.GONE : View.VISIBLE);
                }
            }
        }
    };
}
 
Example #7
Source File: SettingsFragment.java    From SmartPack-Kernel-Manager with GNU General Public License v3.0 6 votes vote down vote up
@Override
@SuppressLint("RestrictedApi")
protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
    return new PreferenceGroupAdapter(preferenceScreen) {
        @Override
        public void onBindViewHolder(@NonNull PreferenceViewHolder holder, int position) {
            super.onBindViewHolder(holder, position);
            Preference preference = getItem(position);
            if (preference instanceof PreferenceCategory)
                setZeroPaddingToLayoutChildren(holder.itemView);
            else {
                View iconFrame = holder.itemView.findViewById(R.id.icon_frame);
                if (iconFrame != null) {
                    iconFrame.setVisibility(preference.getIcon() == null ? View.GONE : View.VISIBLE);
                }
            }
        }
    };
}
 
Example #8
Source File: EnabledApplicationsPreferenceFragment.java    From an2linuxclient with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onSharedPreferenceChanged(SharedPreferences sp, String key) {
    boolean newSettingsValue = sp.getBoolean(key, false);
    String prefEnableDisableAllKey = getString(R.string.preference_enable_disable_all_applications);
    if (key.equals(prefEnableDisableAllKey)) {
        final PreferenceScreen prefScreen = findPreference(getString(R.string.enabled_apps_pref_screen));
        for (int i = 1; i < prefScreen.getPreferenceCount(); i++) {
            ((CheckBoxPreference) (prefScreen.getPreference(i))).setChecked(newSettingsValue);
        }
    }

    // If newSettingsValue == false, clear it from SharedPreferences file to save up some space.
    // Since AN2Linux will default to false if the setting is not found.
    if (!newSettingsValue) {
        sp.edit().remove(key).apply();
    }
}
 
Example #9
Source File: EnabledApplicationsPreferenceFragment.java    From an2linuxclient with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    EnabledApplicationsViewModel viewModel = ViewModelProviders.of(getActivity()).get(EnabledApplicationsViewModel.class);
    viewModel.getFilteredCheckBoxPrefsData().observe(getViewLifecycleOwner(), checkBoxPreferencesData -> {
        setPreferencesFromResource(R.xml.enabled_applications_preferences, null);
        PreferenceScreen prefScreen = (PreferenceScreen) findPreference(getString(R.string.enabled_apps_pref_screen));
        for (CheckBoxPreferenceData checkBoxPreferenceData : checkBoxPreferencesData) {
            CheckBoxPreference c = new CheckBoxPreference(getPreferenceScreen().getContext());
            c.setKey(checkBoxPreferenceData.key);
            c.setTitle(checkBoxPreferenceData.title);
            c.setSummary(checkBoxPreferenceData.summary);
            c.setIcon(checkBoxPreferenceData.icon);
            prefScreen.addPreference(c);
        }
    });
}
 
Example #10
Source File: SettingsActivity.java    From GotoSleep with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onPreferenceStartScreen(androidx.preference.PreferenceFragmentCompat caller, PreferenceScreen pref) {
    final String TAG = "onPreferenceStartScreen";
    SettingsFragment fragment = new SettingsFragment();
    Bundle args = new Bundle();
    args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, pref.getKey());
    fragment.setArguments(args);

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    ft.replace(R.id.fragment, fragment, pref.getKey());
    ft.addToBackStack(pref.getKey());
    ft.commitAllowingStateLoss();

    Log.d(TAG, pref + "");
    return true;
}
 
Example #11
Source File: CommCarePreferenceFragment.java    From commcare-android with Apache License 2.0 6 votes vote down vote up
private void setupLocalizedText() {
    Map<String, String> prefToTitleMap = getPrefKeyTitleMap();
    if (prefToTitleMap != null) {
        PreferenceScreen screen = getPreferenceScreen();
        for (int i = 0; i < screen.getPreferenceCount(); i++) {
            String key = screen.getPreference(i).getKey();
            if (prefToTitleMap.containsKey(key)) {
                try {
                    String localizedString = Localization.get(prefToTitleMap.get(key));
                    screen.getPreference(i).setTitle(localizedString);
                } catch (NoLocalizedTextException nle) {
                    Log.w(TAG, "Unable to localize: " + prefToTitleMap.get(key));
                }
            }
        }
    }
}
 
Example #12
Source File: SettingsFragment.java    From GotoSleep with GNU General Public License v3.0 6 votes vote down vote up
private void advancedPurchased(SharedPreferences sharedPreferences, PreferenceScreen preferenceScreen){
    advancedOptionsPurchased = true;
    sharedPreferences.edit().putBoolean(ADVANCED_PURCHASED_KEY, true).apply();
    preferenceScreen.findPreference(ADS_ENABLED_KEY).setEnabled(false);
    preferenceScreen.findPreference(ADS_ENABLED_KEY).setSummary(getResources().getString(R.string.settingsAdsDisabledSummary));
    preferenceScreen.findPreference("pref_advanced_options").setEnabled(true);
    sharedPreferences.edit().putBoolean(ADS_ENABLED_KEY, false).apply();
    preferenceScreen.findPreference(CUSTOM_NOTIFICATIONS_KEY).setEnabled(true);
    preferenceScreen.findPreference(SMART_NOTIFICATIONS_KEY).setEnabled(true);
    preferenceScreen.findPreference("pref_advanced_purchase").setSummary(getString(R.string.settingsAdvancedPurchasedSummary));
    if (sharedPreferences.getBoolean(SMART_NOTIFICATIONS_KEY, false)){
        preferenceScreen.findPreference(NOTIF_AMOUNT_KEY).setEnabled(false);
    }
    if (sharedPreferences.getBoolean(DND_KEY, false)) {
        preferenceScreen.findPreference(DND_DELAY_KEY).setEnabled(true);
    }
}
 
Example #13
Source File: SettingsFragment.java    From android-popular-movies-app with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {

    // Add movie preferences, defined in the XML file in res->xml->pref_movie
    addPreferencesFromResource(R.xml.pref_movie);

    // Get shared preferences
    SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
    // Get the preference screen
    PreferenceScreen prefScreen = getPreferenceScreen();
    // Get the number of preferences
    int count = prefScreen.getPreferenceCount();

    // Go through all of the preferences, and set up their preference summary.
    for (int i = 0; i < count; i++) {
        Preference p = prefScreen.getPreference(i);

        String value = sharedPreferences.getString(p.getKey(), DEFAULT_VALUE);
        setPreferenceSummary(p, value);
    }
}
 
Example #14
Source File: UserRestrictionsDisplayFragment.java    From android-testdpc with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreatePreferences(Bundle bundle, String rootkey) {
    PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(
            getPreferenceManager().getContext());
    setPreferenceScreen(preferenceScreen);

    final Context preferenceContext = getPreferenceManager().getContext();
    for (UserRestriction restriction : UserRestriction.ALL_USER_RESTRICTIONS) {
        DpcSwitchPreference preference = new DpcSwitchPreference(preferenceContext);
        preference.setTitle(restriction.titleResId);
        preference.setKey(restriction.key);
        preference.setOnPreferenceChangeListener(this);
        preferenceScreen.addPreference(preference);
    }

    updateAllUserRestrictions();
    constrainPreferences();
}
 
Example #15
Source File: SettingsFragment.java    From shortyz with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onPreferenceStartScreen(PreferenceFragmentCompat caller, PreferenceScreen preferenceScreen) {
    try {
        FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
        SettingsFragment fragment = new SettingsFragment();
        Bundle args = new Bundle();
        args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, preferenceScreen.getKey());
        fragment.setArguments(args);
        ft.add(R.id.settings_container, fragment, preferenceScreen.getKey());
        ft.addToBackStack(preferenceScreen.getKey());
        ft.commit();
    } catch(Exception e){
        e.printStackTrace();
        throw e;
    }
    return true;
}
 
Example #16
Source File: UserRestrictionsParentDisplayFragment.java    From android-testdpc with Apache License 2.0 6 votes vote down vote up
@RequiresApi(api = Util.R_VERSION_CODE)
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
    PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(
            getPreferenceManager().getContext());
    setPreferenceScreen(preferenceScreen);

    final Context preferenceContext = getPreferenceManager().getContext();
    for (UserRestriction restriction : UserRestriction.PROFILE_OWNER_ORG_DEVICE_RESTRICTIONS) {
        DpcSwitchPreference preference = new DpcSwitchPreference(preferenceContext);
        preference.setTitle(restriction.titleResId);
        preference.setKey(restriction.key);
        preference.setOnPreferenceChangeListener(this);
        preferenceScreen.addPreference(preference);
    }

    updateAllUserRestrictions();
    constrainPreferences();
}
 
Example #17
Source File: CorrectedPreferenceFragment.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
@SuppressLint("RestrictedApi")
protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
  return new PreferenceGroupAdapter(preferenceScreen) {
    @Override
    public void onBindViewHolder(PreferenceViewHolder holder, int position) {
      super.onBindViewHolder(holder, position);
      Preference preference = getItem(position);
      if (preference instanceof PreferenceCategory) {
        setZeroPaddingToLayoutChildren(holder.itemView);
      } else {
        View iconFrame = holder.itemView.findViewById(R.id.icon_frame);
        if (iconFrame != null) {
          iconFrame.setVisibility(preference.getIcon() == null ? View.GONE : View.VISIBLE);
        }
      }
    }
  };
}
 
Example #18
Source File: SettingsFragment.java    From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void updateNumberOfPacketsSummary() {
	final PreferenceScreen screen = getPreferenceScreen();
	final SharedPreferences preferences = getPreferenceManager().getSharedPreferences();

       String value = preferences.getString(SETTINGS_NUMBER_OF_PACKETS, String.valueOf(SETTINGS_NUMBER_OF_PACKETS_DEFAULT));
       // Security check
       if (TextUtils.isEmpty(value)) {
           value = String.valueOf(SETTINGS_NUMBER_OF_PACKETS_DEFAULT);
           preferences.edit().putString(SETTINGS_NUMBER_OF_PACKETS, value).apply();
       }
       screen.findPreference(SETTINGS_NUMBER_OF_PACKETS).setSummary(value);

	final int valueInt = Integer.parseInt(value);
	if (valueInt > 200 && Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
		new AlertDialog.Builder(requireContext()).setMessage(R.string.dfu_settings_dfu_number_of_packets_info).setTitle(R.string.dfu_settings_dfu_information)
				.setPositiveButton(R.string.ok, null)
				.show();
	}
}
 
Example #19
Source File: AbstractPreferenceFragment.java    From AndroidPreferenceActivity with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
protected final RecyclerView.Adapter<?> onCreateAdapter(
        final PreferenceScreen preferenceScreen) {
    if (adapter == null) {
        adapter = onCreatePreferenceAdapter(preferenceScreen);
    }

    return adapter;
}
 
Example #20
Source File: SettingsFragment.java    From androidtv-Leanback with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onPreferenceStartScreen(PreferenceFragment preferenceFragment,
    PreferenceScreen preferenceScreen) {
    PreferenceFragment frag = buildPreferenceFragment(R.xml.settings,
        preferenceScreen.getKey());
    startPreferenceFragment(frag);
    return true;
}
 
Example #21
Source File: NavigationFragment.java    From AndroidPreferenceActivity with Apache License 2.0 5 votes vote down vote up
@NonNull
protected final PreferenceAdapter onCreatePreferenceAdapter(
        @NonNull final PreferenceScreen preferenceScreen) {
    this.adapter = new NavigationPreferenceAdapter(preferenceScreen, this);
    this.adapter.setSelectionColor(selectionColor);
    this.adapter.setEnabled(enabled);
    notifyOnNavigationAdapterCreated();
    return adapter;
}
 
Example #22
Source File: TalkBackDumpAccessibilityEventActivity.java    From talkback with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
  Context context = getActivity();

  PreferenceSettingsUtils.addPreferencesFromResource(this, R.xml.dump_events_preferences);

  PreferenceScreen screen = getPreferenceScreen();

  for (int eventType : AccessibilityEventUtils.getAllEventTypes()) {
    EventDumperSwitchPreference preference =
        new EventDumperSwitchPreference(context, eventType);
    switchPreferences.add(preference);
    screen.addPreference(preference);
  }
}
 
Example #23
Source File: SettingsFragment.java    From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void updateWheelSizeSummary() {
	final PreferenceScreen screen = getPreferenceScreen();
	final SharedPreferences preferences = getPreferenceManager().getSharedPreferences();

	final String value = preferences.getString(SETTINGS_WHEEL_SIZE, String.valueOf(SETTINGS_WHEEL_SIZE_DEFAULT));
	screen.findPreference(SETTINGS_WHEEL_SIZE).setSummary(getString(R.string.csc_settings_wheel_diameter_summary, value));
}
 
Example #24
Source File: DynamicSettingsActivity.java    From AndroidPreferenceActivity with Apache License 2.0 5 votes vote down vote up
@Override
public final void onRemovePreferenceHeader(final int position) {
    PreferenceScreen preferenceScreen = getNavigationFragment().getPreferenceScreen();
    Preference preference = preferenceScreen.getPreference(position);
    preferenceScreen.removePreference(preference);
    invalidateOptionsMenu();
}
 
Example #25
Source File: PreferenceFragment.java    From Jockey with Apache License 2.0 5 votes vote down vote up
@Override
protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
    return new PreferenceGroupAdapter(preferenceScreen) {
        @Override
        public void onBindViewHolder(PreferenceViewHolder holder, int position) {
            super.onBindViewHolder(holder, position);

            // Override Equalizer preference attachment to add a long click listener
            // and to change the detail text at runtime
            String fragment = getItem(position).getFragment();
            if ("com.marverenic.music.ui.settings.EqualizerFragment".equals(fragment)) {

                ViewGroup itemView = (ViewGroup) holder.itemView;
                TextView title = itemView.findViewById(android.R.id.title);
                TextView detail = itemView.findViewById(android.R.id.summary);

                boolean hasSystemEq = Util.getSystemEqIntent(getContext()) != null;

                if (hasSystemEq && Util.hasEqualizer()) {
                    // If we have Jockey's Equalizer and another Equalizer
                    itemView.setOnLongClickListener(PreferenceFragment.this);
                    detail.setText(R.string.equalizer_more_options_detail);
                    detail.setVisibility(View.VISIBLE);

                } else if (hasSystemEq && !Util.hasEqualizer()) {
                    // If we don't have any equalizers
                    detail.setText(R.string.equalizer_unsupported);
                    detail.setVisibility(View.VISIBLE);
                    itemView.setEnabled(false);
                    title.setEnabled(false);
                    detail.setEnabled(false);
                }
            }
        }
    };
}
 
Example #26
Source File: DeveloperPreferences.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
private Preference[] getOnScreenPrefs() {
    PreferenceScreen prefScreen = getPreferenceScreen();
    Preference[] prefs = new Preference[prefScreen.getPreferenceCount()];
    for (int i = 0; i < prefScreen.getPreferenceCount(); i++) {
        prefs[i] = prefScreen.getPreference(i);
    }
    return prefs;
}
 
Example #27
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 #28
Source File: SettingsFragment.java    From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void updateMBRSize() {
	final PreferenceScreen screen = getPreferenceScreen();
	final SharedPreferences preferences = getPreferenceManager().getSharedPreferences();

	final String value = preferences.getString(SETTINGS_MBR_SIZE, String.valueOf(DfuServiceInitiator.DEFAULT_MBR_SIZE));
	screen.findPreference(SETTINGS_MBR_SIZE).setSummary(value);
}
 
Example #29
Source File: SettingsActivity.java    From AppOpsX with MIT License 5 votes vote down vote up
@Override
protected Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
  return new PreferenceGroupAdapter(preferenceScreen){
    @SuppressLint("RestrictedApi")
    public void onPreferenceHierarchyChange(Preference preference){
      setAllPreferencesToAvoidHavingExtraSpace(preference);
      super.onPreferenceHierarchyChange(preference);
    }
  };
}
 
Example #30
Source File: ScheduleFragment.java    From PresencePublisher with MIT License 5 votes vote down vote up
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
    Context context = getPreferenceManager().getContext();
    PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(context);
    getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(listener);

    Preference messageSchedule = new MessageSchedulePreference(context);
    Preference presenceTopic = new PresenceTopicPreference(context);

    Preference sendBatteryMessage = new SendBatteryMessagePreference(context);
    Preference batteryTopic = new BatteryTopicPreference(context);

    Preference autostart = new AutostartPreference(context);

    lastSuccess = new LastSuccessTimestampPreference(context);
    nextSchedule = new NextScheduleTimestampPreference(context);

    screen.addPreference(messageSchedule);
    screen.addPreference(presenceTopic);
    screen.addPreference(sendBatteryMessage);
    screen.addPreference(batteryTopic);
    screen.addPreference(autostart);
    screen.addPreference(lastSuccess);
    screen.addPreference(nextSchedule);

    setPreferenceScreen(screen);

    batteryTopic.setDependency(SEND_BATTERY_MESSAGE);
}