mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-03 07:21:29 +01:00
Add Check for updates button
This commit is contained in:
parent
7067deb328
commit
85fb5827aa
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -383,6 +383,7 @@
|
||||
|
||||
<!-- Updates -->
|
||||
<string name="update_app_key" translatable="false">update_app_key</string>
|
||||
<string name="manual_update_key">manual_update_key</string>
|
||||
<string name="update_pref_screen_key" translatable="false">update_pref_screen_key</string>
|
||||
<string name="update_expiry_key" translatable="false">update_expiry_key</string>
|
||||
|
||||
|
@ -517,6 +517,8 @@
|
||||
<!-- Updates Settings -->
|
||||
<string name="updates_setting_title">Updates</string>
|
||||
<string name="updates_setting_description">Show a notification to prompt app update when a new version is available</string>
|
||||
<string name="manual_update_title">Check for updates</string>
|
||||
<string name="manual_update_description">Manually check for new versions</string>
|
||||
<!-- Minimize to exit action -->
|
||||
<string name="minimize_on_exit_title">Minimize on app switch</string>
|
||||
<string name="minimize_on_exit_summary">Action when switching to other app from main video player — %s</string>
|
||||
|
@ -12,4 +12,11 @@
|
||||
app:singleLineTitle="false"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<Preference
|
||||
android:key="@string/manual_update_key"
|
||||
android:summary="@string/manual_update_description"
|
||||
android:title="@string/manual_update_title"
|
||||
app:singleLineTitle="false"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
Loading…
Reference in New Issue
Block a user