Skip to content

Commit

Permalink
Ask for consent before starting update checks
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
TobiGr committed Jan 25, 2024
1 parent 03977fb commit 185211d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/src/main/java/org/schabi/newpipe/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
public class App extends Application {
public static final String PACKAGE_NAME = BuildConfig.APPLICATION_ID;
private static final String TAG = App.class.toString();

public boolean isFirstRun = false;
private static App app;

@NonNull
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/org/schabi/newpipe/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,15 @@
import org.schabi.newpipe.player.event.OnKeyDownListener;
import org.schabi.newpipe.player.helper.PlayerHolder;
import org.schabi.newpipe.player.playqueue.PlayQueue;
import org.schabi.newpipe.settings.UpdateSettingsFragment;
import org.schabi.newpipe.util.Constants;
import org.schabi.newpipe.util.DeviceUtils;
import org.schabi.newpipe.util.KioskTranslator;
import org.schabi.newpipe.util.Localization;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.PeertubeHelper;
import org.schabi.newpipe.util.PermissionHelper;
import org.schabi.newpipe.util.ReleaseVersionUtil;
import org.schabi.newpipe.util.SerializedCache;
import org.schabi.newpipe.util.ServiceHelper;
import org.schabi.newpipe.util.StateSaver;
Expand Down Expand Up @@ -167,6 +169,9 @@ protected void onCreate(final Bundle savedInstanceState) {
// if this is enabled by the user.
NotificationWorker.initialize(this);
}
if (App.getApp().isFirstRun && ReleaseVersionUtil.isReleaseApk()) {
UpdateSettingsFragment.askForConsentToUpdateChecks(this);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import androidx.annotation.StringRes;
import androidx.preference.PreferenceManager;

import org.schabi.newpipe.App;
import org.schabi.newpipe.R;
import org.schabi.newpipe.util.DeviceUtils;

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

// first run migrations, then setDefaultValues, since the latter requires the correct types
SettingMigrations.runMigrationsIfNeeded(context, isFirstRun);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package org.schabi.newpipe.settings;

import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.Toast;

import androidx.preference.Preference;
import androidx.preference.PreferenceManager;

import org.schabi.newpipe.NewVersionWorker;
import org.schabi.newpipe.R;
Expand Down Expand Up @@ -36,4 +39,19 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro
findPreference(getString(R.string.manual_update_key))
.setOnPreferenceClickListener(manualUpdateClick);
}

public static void askForConsentToUpdateChecks(final Context context) {
new AlertDialog.Builder(context)
.setTitle(context.getString(R.string.check_for_updates))
.setMessage(context.getString(R.string.auto_update_check_description))
.setPositiveButton(context.getString(R.string.ok), (d, w) -> {
d.dismiss();
PreferenceManager.getDefaultSharedPreferences(context)
.edit()
.putBoolean(context.getString(R.string.update_app_key), true)
.apply();
})
.setNegativeButton(R.string.cancel, (d, w) -> d.dismiss())
.show();
}
}
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,10 @@
<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="check_for_updates">Check for updates</string>
<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>
<string name="manual_update_title" translatable="false">@string/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>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/update_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:title="@string/settings_category_updates_title">

<SwitchPreferenceCompat
android:defaultValue="true"
android:defaultValue="false"
android:key="@string/update_app_key"
android:summary="@string/updates_setting_description"
android:title="@string/updates_setting_title"
Expand Down

0 comments on commit 185211d

Please sign in to comment.