From 85fb5827aa30fb5f849b107e192e8529c0f1290b Mon Sep 17 00:00:00 2001 From: vhouriet Date: Fri, 22 Oct 2021 21:07:53 +0200 Subject: [PATCH] Add Check for updates button --- .../newpipe/settings/MainSettingsFragment.java | 7 +++++-- .../newpipe/settings/UpdateSettingsFragment.java | 13 +++++++++++++ app/src/main/res/values/settings_keys.xml | 1 + app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/update_settings.xml | 7 +++++++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/settings/MainSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/MainSettingsFragment.java index 2f65af4d6..0eebfb5a2 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/MainSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/MainSettingsFragment.java @@ -17,8 +17,11 @@ public class MainSettingsFragment extends BasePreferenceFragment { addPreferencesFromResource(R.xml.main_settings); if (!CheckForNewAppVersion.isGithubApk(App.getApp())) { - final Preference update = findPreference(getString(R.string.update_pref_screen_key)); - getPreferenceScreen().removePreference(update); + if (!DEBUG) { + final Preference update + = findPreference(getString(R.string.update_pref_screen_key)); + getPreferenceScreen().removePreference(update); + } defaultPreferences.edit().putBoolean(getString(R.string.update_app_key), false).apply(); } diff --git a/app/src/main/java/org/schabi/newpipe/settings/UpdateSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/UpdateSettingsFragment.java index d2f56b487..0fdf96757 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/UpdateSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/UpdateSettingsFragment.java @@ -1,5 +1,7 @@ package org.schabi.newpipe.settings; +import android.content.Intent; +import android.net.Uri; import android.os.Bundle; import androidx.preference.Preference; @@ -9,6 +11,8 @@ import org.schabi.newpipe.R; import static org.schabi.newpipe.CheckForNewAppVersion.startNewVersionCheckService; public class UpdateSettingsFragment extends BasePreferenceFragment { + private static final String RELEASES_URL = "https://github.com/TeamNewPipe/NewPipe/releases"; + private final Preference.OnPreferenceChangeListener updatePreferenceChange = (preference, checkForUpdates) -> { defaultPreferences.edit() @@ -24,11 +28,20 @@ public class UpdateSettingsFragment extends BasePreferenceFragment { return true; }; + private final Preference.OnPreferenceClickListener manualUpdateClick + = preference -> { + final Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(RELEASES_URL)); + startActivity(browserIntent); + return true; + }; + @Override public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) { addPreferencesFromResource(R.xml.update_settings); final String updateToggleKey = getString(R.string.update_app_key); + final String manualUpdateKey = getString(R.string.manual_update_key); findPreference(updateToggleKey).setOnPreferenceChangeListener(updatePreferenceChange); + findPreference(manualUpdateKey).setOnPreferenceClickListener(manualUpdateClick); } } diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 9489ef543..1c57178b4 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -383,6 +383,7 @@ update_app_key + manual_update_key update_pref_screen_key update_expiry_key diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 897ec0af8..9ab2d2643 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -517,6 +517,8 @@ Updates Show a notification to prompt app update when a new version is available + Check for updates + Manually check for new versions Minimize on app switch Action when switching to other app from main video player — %s diff --git a/app/src/main/res/xml/update_settings.xml b/app/src/main/res/xml/update_settings.xml index adaa47352..ef121ec4e 100644 --- a/app/src/main/res/xml/update_settings.xml +++ b/app/src/main/res/xml/update_settings.xml @@ -12,4 +12,11 @@ app:singleLineTitle="false" app:iconSpaceReserved="false" /> + +