commit 2eb70e4a89a1b00a53d317d1677e9cf70c8aaadd
Author: leszek <leszek@koltunski.pl>
Date:   Fri Apr 26 15:37:35 2024 +0200

    some progress with the main settings popup

diff --git a/src/main/java/org/distorted/main/MainActivity.java b/src/main/java/org/distorted/main/MainActivity.java
index 7bfc549e..3128fea5 100644
--- a/src/main/java/org/distorted/main/MainActivity.java
+++ b/src/main/java/org/distorted/main/MainActivity.java
@@ -412,13 +412,13 @@ android.util.Log.e("D", "onDestroy");
 
     public void onSettings(View v)
       {
-      int sw = (int)(mScreenWidth*0.7);
-      int sh = (int)(mScreenHeight*0.2f);
+      int sw = (int)(mScreenWidth*0.70);
+      int sh = (int)(mScreenHeight*0.25f);
 
       int vw = v.getWidth();
 
-      MainSettingsPopup popup = new MainSettingsPopup(this,mSortMode,mCurrentTheme,mScreenWidth,mScreenHeight);
-      popup.displayPopup(this,v,sw,sh,((vw-sw)/2),0);
+      MainSettingsPopup popup = new MainSettingsPopup(this,mSortMode,mCurrentTheme,mScreenWidth,sw,sh);
+      popup.displayPopup(this,v,((vw-sw)/2),0);
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/main/MainSettingsPopup.java b/src/main/java/org/distorted/main/MainSettingsPopup.java
index 46fead80..19b19b9f 100644
--- a/src/main/java/org/distorted/main/MainSettingsPopup.java
+++ b/src/main/java/org/distorted/main/MainSettingsPopup.java
@@ -42,6 +42,7 @@ public class MainSettingsPopup implements AdapterView.OnItemSelectedListener
   private static final float MENU_TEXT_SIZE = 0.060f;
   private static final int[] mLocation = new int[2];
 
+  private final int mWidth, mHeight;
   private PopupWindow mPopup;
   private WeakReference<MainActivity> mAct;
   private int mCurrMethod;
@@ -85,10 +86,14 @@ public class MainSettingsPopup implements AdapterView.OnItemSelectedListener
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  MainSettingsPopup(MainActivity act, int sortMethod, int themeValue, int width, int height)
+  MainSettingsPopup(MainActivity act, int sortMethod, int themeValue,
+                    int scrWidth, int popupWidth, int popupHeight)
     {
     mAct = new WeakReference<>(act);
 
+    mWidth = popupWidth;
+    mHeight= popupHeight;
+
     // due to bugs in Android API <=25, a Spinner inside a PopupWindow will crash once you click on it.
     // solution: on those APIs, use a special Spinner in dialog mode (this does not crash)
     int id = android.os.Build.VERSION.SDK_INT <= 25 ? R.layout.settings_popup_android25 : R.layout.settings_popup;
@@ -100,15 +105,15 @@ public class MainSettingsPopup implements AdapterView.OnItemSelectedListener
     mPopup.setContentView(layout);
     mPopup.setFocusable(true);
 
-    int titleSize = (int)(MENU_TITLE_SIZE*width);
-    int textSize  = (int)(MENU_TEXT_SIZE*width);
+    int titleSize = (int)(0.26f*popupHeight);
+    int textSize  = (int)(0.19f*popupHeight);
 
     TextView title = layout.findViewById(R.id.settingsTitle);
-    title.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
+    //title.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
     TextView sortText = layout.findViewById(R.id.sortText);
-    sortText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
+    //sortText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
     TextView themeTitle = layout.findViewById(R.id.themeText);
-    themeTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
+   // themeTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
 
     Spinner sortSpinner  = layout.findViewById(R.id.sortMethod);
     sortSpinner.setOnItemSelectedListener(this);
@@ -116,7 +121,7 @@ public class MainSettingsPopup implements AdapterView.OnItemSelectedListener
     mCurrMethod = sortMethod;
     buildSortOptions(act);
 
-    ArrayAdapter<String> sortAdapter = new ArrayAdapter<>(act, android.R.layout.simple_spinner_item, mSortNames);
+    ArrayAdapter<String> sortAdapter = new ArrayAdapter<>(act, R.layout.settings_spinner_item, mSortNames);
     sortAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
     sortSpinner.setAdapter(sortAdapter);
 
@@ -128,7 +133,7 @@ public class MainSettingsPopup implements AdapterView.OnItemSelectedListener
     mCurrTheme = themeValue;
     buildThemeOptions(act);
 
-    ArrayAdapter<String> themeAdapter = new ArrayAdapter<>(act, android.R.layout.simple_spinner_item, mThemeNames);
+    ArrayAdapter<String> themeAdapter = new ArrayAdapter<>(act, R.layout.settings_spinner_item, mThemeNames);
     themeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
     themeSpinner.setAdapter(themeAdapter);
 
@@ -164,7 +169,7 @@ public class MainSettingsPopup implements AdapterView.OnItemSelectedListener
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // work around lame bugs in Android's version <= 10 pop-up and split-screen modes
 
-  public void displayPopup(MainActivity act, View view, int w, int h, int xoff, int yoff)
+  public void displayPopup(MainActivity act, View view, int xoff, int yoff)
     {
     View v = mPopup.getContentView();
     v.setSystemUiVisibility(MainActivity.FLAGS);
@@ -189,17 +194,17 @@ public class MainSettingsPopup implements AdapterView.OnItemSelectedListener
       if (Build.VERSION_CODES.R<=Build.VERSION.SDK_INT || isFullScreen )
         {
         mPopup.showAsDropDown(view, xoff, yoff, Gravity.CENTER);
-        mPopup.update(view, w, h);
+        mPopup.update(view, mWidth, mHeight);
         }
       else  // Android 10 or below in pop-up mode or split-screen mode
         {
         view.getLocationOnScreen(mLocation);
         int width  = view.getWidth();
         int height = view.getHeight();
-        int x = mLocation[0]+(width-w)/2;
+        int x = mLocation[0]+(width-mWidth)/2;
         int y = mLocation[1]+height+yoff;
         mPopup.showAsDropDown(view);
-        mPopup.update(x,y,w,h);
+        mPopup.update(x,y,mWidth,mHeight);
         }
       }
     catch( IllegalArgumentException iae )
diff --git a/src/main/res/layout/settings_popup.xml b/src/main/res/layout/settings_popup.xml
index 44aadfcc..b8272e9a 100644
--- a/src/main/res/layout/settings_popup.xml
+++ b/src/main/res/layout/settings_popup.xml
@@ -11,6 +11,7 @@
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:text="@string/settings_title"
+        android:textSize="34sp"
         android:background="@color/light_grey"
         android:gravity="center"/>
 
@@ -27,12 +28,14 @@
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
             android:text="@string/sort_by"
+            android:textSize="24sp"
             android:gravity="start|center_vertical"/>
 
         <Spinner
             android:id="@+id/sortMethod"
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
+            android:layout_margin="10dip"
             android:gravity="center|center_vertical"/>
 
         <TextView
@@ -42,12 +45,14 @@
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
             android:text="@string/theme"
+            android:textSize="24sp"
             android:gravity="start|center_vertical"/>
 
         <Spinner
             android:id="@+id/themeValue"
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
+            android:layout_margin="10dip"
             android:gravity="center|center_vertical"/>
 
    </GridLayout>
diff --git a/src/main/res/layout/settings_spinner_item.xml b/src/main/res/layout/settings_spinner_item.xml
new file mode 100644
index 00000000..bde17195
--- /dev/null
+++ b/src/main/res/layout/settings_spinner_item.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<TextView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    style="?android:attr/spinnerItemStyle"
+    android:layout_width="80dp"
+    android:layout_height="wrap_content"
+    android:textSize="24sp"
+    android:gravity="end"
+    android:singleLine="true"
+    android:textColor="#FFFFFF"
+    />
\ No newline at end of file
