Skip to content

Commit

Permalink
Use preference to store whether the user was asked for consent regard…
Browse files Browse the repository at this point in the history
…ing update checks
  • Loading branch information
TobiGr committed Mar 23, 2024
1 parent feb5f25 commit 2fbe9c0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/src/main/java/org/schabi/newpipe/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ protected void onCreate(final Bundle savedInstanceState) {
// if this is enabled by the user.
NotificationWorker.initialize(this);
}
if (App.getApp().isFirstRun() && ReleaseVersionUtil.INSTANCE.isReleaseApk()) {
if (!UpdateSettingsFragment.wasUserAskedForConsent(this)
&& ReleaseVersionUtil.INSTANCE.isReleaseApk()) {
UpdateSettingsFragment.askForConsentToUpdateChecks(this);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ private static void setAutoUpdateCheckEnabled(final Context context, final boole
PreferenceManager.getDefaultSharedPreferences(context)
.edit()
.putBoolean(context.getString(R.string.update_app_key), enabled)
.putBoolean(context.getString(R.string.update_check_consent_key), true)
.apply();
}

/**
* Whether the user was asked for consent to automatically check for app updates.
* @param context
* @return true if the user was asked for consent, false otherwise
*/
public static boolean wasUserAskedForConsent(final Context context) {
return PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(context.getString(R.string.update_check_consent_key), false);
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values/settings_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@
</string-array>

<!-- Updates -->
<string name="update_check_consent_key">update_check_consent_key</string>
<string name="update_app_key">update_app_key</string>
<string name="manual_update_key">manual_update_key</string>
<string name="update_pref_screen_key">update_pref_screen_key</string>
Expand Down

0 comments on commit 2fbe9c0

Please sign in to comment.