From 31afbe0423be20b0e065a1b9a37b0bd99aa5786e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=AD?= <mvdan@mvdan.cc>
Date: Fri, 11 Oct 2013 18:20:23 +0200
Subject: [PATCH] AppDetails Apk layout tweaks, show ABIs in expert mode

---
 res/layout/apklistitem.xml            | 41 +++++++++++---------
 src/org/fdroid/fdroid/AppDetails.java | 55 ++++++++++++++++-----------
 2 files changed, 55 insertions(+), 41 deletions(-)

diff --git a/res/layout/apklistitem.xml b/res/layout/apklistitem.xml
index 50c55e1f5..d26c443a8 100644
--- a/res/layout/apklistitem.xml
+++ b/res/layout/apklistitem.xml
@@ -9,42 +9,47 @@
 		android:paddingLeft="2dp"
 		android:paddingRight="2dp">
 
-  <TextView android:id="@+id/buildtype"
-	    android:textSize="12sp"
-	    android:layout_alignParentRight="true"
-	    android:layout_height="wrap_content"
-	    android:layout_width="wrap_content" />
-
   <TextView android:id="@+id/version"
 	    android:textStyle="bold"
 	    android:maxLines="2"
 	    android:ellipsize="end"
-	    android:layout_width="fill_parent"
+	    android:layout_width="wrap_content"
 	    android:layout_height="wrap_content"
-	    android:layout_toLeftOf="@id/buildtype"
 	    android:textSize="18sp" />
 
-  <TextView android:id="@+id/size"
-	    android:textSize="12sp"
-	    android:layout_below="@id/version"
-	    android:layout_alignParentRight="true"
-	    android:layout_height="wrap_content"
-	    android:layout_width="wrap_content" />
-
   <TextView android:id="@+id/status"
 	    android:textSize="12sp"
 	    android:maxLines="2"
 	    android:ellipsize="end"
 	    android:layout_below="@id/version"
-	    android:layout_toLeftOf="@id/size"
-	    android:layout_alignParentLeft="true"
 	    android:layout_height="wrap_content"
 	    android:layout_width="wrap_content" />
 
   <TextView android:id="@+id/added"
 	    android:textSize="12sp"
 	    android:layout_below="@id/status"
-	    android:layout_alignParentLeft="true"
+	    android:layout_height="wrap_content"
+	    android:layout_width="wrap_content" />
+
+  <TextView android:id="@+id/buildtype"
+	    android:textSize="12sp"
+	    android:layout_alignParentRight="true"
+	    android:layout_height="wrap_content"
+		android:layout_width="wrap_content"
+		android:layout_marginBottom="4sp" />
+
+  <TextView android:id="@+id/size"
+	    android:textSize="12sp"
+	    android:layout_below="@id/buildtype"
+	    android:layout_alignParentRight="true"
+	    android:layout_height="wrap_content"
+	    android:layout_width="wrap_content"
+		android:layout_marginBottom="4sp" />
+
+  <TextView android:id="@+id/nativecode"
+	    android:textSize="12sp"
+	    android:layout_below="@id/size"
+	    android:layout_alignParentRight="true"
 	    android:layout_height="wrap_content"
 	    android:layout_width="wrap_content" />
 
diff --git a/src/org/fdroid/fdroid/AppDetails.java b/src/org/fdroid/fdroid/AppDetails.java
index b1165c4ff..1a863e7c5 100644
--- a/src/org/fdroid/fdroid/AppDetails.java
+++ b/src/org/fdroid/fdroid/AppDetails.java
@@ -113,49 +113,58 @@ public class AppDetails extends ListActivity {
         public View getView(int position, View convertView, ViewGroup parent) {
 
             java.text.DateFormat df = DateFormat.getDateFormat(mctx);
+            DB.Apk apk = items.get(position);
 
             View v = convertView;
             if (v == null) {
                 LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                 v = vi.inflate(R.layout.apklistitem, null);
             }
-            DB.Apk apk = items.get(position);
-            TextView version = (TextView) v.findViewById(R.id.version);
-            boolean iscurrent = apk.vercode == app_currentvercode;
-            version.setText(getString(R.string.version) + " " + apk.version
-                    + (iscurrent ? " *" : ""));
+            v.setEnabled(apk.compatible);
 
-            TextView status = (TextView) v.findViewById(R.id.status);
+            TextView tv = (TextView) v.findViewById(R.id.version);
+            boolean iscurrent = apk.vercode == app_currentvercode;
+            tv.setText(getString(R.string.version) + " " + apk.version
+                    + (iscurrent ? " *" : ""));
+            tv.setEnabled(apk.compatible);
+
+            tv = (TextView) v.findViewById(R.id.status);
             if (apk.vercode == app.installedVerCode
                     && apk.sig.equals(mInstalledSigID))
-                status.setText(getString(R.string.inst));
+                tv.setText(getString(R.string.inst));
             else
-                status.setText(getString(R.string.not_inst));
+                tv.setText(getString(R.string.not_inst));
+            tv.setEnabled(apk.compatible);
 
-            TextView size = (TextView) v.findViewById(R.id.size);
+            tv = (TextView) v.findViewById(R.id.size);
             if (apk.detail_size == 0) {
-                size.setText("");
+                tv.setText("");
             } else {
-                size.setText(Utils.getFriendlySize(apk.detail_size));
+                tv.setText(Utils.getFriendlySize(apk.detail_size));
+                tv.setEnabled(apk.compatible);
             }
-            TextView buildtype = (TextView) v.findViewById(R.id.buildtype);
+            tv = (TextView) v.findViewById(R.id.buildtype);
             if (apk.srcname != null) {
-                buildtype.setText("source");
+                tv.setText("source");
             } else {
-                buildtype.setText("bin");
+                tv.setText("bin");
             }
-            TextView added = (TextView) v.findViewById(R.id.added);
+            tv.setEnabled(apk.compatible);
+            tv = (TextView) v.findViewById(R.id.added);
             if (apk.added != null) {
-                added.setVisibility(View.VISIBLE);
-                added.setText(getString(R.string.added_on, df.format(apk.added)));
+                tv.setVisibility(View.VISIBLE);
+                tv.setText(getString(R.string.added_on, df.format(apk.added)));
+                tv.setEnabled(apk.compatible);
             } else {
-                added.setVisibility(View.GONE);
+                tv.setVisibility(View.GONE);
             }
-
-            // Disable it all if it isn't compatible...
-            View[] views = { v, version, status, size, buildtype, added };
-            for (View view : views) {
-                view.setEnabled(apk.compatible);
+            tv = (TextView) v.findViewById(R.id.nativecode);
+            if (pref_expert && apk.nativecode != null) {
+                tv.setVisibility(View.VISIBLE);
+                tv.setText(apk.nativecode.toString().replaceAll(","," "));
+                tv.setEnabled(apk.compatible);
+            } else {
+                tv.setVisibility(View.GONE);
             }
 
             return v;