Add default global pref description

This commit is contained in:
Chumva 2019-09-23 16:34:42 +03:00
parent 17d2ecc67c
commit e681b8089f
2 changed files with 31 additions and 0 deletions

View file

@ -11,6 +11,7 @@
Thx - Hardy
-->
<string name="shared_string_by_default">By default</string>
<string name="plugins_settings">Plugin settings</string>
<string name="logcat_buffer">Logcat buffer</string>
<string name="application_profile_changed">Application profile changed to \"%s\"</string>

View file

@ -8,20 +8,26 @@ import android.support.annotation.NonNull;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AlertDialog;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.support.v7.preference.TwoStatePreference;
import android.support.v7.widget.AppCompatCheckedTextView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.settings.bottomsheets.ChangeGeneralProfilesPrefBottomSheet;
import net.osmand.plus.settings.preferences.ListPreferenceEx;
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
import net.osmand.plus.widgets.style.CustomTypefaceSpan;
import java.util.ArrayList;
import java.util.Arrays;
@ -82,6 +88,30 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
setupExternalInputDevicePref();
}
@Override
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
super.onBindPreferenceViewHolder(preference, holder);
OsmandSettings.OsmandPreference osmandPreference = settings.getPreference(preference.getKey());
TextView summaryView = (TextView) holder.findViewById(android.R.id.summary);
if (osmandPreference != null && summaryView != null) {
CharSequence summary = null;
if (preference instanceof TwoStatePreference) {
TwoStatePreference statePreference = (TwoStatePreference) preference;
summary = statePreference.isChecked() ? statePreference.getSummaryOn() : statePreference.getSummaryOff();
}
if (TextUtils.isEmpty(summary)) {
summary = preference.getSummary();
}
if (!osmandPreference.isSetForMode(getSelectedAppMode())) {
String baseString = getString(R.string.shared_string_by_default) + ": %s";
summary = AndroidUtils.getStyledString(baseString, summary, new CustomTypefaceSpan(FontCache.getRobotoMedium(app)), null);
}
summaryView.setText(summary);
}
}
private void setupAppThemePref() {
final ListPreferenceEx appTheme = (ListPreferenceEx) findPreference(settings.OSMAND_THEME.getId());
appTheme.setEntries(new String[] {getString(R.string.dark_theme), getString(R.string.light_theme)});