Revision 881697b3
Added by Leszek Koltunski 11 months ago
src/main/java/org/distorted/main/MainSettingsPopup.java | ||
---|---|---|
10 | 10 |
package org.distorted.main; |
11 | 11 |
|
12 | 12 |
import android.content.Context; |
13 |
import android.content.res.Resources; |
|
13 | 14 |
import android.os.Build; |
14 | 15 |
import android.util.TypedValue; |
15 | 16 |
import android.view.Gravity; |
... | ... | |
30 | 31 |
public class MainSettingsPopup implements AdapterView.OnItemSelectedListener |
31 | 32 |
{ |
32 | 33 |
public static final int SORT_CLASSIC = 0; |
33 |
public static final int SORT_CATEGORY = 1;
|
|
34 |
public static final int SORT_SHAPE = 1;
|
|
34 | 35 |
public static final int SORT_DIFFICULTY = 2; |
35 | 36 |
public static final int SORT_AUTHOR = 3; |
36 | 37 |
public static final int SORT_YEAR = 4; |
37 | 38 |
|
38 | 39 |
public static final int SORT_DEFAULT = SORT_CLASSIC; |
39 | 40 |
|
40 |
private static final String[] mSortNames = { "Classic" , "Category" , "Difficulty", "Author" , "Year" }; |
|
41 | 41 |
private static final float MENU_TITLE_SIZE= 0.070f; |
42 | 42 |
private static final float MENU_TEXT_SIZE = 0.060f; |
43 | 43 |
private static final int[] mLocation = new int[2]; |
... | ... | |
45 | 45 |
private final PopupWindow mPopup; |
46 | 46 |
private final WeakReference<MainActivity> mAct; |
47 | 47 |
private int mCurrMethod; |
48 |
private String[] mSortNames; |
|
48 | 49 |
|
49 | 50 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
50 | 51 |
// this is supposed to prevent showing the navigational bar when we show the drop down list, |
... | ... | |
109 | 110 |
actSpinner.setOnItemSelectedListener(this); |
110 | 111 |
|
111 | 112 |
mCurrMethod = sortMethod; |
113 |
buildSortOptions(act); |
|
112 | 114 |
|
113 | 115 |
ArrayAdapter<String> actAdapter = new ArrayAdapter<>(act, android.R.layout.simple_spinner_item, mSortNames); |
114 | 116 |
actAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
... | ... | |
117 | 119 |
if( sortMethod>=0 && sortMethod<mSortNames.length ) actSpinner.setSelection(sortMethod); |
118 | 120 |
} |
119 | 121 |
|
122 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
123 |
|
|
124 |
private void buildSortOptions(MainActivity act) |
|
125 |
{ |
|
126 |
Resources res = act.getResources(); |
|
127 |
mSortNames = new String[5]; |
|
128 |
|
|
129 |
mSortNames[0] = res.getString(R.string.sort_classic); |
|
130 |
mSortNames[1] = res.getString(R.string.sort_shape); |
|
131 |
mSortNames[2] = res.getString(R.string.sort_difficulty); |
|
132 |
mSortNames[3] = res.getString(R.string.sort_author); |
|
133 |
mSortNames[4] = res.getString(R.string.sort_year); |
|
134 |
} |
|
135 |
|
|
120 | 136 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
121 | 137 |
// work around lame bugs in Android's version <= 10 pop-up and split-screen modes |
122 | 138 |
|
src/main/java/org/distorted/objects/RubikObjectCategories.java | ||
---|---|---|
69 | 69 |
{ |
70 | 70 |
switch(sortMode) |
71 | 71 |
{ |
72 |
case SORT_CATEGORY : return new RubikObjectCategoriesCat();
|
|
72 |
case SORT_SHAPE : return new RubikObjectCategoriesShape();
|
|
73 | 73 |
case SORT_DIFFICULTY: return new RubikObjectCategoriesDiff(); |
74 | 74 |
case SORT_AUTHOR : return new RubikObjectCategoriesAuthor(); |
75 | 75 |
case SORT_YEAR : return new RubikObjectCategoriesYear(); |
src/main/java/org/distorted/objects/RubikObjectCategoriesCat.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2024 Leszek Koltunski // |
|
3 |
// // |
|
4 |
// This file is part of Magic Cube. // |
|
5 |
// // |
|
6 |
// Magic Cube is proprietary software licensed under an EULA which you should have received // |
|
7 |
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html // |
|
8 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
9 |
|
|
10 |
package org.distorted.objects; |
|
11 |
|
|
12 |
import java.util.Arrays; |
|
13 |
|
|
14 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
15 |
|
|
16 |
public class RubikObjectCategoriesCat extends RubikObjectCategories |
|
17 |
{ |
|
18 |
private void buildSort(int[] data) |
|
19 |
{ |
|
20 |
int numObjects = data.length; |
|
21 |
int[] sorted = new int[numObjects]; |
|
22 |
System.arraycopy(data, 0, sorted, 0, numObjects); |
|
23 |
|
|
24 |
Arrays.sort(sorted); |
|
25 |
|
|
26 |
int[] categories = new int[numObjects]; |
|
27 |
int numCategories = 0; |
|
28 |
|
|
29 |
for(int o=0; o<numObjects; o++) |
|
30 |
if( o==0 || sorted[o-1]!=sorted[o] ) |
|
31 |
{ |
|
32 |
categories[numCategories] = sorted[o]; |
|
33 |
numCategories++; |
|
34 |
} |
|
35 |
|
|
36 |
int lastChange = -1; |
|
37 |
int curr = 0; |
|
38 |
int[] numInCategory = new int[numCategories]; |
|
39 |
|
|
40 |
for(int o=0; o<numObjects; o++) |
|
41 |
if( o==numObjects-1 || sorted[o]!=sorted[o+1] ) |
|
42 |
{ |
|
43 |
numInCategory[curr] = o-lastChange; |
|
44 |
curr++; |
|
45 |
lastChange = o; |
|
46 |
} |
|
47 |
|
|
48 |
mObjectIndices = new int[numCategories][]; |
|
49 |
|
|
50 |
for(int c=0; c<numCategories; c++) |
|
51 |
{ |
|
52 |
mObjectIndices[c] = new int[numInCategory[c]]; |
|
53 |
|
|
54 |
int cat = categories[c]; |
|
55 |
int index = 0; |
|
56 |
|
|
57 |
for(int o=0; o<numObjects; o++) |
|
58 |
if( data[o]==cat ) mObjectIndices[c][index++] = o; |
|
59 |
} |
|
60 |
} |
|
61 |
|
|
62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
63 |
|
|
64 |
void buildIndices() |
|
65 |
{ |
|
66 |
int numObjects = RubikObjectList.getNumObjects(); |
|
67 |
int[] cats = new int[numObjects]; |
|
68 |
|
|
69 |
for(int o=0; o<numObjects; o++) |
|
70 |
{ |
|
71 |
RubikObject obj = RubikObjectList.getObject(o); |
|
72 |
cats[o] = obj==null ? 0 : obj.getCategory(); |
|
73 |
} |
|
74 |
|
|
75 |
buildSort(cats); |
|
76 |
} |
|
77 |
|
|
78 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
79 |
|
|
80 |
void buildTitle() |
|
81 |
{ |
|
82 |
mIconIDs = new int[mNumCategories]; |
|
83 |
|
|
84 |
for(int t=0; t<mNumCategories; t++) |
|
85 |
{ |
|
86 |
int obj = mObjectIndices[t][0]; |
|
87 |
RubikObject object = RubikObjectList.getObject(obj); |
|
88 |
int category = object==null ? 0 : object.getCategory(); |
|
89 |
mIconIDs[t] = CATEGORY_IMAGES[category%5]; //TODO |
|
90 |
} |
|
91 |
} |
|
92 |
} |
src/main/java/org/distorted/objects/RubikObjectCategoriesShape.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2024 Leszek Koltunski // |
|
3 |
// // |
|
4 |
// This file is part of Magic Cube. // |
|
5 |
// // |
|
6 |
// Magic Cube is proprietary software licensed under an EULA which you should have received // |
|
7 |
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html // |
|
8 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
9 |
|
|
10 |
package org.distorted.objects; |
|
11 |
|
|
12 |
import java.util.Arrays; |
|
13 |
|
|
14 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
15 |
|
|
16 |
public class RubikObjectCategoriesShape extends RubikObjectCategories |
|
17 |
{ |
|
18 |
private void buildSort(int[] data) |
|
19 |
{ |
|
20 |
int numObjects = data.length; |
|
21 |
int[] sorted = new int[numObjects]; |
|
22 |
System.arraycopy(data, 0, sorted, 0, numObjects); |
|
23 |
|
|
24 |
Arrays.sort(sorted); |
|
25 |
|
|
26 |
int[] categories = new int[numObjects]; |
|
27 |
int numCategories = 0; |
|
28 |
|
|
29 |
for(int o=0; o<numObjects; o++) |
|
30 |
if( o==0 || sorted[o-1]!=sorted[o] ) |
|
31 |
{ |
|
32 |
categories[numCategories] = sorted[o]; |
|
33 |
numCategories++; |
|
34 |
} |
|
35 |
|
|
36 |
int lastChange = -1; |
|
37 |
int curr = 0; |
|
38 |
int[] numInCategory = new int[numCategories]; |
|
39 |
|
|
40 |
for(int o=0; o<numObjects; o++) |
|
41 |
if( o==numObjects-1 || sorted[o]!=sorted[o+1] ) |
|
42 |
{ |
|
43 |
numInCategory[curr] = o-lastChange; |
|
44 |
curr++; |
|
45 |
lastChange = o; |
|
46 |
} |
|
47 |
|
|
48 |
mObjectIndices = new int[numCategories][]; |
|
49 |
|
|
50 |
for(int c=0; c<numCategories; c++) |
|
51 |
{ |
|
52 |
mObjectIndices[c] = new int[numInCategory[c]]; |
|
53 |
|
|
54 |
int cat = categories[c]; |
|
55 |
int index = 0; |
|
56 |
|
|
57 |
for(int o=0; o<numObjects; o++) |
|
58 |
if( data[o]==cat ) mObjectIndices[c][index++] = o; |
|
59 |
} |
|
60 |
} |
|
61 |
|
|
62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
63 |
|
|
64 |
private int digestCategory(int cat) |
|
65 |
{ |
|
66 |
int shape = (cat & 0x7); |
|
67 |
int axis = (cat & 0x1f) >> 3; |
|
68 |
return (shape<<2) + axis; // only shape and axis sorted by shape |
|
69 |
} |
|
70 |
|
|
71 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
72 |
|
|
73 |
void buildIndices() |
|
74 |
{ |
|
75 |
int numObjects = RubikObjectList.getNumObjects(); |
|
76 |
int[] cats = new int[numObjects]; |
|
77 |
|
|
78 |
for(int o=0; o<numObjects; o++) |
|
79 |
{ |
|
80 |
RubikObject obj = RubikObjectList.getObject(o); |
|
81 |
int cat = obj==null ? 0 : obj.getCategory(); |
|
82 |
cats[o] = digestCategory(cat); |
|
83 |
} |
|
84 |
|
|
85 |
buildSort(cats); |
|
86 |
} |
|
87 |
|
|
88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
89 |
|
|
90 |
void buildTitle() |
|
91 |
{ |
|
92 |
mIconIDs = new int[mNumCategories]; |
|
93 |
|
|
94 |
for(int t=0; t<mNumCategories; t++) |
|
95 |
{ |
|
96 |
int obj = mObjectIndices[t][0]; |
|
97 |
RubikObject object = RubikObjectList.getObject(obj); |
|
98 |
int cat = object==null ? 0 : object.getCategory(); |
|
99 |
int category = digestCategory(cat); |
|
100 |
mIconIDs[t] = CATEGORY_IMAGES[category%5]; //TODO |
|
101 |
} |
|
102 |
} |
|
103 |
} |
src/main/res/values-de/strings.xml | ||
---|---|---|
85 | 85 |
<string name="config_mesh_fast">Schelles</string> |
86 | 86 |
<string name="config_mesh_nice">Hübsches</string> |
87 | 87 |
|
88 |
<string name="sort_classic">klassisch</string> |
|
89 |
<string name="sort_shape">form</string> |
|
90 |
<string name="sort_difficulty">schwierigkeit</string> |
|
91 |
<string name="sort_author">autor</string> |
|
92 |
<string name="sort_year">jahr</string> |
|
93 |
|
|
88 | 94 |
<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> |
89 | 95 |
<string name="credits2">Hübsche Muster von Walter Randelshofer. Sehen Sie <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
90 | 96 |
<string name="credits3">Rubik und Rubik Cube sind eingetragene Warenzeichen. Wir sind damit nicht verbunden.</string> |
src/main/res/values-es/strings.xml | ||
---|---|---|
85 | 85 |
<string name="config_mesh_fast">Rápida</string> |
86 | 86 |
<string name="config_mesh_nice">Bonita</string> |
87 | 87 |
|
88 |
<string name="sort_classic">clásico</string> |
|
89 |
<string name="sort_shape">forma</string> |
|
90 |
<string name="sort_difficulty">dificultad</string> |
|
91 |
<string name="sort_author">autor</string> |
|
92 |
<string name="sort_year">año</string> |
|
93 |
|
|
88 | 94 |
<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> |
89 | 95 |
<string name="credits2">Pretty Patterns por Walter Randelshofer. Mira <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
90 | 96 |
<string name="credits3">Rubik y Rubik Cube son marcas registradas. No estamos afiliados a ella.</string> |
src/main/res/values-fr/strings.xml | ||
---|---|---|
85 | 85 |
<string name="config_mesh_fast">Rapide</string> |
86 | 86 |
<string name="config_mesh_nice">Belle</string> |
87 | 87 |
|
88 |
<string name="sort_classic">classique</string> |
|
89 |
<string name="sort_shape">forme</string> |
|
90 |
<string name="sort_difficulty">difficulté</string> |
|
91 |
<string name="sort_author">auteur</string> |
|
92 |
<string name="sort_year">année</string> |
|
93 |
|
|
88 | 94 |
<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> |
89 | 95 |
<string name="credits2">Pretty Patterns par Walter Randelshofer. Voir <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
90 | 96 |
<string name="credits3">Rubik et Rubik Cube sont des marques déposées. Nous n\'y sommes pas affiliés.</string> |
src/main/res/values-ja/strings.xml | ||
---|---|---|
85 | 85 |
<string name="config_mesh_fast">速い</string> |
86 | 86 |
<string name="config_mesh_nice">良い</string> |
87 | 87 |
|
88 |
<string name="sort_classic">古典学</string> |
|
89 |
<string name="sort_shape">形</string> |
|
90 |
<string name="sort_difficulty">困難</string> |
|
91 |
<string name="sort_author">著者</string> |
|
92 |
<string name="sort_year">年</string> |
|
93 |
|
|
88 | 94 |
<string name="credits1">ディストートグラフィックのライブラリを使用して開発されたオープンソースアプリ。<a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPL バージョン 2</a>でライセンスされているか、または-オプション-それ以降のすべてのバージョン。</string> |
89 | 95 |
<string name="credits2">Pretty Patterns 沿って Walter Randelshofer. 見る <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
90 | 96 |
<string name="credits3">ルービックキューブおよびルービックキューブは登録商標です。 私たちはそれと提携していません。</string> |
src/main/res/values-ko/strings.xml | ||
---|---|---|
85 | 85 |
<string name="config_mesh_fast">빠른</string> |
86 | 86 |
<string name="config_mesh_nice">멋진</string> |
87 | 87 |
|
88 |
<string name="sort_classic">전통적인</string> |
|
89 |
<string name="sort_shape">모양</string> |
|
90 |
<string name="sort_difficulty">어려움</string> |
|
91 |
<string name="sort_author">작가</string> |
|
92 |
<string name="sort_year">년도</string> |
|
93 |
|
|
88 | 94 |
<string name="credits1">왜곡된 그래픽 라이브러리를 사용하여 개발된 오픈 소스 앱. <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPL 버전 2</a> 또는 귀하의 선택에 따라 최신 버전으로 라이센스가 부여됩니다.</string> |
89 | 95 |
<string name="credits2">Pretty Patterns 으로 Walter Randelshofer. 보다 <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
90 | 96 |
<string name="credits3">Rubik 및 Rubik Cube는 등록 상표입니다. 우리는 그것과 제휴하지 않습니다.</string> |
src/main/res/values-pl/strings.xml | ||
---|---|---|
85 | 85 |
<string name="config_mesh_fast">Szybka</string> |
86 | 86 |
<string name="config_mesh_nice">Ładna</string> |
87 | 87 |
|
88 |
<string name="sort_classic">klasycznie</string> |
|
89 |
<string name="sort_shape">kształt</string> |
|
90 |
<string name="sort_difficulty">trudność</string> |
|
91 |
<string name="sort_author">autor</string> |
|
92 |
<string name="sort_year">rok</string> |
|
93 |
|
|
88 | 94 |
<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> |
89 | 95 |
<string name="credits2">Piękne Wzory Waltera Randelshofera. Zobacz <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
90 | 96 |
<string name="credits3">Rubik i RubikCube to zarejestrowane znaki towarowe. Nie jesteśmy z nimi powiązani.</string> |
src/main/res/values-ru/strings.xml | ||
---|---|---|
85 | 85 |
<string name="config_mesh_fast">Быстрая</string> |
86 | 86 |
<string name="config_mesh_nice">Красивая</string> |
87 | 87 |
|
88 |
<string name="sort_classic">классик</string> |
|
89 |
<string name="sort_shape">форма</string> |
|
90 |
<string name="sort_difficulty">сложность</string> |
|
91 |
<string name="sort_author">автор</string> |
|
92 |
<string name="sort_year">год</string> |
|
93 |
|
|
88 | 94 |
<string name="credits1">Приложение с открытым исходным кодом, разработанное с использованием библиотеки графики Искажений. Лицензируется согласно <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">версии 2 GPL</a> или любой более поздней версии по вашему выбору.</string> |
89 | 95 |
<string name="credits2">Pretty Patterns по Walter Randelshofer. Смотри <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
90 | 96 |
<string name="credits3">Рубик и Кубик Рубика являются зарегистрированными товарными знаками. Мы не связаны с этим.</string> |
src/main/res/values-zh-rCN/strings.xml | ||
---|---|---|
85 | 85 |
<string name="config_mesh_fast">快</string> |
86 | 86 |
<string name="config_mesh_nice">好的</string> |
87 | 87 |
|
88 |
<string name="sort_classic">經典的</string> |
|
89 |
<string name="sort_shape">形狀</string> |
|
90 |
<string name="sort_difficulty">困难</string> |
|
91 |
<string name="sort_author">作者</string> |
|
92 |
<string name="sort_year">年</string> |
|
93 |
|
|
88 | 94 |
<string name="credits1">此应用程式原始码开发使用Distorted图型库。根据<a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">通用公共许可版本2</a>或者任何更新版本(根据您的选择)进行许可。</string> |
89 | 95 |
<string name="credits2">Pretty Patterns by Werner Randelshofer. 請看 <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
90 | 96 |
<string name="credits3">魔方和魔方是注册商标。 我们不隶属于它。</string> |
src/main/res/values-zh-rTW/strings.xml | ||
---|---|---|
85 | 85 |
<string name="config_mesh_fast">快</string> |
86 | 86 |
<string name="config_mesh_nice">好的</string> |
87 | 87 |
|
88 |
<string name="sort_classic">经典的</string> |
|
89 |
<string name="sort_shape">形状</string> |
|
90 |
<string name="sort_difficulty">困難</string> |
|
91 |
<string name="sort_author">作者</string> |
|
92 |
<string name="sort_year">年</string> |
|
93 |
|
|
88 | 94 |
<string name="credits1">此應用程式原始碼開發使用Distorted圖型庫。根據<a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">通用公共許可版本2</a>或者任何更新版本(根據您的選擇)進行許可。</string> |
89 | 95 |
<string name="credits2">Pretty Patterns by Werner Randelshofer. 請看 <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
90 | 96 |
<string name="credits3">魔方和魔方是註冊商標。 我們不隸屬於它。</string> |
src/main/res/values/strings.xml | ||
---|---|---|
109 | 109 |
<string name="config_mesh_fast">Fast</string> |
110 | 110 |
<string name="config_mesh_nice">Nice</string> |
111 | 111 |
|
112 |
<string name="sort_classic">classic</string> |
|
113 |
<string name="sort_shape">shape</string> |
|
114 |
<string name="sort_difficulty">difficulty</string> |
|
115 |
<string name="sort_author">author</string> |
|
116 |
<string name="sort_year">year</string> |
|
117 |
|
|
112 | 118 |
<string name="webview_error" translatable="false">Error Loading WebView</string> |
113 | 119 |
<string name="opengl_error" translatable="false">Error</string> |
114 | 120 |
<string name="opengl_error_text" translatable="false">This device does not support OpenGL 3.0</string> |
Also available in: Unified diff
progress