From 19d54c5c052a93cfe373a58c37bc79fbcb64639b Mon Sep 17 00:00:00 2001 From: massimiliano Date: Tue, 15 Jan 2019 18:32:42 +0100 Subject: [PATCH] pull refresh option+shortcut to themes --- .../activity/SettingsActivity.java | 9 +++++++++ .../dfa/diaspora_android/util/AppSettings.java | 4 ++++ .../diaspora_android/util/DiasporaUrlHelper.java | 10 ++++++++++ .../dfa/diaspora_android/web/BrowserFragment.java | 14 +++++++++++--- .../main/res/values/strings-not_translatable.xml | 2 ++ app/src/main/res/values/strings.xml | 4 ++++ app/src/main/res/xml/preferences__master.xml | 7 +++++++ app/src/main/res/xml/preferences__sub_themes.xml | 7 +++++++ gradle/wrapper/gradle-wrapper.properties | 4 ++-- 9 files changed, 56 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java index acda2b0d..0a38744e 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java @@ -271,6 +271,8 @@ public class SettingsActivity extends ThemedActivity implements SharedPreference @Override public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) { + AppSettings settings = ((App) getActivity().getApplication()).getSettings(); + DiasporaUrlHelper diasporaUrlHelper = new DiasporaUrlHelper(settings); if (isAdded() && preference.hasKey()) { String key = preference.getKey(); if (key.equals(getString(R.string.pref_key__primary_color__preference_click))) { @@ -279,6 +281,13 @@ public class SettingsActivity extends ThemedActivity implements SharedPreference } else if (key.equals(getString(R.string.pref_key__accent_color__preference_click))) { showColorPickerDialog(2); return true; + } else if (key.equals(getString(R.string.pref_key__manage_theme))) { + Intent intent = new Intent(getActivity(), MainActivity.class); + intent.setAction(MainActivity.ACTION_OPEN_URL); + intent.putExtra(MainActivity.URL_MESSAGE, diasporaUrlHelper.getThemeUrl()); + startActivity(intent); + getActivity().finish(); + return true; } } return super.onPreferenceTreeClick(screen, preference); diff --git a/app/src/main/java/com/github/dfa/diaspora_android/util/AppSettings.java b/app/src/main/java/com/github/dfa/diaspora_android/util/AppSettings.java index 8ae76fea..80c672ad 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/util/AppSettings.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/util/AppSettings.java @@ -363,6 +363,10 @@ public class AppSettings extends SharedPreferencesPropertyBackend { return getBool(R.string.pref_key__open_youtube_external_enabled, true); } + public boolean isSwipeRefreshEnabled() { + return getBool(R.string.pref_key__swipe_refresh_enabled, true); + } + public String getScreenRotation() { return getString(R.string.pref_key__screen_rotation, R.string.rotation_val_system); } diff --git a/app/src/main/java/com/github/dfa/diaspora_android/util/DiasporaUrlHelper.java b/app/src/main/java/com/github/dfa/diaspora_android/util/DiasporaUrlHelper.java index a283540b..b272dac0 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/util/DiasporaUrlHelper.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/util/DiasporaUrlHelper.java @@ -62,6 +62,7 @@ public class DiasporaUrlHelper { public static final String SUBURL_NOTIFICATIONS_MENTIONED = "/notifications?type=mentioned"; public static final String SUBURL_NOTIFICATIONS_RESHARED = "/notifications?type=reshared"; public static final String SUBURL_NOTIFICATIONS_STARTED_SHARING = "/notifications?type=started_sharing"; + public static final String SUBURL_THEME = "/user/edit"; public DiasporaUrlHelper(AppSettings settings) { this.settings = settings; @@ -353,4 +354,13 @@ public class DiasporaUrlHelper { } return app.getString(R.string.aspects); } + + /** + * Return a url that points to the settings of the pod. + * + * @return https://(pod-domain.tld)/user/edit + */ + public String getThemeUrl() { + return getPodUrl() + SUBURL_THEME; + } } diff --git a/app/src/main/java/com/github/dfa/diaspora_android/web/BrowserFragment.java b/app/src/main/java/com/github/dfa/diaspora_android/web/BrowserFragment.java index d28716d4..02ff9d3c 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/web/BrowserFragment.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/web/BrowserFragment.java @@ -94,9 +94,17 @@ public class BrowserFragment extends ThemedFragment { this.setRetainInstance(true); //pull to refresh - swipe = view.findViewById(R.id.swipe); - swipe.setOnRefreshListener(() -> reloadUrl()); - swipe.setDistanceToTriggerSync(2000); + swipe = view.findViewById( R.id.swipe ); + swipe.setDistanceToTriggerSync( 2000 ); + swipe.setOnRefreshListener( () -> reloadUrl() ); + if (appSettings.isSwipeRefreshEnabled()){ + swipe.setEnabled( true ); + + }else { + swipe.setRefreshing(false); + swipe.setEnabled( false ); + return; + } } @Override diff --git a/app/src/main/res/values/strings-not_translatable.xml b/app/src/main/res/values/strings-not_translatable.xml index c66a18d4..7ffbe26a 100644 --- a/app/src/main/res/values/strings-not_translatable.xml +++ b/app/src/main/res/values/strings-not_translatable.xml @@ -149,4 +149,6 @@ PDF gsantner pref_key__open_youtube_external_enabled + pref_key_manage_theme + pref_key__swipe_refresh_enabled diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6c542f21..e612a34e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -255,5 +255,9 @@ Tell me more Enable to open Youtube links on external app Youtube links + Change the theme of your channel + Hubzilla theme settings + Pull to refresh + Pulling down on top of page to refresh.\nYou need to restart the app for changes to take effect. diff --git a/app/src/main/res/xml/preferences__master.xml b/app/src/main/res/xml/preferences__master.xml index c1ab7939..f5a11a42 100644 --- a/app/src/main/res/xml/preferences__master.xml +++ b/app/src/main/res/xml/preferences__master.xml @@ -103,6 +103,13 @@ android:summary="@string/control_screen_rotation" android:title="@string/screen_rotation"/> + + diff --git a/app/src/main/res/xml/preferences__sub_themes.xml b/app/src/main/res/xml/preferences__sub_themes.xml index ec5a5e00..92217ce2 100644 --- a/app/src/main/res/xml/preferences__sub_themes.xml +++ b/app/src/main/res/xml/preferences__sub_themes.xml @@ -21,5 +21,12 @@ android:summary="@string/amoled_mode_description__app_specific" android:title="@string/amoled_mode" android:icon="@drawable/ic_color_lens_black_24px" /> + + + \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 18a0cf95..a60ade83 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun Apr 08 08:39:15 CEST 2018 +#Tue Jan 15 17:52:59 CET 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip