Merge branch 'more-clean-up-towards-usb-swap' into 'master'
More clean up towards usb swap See merge request fdroid/fdroidclient!664
This commit is contained in:
commit
2d0168215e
@ -82,8 +82,7 @@ public class IndexV1Updater extends RepoUpdater {
|
||||
Downloader downloader = null;
|
||||
try {
|
||||
// read file name from file
|
||||
final Uri dataUri = Uri.parse(indexUrl);
|
||||
downloader = DownloaderFactory.create(context, dataUri.toString());
|
||||
downloader = DownloaderFactory.create(context, indexUrl);
|
||||
downloader.setCacheTag(repo.lastetag);
|
||||
downloader.setListener(downloadListener);
|
||||
downloader.download();
|
||||
@ -108,8 +107,7 @@ public class IndexV1Updater extends RepoUpdater {
|
||||
try {
|
||||
mirrorUrl = FDroidApp.getMirror(prevMirrorUrl, repo);
|
||||
prevMirrorUrl = mirrorUrl;
|
||||
Uri dataUri2 = Uri.parse(mirrorUrl);
|
||||
downloader = DownloaderFactory.create(context, dataUri2.toString());
|
||||
downloader = DownloaderFactory.create(context, mirrorUrl);
|
||||
downloader.setCacheTag(repo.lastetag);
|
||||
downloader.setListener(downloadListener);
|
||||
downloader.setTimeout(FDroidApp.getTimeout());
|
||||
|
@ -225,10 +225,8 @@ public class InstalledAppProvider extends FDroidProvider {
|
||||
QuerySelection query = new QuerySelection(where, whereArgs);
|
||||
query = query.add(queryAppSubQuery(packageName));
|
||||
|
||||
Utils.debugLog(TAG, "Deleting " + packageName);
|
||||
int count = db().delete(getTableName(), query.getSelection(), query.getArgs());
|
||||
|
||||
Utils.debugLog(TAG, "Requesting the suggested apk get recalculated for " + packageName);
|
||||
AppProvider.Helper.calcSuggestedApk(getContext(), packageName);
|
||||
|
||||
return count;
|
||||
@ -252,10 +250,8 @@ public class InstalledAppProvider extends FDroidProvider {
|
||||
|
||||
verifyVersionNameNotNull(values);
|
||||
|
||||
Utils.debugLog(TAG, "Inserting/updating " + packageName);
|
||||
db().replaceOrThrow(getTableName(), null, values);
|
||||
|
||||
Utils.debugLog(TAG, "Requesting the suggested apk get recalculated for " + packageName);
|
||||
AppProvider.Helper.calcSuggestedApk(getContext(), packageName);
|
||||
|
||||
return getAppUri(values.getAsString(Cols.Package.NAME));
|
||||
|
@ -10,7 +10,6 @@ import android.content.pm.Signature;
|
||||
import android.net.Uri;
|
||||
import android.os.Process;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
import org.acra.ACRA;
|
||||
import org.fdroid.fdroid.AppUpdateStatusManager;
|
||||
import org.fdroid.fdroid.Hasher;
|
||||
@ -221,7 +220,6 @@ public class InstalledAppProviderService extends IntentService {
|
||||
if (ACTION_INSERT.equals(action)) {
|
||||
PackageInfo packageInfo = getPackageInfo(intent, packageName);
|
||||
if (packageInfo != null) {
|
||||
Log.i(TAG, "Marking " + packageName + " as installed");
|
||||
File apk = getPathToInstalledApk(packageInfo);
|
||||
if (apk == null) {
|
||||
return;
|
||||
@ -255,7 +253,6 @@ public class InstalledAppProviderService extends IntentService {
|
||||
}
|
||||
}
|
||||
} else if (ACTION_DELETE.equals(action)) {
|
||||
Log.i(TAG, "Marking " + packageName + " as no longer installed");
|
||||
deleteAppFromDb(this, packageName);
|
||||
}
|
||||
packageChangeNotifier.onNext(packageName);
|
||||
|
@ -20,19 +20,14 @@ public class DownloaderFactory {
|
||||
throws IOException {
|
||||
File destFile = File.createTempFile("dl-", "", context.getCacheDir());
|
||||
destFile.deleteOnExit(); // this probably does nothing, but maybe...
|
||||
return create(context, urlString, destFile);
|
||||
Uri uri = Uri.parse(urlString);
|
||||
return create(context, uri, destFile);
|
||||
}
|
||||
|
||||
public static Downloader create(Context context, Uri uri, File destFile)
|
||||
throws IOException {
|
||||
return create(context, uri.toString(), destFile);
|
||||
}
|
||||
|
||||
public static Downloader create(Context context, String urlString, File destFile)
|
||||
throws IOException {
|
||||
Downloader downloader;
|
||||
|
||||
Uri uri = Uri.parse(urlString);
|
||||
String scheme = uri.getScheme();
|
||||
if ("bluetooth".equals(scheme)) {
|
||||
downloader = new BluetoothDownloader(uri, destFile);
|
||||
|
@ -241,7 +241,8 @@ public class ManageReposActivity extends AppCompatActivity
|
||||
for (String url : repo.getMirrorList()) {
|
||||
urlRepoMap.put(url, repo);
|
||||
}
|
||||
if (TextUtils.equals(getRepoType(newAddress), getRepoType(repo.address))) {
|
||||
if (!TextUtils.isEmpty(repo.fingerprint)
|
||||
&& TextUtils.equals(getRepoType(newAddress), getRepoType(repo.address))) {
|
||||
fingerprintRepoMap.put(repo.fingerprint, repo);
|
||||
}
|
||||
}
|
||||
@ -296,7 +297,7 @@ public class ManageReposActivity extends AppCompatActivity
|
||||
try {
|
||||
url = normalizeUrl(url);
|
||||
} catch (URISyntaxException e) {
|
||||
invalidUrl(null);
|
||||
invalidUrl();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -411,7 +412,7 @@ public class ManageReposActivity extends AppCompatActivity
|
||||
}
|
||||
|
||||
if (repo == null) {
|
||||
repoDoesntExist(repo);
|
||||
repoDoesntExist();
|
||||
} else {
|
||||
if (repo.isSwap) {
|
||||
repoIsSwap(repo);
|
||||
@ -432,8 +433,8 @@ public class ManageReposActivity extends AppCompatActivity
|
||||
}
|
||||
}
|
||||
|
||||
private void repoDoesntExist(Repo repo) {
|
||||
updateUi(repo, AddRepoState.DOESNT_EXIST, 0, false, R.string.repo_add_add, true);
|
||||
private void repoDoesntExist() {
|
||||
updateUi(null, AddRepoState.DOESNT_EXIST, 0, false, R.string.repo_add_add, true);
|
||||
}
|
||||
|
||||
private void repoIsSwap(Repo repo) {
|
||||
@ -450,8 +451,8 @@ public class ManageReposActivity extends AppCompatActivity
|
||||
true, R.string.overwrite, false);
|
||||
}
|
||||
|
||||
private void invalidUrl(Repo repo) {
|
||||
updateUi(repo, AddRepoState.INVALID_URL, R.string.invalid_url, true,
|
||||
private void invalidUrl() {
|
||||
updateUi(null, AddRepoState.INVALID_URL, R.string.invalid_url, true,
|
||||
R.string.repo_add_add, false);
|
||||
}
|
||||
|
||||
@ -480,8 +481,15 @@ public class ManageReposActivity extends AppCompatActivity
|
||||
if (addRepoState != state) {
|
||||
addRepoState = state;
|
||||
|
||||
String name;
|
||||
if (repo == null) {
|
||||
name = '"' + getString(R.string.unknown) + '"';
|
||||
} else {
|
||||
name = repo.name;
|
||||
}
|
||||
|
||||
if (messageRes > 0) {
|
||||
overwriteMessage.setText(String.format(getString(messageRes), repo.name));
|
||||
overwriteMessage.setText(String.format(getString(messageRes), name));
|
||||
overwriteMessage.setVisibility(View.VISIBLE);
|
||||
if (redMessage) {
|
||||
overwriteMessage.setTextColor(getResources().getColor(R.color.red));
|
||||
@ -667,17 +675,24 @@ public class ManageReposActivity extends AppCompatActivity
|
||||
* Currently it normalizes the path so that "/./" are removed and "test/../" is collapsed.
|
||||
* This is done using {@link URI#normalize()}. It also removes multiple consecutive forward
|
||||
* slashes in the path and replaces them with one. Finally, it removes trailing slashes.
|
||||
* <p>
|
||||
* {@code content://} URLs used for repos stored on removable storage get messed up by
|
||||
* {@link URI}.
|
||||
*/
|
||||
private String normalizeUrl(String urlString) throws URISyntaxException {
|
||||
if (urlString == null) {
|
||||
return null;
|
||||
}
|
||||
URI uri = new URI(urlString);
|
||||
Uri uri = Uri.parse(urlString);
|
||||
if (!uri.isAbsolute()) {
|
||||
throw new URISyntaxException(urlString, "Must provide an absolute URI for repositories");
|
||||
}
|
||||
|
||||
uri = uri.normalize();
|
||||
if (!uri.isHierarchical()) {
|
||||
throw new URISyntaxException(urlString, "Must provide an hierarchical URI for repositories");
|
||||
}
|
||||
if ("content".equals(uri.getScheme())) {
|
||||
return uri.toString();
|
||||
}
|
||||
String path = uri.getPath();
|
||||
if (path != null) {
|
||||
path = path.replaceAll("//*/", "/"); // Collapse multiple forward slashes into 1.
|
||||
@ -685,9 +700,13 @@ public class ManageReposActivity extends AppCompatActivity
|
||||
path = path.substring(0, path.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(),
|
||||
path, uri.getQuery(), uri.getFragment()).toString();
|
||||
return new URI(uri.getScheme().toLowerCase(Locale.ENGLISH),
|
||||
uri.getUserInfo(),
|
||||
uri.getHost().toLowerCase(Locale.ENGLISH),
|
||||
uri.getPort(),
|
||||
path,
|
||||
uri.getQuery(),
|
||||
uri.getFragment()).normalize().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,6 +117,7 @@ public class ScreenShotsActivity extends AppCompatActivity {
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
|
||||
DisplayImageOptions displayImageOptions = Utils.getDefaultDisplayImageOptionsBuilder()
|
||||
.showImageOnFail(R.drawable.screenshot_placeholder)
|
||||
.showImageOnLoading(R.drawable.screenshot_placeholder)
|
||||
.showImageForEmptyUri(R.drawable.screenshot_placeholder)
|
||||
.build();
|
||||
|
@ -26,6 +26,7 @@ class ScreenShotsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.V
|
||||
|
||||
screenshots = app.getAllScreenshots(context);
|
||||
displayImageOptions = Utils.getDefaultDisplayImageOptionsBuilder()
|
||||
.showImageOnFail(R.drawable.screenshot_placeholder)
|
||||
.showImageOnLoading(R.drawable.screenshot_placeholder)
|
||||
.showImageForEmptyUri(R.drawable.screenshot_placeholder)
|
||||
.build();
|
||||
|
Loading…
x
Reference in New Issue
Block a user