Project

General

Profile

« Previous | Next » 

Revision 236cc1c1

Added by Leszek Koltunski 8 months ago

major progress with the main settings popup

View differences:

src/main/java/org/distorted/helpers/BaseActivity.java
44 44
    protected int mCurrentTheme;
45 45
    protected int mScreenWidth, mScreenHeight;
46 46
    protected int mHeightLowerBar, mHeightUpperBar;
47
    protected float mDensity;
47 48
    protected SharedPreferences mPreferences;
48 49

  
49 50
///////////////////////////////////////////////////////////////////////////////////////////////////
......
54 55
      mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
55 56
      mCurrentTheme = mPreferences.getInt("theme",THEME_GREY);
56 57

  
58
      mDensity = getResources().getDisplayMetrics().density;
59

  
57 60
      switch(mCurrentTheme)
58 61
        {
59 62
        case THEME_WHITE : setTheme(R.style.WhiteTheme); break;
......
61 64
        default          : setTheme(R.style.GreyTheme);  break;
62 65
        }
63 66

  
64
      android.util.Log.e("D", "current theme: "+mCurrentTheme);
65

  
66 67
      super.onCreate(savedState);
67 68
      }
68 69

  
src/main/java/org/distorted/main/MainActivity.java
14 14
import android.content.pm.PackageInfo;
15 15
import android.content.pm.PackageManager;
16 16
import android.content.res.Configuration;
17
import android.os.Build;
18 17
import android.os.Bundle;
19 18
import android.util.TypedValue;
20
import android.view.DisplayCutout;
21 19
import android.view.View;
22 20
import android.view.ViewGroup;
23 21
import android.widget.LinearLayout;
......
79 77
      computeHeights();
80 78

  
81 79
      getWindowWidth(getResources().getConfiguration());
82
android.util.Log.e("D", "onCreate: "+mScreenWidth+" "+mScreenHeight);
83 80

  
84 81
      mCurrVersion = getAppVers();
85 82

  
......
120 117
      layoutBot.setLayoutParams(pL);
121 118
      }
122 119

  
123
///////////////////////////////////////////////////////////////////////////////////////////////////
124
/*
125
    @Override
126
    public void onAttachedToWindow()
127
      {
128
      super.onAttachedToWindow();
129

  
130
      getWindowWidth(getResources().getConfiguration());
131

  
132

  
133
android.util.Log.e("D", "onAttachedToWindow: "+mScreenWidth+" "+mScreenHeight);
134

  
135

  
136
      mGrid = new MainScrollGrid();
137
      mGrid.createGrid(this,mScreenWidth,mSortMode);
138

  
139
      if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.P )
140
        {
141
        DisplayCutout cutout = getWindow().getDecorView().getRootWindowInsets().getDisplayCutout();
142
        int insetHeight = cutout!=null ? cutout.getSafeInsetTop() : 0;
143

  
144
        if( insetHeight>0 )
145
          {
146
          LinearLayout.LayoutParams pH = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, RATIO_HID);
147
          LinearLayout layoutHid = findViewById(R.id.hiddenBar);
148
          layoutHid.setLayoutParams(pH);
149

  
150
          LinearLayout.LayoutParams pS = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1-2*RATIO_BAR-RATIO_HID);
151
          ScrollView scroll = findViewById(R.id.objectScroll);
152
          scroll.setLayoutParams(pS);
153
          }
154
        }
155
      }
156
*/
157 120
///////////////////////////////////////////////////////////////////////////////////////////////////
158 121

  
159 122
    @Override
160 123
    public void onConfigurationChanged(@NonNull Configuration conf)
161 124
      {
162 125
      super.onConfigurationChanged(conf);
163

  
164
android.util.Log.e("D", "onConfigurationChanged");
165

  
166 126
      getWindowWidth(conf);
167 127
      if( mGrid!=null ) mGrid.updateGrid(this,mScreenWidth);
168 128
      }
......
175 135
      super.onPause();
176 136
      RubikNetwork.onPause();
177 137
      savePreferences();
178

  
179

  
180
android.util.Log.e("D", "onPause");
181

  
182 138
      }
183 139

  
184 140
///////////////////////////////////////////////////////////////////////////////////////////////////
......
188 144
      {
189 145
      super.onResume();
190 146

  
191
android.util.Log.e("D", "onResume");
192

  
193 147
      restorePreferences(mJustStarted);
194 148

  
195 149
      RubikNetwork network = RubikNetwork.getInstance();
......
225 179
    protected void onDestroy() 
226 180
      {
227 181
      super.onDestroy();
228

  
229
android.util.Log.e("D", "onDestroy");
230 182
      }
231 183

  
232 184
///////////////////////////////////////////////////////////////////////////////////////////////////
......
412 364

  
413 365
    public void onSettings(View v)
414 366
      {
415
      int sw = (int)(mScreenWidth*0.70);
416
      int sh = (int)(mScreenHeight*0.25f);
367
      int sw = (int)(340*mDensity + 0.5f);
368
      int sh = (int)(188*mDensity + 0.5f);
417 369

  
418 370
      int vw = v.getWidth();
419 371

  
src/main/java/org/distorted/main/MainSettingsPopup.java
122 122
    buildSortOptions(act);
123 123

  
124 124
    ArrayAdapter<String> sortAdapter = new ArrayAdapter<>(act, R.layout.settings_spinner_item, mSortNames);
125
    sortAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
125
    sortAdapter.setDropDownViewResource(R.layout.settings_spinner_item);
126 126
    sortSpinner.setAdapter(sortAdapter);
127 127

  
128 128
    if( sortMethod>=0 && sortMethod<mSortNames.length ) sortSpinner.setSelection(sortMethod);
......
134 134
    buildThemeOptions(act);
135 135

  
136 136
    ArrayAdapter<String> themeAdapter = new ArrayAdapter<>(act, R.layout.settings_spinner_item, mThemeNames);
137
    themeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
137
    themeAdapter.setDropDownViewResource(R.layout.settings_spinner_item);
138 138
    themeSpinner.setAdapter(themeAdapter);
139 139

  
140 140
    if( themeValue>=0 && themeValue<mThemeNames.length ) themeSpinner.setSelection(themeValue);
src/main/res/layout/settings_popup.xml
23 23

  
24 24
        <TextView
25 25
            android:id="@+id/sortText"
26
            android:layout_marginStart="5dp"
27
            android:layout_marginEnd="25dp"
26
            android:layout_marginStart="10dp"
27
            android:layout_marginEnd="15dp"
28
            android:layout_marginTop="10dp"
29
            android:layout_marginBottom="10dp"
28 30
            android:layout_width="wrap_content"
29 31
            android:layout_height="match_parent"
30 32
            android:text="@string/sort_by"
......
35 37
            android:id="@+id/sortMethod"
36 38
            android:layout_width="wrap_content"
37 39
            android:layout_height="match_parent"
38
            android:layout_margin="10dip"
39
            android:gravity="center|center_vertical"/>
40
            android:layout_marginStart="15dp"
41
            android:layout_marginEnd="10dp"
42
            android:layout_marginTop="10dp"
43
            android:layout_marginBottom="10dp"
44
            android:gravity="start|center_vertical"/>
40 45

  
41 46
        <TextView
42 47
            android:id="@+id/themeText"
43
            android:layout_marginStart="5dp"
44
            android:layout_marginEnd="25dp"
48
            android:layout_marginStart="10dp"
49
            android:layout_marginEnd="15dp"
50
            android:layout_marginTop="10dp"
51
            android:layout_marginBottom="10dp"
45 52
            android:layout_width="wrap_content"
46 53
            android:layout_height="match_parent"
47 54
            android:text="@string/theme"
......
52 59
            android:id="@+id/themeValue"
53 60
            android:layout_width="wrap_content"
54 61
            android:layout_height="match_parent"
55
            android:layout_margin="10dip"
56
            android:gravity="center|center_vertical"/>
62
            android:layout_marginStart="15dp"
63
            android:layout_marginEnd="10dp"
64
            android:layout_marginTop="10dp"
65
            android:layout_marginBottom="10dp"
66
            android:gravity="start|center_vertical"/>
57 67

  
58 68
   </GridLayout>
59 69
</LinearLayout>
src/main/res/layout/settings_popup_android25.xml
11 11
        android:layout_width="match_parent"
12 12
        android:layout_height="wrap_content"
13 13
        android:text="@string/settings_title"
14
        android:textSize="34sp"
14 15
        android:background="@color/light_grey"
15 16
        android:gravity="center"/>
16 17

  
17
   <LinearLayout
18
        android:layout_width="wrap_content"
19
        android:layout_height="match_parent"
20
        android:gravity="center"
21
        android:orientation="horizontal">
18
   <GridLayout
19
        android:layout_width="match_parent"
20
        android:layout_height="wrap_content"
21
        android:rowCount="2"
22
        android:columnCount="2">
22 23

  
23
       <TextView
24
        <TextView
24 25
            android:id="@+id/sortText"
25
            android:layout_marginStart="5dp"
26
            android:layout_marginEnd="25dp"
26
            android:layout_marginStart="10dp"
27
            android:layout_marginEnd="15dp"
28
            android:layout_marginTop="10dp"
29
            android:layout_marginBottom="10dp"
27 30
            android:layout_width="wrap_content"
28 31
            android:layout_height="match_parent"
29 32
            android:text="@string/sort_by"
33
            android:textSize="24sp"
30 34
            android:gravity="start|center_vertical"/>
31 35

  
32 36
        <Spinner
33 37
            android:id="@+id/sortMethod"
34 38
            android:layout_width="wrap_content"
35 39
            android:layout_height="match_parent"
40
            android:layout_marginStart="15dp"
41
            android:layout_marginEnd="10dp"
42
            android:layout_marginTop="10dp"
43
            android:layout_marginBottom="10dp"
36 44
            android:spinnerMode="dialog"
37
            android:gravity="end|center_vertical"/>
38

  
39
   </LinearLayout>
40

  
41
   <LinearLayout
42
        android:layout_width="wrap_content"
43
        android:layout_height="match_parent"
44
        android:gravity="center"
45
        android:orientation="horizontal">
45
            android:gravity="start|center_vertical"/>
46 46

  
47
       <TextView
47
        <TextView
48 48
            android:id="@+id/themeText"
49
            android:layout_marginStart="5dp"
50
            android:layout_marginEnd="25dp"
49
            android:layout_marginStart="10dp"
50
            android:layout_marginEnd="15dp"
51
            android:layout_marginTop="10dp"
52
            android:layout_marginBottom="10dp"
51 53
            android:layout_width="wrap_content"
52 54
            android:layout_height="match_parent"
53 55
            android:text="@string/theme"
56
            android:textSize="24sp"
54 57
            android:gravity="start|center_vertical"/>
55 58

  
56
       <Spinner
59
        <Spinner
57 60
            android:id="@+id/themeValue"
58 61
            android:layout_width="wrap_content"
59 62
            android:layout_height="match_parent"
60
            android:gravity="end|center_vertical"/>
63
            android:layout_marginStart="15dp"
64
            android:layout_marginEnd="10dp"
65
            android:layout_marginTop="10dp"
66
            android:layout_marginBottom="10dp"
67
            android:spinnerMode="dialog"
68
            android:gravity="start|center_vertical"/>
61 69

  
62
   </LinearLayout>
70
   </GridLayout>
63 71
</LinearLayout>
src/main/res/layout/settings_spinner_item.xml
3 3
<TextView
4 4
    xmlns:android="http://schemas.android.com/apk/res/android"
5 5
    style="?android:attr/spinnerItemStyle"
6
    android:layout_width="80dp"
6
    android:layout_width="160dp"
7 7
    android:layout_height="wrap_content"
8
    android:paddingTop="8dp"
9
    android:paddingBottom="8dp"
8 10
    android:textSize="24sp"
9
    android:gravity="end"
11
    android:gravity="start"
10 12
    android:singleLine="true"
11 13
    android:textColor="#FFFFFF"
12 14
    />
src/main/res/values-de/strings.xml
90 90
    <string name="config_corner">Ecken</string>
91 91
    <string name="config_no_support">Das aktuelle Puzzle unterstützt keine Farbanpassung.</string>
92 92

  
93
    <string name="sort_classic">klassisch</string>
94
    <string name="sort_shape">form</string>
95
    <string name="sort_difficulty">schwierigkeit</string>
96
    <string name="sort_author">autor</string>
97
    <string name="sort_year">jahr</string>
93
    <string name="sort_classic">Klassisch</string>
94
    <string name="sort_shape">Form</string>
95
    <string name="sort_difficulty">Schwierigkeit</string>
96
    <string name="sort_author">Autor</string>
97
    <string name="sort_year">Jahr</string>
98 98

  
99 99
    <string name="credits1">Open Source App, die mit der Distorted Graphics Library entwickelt wurde. Lizenziert unter <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPL Version 2</a> oder wie gewünscht einer späteren Version.</string>
100 100
    <string name="credits2">Hübsche Muster von Walter Randelshofer. Sehen Sie <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string>
src/main/res/values-es/strings.xml
90 90
    <string name="config_corner">Esquinas</string>
91 91
    <string name="config_no_support">El cubo actual no admite el ajuste de colores.</string>
92 92

  
93
    <string name="sort_classic">clásico</string>
94
    <string name="sort_shape">forma</string>
95
    <string name="sort_difficulty">dificultad</string>
96
    <string name="sort_author">autor</string>
97
    <string name="sort_year">año</string>
93
    <string name="sort_classic">Clásico</string>
94
    <string name="sort_shape">Forma</string>
95
    <string name="sort_difficulty">Dificultad</string>
96
    <string name="sort_author">Autor</string>
97
    <string name="sort_year">Año</string>
98 98

  
99 99
    <string name="credits1">Aplicación de código abierto desarrollada con la biblioteca de gráficos de Distorted. Con licencia <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPL versión 2</a> o, a tu elección, cualquier versión posterior.</string>
100 100
    <string name="credits2">Pretty Patterns por Walter Randelshofer. Mira <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string>
src/main/res/values-fr/strings.xml
90 90
    <string name="config_corner">Coins</string>
91 91
    <string name="config_no_support">Le cube actuel ne prend pas en charge le réglage des couleurs.</string>
92 92

  
93
    <string name="sort_classic">classique</string>
94
    <string name="sort_shape">forme</string>
95
    <string name="sort_difficulty">difficulté</string>
96
    <string name="sort_author">auteur</string>
97
    <string name="sort_year">année</string>
93
    <string name="sort_classic">Classique</string>
94
    <string name="sort_shape">Forme</string>
95
    <string name="sort_difficulty">Difficulté</string>
96
    <string name="sort_author">Auteur</string>
97
    <string name="sort_year">Année</string>
98 98

  
99 99
    <string name="credits1">Appli Open Source développée à l\'aide de la bibliothèque graphique Distorted. Sous licence <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPL version 2</a> ou - à votre choix - toute version ultérieure.</string>
100 100
    <string name="credits2">Pretty Patterns par Walter Randelshofer. Voir <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string>
src/main/res/values-pl/strings.xml
90 90
    <string name="config_corner">Rogi</string>
91 91
    <string name="config_no_support">Bieżąca kostka nie wspomaga zmieniania kolorów.</string>
92 92

  
93
    <string name="sort_classic">klasycznie</string>
94
    <string name="sort_shape">kształt</string>
95
    <string name="sort_difficulty">trudność</string>
96
    <string name="sort_author">autor</string>
97
    <string name="sort_year">rok</string>
93
    <string name="sort_classic">Klasycznie</string>
94
    <string name="sort_shape">Kształt</string>
95
    <string name="sort_difficulty">Trudność</string>
96
    <string name="sort_author">Autor</string>
97
    <string name="sort_year">Rok</string>
98 98

  
99 99
    <string name="credits1">Aplikacja open-source napisana wykorzystując bibliotekę Distorted. Licencja: <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPL wersja 2</a> albo jakakolwiek poźniejsza.</string>
100 100
    <string name="credits2">Piękne Wzory Waltera Randelshofera. Zobacz <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string>
src/main/res/values-ru/strings.xml
90 90
    <string name="config_corner">Углы</string>
91 91
    <string name="config_no_support">Текущий куб не поддерживает настройку цветов.</string>
92 92

  
93
    <string name="sort_classic">классик</string>
94
    <string name="sort_shape">форма</string>
95
    <string name="sort_difficulty">сложность</string>
96
    <string name="sort_author">автор</string>
97
    <string name="sort_year">год</string>
93
    <string name="sort_classic">Классик</string>
94
    <string name="sort_shape">Форма</string>
95
    <string name="sort_difficulty">Сложность</string>
96
    <string name="sort_author">Автор</string>
97
    <string name="sort_year">Год</string>
98 98

  
99 99
    <string name="credits1">Приложение с открытым исходным кодом, разработанное с использованием библиотеки графики Искажений. Лицензируется согласно <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">версии 2 GPL</a> или любой более поздней версии по вашему выбору.</string>
100 100
    <string name="credits2">Pretty Patterns по Walter Randelshofer. Смотри <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string>
src/main/res/values/strings.xml
124 124
    <string name="sort_by">Sort by</string>
125 125
    <string name="settings_title">Settings</string>
126 126

  
127
    <string name="sort_classic">classic</string>
128
    <string name="sort_shape">shape</string>
129
    <string name="sort_difficulty">difficulty</string>
130
    <string name="sort_author">author</string>
131
    <string name="sort_year">year</string>
127
    <string name="sort_classic">Classic</string>
128
    <string name="sort_shape">Shape</string>
129
    <string name="sort_difficulty">Difficulty</string>
130
    <string name="sort_author">Author</string>
131
    <string name="sort_year">Year</string>
132 132

  
133 133
    <string name="webview_error" translatable="false">Error Loading WebView</string>
134 134
    <string name="opengl_error" translatable="false">Error</string>

Also available in: Unified diff