From cce393de096c3b07093e54622b85cb40899c67ef Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 25 Apr 2014 23:57:42 -0400 Subject: [PATCH] "unverified" repo state for repos w/ fingerprints but not yet pubkeys If a repo was configured with a fingerprint, but it has not yet updated and gotten the pubkey from the index.jar, then it will be in an "unverified" state, i.e. the signing key fingerprint is stored, but it has not yet been used to check against the pubkey in the index.jar --- res/values/colors.xml | 1 + res/values/strings.xml | 1 + src/org/fdroid/fdroid/data/Repo.java | 9 ++++++++- src/org/fdroid/fdroid/views/RepoAdapter.java | 8 +++++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/res/values/colors.xml b/res/values/colors.xml index 7cd1486ca..d2777848b 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -2,4 +2,5 @@ #ffcccccc #ffCC0000 + #ff999999 \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index b068d0ae9..e8e837990 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -176,6 +176,7 @@ Show icons at regular size Theme Unsigned + Unverified URL Number of apps Fingerprint of Repo Signing Key (SHA-256) diff --git a/src/org/fdroid/fdroid/data/Repo.java b/src/org/fdroid/fdroid/data/Repo.java index 76001ca1d..64d6b3f78 100644 --- a/src/org/fdroid/fdroid/data/Repo.java +++ b/src/org/fdroid/fdroid/data/Repo.java @@ -2,6 +2,7 @@ package org.fdroid.fdroid.data; import android.content.ContentValues; import android.database.Cursor; +import android.text.TextUtils; import android.util.Log; import org.fdroid.fdroid.Utils; @@ -78,7 +79,13 @@ public class Repo extends ValueObject { } public boolean isSigned() { - return this.pubkey != null && this.pubkey.length() > 0; + return !TextUtils.isEmpty(this.pubkey); + } + + // this happens when a repo is configed with a fingerprint, but the client + // has not connected to it yet to download its pubkey + public boolean isSignedButUnverified() { + return TextUtils.isEmpty(this.pubkey) && !TextUtils.isEmpty(this.fingerprint); } public boolean hasBeenUpdated() { diff --git a/src/org/fdroid/fdroid/views/RepoAdapter.java b/src/org/fdroid/fdroid/views/RepoAdapter.java index 307f325de..aa816bda6 100644 --- a/src/org/fdroid/fdroid/views/RepoAdapter.java +++ b/src/org/fdroid/fdroid/views/RepoAdapter.java @@ -97,10 +97,16 @@ public class RepoAdapter extends CursorAdapter { // If we set the signed view to GONE instead of INVISIBLE, then the // height of each list item varies. - View signedView = view.findViewById(R.id.repo_unsigned); + TextView signedView = (TextView) view.findViewById(R.id.repo_unsigned); if (repo.isSigned()) { signedView.setVisibility(View.INVISIBLE); + } else if (repo.isSignedButUnverified()) { + signedView.setText(R.string.unverified); + signedView.setTextColor(view.getResources().getColor(R.color.unverified)); + signedView.setVisibility(View.VISIBLE); } else { + signedView.setText(R.string.unsigned); + signedView.setTextColor(view.getResources().getColor(R.color.unsigned)); signedView.setVisibility(View.VISIBLE); } }