display mirrors in RepoDetailsActivity

This is rough, but better than nothing.
This commit is contained in:
Hans-Christoph Steiner 2018-03-29 14:16:25 +02:00
parent b3d90cd1b6
commit 759c3b90fc
3 changed files with 70 additions and 24 deletions

View File

@ -50,26 +50,26 @@ public class RepoDetailsActivity extends ActionBarActivity {
* all of this info, otherwise they will be hidden.
*/
private static final int[] SHOW_IF_EXISTS = {
R.id.label_repo_name,
R.id.text_repo_name,
R.id.text_description,
R.id.label_num_apps,
R.id.text_num_apps,
R.id.label_last_update,
R.id.text_last_update,
R.id.label_username,
R.id.text_username,
R.id.button_edit_credentials,
R.id.label_repo_fingerprint,
R.id.text_repo_fingerprint,
R.id.text_repo_fingerprint_description,
R.id.label_repo_name,
R.id.text_repo_name,
R.id.text_description,
R.id.label_num_apps,
R.id.text_num_apps,
R.id.label_last_update,
R.id.text_last_update,
R.id.label_username,
R.id.text_username,
R.id.button_edit_credentials,
R.id.label_repo_fingerprint,
R.id.text_repo_fingerprint,
R.id.text_repo_fingerprint_description,
};
/**
* If the repo has <em>not</em> been updated yet, then we only show
* these, otherwise they are hidden.
*/
private static final int[] HIDE_IF_EXISTS = {
R.id.text_not_yet_updated,
R.id.text_not_yet_updated,
};
private Repo repo;
private long repoId;
@ -108,12 +108,18 @@ public class RepoDetailsActivity extends ActionBarActivity {
RepoTable.Cols.NAME,
RepoTable.Cols.ADDRESS,
RepoTable.Cols.FINGERPRINT,
RepoTable.Cols.MIRRORS,
};
repo = RepoProvider.Helper.findById(this, repoId, projection);
TextView inputUrl = (TextView) findViewById(R.id.input_repo_url);
inputUrl.setText(repo.address);
if (repo.address.startsWith("content://")) {
// no need to show a QR Code, it is not shareable
return;
}
Uri uri = Uri.parse(repo.address);
uri = uri.buildUpon().appendQueryParameter("fingerprint", repo.fingerprint).build();
String qrUriString = uri.toString();
@ -321,6 +327,20 @@ public class RepoDetailsActivity extends ActionBarActivity {
TextView numApps = (TextView) repoView.findViewById(R.id.text_num_apps);
TextView lastUpdated = (TextView) repoView.findViewById(R.id.text_last_update);
if (repo.mirrors != null) {
TextView officialMirrorsLabel = (TextView) repoView.findViewById(R.id.label_official_mirrors);
officialMirrorsLabel.setVisibility(View.VISIBLE);
TextView officialMirrorsText = (TextView) repoView.findViewById(R.id.text_official_mirrors);
officialMirrorsText.setVisibility(View.VISIBLE);
StringBuilder builder = new StringBuilder();
for (String url : repo.mirrors) {
builder.append("");
builder.append(url);
builder.append('\n');
}
officialMirrorsText.setText(builder.toString());
}
name.setText(repo.name);
int appCount = RepoProvider.Helper.countAppsForRepo(this, repoId);
@ -345,22 +365,22 @@ public class RepoDetailsActivity extends ActionBarActivity {
private void promptForDelete() {
new AlertDialog.Builder(this)
.setTitle(R.string.repo_confirm_delete_title)
.setMessage(R.string.repo_confirm_delete_body)
.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
RepoProvider.Helper.remove(getApplicationContext(), repoId);
finish();
}
}).setNegativeButton(android.R.string.cancel,
.setTitle(R.string.repo_confirm_delete_title)
.setMessage(R.string.repo_confirm_delete_body)
.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
RepoProvider.Helper.remove(getApplicationContext(), repoId);
finish();
}
}).setNegativeButton(android.R.string.cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Do nothing...
}
}
).show();
).show();
}
public void showChangePasswordDialog(final View parentView) {

View File

@ -71,6 +71,30 @@
android:id="@+id/text_last_update"
style="@style/BodyText" />
<!-- mirrors included in the index -->
<TextView
android:id="@+id/label_official_mirrors"
android:visibility="gone"
android:text="@string/repo_official_mirrors"
style="@style/CaptionText" />
<TextView
android:id="@+id/text_official_mirrors"
android:visibility="gone"
android:textColor="@android:color/black"
style="@style/CaptionText" />
<!-- mirrors added by the user -->
<TextView
android:id="@+id/label_user_mirrors"
android:visibility="gone"
android:text="@string/repo_user_mirrors"
style="@style/CaptionText" />
<TextView
android:id="@+id/text_user_mirrors"
android:visibility="gone"
android:textColor="@android:color/black"
style="@style/CaptionText" />
<!-- The credentials used to access this repo (optional) -->
<TextView
android:id="@+id/label_username"

View File

@ -307,6 +307,8 @@ This often occurs with apps installed via Google Play or other sources, if they
<string name="repo_fingerprint">Fingerprint of the signing key (SHA-256)</string>
<string name="repo_description">Description</string>
<string name="repo_last_update">Last update</string>
<string name="repo_official_mirrors">Official mirrors</string>
<string name="repo_user_mirrors">User mirrors</string>
<string name="repo_name">Name</string>
<string name="unsigned_description">This means that the list of
apps could not be verified. You should be careful