allow SDCard/TreeUri scans to be manually triggered by user button press
Before, the preference blocked all scans. That lead to confusing UX since the "Try it" and USB-OTG buttons would do nothing.
This commit is contained in:
parent
6af66abf54
commit
8209bf9a0b
@ -28,11 +28,10 @@ import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.os.Process;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import android.util.Log;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import org.fdroid.fdroid.IndexUpdater;
|
||||
import org.fdroid.fdroid.IndexV1Updater;
|
||||
import org.fdroid.fdroid.Preferences;
|
||||
import org.fdroid.fdroid.Utils;
|
||||
|
||||
import java.io.File;
|
||||
@ -55,7 +54,7 @@ import java.util.List;
|
||||
* "External Storage"
|
||||
* <p>
|
||||
* Scanning the removable storage requires that the user allowed it. This
|
||||
* requires both the {@link Preferences#isScanRemovableStorageEnabled()}
|
||||
* requires both the {@link org.fdroid.fdroid.Preferences#isScanRemovableStorageEnabled()}
|
||||
* and the {@link android.Manifest.permission#READ_EXTERNAL_STORAGE}
|
||||
* permission to be enabled.
|
||||
*
|
||||
@ -75,11 +74,9 @@ public class SDCardScannerService extends IntentService {
|
||||
}
|
||||
|
||||
public static void scan(Context context) {
|
||||
if (Preferences.get().isScanRemovableStorageEnabled()) {
|
||||
Intent intent = new Intent(context, SDCardScannerService.class);
|
||||
intent.setAction(ACTION_SCAN);
|
||||
context.startService(intent);
|
||||
}
|
||||
Intent intent = new Intent(context, SDCardScannerService.class);
|
||||
intent.setAction(ACTION_SCAN);
|
||||
context.startService(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,7 +20,6 @@
|
||||
package org.fdroid.fdroid.nearby;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.IntentService;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
@ -28,15 +27,14 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Process;
|
||||
import androidx.documentfile.provider.DocumentFile;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
import androidx.documentfile.provider.DocumentFile;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.fdroid.fdroid.AddRepoIntentService;
|
||||
import org.fdroid.fdroid.IndexUpdater;
|
||||
import org.fdroid.fdroid.IndexV1Updater;
|
||||
import org.fdroid.fdroid.Preferences;
|
||||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.Utils;
|
||||
import org.fdroid.fdroid.data.Repo;
|
||||
@ -82,12 +80,10 @@ public class TreeUriScannerIntentService extends IntentService {
|
||||
}
|
||||
|
||||
public static void scan(Context context, Uri data) {
|
||||
if (Preferences.get().isScanRemovableStorageEnabled()) {
|
||||
Intent intent = new Intent(context, TreeUriScannerIntentService.class);
|
||||
intent.setAction(ACTION_SCAN_TREE_URI);
|
||||
intent.setData(data);
|
||||
context.startService(intent);
|
||||
}
|
||||
Intent intent = new Intent(context, TreeUriScannerIntentService.class);
|
||||
intent.setAction(ACTION_SCAN_TREE_URI);
|
||||
intent.setData(data);
|
||||
context.startService(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -539,7 +539,9 @@ public class FDroidApp extends Application {
|
||||
atStartTime.edit().remove(queryStringKey).apply();
|
||||
}
|
||||
|
||||
SDCardScannerService.scan(this);
|
||||
if (Preferences.get().isScanRemovableStorageEnabled()) {
|
||||
SDCardScannerService.scan(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user