Merge branch 'fixes-for-1.0-alpha2' into 'master'
Fixes for 1.0 alpha2 Closes #1149 See merge request !573
@ -207,6 +207,10 @@ android {
 | 
			
		||||
        targetCompatibility JavaVersion.VERSION_1_7
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    aaptOptions {
 | 
			
		||||
        cruncherEnabled = false
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    defaultConfig {
 | 
			
		||||
        versionCode 1000001
 | 
			
		||||
        versionName getVersionName()
 | 
			
		||||
 | 
			
		||||
| 
		 Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.6 KiB  | 
| 
		 Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB  | 
| 
		 Before Width: | Height: | Size: 887 B After Width: | Height: | Size: 853 B  | 
@ -93,7 +93,7 @@ public class CleanCacheService extends IntentService {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        for (File f : files) {
 | 
			
		||||
            if (f.getName().startsWith("install-")) {
 | 
			
		||||
            if (f.getName().endsWith(".apk")) {
 | 
			
		||||
                clearOldFiles(f, TimeUnit.HOURS.toMillis(1));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -138,6 +138,10 @@ public class RepoXMLHandler extends DefaultHandler {
 | 
			
		||||
                    break;
 | 
			
		||||
                case ApkTable.Cols.SIGNATURE:
 | 
			
		||||
                    curapk.sig = str;
 | 
			
		||||
                    // the first APK in the list provides the preferred signature
 | 
			
		||||
                    if (curapp.preferredSigner == null) {
 | 
			
		||||
                        curapp.preferredSigner = str;
 | 
			
		||||
                    }
 | 
			
		||||
                    break;
 | 
			
		||||
                case ApkTable.Cols.SOURCE_NAME:
 | 
			
		||||
                    curapk.srcname = str;
 | 
			
		||||
 | 
			
		||||
@ -15,6 +15,7 @@ import android.os.Environment;
 | 
			
		||||
import android.os.LocaleList;
 | 
			
		||||
import android.os.Parcel;
 | 
			
		||||
import android.os.Parcelable;
 | 
			
		||||
import android.support.annotation.NonNull;
 | 
			
		||||
import android.support.annotation.Nullable;
 | 
			
		||||
import android.text.TextUtils;
 | 
			
		||||
import android.util.Log;
 | 
			
		||||
@ -101,6 +102,7 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
 | 
			
		||||
    @JsonIgnore
 | 
			
		||||
    private AppPrefs prefs;
 | 
			
		||||
    @JsonIgnore
 | 
			
		||||
    @NonNull
 | 
			
		||||
    public String preferredSigner;
 | 
			
		||||
 | 
			
		||||
    @JacksonInject("repoId")
 | 
			
		||||
@ -159,6 +161,7 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
 | 
			
		||||
     * The index-v1 metadata uses the term `suggestedVersionCode` but we need that
 | 
			
		||||
     * value to end up in the `upstreamVersionCode` property here. These variables
 | 
			
		||||
     * need to be renamed across the whole F-Droid ecosystem to make sense.
 | 
			
		||||
     *
 | 
			
		||||
     * @see <a href="https://gitlab.com/fdroid/fdroidclient/issues/1063">issue #1063</a>
 | 
			
		||||
     */
 | 
			
		||||
    @JsonProperty("suggestedVersionCode")
 | 
			
		||||
@ -210,7 +213,7 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int compareTo(App app) {
 | 
			
		||||
    public int compareTo(@NonNull App app) {
 | 
			
		||||
        return name.compareToIgnoreCase(app.name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -1137,17 +1140,14 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
 | 
			
		||||
     * However, if the app is installed, then we override this and instead want to only encourage
 | 
			
		||||
     * the user to try and install versions with that signature (because thats all the OS will let
 | 
			
		||||
     * them do).
 | 
			
		||||
     * TODO: I don't think preferredSigner should ever be null, because if an app has apks then
 | 
			
		||||
     * we should have chosen the first and used that. If so, then we should change to @NonNull and
 | 
			
		||||
     * throw an exception if it is null.
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    @NonNull
 | 
			
		||||
    public String getMostAppropriateSignature() {
 | 
			
		||||
        if (!TextUtils.isEmpty(installedSig)) {
 | 
			
		||||
            return installedSig;
 | 
			
		||||
        } else if (!TextUtils.isEmpty(preferredSigner)) {
 | 
			
		||||
            return preferredSigner;
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
        throw new IllegalStateException("Most Appropriate Signature not found!");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -127,10 +127,10 @@ public final class LocalRepoManager {
 | 
			
		||||
        try {
 | 
			
		||||
            appInfo = pm.getApplicationInfo(fdroidPackageName, PackageManager.GET_META_DATA);
 | 
			
		||||
            SanitizedFile apkFile = SanitizedFile.knownSanitized(appInfo.publicSourceDir);
 | 
			
		||||
            SanitizedFile fdroidApkLink = new SanitizedFile(webRoot, "fdroid.client.apk");
 | 
			
		||||
            SanitizedFile fdroidApkLink = new SanitizedFile(fdroidDir, "F-Droid.apk");
 | 
			
		||||
            attemptToDelete(fdroidApkLink);
 | 
			
		||||
            if (Utils.symlinkOrCopyFileQuietly(apkFile, fdroidApkLink)) {
 | 
			
		||||
                fdroidClientURL = "/" + fdroidApkLink.getName();
 | 
			
		||||
                fdroidClientURL = "/" + fdroidDir.getName() + "/" + fdroidApkLink.getName();
 | 
			
		||||
            }
 | 
			
		||||
        } catch (PackageManager.NameNotFoundException e) {
 | 
			
		||||
            Log.e(TAG, "Could not set up F-Droid apk in the webroot", e);
 | 
			
		||||
 | 
			
		||||
| 
		 Before Width: | Height: | Size: 498 B After Width: | Height: | Size: 313 B  | 
| 
		 Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 8.0 KiB  | 
| 
		 Before Width: | Height: | Size: 657 B After Width: | Height: | Size: 910 B  | 
| 
		 Before Width: | Height: | Size: 947 B After Width: | Height: | Size: 1.3 KiB  | 
| 
		 Before Width: | Height: | Size: 127 B After Width: | Height: | Size: 157 B  | 
| 
		 Before Width: | Height: | Size: 195 B After Width: | Height: | Size: 248 B  | 
| 
		 Before Width: | Height: | Size: 307 B After Width: | Height: | Size: 427 B  | 
| 
		 Before Width: | Height: | Size: 579 B After Width: | Height: | Size: 280 B  | 
| 
		 Before Width: | Height: | Size: 788 B After Width: | Height: | Size: 557 B  | 
| 
		 Before Width: | Height: | Size: 738 B After Width: | Height: | Size: 1.1 KiB  | 
| 
		 Before Width: | Height: | Size: 634 B After Width: | Height: | Size: 451 B  | 
| 
		 Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 982 B  | 
| 
		 Before Width: | Height: | Size: 161 B After Width: | Height: | Size: 230 B  | 
| 
		 Before Width: | Height: | Size: 476 B After Width: | Height: | Size: 718 B  | 
| 
		 Before Width: | Height: | Size: 974 B After Width: | Height: | Size: 763 B  | 
| 
		 Before Width: | Height: | Size: 841 B After Width: | Height: | Size: 682 B  | 
| 
		 Before Width: | Height: | Size: 280 B After Width: | Height: | Size: 212 B  | 
| 
		 Before Width: | Height: | Size: 291 B After Width: | Height: | Size: 223 B  | 
| 
		 Before Width: | Height: | Size: 494 B After Width: | Height: | Size: 446 B  | 
| 
		 Before Width: | Height: | Size: 367 B After Width: | Height: | Size: 206 B  | 
| 
		 Before Width: | Height: | Size: 690 B After Width: | Height: | Size: 383 B  | 
| 
		 Before Width: | Height: | Size: 760 B After Width: | Height: | Size: 533 B  | 
| 
		 Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB  | 
| 
		 Before Width: | Height: | Size: 365 B After Width: | Height: | Size: 365 B  | 
| 
		 Before Width: | Height: | Size: 786 B After Width: | Height: | Size: 1.2 KiB  | 
| 
		 Before Width: | Height: | Size: 216 B After Width: | Height: | Size: 298 B  | 
| 
		 Before Width: | Height: | Size: 746 B After Width: | Height: | Size: 519 B  | 
| 
		 Before Width: | Height: | Size: 387 B After Width: | Height: | Size: 675 B  | 
| 
		 Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.2 KiB  | 
| 
		 Before Width: | Height: | Size: 396 B After Width: | Height: | Size: 579 B  | 
| 
		 Before Width: | Height: | Size: 397 B After Width: | Height: | Size: 757 B  | 
| 
		 Before Width: | Height: | Size: 416 B After Width: | Height: | Size: 386 B  | 
| 
		 Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.6 KiB  | 
| 
		 Before Width: | Height: | Size: 928 B After Width: | Height: | Size: 823 B  | 
| 
		 Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 9.2 KiB  | 
| 
		 Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 14 KiB  | 
| 
		 Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 5.2 KiB  | 
| 
		 Before Width: | Height: | Size: 351 B After Width: | Height: | Size: 135 B  | 
| 
		 Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.5 KiB  | 
| 
		 Before Width: | Height: | Size: 356 B After Width: | Height: | Size: 113 B  | 
| 
		 Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.8 KiB  | 
| 
		 Before Width: | Height: | Size: 360 B After Width: | Height: | Size: 114 B  | 
| 
		 Before Width: | Height: | Size: 890 B After Width: | Height: | Size: 730 B  | 
| 
		 Before Width: | Height: | Size: 460 B After Width: | Height: | Size: 243 B  | 
| 
		 Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.3 KiB  | 
| 
		 Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 2.8 KiB  | 
| 
		 Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.1 KiB  | 
| 
		 Before Width: | Height: | Size: 370 B After Width: | Height: | Size: 157 B  | 
| 
		 Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 2.9 KiB  | 
| 
		 Before Width: | Height: | Size: 427 B After Width: | Height: | Size: 604 B  | 
| 
		 Before Width: | Height: | Size: 650 B After Width: | Height: | Size: 963 B  | 
| 
		 Before Width: | Height: | Size: 88 B After Width: | Height: | Size: 115 B  | 
| 
		 Before Width: | Height: | Size: 160 B After Width: | Height: | Size: 214 B  | 
| 
		 Before Width: | Height: | Size: 718 B After Width: | Height: | Size: 715 B  | 
| 
		 Before Width: | Height: | Size: 213 B After Width: | Height: | Size: 302 B  | 
| 
		 Before Width: | Height: | Size: 541 B After Width: | Height: | Size: 271 B  | 
| 
		 Before Width: | Height: | Size: 623 B After Width: | Height: | Size: 394 B  | 
| 
		 Before Width: | Height: | Size: 510 B After Width: | Height: | Size: 744 B  | 
| 
		 Before Width: | Height: | Size: 495 B After Width: | Height: | Size: 368 B  | 
| 
		 Before Width: | Height: | Size: 741 B After Width: | Height: | Size: 712 B  | 
| 
		 Before Width: | Height: | Size: 115 B After Width: | Height: | Size: 163 B  | 
| 
		 Before Width: | Height: | Size: 324 B After Width: | Height: | Size: 485 B  | 
| 
		 Before Width: | Height: | Size: 801 B After Width: | Height: | Size: 573 B  | 
| 
		 Before Width: | Height: | Size: 617 B After Width: | Height: | Size: 462 B  | 
| 
		 Before Width: | Height: | Size: 240 B After Width: | Height: | Size: 184 B  | 
| 
		 Before Width: | Height: | Size: 222 B After Width: | Height: | Size: 178 B  | 
| 
		 Before Width: | Height: | Size: 384 B After Width: | Height: | Size: 142 B  | 
| 
		 Before Width: | Height: | Size: 263 B After Width: | Height: | Size: 154 B  | 
| 
		 Before Width: | Height: | Size: 506 B After Width: | Height: | Size: 302 B  | 
| 
		 Before Width: | Height: | Size: 621 B After Width: | Height: | Size: 395 B  | 
| 
		 Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB  | 
| 
		 Before Width: | Height: | Size: 225 B After Width: | Height: | Size: 237 B  | 
| 
		 Before Width: | Height: | Size: 607 B After Width: | Height: | Size: 546 B  | 
| 
		 Before Width: | Height: | Size: 538 B After Width: | Height: | Size: 901 B  | 
| 
		 Before Width: | Height: | Size: 160 B After Width: | Height: | Size: 224 B  | 
| 
		 Before Width: | Height: | Size: 417 B After Width: | Height: | Size: 177 B  | 
| 
		 Before Width: | Height: | Size: 254 B After Width: | Height: | Size: 426 B  | 
| 
		 Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 884 B  | 
| 
		 Before Width: | Height: | Size: 247 B After Width: | Height: | Size: 389 B  | 
| 
		 Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB  | 
| 
		 Before Width: | Height: | Size: 436 B After Width: | Height: | Size: 400 B  | 
| 
		 Before Width: | Height: | Size: 684 B After Width: | Height: | Size: 449 B  | 
| 
		 Before Width: | Height: | Size: 710 B After Width: | Height: | Size: 601 B  | 
| 
		 Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 3.9 KiB  | 
| 
		 Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB  | 
| 
		 Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.1 KiB  | 
| 
		 Before Width: | Height: | Size: 625 B After Width: | Height: | Size: 491 B  | 
| 
		 Before Width: | Height: | Size: 880 B After Width: | Height: | Size: 1.1 KiB  | 
| 
		 Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.7 KiB  | 
| 
		 Before Width: | Height: | Size: 97 B After Width: | Height: | Size: 127 B  | 
| 
		 Before Width: | Height: | Size: 235 B After Width: | Height: | Size: 269 B  | 
| 
		 Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.1 KiB  |