Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance weather view settings: Use checkbox instead of dialog #1257

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ public class PreferencesActivity extends PreferenceActivity

ListPreference preferredUnits;
ListPreference preferredTempUnits;
ListPreference showWeatherDisplayPref;

ListPreference mThemePref;

Expand Down Expand Up @@ -192,9 +191,6 @@ public void onCreate(Bundle savedInstanceState) {
preferredTempUnits = (ListPreference) findPreference(
getString(R.string.preference_key_preferred_temperature_units));

showWeatherDisplayPref = (ListPreference) findPreference(
getString(R.string.preference_key_show_weather_view));

mThemePref = (ListPreference) findPreference(
getString(R.string.preference_key_app_theme));
mThemePref.setOnPreferenceChangeListener(this);
Expand Down Expand Up @@ -250,7 +246,6 @@ protected void onResume() {
changePreferenceSummary(getString(R.string.preference_key_region));
changePreferenceSummary(getString(R.string.preference_key_preferred_units));
changePreferenceSummary(getString(R.string.preference_key_preferred_temperature_units));
changePreferenceSummary(getString(R.string.preference_key_show_weather_view));
changePreferenceSummary(getString(R.string.preference_key_app_theme));
changePreferenceSummary(getString(R.string.preference_key_otp_api_url));

Expand Down Expand Up @@ -332,8 +327,6 @@ private void changePreferenceSummary(String preferenceKey) {
}else if (preferenceKey
.equalsIgnoreCase(getString(R.string.preference_key_preferred_temperature_units))) {
preferredTempUnits.setSummary(preferredTempUnits.getValue());
}else if(preferenceKey.equalsIgnoreCase(getString(R.string.preference_key_show_weather_view))){
showWeatherDisplayPref.setSummary(showWeatherDisplayPref.getValue());
}
}

Expand Down Expand Up @@ -574,9 +567,6 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
}else if (key.equalsIgnoreCase(getString(R.string.preference_key_preferred_temperature_units))) {
// Change the preferred temp unit description
changePreferenceSummary(key);
}else if (key.equalsIgnoreCase(getString(R.string.preference_key_show_weather_view))) {
// Change the preferred weather show or hide option
changePreferenceSummary(key);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,8 @@ public static void setWeatherTemp(TextView weatherTempTxtView, double temp) {

public static boolean isWeatherViewHiddenPref() {
Application app = Application.get();
SharedPreferences sharedPreferences = Application.getPrefs();

String showOption = app.getString(R.string.show);
String pref = sharedPreferences.getString(app.getString(R.string.preference_key_show_weather_view), showOption);

return (!pref.equals(showOption));
boolean isWeatherViewEnabled = Application.getPrefs().getBoolean(app.getString(R.string.preference_key_display_weather_view), true);
return (!isWeatherViewEnabled);
}

public static void toggleWeatherViewVisibility(boolean shouldShow, View weatherView) {
Expand Down
1 change: 1 addition & 0 deletions onebusaway-android/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1118,4 +1118,5 @@
<string name="remind_me_latter">Recordármelo más tarde</string>
<string name="survey_dismiss_dialog_skip_this_survey">Omitir esta encuesta</string>
<string name="dismiss_survey_dialog_body">Tu opinión ayuda a mejorar los servicios de tránsito y las experiencias en la aplicación.</string>
<string name="preferences_show_weather_view_on_map">Mostrar la vista del clima en el mapa</string>
</resources>
1 change: 1 addition & 0 deletions onebusaway-android/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -715,4 +715,5 @@
<string name="remind_me_latter">Muistuta myöhemmin</string>
<string name="survey_dismiss_dialog_skip_this_survey">Ohita tämä kysely</string>
<string name="dismiss_survey_dialog_body">Palautteesi auttaa parantamaan liikennepalveluja ja sovelluskokemuksia.</string>
<string name="preferences_show_weather_view_on_map">Näytä säätiedot kartalla</string>
</resources>
1 change: 1 addition & 0 deletions onebusaway-android/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1029,4 +1029,5 @@
<string name="remind_me_latter">Ricordamelo più tardi</string>
<string name="survey_dismiss_dialog_skip_this_survey">Salta questo sondaggio</string>
<string name="dismiss_survey_dialog_body">Il tuo feedback aiuta a migliorare i servizi di trasporto e le esperienze con l\'app.</string>
<string name="preferences_show_weather_view_on_map">Mostra la vista del meteo sulla mappa</string>
</resources>
1 change: 1 addition & 0 deletions onebusaway-android/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -735,4 +735,5 @@
<string name="remind_me_later">Przypomnij mi później</string>
<string name="survey_dismiss_dialog_skip_this_survey">Pomiń tę ankietę</string>
<string name="dismiss_survey_dialog_body">Twoja opinia pomoże w poprawie usług transportowych i doświadczeń z aplikacją.</string>
<string name="preferences_show_weather_view_on_map">Wyświetl widok pogody na mapie</string>
</resources>
4 changes: 0 additions & 4 deletions onebusaway-android/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@
<item>@string/fahrenheit</item>
<item>@string/celsius</item>
</string-array>
<string-array name="preferred_weather_view_option">
<item>@string/show</item>
<item>@string/hide</item>
</string-array>
<string-array name="app_theme_options">
<item>@string/preferences_app_theme_option_system_default</item>
<item>@string/preferences_app_theme_option_light</item>
Expand Down
2 changes: 1 addition & 1 deletion onebusaway-android/src/main/res/values/donottranslate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<string name="preferences_key_about">preference_about</string>
<string name="preference_key_preferred_units">preference_preferred_units</string>
<string name="preference_key_preferred_temperature_units">preference_preferred_temperature_units</string>
<string name="preference_key_show_weather_view">preference_key_show_weather_view</string>
<string name="preference_key_display_weather_view">preference_key_display_weather_view</string>
<string name="preference_key_app_theme">preference_app_theme</string>
<string name="preference_key_arrival_info_style">preference_arrival_info_style</string>
<string name="preference_key_show_negative_arrivals">preference_show_negative_arrivals</string>
Expand Down
1 change: 1 addition & 0 deletions onebusaway-android/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1267,4 +1267,5 @@
<string name="remind_me_latter">Remind Me Later</string>
<string name="survey_dismiss_dialog_skip_this_survey">Skip This Survey</string>
<string name="dismiss_survey_dialog_body">Your feedback helps improve transit services and app experiences.</string>
<string name="preferences_show_weather_view_on_map">Display the weather view on the map</string>
</resources>
14 changes: 6 additions & 8 deletions onebusaway-android/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
android:summary="@string/preferences_enable_map_3d_mode_summary"
android:title="@string/preferences_enable_map_3d_mode_title" />

<CheckBoxPreference
android:defaultValue="true"
android:key="@string/preference_key_display_weather_view"
android:summary="@string/preferences_show_weather_view_on_map"
android:title="@string/preferences_show_weather_view" />

<CheckBoxPreference
android:defaultValue="true"
android:key="@string/preference_key_show_available_studies"
Expand Down Expand Up @@ -90,14 +96,6 @@
android:key="@string/preference_key_preferred_temperature_units"
android:title="@string/preferred_temperature_unit" />

<ListPreference
android:defaultValue="@string/show"
android:negativeButtonText="@string/close"
android:entries="@array/preferred_weather_view_option"
android:entryValues="@array/preferred_weather_view_option"
android:key="@string/preference_key_show_weather_view"
android:title="@string/preferences_show_weather_view" />

<ListPreference
android:defaultValue="@string/preferences_app_theme_option_system_default"
android:negativeButtonText="@string/close"
Expand Down
Loading