Revision ef1f3e34
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/dialogs/RubikDialogTutorialPagerAdapter.java | ||
---|---|---|
66 | 66 |
{ |
67 | 67 |
DisplayMetrics metrics = mAct.getResources().getDisplayMetrics(); |
68 | 68 |
|
69 |
mViews[position] = new RubikDialogTutorialView(mAct, metrics.heightPixels, position);
|
|
69 |
mViews[position] = new RubikDialogTutorialView(mAct, metrics.widthPixels, position);
|
|
70 | 70 |
collection.addView(mViews[position]); |
71 | 71 |
|
72 | 72 |
return mViews[position]; |
src/main/java/org/distorted/dialogs/RubikDialogTutorialView.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import android.content.Context; |
23 | 23 |
import android.content.res.Resources; |
24 |
import android.graphics.drawable.Drawable; |
|
25 | 24 |
import android.os.Bundle; |
26 | 25 |
import android.util.AttributeSet; |
27 | 26 |
import android.util.TypedValue; |
28 | 27 |
import android.view.View; |
29 | 28 |
import android.widget.Button; |
30 | 29 |
import android.widget.FrameLayout; |
30 |
import android.widget.ImageView; |
|
31 | 31 |
import android.widget.LinearLayout; |
32 |
import android.widget.TextView; |
|
32 | 33 |
|
33 |
import androidx.core.content.ContextCompat; |
|
34 | 34 |
import androidx.fragment.app.FragmentActivity; |
35 | 35 |
|
36 | 36 |
import com.google.firebase.analytics.FirebaseAnalytics; |
... | ... | |
59 | 59 |
|
60 | 60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
61 | 61 |
|
62 |
public RubikDialogTutorialView(FragmentActivity act, int height, int position)
|
|
62 |
public RubikDialogTutorialView(FragmentActivity act, int width, int position)
|
|
63 | 63 |
{ |
64 | 64 |
super(act); |
65 | 65 |
|
66 |
int heightT = (int)(height* RubikActivity.TUTORIAL_ITEM_TEXT);
|
|
66 |
int widthT = (int)(width* RubikActivity.TUTORIAL_ITEM_TEXT);
|
|
67 | 67 |
|
68 | 68 |
RubikActivity ract = (RubikActivity)getContext(); |
69 | 69 |
Resources res = act.getResources(); |
... | ... | |
87 | 87 |
|
88 | 88 |
int countryID = res.getIdentifier( coun, "drawable", packageName); |
89 | 89 |
|
90 |
View row = createRow(ract,countryID,desc,url,auth,heightT,objList,size);
|
|
90 |
View row = createRow(ract,countryID,desc,url,auth,widthT,objList,size);
|
|
91 | 91 |
layout.addView(row); |
92 | 92 |
} |
93 | 93 |
|
... | ... | |
97 | 97 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
98 | 98 |
|
99 | 99 |
private View createRow(final RubikActivity act, int countryID, final String desc, final String url, |
100 |
final String auth, int height, final ObjectList obj, final int size)
|
|
100 |
final String auth, int width, final ObjectList obj, final int size)
|
|
101 | 101 |
{ |
102 | 102 |
View row = inflate( act, R.layout.dialog_tutorial_row, null); |
103 |
Button butt = row.findViewById(R.id.tutorialRowButton);
|
|
103 |
Button butt = row.findViewById(R.id.tutorialButton); |
|
104 | 104 |
|
105 |
int id = countryID!=0 ? countryID : R.drawable.un; |
|
106 |
final String buttText = desc+" ("+auth+")"; |
|
107 |
|
|
108 |
butt.setText(buttText); |
|
109 |
butt.setTextSize(TypedValue.COMPLEX_UNIT_PX, 0.5f*height); |
|
110 |
butt.setHeight(height); |
|
111 |
|
|
112 |
Drawable img = ContextCompat.getDrawable(act,id); |
|
113 |
img.setBounds(0, 0, (int)(1.0f*height), (int)(0.66f*height) ); |
|
114 |
butt.setCompoundDrawables(img,null,null,null); |
|
105 |
butt.setText(R.string.view); |
|
106 |
butt.setTextSize(TypedValue.COMPLEX_UNIT_PX, 0.5f*width); |
|
107 |
butt.setHeight(width); |
|
115 | 108 |
|
116 | 109 |
butt.setOnClickListener( new View.OnClickListener() |
117 | 110 |
{ |
... | ... | |
123 | 116 |
} |
124 | 117 |
}); |
125 | 118 |
|
119 |
ImageView image = row.findViewById(R.id.tutorialCountry); |
|
120 |
int id = countryID!=0 ? countryID : R.drawable.un; |
|
121 |
image.setImageResource(id); |
|
122 |
|
|
123 |
TextView author = row.findViewById(R.id.tutorialAuthor); |
|
124 |
author.setTextSize(TypedValue.COMPLEX_UNIT_PX, 0.5f*width); |
|
125 |
author.setText(auth); |
|
126 |
|
|
127 |
TextView title = row.findViewById(R.id.tutorialTitle); |
|
128 |
title.setTextSize(TypedValue.COMPLEX_UNIT_PX, 0.5f*width); |
|
129 |
title.setText(desc); |
|
130 |
|
|
126 | 131 |
return row; |
127 | 132 |
} |
128 | 133 |
|
src/main/java/org/distorted/main/RubikActivity.java | ||
---|---|---|
67 | 67 |
public static final float PATTERN_CHILD_TEXT = 0.02f; |
68 | 68 |
public static final float SCORES_LEVEL_TEXT = 0.035f; |
69 | 69 |
public static final float SCORES_ITEM_TEXT = 0.030f; |
70 |
public static final float TUTORIAL_ITEM_TEXT = 0.050f;
|
|
70 |
public static final float TUTORIAL_ITEM_TEXT = 0.100f;
|
|
71 | 71 |
public static final float DIALOG_BUTTON_SIZE = 0.06f; |
72 | 72 |
public static final float MENU_BIG_TEXT_SIZE = 0.05f; |
73 | 73 |
public static final float MENU_MED_TEXT_SIZE = 0.04f; |
src/main/java/org/distorted/tutorial/TutorialList.java | ||
---|---|---|
29 | 29 |
new String[][] { |
30 | 30 |
{"gb","rJlh5p2wAKA","How to Solve a 2x2 Rubik's Cube","Z3"}, |
31 | 31 |
{"es","f85wqJTIDlw","Resolver cubo de Rubik 2X2","Cuby"}, |
32 |
{"ru","azC6P3VYFkc","Как собрать кубик 2Х2","Евгений Бондаренко"},
|
|
32 |
{"ru","azC6P3VYFkc","Как собрать кубик 2Х2","Е Бондаренко"}, |
|
33 | 33 |
{"fr","V1XS993AUuw","Résoudre le cube 2x2","Rachma Nikov"}, |
34 | 34 |
{"pl","haNWdAYWGsY","Jak ułożyć kostkę Rubika 2x2","DżoDżo"}, |
35 | 35 |
// {"tw","CfOCXxhCb8U","2x2魔術方塊復原","1hrBLD"}, |
... | ... | |
40 | 40 |
new String[][] { |
41 | 41 |
{"gb","-8ohoCKN0Zw","How to Solve a Rubik's Cube","Z3"}, |
42 | 42 |
{"es","GyY0OxDk5lI","Resolver cubo de Rubik 3x3","Cuby"}, |
43 |
{"ru","5S2eq81FRzI","Как собрать кубик рубика","Евгений Бондаренко"},
|
|
43 |
{"ru","5S2eq81FRzI","Как собрать кубик рубика","Е Бондаренко"}, |
|
44 | 44 |
{"fr","T-ASx2wbHVY","Comment résoudre un Rubik's Cube","Le Cube"}, |
45 | 45 |
{"pl","cBU9Y729nQM","Jak ułożyć kostkę Rubika 3x3","DżoDżo"}, |
46 | 46 |
// {"tw","76NmRQx5CLA","魔術方塊教學","1hrBLD"}, |
... | ... | |
76 | 76 |
new String[][] { |
77 | 77 |
{"gb","xIQtn2qazvg","Pyraminx Layer By Layer","Z3"}, |
78 | 78 |
{"es","4cJJe9RAzAU","Resolver Pyraminx","Cuby"}, |
79 |
{"ru","F4_bhfWyVRQ","Как собрать ПИРАМИДКУ","Евгений Бондаренко"},
|
|
79 |
{"ru","F4_bhfWyVRQ","Как собрать ПИРАМИДКУ","Е Бондаренко"}, |
|
80 | 80 |
{"fr","Z2h1YI6jPes","Comment résoudre le Pyraminx","ValentinoCube"}, |
81 | 81 |
{"pl","uNpKpJfAa5I","Jak ułożyć: Pyraminx","DżoDżo"}, |
82 | 82 |
// {"tw","YS3cDcP6Aro","金字塔方塊解法","1hrBLD"}, |
src/main/res/layout/dialog_tutorial_row.xml | ||
---|---|---|
1 | 1 |
<?xml version="1.0" encoding="utf-8"?> |
2 |
<Button xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
android:id="@+id/tutorialRowButton" |
|
4 |
android:layout_width="match_parent" |
|
5 |
android:layout_height="wrap_content" |
|
6 |
android:paddingRight="15dp" |
|
7 |
android:paddingLeft="15dp" |
|
8 |
android:singleLine="true" |
|
9 |
android:textAllCaps="false" |
|
10 |
android:gravity="center"/> |
|
2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
android:layout_width="fill_parent" |
|
4 |
android:layout_height="fill_parent" |
|
5 |
android:gravity="center|fill_horizontal" |
|
6 |
android:layout_marginLeft="8dp" |
|
7 |
android:layout_marginRight="8dp" |
|
8 |
android:layout_marginTop="10dp" |
|
9 |
android:layout_marginBottom="10dp" |
|
10 |
android:background="@color/black" |
|
11 |
android:orientation="vertical"> |
|
12 |
|
|
13 |
<TextView |
|
14 |
android:id="@+id/tutorialTitle" |
|
15 |
android:layout_width="match_parent" |
|
16 |
android:layout_height="wrap_content" |
|
17 |
android:gravity="center" |
|
18 |
android:textSize="18sp" |
|
19 |
android:layout_marginTop="10dp" |
|
20 |
android:layout_marginLeft="10dp" |
|
21 |
android:layout_marginRight="10dp" |
|
22 |
android:paddingLeft="2dp" |
|
23 |
android:paddingRight="2dp" |
|
24 |
android:maxLines="1" |
|
25 |
android:background="@color/grey"/> |
|
26 |
|
|
27 |
<LinearLayout |
|
28 |
android:id="@+id/tutorialLayout" |
|
29 |
android:layout_width="fill_parent" |
|
30 |
android:layout_height="wrap_content" |
|
31 |
android:layout_marginLeft="10dp" |
|
32 |
android:layout_marginRight="10dp" |
|
33 |
android:background="@color/grey" |
|
34 |
android:gravity="center" |
|
35 |
android:orientation="horizontal"> |
|
36 |
|
|
37 |
<LinearLayout |
|
38 |
android:layout_width="0dp" |
|
39 |
android:layout_height="match_parent" |
|
40 |
android:layout_weight="0.4" |
|
41 |
android:gravity="left" |
|
42 |
android:orientation="horizontal"> |
|
43 |
|
|
44 |
<ImageView |
|
45 |
android:id="@+id/tutorialCountry" |
|
46 |
android:layout_width="match_parent" |
|
47 |
android:layout_height="match_parent" |
|
48 |
android:paddingBottom="3dp" |
|
49 |
android:paddingTop="3dp" |
|
50 |
android:paddingLeft="10dp"/> |
|
51 |
</LinearLayout> |
|
52 |
|
|
53 |
<LinearLayout |
|
54 |
android:layout_width="0dp" |
|
55 |
android:layout_height="match_parent" |
|
56 |
android:layout_weight="1.5" |
|
57 |
android:gravity="left" |
|
58 |
android:orientation="horizontal"> |
|
59 |
|
|
60 |
<TextView |
|
61 |
android:id="@+id/tutorialAuthor" |
|
62 |
android:layout_width="wrap_content" |
|
63 |
android:layout_height="wrap_content" |
|
64 |
android:paddingLeft="5dp" |
|
65 |
android:textSize="18sp" |
|
66 |
android:maxLines="1" |
|
67 |
android:layout_gravity="center_vertical|start"/> |
|
68 |
</LinearLayout> |
|
69 |
|
|
70 |
<LinearLayout |
|
71 |
android:layout_width="0dp" |
|
72 |
android:layout_height="match_parent" |
|
73 |
android:layout_weight="1.0" |
|
74 |
android:gravity="right" |
|
75 |
android:orientation="horizontal"> |
|
76 |
|
|
77 |
<Button |
|
78 |
android:id="@+id/tutorialButton" |
|
79 |
android:layout_width="match_parent" |
|
80 |
android:layout_height="wrap_content" |
|
81 |
android:paddingRight="15dp" |
|
82 |
android:paddingLeft="15dp" |
|
83 |
android:singleLine="true" |
|
84 |
android:textAllCaps="false" |
|
85 |
android:layout_gravity="right"/> |
|
86 |
</LinearLayout> |
|
87 |
|
|
88 |
</LinearLayout> |
|
89 |
</LinearLayout> |
src/main/res/values/strings.xml | ||
---|---|---|
37 | 37 |
<string name="submitting">Submitting…</string> |
38 | 38 |
<string name="tutorial">Watch a tutorial?</string> |
39 | 39 |
<string name="tutorials">Tutorials</string> |
40 |
<string name="view">View</string> |
|
40 | 41 |
|
41 | 42 |
<string name="credits1">Open Source app developed using the Distorted graphics library. Licensed under <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPL version 2</a> or - at your option - any later version.</string> |
42 | 43 |
<string name="credits2">Pretty Patterns by Walter Randelshofer. See <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
Also available in: Unified diff
Make the Tutorial Dialog look better