Merge branch 'materialize-repository-details' into 'master'

Materialize repository details

Modernize the look of repo details. Enabled repo before and after:

![1a](https://gitlab.com/relan/fdroidclient/uploads/c3e7906508763081fcde5d0ebd1d7b7b/1a.png)
![1b](https://gitlab.com/relan/fdroidclient/uploads/6be4bd19cd375abf8df1f403464dfca0/1b.png)

Disabled repo before and after:

![2a](https://gitlab.com/relan/fdroidclient/uploads/6ff39317b598c3da3a814e60f74e75cb/2a.png)
![2b](https://gitlab.com/relan/fdroidclient/uploads/5354ec4c56dd3dc0958d7f002543ee9b/2b.png)


See merge request !148
This commit is contained in:
Daniel Martí 2015-10-02 19:18:30 +00:00
commit fc50fea18c
8 changed files with 121 additions and 180 deletions

View File

@ -347,7 +347,7 @@
</activity>-->
<activity
android:name=".views.RepoDetailsActivity"
android:label="@string/menu_manage"
android:label="@string/repo_details"
android:parentActivityName=".views.ManageReposActivity"
android:windowSoftInputMode="stateHidden">
<meta-data

View File

@ -1,149 +1,113 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="@dimen/padding_top"
android:paddingLeft="@dimen/padding_side"
android:paddingStart="@dimen/padding_side"
android:paddingRight="@dimen/padding_side"
android:paddingEnd="@dimen/padding_side">
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/repoView"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:paddingLeft="?attr/listPreferredItemPaddingLeft"
android:paddingRight="?attr/listPreferredItemPaddingRight"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/input_repo_url"
android:textStyle="bold"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />
<!-- URL of this repo -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/repo_url"
style="@style/RepoDetailsCaption"/>
<TextView
android:id="@+id/input_repo_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/RepoDetailsBody"/>
<!-- Name of this repo -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/label_repo_name"
android:text="@string/repo_name"
android:layout_below="@id/input_repo_url"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:paddingTop="@dimen/form_label_top"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
android:id="@+id/text_repo_name"
android:layout_below="@id/label_repo_name" android:textStyle="bold"/>
<!-- Name of this repo -->
<TextView
android:id="@+id/label_repo_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/repo_name"
style="@style/RepoDetailsCaption"/>
<TextView
android:id="@+id/text_repo_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/RepoDetailsBody"/>
<!-- Description - as pulled from the index file during last update... -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/label_description"
android:text="@string/repo_description"
android:layout_below="@id/text_repo_name"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:paddingTop="@dimen/form_label_top"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
android:scrollHorizontally="false"
android:id="@+id/text_description"
android:layout_below="@id/label_description" android:textStyle="bold"/>
<!-- Description - as pulled from the index file during last update... -->
<TextView
android:id="@+id/label_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/repo_description"
style="@style/RepoDetailsCaption"/>
<TextView
android:id="@+id/text_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/RepoDetailsBody"/>
<!-- Number of apps belonging to this repo -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/label_num_apps"
android:text="@string/repo_num_apps"
android:layout_below="@id/text_description"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:paddingTop="@dimen/form_label_top" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text_num_apps"
android:layout_below="@id/label_num_apps" android:textStyle="bold"/>
<!-- Number of apps belonging to this repo -->
<TextView
android:id="@+id/label_num_apps"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/repo_num_apps"
style="@style/RepoDetailsCaption"/>
<TextView
android:id="@+id/text_num_apps"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/RepoDetailsBody"/>
<!-- The last time this repo was updated -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/label_last_update"
android:text="@string/repo_last_update"
android:layout_below="@id/text_num_apps"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:paddingTop="@dimen/form_label_top" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text_last_update"
android:layout_below="@id/label_last_update" android:textStyle="bold"/>
<!-- The last time this repo was updated -->
<TextView
android:id="@+id/label_last_update"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/repo_last_update"
style="@style/RepoDetailsCaption"/>
<TextView
android:id="@+id/text_last_update"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/RepoDetailsBody"/>
<!-- Signature (or "unsigned" if none) -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/label_repo_fingerprint"
android:text="@string/repo_fingerprint"
android:layout_below="@id/text_last_update"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:paddingTop="@dimen/form_label_top" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="false"
android:scrollHorizontally="false"
android:id="@+id/text_repo_fingerprint"
android:layout_below="@id/label_repo_fingerprint" android:textStyle="bold"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="false"
android:scrollHorizontally="false"
android:id="@+id/text_repo_fingerprint_description"
android:layout_below="@id/text_repo_fingerprint"/>
<!-- Signature (or "unsigned" if none) -->
<TextView
android:id="@+id/label_repo_fingerprint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/repo_fingerprint"
style="@style/RepoDetailsCaption"/>
<TextView
android:id="@+id/text_repo_fingerprint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:typeface="monospace"
style="@style/RepoDetailsBody"/>
<TextView
android:id="@+id/text_repo_fingerprint_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/RepoDetailsBody"/>
<!-- The last time this repo was updated -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text_not_yet_updated"
android:layout_below="@id/input_repo_url"
android:text="@string/repo_not_yet_updated"
android:textStyle="bold"
android:paddingTop="@dimen/form_label_top"/>
<TextView
android:id="@+id/text_not_yet_updated"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/repo_not_yet_updated"
style="@style/RepoDetailsBody"/>
<Button
android:id="@+id/btn_update"
android:layout_centerHorizontal="true"
android:text="@string/repo_update"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/text_not_yet_updated"/>
<ImageView
android:id="@+id/qr_code"
android:src="@drawable/swap_qr_example"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp"/>
</RelativeLayout>
<ImageView
android:id="@+id/qr_code"
android:src="@drawable/swap_qr_example"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>

View File

@ -2,11 +2,6 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_update"
android:icon="@drawable/ic_refresh_white"
android:title="@string/repo_update"
app:showAsAction="always|withText" />
<item
android:id="@+id/menu_delete"
android:icon="@drawable/ic_delete_white"
@ -18,4 +13,4 @@
android:title="@string/enable_nfc_send"
app:showAsAction="ifRoom|withText" />
</menu>
</menu>

View File

@ -0,0 +1,8 @@
<?xml version='1.0' encoding='utf-8'?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="RepoDetailsBody">
<item name="android:lineSpacingMultiplier">1.25</item>
</style>
</resources>

View File

@ -1,9 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="padding_side">8dp</dimen>
<dimen name="padding_top">5dp</dimen>
<dimen name="form_label_top">5dp</dimen>
<dimen name="applist_icon_normal_size">48dp</dimen>
<dimen name="applist_icon_compact_size">32dp</dimen>

View File

@ -188,8 +188,10 @@
<string name="theme">Theme</string>
<string name="unsigned">Unsigned</string>
<string name="unverified">Unverified</string>
<string name="repo_details">Repository</string>
<string name="repo_url">Address</string>
<string name="repo_num_apps">Number of apps</string>
<string name="repo_fingerprint">Fingerprint of Repo Signing Key (SHA-256)</string>
<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_update">Update</string>
@ -198,9 +200,7 @@
applications could not be verified. You should be careful
with applications downloaded from unsigned indexes.</string>
<string name="repo_not_yet_updated">This repository has not been used yet.
In order to view the apps it provides, you will need to update
it.\n\nOnce updated, the description and other details will
become available here.</string>
You need to enable it to view the apps it provides.</string>
<string name="unknown">Unknown</string>
<string name="repo_confirm_delete_title">Delete Repository?</string>
<string name="repo_confirm_delete_body">Deleting a repository means

View File

@ -1,3 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppBaseThemeDark" parent="Theme.AppCompat">
@ -38,6 +39,15 @@
<item name="colorAccent">@color/fdroid_green</item>
</style>
<style name="RepoDetailsCaption">
<item name="android:paddingTop">16dp</item>
<item name="android:paddingBottom">4dp</item>
<item name="android:textSize">12sp</item>
<item name="android:textColor">?android:attr/textColorSecondary</item>
</style>
<style name="RepoDetailsBody" />
<style name="SwapTheme.Wizard" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorButtonNormal">@color/swap_bright_blue</item>
<item name="android:actionBarStyle">@style/Widget.AppCompat.ActionBar.Solid</item>
@ -168,4 +178,4 @@
<item name="android:textStyle">italic</item>
</style>
</resources>
</resources>

View File

@ -2,7 +2,6 @@ package org.fdroid.fdroid.views;
import android.annotation.TargetApi;
import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@ -21,7 +20,6 @@ import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
@ -50,7 +48,6 @@ public class RepoDetailsActivity extends ActionBarActivity {
private static final int[] SHOW_IF_EXISTS = {
R.id.label_repo_name,
R.id.text_repo_name,
R.id.label_description,
R.id.text_description,
R.id.label_num_apps,
R.id.text_num_apps,
@ -66,7 +63,6 @@ public class RepoDetailsActivity extends ActionBarActivity {
*/
private static final int[] HIDE_IF_EXISTS = {
R.id.text_not_yet_updated,
R.id.btn_update
};
private Repo repo;
private long repoId;
@ -104,19 +100,9 @@ public class RepoDetailsActivity extends ActionBarActivity {
};
repo = RepoProvider.Helper.findById(this, repoId, projection);
setTitle(repo.name);
TextView inputUrl = (TextView) findViewById(R.id.input_repo_url);
inputUrl.setText(repo.address);
Button update = (Button) repoView.findViewById(R.id.btn_update);
update.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
performUpdate();
}
});
Uri uri = Uri.parse(repo.address);
uri = uri.buildUpon().appendQueryParameter("fingerprint", repo.fingerprint).build();
String qrUriString = uri.toString().toUpperCase(Locale.ENGLISH);
@ -207,9 +193,6 @@ public class RepoDetailsActivity extends ActionBarActivity {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
case R.id.menu_update:
performUpdate();
return true;
case R.id.menu_delete:
promptForDelete();
return true;
@ -271,23 +254,20 @@ public class RepoDetailsActivity extends ActionBarActivity {
TextView repoFingerprintDescView = (TextView) parent.findViewById(R.id.text_repo_fingerprint_description);
String repoFingerprint;
int repoFingerprintColor;
// TODO show the current state of the signature check, not just whether there is a key or not
if (TextUtils.isEmpty(repo.fingerprint) && TextUtils.isEmpty(repo.pubkey)) {
repoFingerprint = getResources().getString(R.string.unsigned);
repoFingerprintColor = getResources().getColor(R.color.unsigned);
repoFingerprintView.setTextColor(getResources().getColor(R.color.unsigned));
repoFingerprintDescView.setVisibility(View.VISIBLE);
repoFingerprintDescView.setText(getResources().getString(R.string.unsigned_description));
} else {
// this is based on repo.fingerprint always existing, which it should
repoFingerprint = Utils.formatFingerprint(this, repo.fingerprint);
repoFingerprintColor = getResources().getColor(R.color.signed);
repoFingerprintDescView.setVisibility(View.GONE);
}
repoFingerprintView.setText(repoFingerprint);
repoFingerprintView.setTextColor(repoFingerprintColor);
}
private void updateRepoView() {
@ -328,19 +308,6 @@ public class RepoDetailsActivity extends ActionBarActivity {
lastUpdated.setText(lastUpdate);
}
/**
* When an update is performed, notify the listener so that the repo
* list can be updated. We will perform the update ourselves though.
*/
private void performUpdate() {
// Ensure repo is enabled before updating...
ContentValues values = new ContentValues(1);
values.put(RepoProvider.DataColumns.IN_USE, 1);
RepoProvider.Helper.update(this, repo, values);
UpdateService.updateRepoNow(repo.address, this);
}
private void promptForDelete() {
new AlertDialog.Builder(this)
.setTitle(R.string.repo_confirm_delete_title)