commit cd432dd3a220a663cb870660a16424c1ca8fd514
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue Aug 16 14:36:28 2022 +0200

    IAP part 5: new 'Purchase' activity (cont'd)

diff --git a/src/main/java/org/distorted/purchase/PurchaseScreenPane.java b/src/main/java/org/distorted/purchase/PurchaseScreenPane.java
index c61c00aa..482ad9d9 100644
--- a/src/main/java/org/distorted/purchase/PurchaseScreenPane.java
+++ b/src/main/java/org/distorted/purchase/PurchaseScreenPane.java
@@ -12,7 +12,6 @@ package org.distorted.purchase;
 import android.util.TypedValue;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
-import android.widget.RelativeLayout;
 import android.widget.TextView;
 
 import org.distorted.main.R;
@@ -37,7 +36,7 @@ public class PurchaseScreenPane
 
   private static final int NUM_IMAGES      = IMAGES.length;
   public  static final float PADDING_RATIO = 0.025f;
-  private static final float TEXT_RATIO    = 0.042f;
+  private static final float TEXT_RATIO    = 0.050f;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -49,26 +48,34 @@ public class PurchaseScreenPane
       {
       InputStream stream = object.getObjectStream(act);
       JsonReader reader = JsonReader.getInstance();
-      String name;
-      int difficulty;
+      String author, name;
+      int year, difficulty;
 
       try
         {
         reader.parseJsonFileMetadata(stream);
         name       = reader.getObjectName();
+        author     = reader.getInventor();
+        year       = reader.getYearOfInvention();
         difficulty = reader.getComplexity();
         }
       catch(Exception ex)
         {
         name = "?";
+        author = "?";
+        year = 0;
         difficulty = 0;
         }
 
       if( difficulty<0           ) difficulty=0;
       if( difficulty>=NUM_IMAGES ) difficulty=NUM_IMAGES-1;
 
-      TextView view = act.findViewById(R.id.purchaseDetailsName);
-      view.setText(name);
+      String both = year>0 ? author+" "+year : author;
+
+      TextView v1 = act.findViewById(R.id.purchaseUpperName);
+      v1.setText(name);
+      TextView v2 = act.findViewById(R.id.purchaseUpperAuthor);
+      v2.setText(both);
       ImageView image = act.findViewById(R.id.purchaseDifficulty);
       image.setImageResource(IMAGES[difficulty]);
       }
@@ -82,26 +89,34 @@ public class PurchaseScreenPane
     float textSize = width*TEXT_RATIO;
     int padding = (int)(width*PADDING_RATIO);
 
-    RelativeLayout upperBar  = act.findViewById(R.id.upperBar);
-    LinearLayout oneLayout   = act.findViewById(R.id.purchaseLayoutOne);
-    LinearLayout allLayout   = act.findViewById(R.id.purchaseLayoutAll);
+    LinearLayout upperBar  = act.findViewById(R.id.upperBar);
+    LinearLayout oneLayout = act.findViewById(R.id.purchaseLayoutOne);
+    LinearLayout allLayout = act.findViewById(R.id.purchaseLayoutAll);
 
-    upperBar.setPadding(padding,padding,padding,padding/2);
+    upperBar.setPadding( padding,padding/2,padding,padding/2);
     oneLayout.setPadding(padding,padding/2,padding,padding/2);
     allLayout.setPadding(padding,padding/2,padding,padding/2);
 
-    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.00f);
-    params.bottomMargin = 0;
-    params.topMargin    = padding;
-    params.leftMargin   = padding;
-    params.rightMargin  = padding;
+    LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.00f);
+    params1.bottomMargin = 0;
+    params1.topMargin    = padding;
+    params1.leftMargin   = padding;
+    params1.rightMargin  = padding;
+
+    LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.00f);
+    params2.bottomMargin = padding;
+    params2.topMargin    = padding;
+    params2.leftMargin   = padding;
+    params2.rightMargin  = padding;
 
-    upperBar.setLayoutParams(params);
-    oneLayout.setLayoutParams(params);
-    allLayout.setLayoutParams(params);
+    upperBar.setLayoutParams(params1);
+    oneLayout.setLayoutParams(params1);
+    allLayout.setLayoutParams(params2);
 
     TextView text;
-    text = upperBar.findViewById(R.id.purchaseDetailsName);
+    text = upperBar.findViewById(R.id.purchaseUpperName);
+    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
+    text = upperBar.findViewById(R.id.purchaseUpperAuthor);
     text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
     text = oneLayout.findViewById(R.id.purchaseTextOne);
     text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
diff --git a/src/main/res/layout/purchase.xml b/src/main/res/layout/purchase.xml
index 778c3a56..d3632cff 100644
--- a/src/main/res/layout/purchase.xml
+++ b/src/main/res/layout/purchase.xml
@@ -6,7 +6,7 @@
     android:background="@color/light_grey"
     android:orientation="vertical">
 
-    <RelativeLayout
+    <LinearLayout
          android:id="@+id/upperBar"
          android:layout_width="fill_parent"
          android:layout_height="100dp"
@@ -15,22 +15,40 @@
          android:background="@color/grey"
          android:orientation="horizontal">
 
-         <TextView
-             android:id="@+id/purchaseDetailsName"
-             android:layout_width="wrap_content"
+         <LinearLayout
+             android:id="@+id/upperBarLeft"
+             android:layout_width="0dp"
              android:layout_height="match_parent"
-             android:layout_alignParentStart="true"
-             android:paddingStart="5dp"
-             android:textSize="26sp"
-             android:singleLine="true"
-             android:maxLines="1"/>
+             android:layout_weight="3.0"
+             android:gravity="center_vertical|start"
+             android:background="@color/grey"
+             android:orientation="vertical">
+
+             <TextView
+                 android:id="@+id/purchaseUpperName"
+                 android:layout_width="match_parent"
+                 android:layout_height="wrap_content"
+                 android:paddingStart="5dp"
+                 android:textSize="26sp"
+                 android:singleLine="true"
+                 android:maxLines="1"/>
+             <TextView
+                 android:id="@+id/purchaseUpperAuthor"
+                 android:layout_width="match_parent"
+                 android:layout_height="wrap_content"
+                 android:paddingStart="5dp"
+                 android:textSize="26sp"
+                 android:singleLine="true"
+                 android:maxLines="1"/>
+         </LinearLayout>
 
          <ImageView
              android:id="@+id/purchaseDifficulty"
-             android:layout_width="wrap_content"
+             android:layout_width="0dp"
              android:layout_height="match_parent"
-             android:layout_alignParentEnd="true"/>
-    </RelativeLayout>
+             android:layout_weight="1.0"/>
+
+    </LinearLayout>
 
     <org.distorted.purchase.PurchaseSurfaceView
         android:id="@+id/purchaseSurfaceView"
