Skip to content

Commit 185211d

Browse files
committed
Ask for consent before starting update checks
NewPipe is contacting its servers without asking for the users' contensent. This is categorized as "tracking" by F-Droid (see #10785). This commit disabled checking for udpates by default and adds an AlertDialog asking for the user's consent if the app version is eligable for them.
1 parent 03977fb commit 185211d

File tree

6 files changed

+30
-1
lines changed

6 files changed

+30
-1
lines changed

app/src/main/java/org/schabi/newpipe/App.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
public class App extends Application {
6161
public static final String PACKAGE_NAME = BuildConfig.APPLICATION_ID;
6262
private static final String TAG = App.class.toString();
63+
64+
public boolean isFirstRun = false;
6365
private static App app;
6466

6567
@NonNull

app/src/main/java/org/schabi/newpipe/MainActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,15 @@
7979
import org.schabi.newpipe.player.event.OnKeyDownListener;
8080
import org.schabi.newpipe.player.helper.PlayerHolder;
8181
import org.schabi.newpipe.player.playqueue.PlayQueue;
82+
import org.schabi.newpipe.settings.UpdateSettingsFragment;
8283
import org.schabi.newpipe.util.Constants;
8384
import org.schabi.newpipe.util.DeviceUtils;
8485
import org.schabi.newpipe.util.KioskTranslator;
8586
import org.schabi.newpipe.util.Localization;
8687
import org.schabi.newpipe.util.NavigationHelper;
8788
import org.schabi.newpipe.util.PeertubeHelper;
8889
import org.schabi.newpipe.util.PermissionHelper;
90+
import org.schabi.newpipe.util.ReleaseVersionUtil;
8991
import org.schabi.newpipe.util.SerializedCache;
9092
import org.schabi.newpipe.util.ServiceHelper;
9193
import org.schabi.newpipe.util.StateSaver;
@@ -167,6 +169,9 @@ protected void onCreate(final Bundle savedInstanceState) {
167169
// if this is enabled by the user.
168170
NotificationWorker.initialize(this);
169171
}
172+
if (App.getApp().isFirstRun && ReleaseVersionUtil.isReleaseApk()) {
173+
UpdateSettingsFragment.askForConsentToUpdateChecks(this);
174+
}
170175
}
171176

172177
@Override

app/src/main/java/org/schabi/newpipe/settings/NewPipeSettings.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import androidx.annotation.StringRes;
1212
import androidx.preference.PreferenceManager;
1313

14+
import org.schabi.newpipe.App;
1415
import org.schabi.newpipe.R;
1516
import org.schabi.newpipe.util.DeviceUtils;
1617

@@ -49,6 +50,7 @@ public static void initSettings(final Context context) {
4950
final int lastUsedPrefVersion = PreferenceManager.getDefaultSharedPreferences(context)
5051
.getInt(context.getString(R.string.last_used_preferences_version), -1);
5152
final boolean isFirstRun = lastUsedPrefVersion == -1;
53+
App.getApp().isFirstRun = isFirstRun;
5254

5355
// first run migrations, then setDefaultValues, since the latter requires the correct types
5456
SettingMigrations.runMigrationsIfNeeded(context, isFirstRun);

app/src/main/java/org/schabi/newpipe/settings/UpdateSettingsFragment.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package org.schabi.newpipe.settings;
22

3+
import android.app.AlertDialog;
4+
import android.content.Context;
35
import android.os.Bundle;
46
import android.widget.Toast;
57

68
import androidx.preference.Preference;
9+
import androidx.preference.PreferenceManager;
710

811
import org.schabi.newpipe.NewVersionWorker;
912
import org.schabi.newpipe.R;
@@ -36,4 +39,19 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro
3639
findPreference(getString(R.string.manual_update_key))
3740
.setOnPreferenceClickListener(manualUpdateClick);
3841
}
42+
43+
public static void askForConsentToUpdateChecks(final Context context) {
44+
new AlertDialog.Builder(context)
45+
.setTitle(context.getString(R.string.check_for_updates))
46+
.setMessage(context.getString(R.string.auto_update_check_description))
47+
.setPositiveButton(context.getString(R.string.ok), (d, w) -> {
48+
d.dismiss();
49+
PreferenceManager.getDefaultSharedPreferences(context)
50+
.edit()
51+
.putBoolean(context.getString(R.string.update_app_key), true)
52+
.apply();
53+
})
54+
.setNegativeButton(R.string.cancel, (d, w) -> d.dismiss())
55+
.show();
56+
}
3957
}

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,10 @@
556556
<string name="updates_setting_title">Updates</string>
557557
<string name="updates_setting_description">Show a notification to prompt app update when a new version is available</string>
558558
<string name="check_for_updates">Check for updates</string>
559+
<string name="auto_update_check_description">NewPipe can automatically check for new versions from time to time and notify you once they are available.</string>
559560
<string name="manual_update_title" translatable="false">@string/check_for_updates</string>
560561
<string name="manual_update_description">Manually check for new versions</string>
562+
561563
<!-- Minimize to exit action -->
562564
<string name="minimize_on_exit_title">Minimize on app switch</string>
563565
<string name="minimize_on_exit_summary">Action when switching to other app from main video player — %s</string>

app/src/main/res/xml/update_settings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
android:title="@string/settings_category_updates_title">
55

66
<SwitchPreferenceCompat
7-
android:defaultValue="true"
7+
android:defaultValue="false"
88
android:key="@string/update_app_key"
99
android:summary="@string/updates_setting_description"
1010
android:title="@string/updates_setting_title"

0 commit comments

Comments
 (0)