Revision 52d0a923
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/dialogs/RubikDialogEffects.java | ||
---|---|---|
58 | 58 |
private void addSettingsSection(FragmentActivity act, LinearLayout layout, int index) |
59 | 59 |
{ |
60 | 60 |
BaseEffect.Type beType = BaseEffect.Type.getType(index); |
61 |
DisplayMetrics metrics = act.getResources().getDisplayMetrics(); |
|
62 |
final float scale = metrics.density; |
|
63 |
mTextSize = metrics.widthPixels * RubikActivity.MENU_SMALL_TEXT_SIZE; |
|
64 | 61 |
|
65 |
int textH= (int)(mTextSize); |
|
66 |
int layoH= (int)(1.2f*mTextSize);
|
|
67 |
int margH=10;
|
|
62 |
int textH= (int)(1.35f*mTextSize);
|
|
63 |
float A= 1.2f;
|
|
64 |
float B= 0.25f;
|
|
68 | 65 |
|
69 | 66 |
///// OUTER LAYOUT /////////////////////////////////////////////////////////////////// |
70 | 67 |
|
71 |
int margin = (int)(scale*margH + 0.5f);
|
|
68 |
int margin = (int)(B*textH);
|
|
72 | 69 |
int color = ContextCompat.getColor(act, R.color.grey); |
73 | 70 |
LinearLayout outerLayout = new LinearLayout(act); |
74 | 71 |
LinearLayout.LayoutParams outerLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT, 0.5f); |
... | ... | |
85 | 82 |
|
86 | 83 |
///// TEXT /////////////////////////////////////////////////////////////////////////// |
87 | 84 |
|
88 |
int layoutHeight = (int)(scale*textH + 0.5f);
|
|
89 |
int padding = (int)(scale*10 + 0.5f);
|
|
85 |
int layoutHeight = (int)(A*textH);
|
|
86 |
int padding = (int)(B*textH);
|
|
90 | 87 |
|
91 | 88 |
LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,layoutHeight); |
92 | 89 |
|
... | ... | |
100 | 97 |
|
101 | 98 |
///// INNER LAYOUT1 ////////////////////////////////////////////////////////////////// |
102 | 99 |
|
103 |
int innerLayout1Height = (int)(scale*layoH + 0.5f);
|
|
100 |
int innerLayout1Height = (int)((A+B)*textH);
|
|
104 | 101 |
LinearLayout innerLayout1 = new LinearLayout(act); |
105 | 102 |
LinearLayout.LayoutParams innerLayout1Params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,innerLayout1Height); |
106 | 103 |
|
... | ... | |
111 | 108 |
|
112 | 109 |
///// STUFF INSIDE INNER LAYOUT1 ///////////////////////////////////////////////////// |
113 | 110 |
|
114 |
int text1Padding = (int)(scale*5 + 0.5f);
|
|
111 |
int text1Padding = (int)(B*textH);
|
|
115 | 112 |
LinearLayout.LayoutParams text1LayoutParams = new LinearLayout.LayoutParams(0,layoutHeight,0.25f); |
116 | 113 |
|
117 | 114 |
TextView text1View = new TextView(act); |
... | ... | |
122 | 119 |
text1View.setPadding(text1Padding,0,text1Padding,0); |
123 | 120 |
innerLayout1.addView(text1View); |
124 | 121 |
////////////////////////////////////////////////////////////////// |
125 |
int text2Padding = (int)(scale*5 + 0.5f);
|
|
122 |
int text2Padding = (int)(B*textH);
|
|
126 | 123 |
LinearLayout.LayoutParams text2LayoutParams = new LinearLayout.LayoutParams(0,layoutHeight,0.25f); |
127 | 124 |
|
128 | 125 |
mDurationText[index] = new TextView(act); |
... | ... | |
132 | 129 |
mDurationText[index].setPadding(text2Padding,0,text2Padding,0); |
133 | 130 |
innerLayout1.addView(mDurationText[index]); |
134 | 131 |
////////////////////////////////////////////////////////////////// |
135 |
int seekPadding = (int)(scale*10 + 0.5f);
|
|
132 |
int seekPadding = (int)(B*textH);
|
|
136 | 133 |
LinearLayout.LayoutParams seekLayoutParams = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,0.5f); |
137 | 134 |
|
138 | 135 |
SeekBar seekBar = new SeekBar(act); |
... | ... | |
146 | 143 |
|
147 | 144 |
///// INNER LAYOUT2 ////////////////////////////////////////////////////////////////// |
148 | 145 |
|
149 |
int innerLayout2Height = (int)(scale*layoH + 0.5f);
|
|
146 |
int innerLayout2Height = (int)((A+B)*textH);
|
|
150 | 147 |
LinearLayout innerLayout2 = new LinearLayout(act); |
151 | 148 |
LinearLayout.LayoutParams innerLayout2Params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,innerLayout2Height); |
152 | 149 |
|
... | ... | |
157 | 154 |
|
158 | 155 |
///// STUFF INSIDE INNER LAYOUT2 ///////////////////////////////////////////////////// |
159 | 156 |
|
160 |
int text3Padding = (int)(scale*5 + 0.5f);
|
|
157 |
int text3Padding = (int)(B*textH);
|
|
161 | 158 |
LinearLayout.LayoutParams text3LayoutParams = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,0.25f); |
162 | 159 |
|
163 | 160 |
TextView text3View = new TextView(act); |
... | ... | |
168 | 165 |
text3View.setPadding(text3Padding,0,text3Padding,0); |
169 | 166 |
innerLayout2.addView(text3View); |
170 | 167 |
////////////////////////////////////////////////////////////////// |
171 |
int spinnerPadding = (int)(scale*10 + 0.5f);
|
|
172 |
int spinnerMargin = (int)(scale* 3 + 0.5f);
|
|
168 |
int spinnerPadding = (int)(B*textH);
|
|
169 |
int spinnerMargin = (int)(B*0.5f*textH);
|
|
173 | 170 |
LinearLayout.LayoutParams spinnerLayoutParams = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,0.75f); |
174 | 171 |
spinnerLayoutParams.topMargin = spinnerMargin; |
175 | 172 |
spinnerLayoutParams.bottomMargin = spinnerMargin; |
... | ... | |
218 | 215 |
final float titleSize= displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE; |
219 | 216 |
final float okSize = displaymetrics.widthPixels * RubikActivity.MENU_MEDIUM_TEXT_SIZE; |
220 | 217 |
|
218 |
mTextSize = displaymetrics.widthPixels * RubikActivity.MENU_SMALL_TEXT_SIZE; |
|
219 |
|
|
221 | 220 |
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize); |
222 | 221 |
tv.setText(R.string.effects); |
223 | 222 |
builder.setCustomTitle(tv); |
src/main/java/org/distorted/dialogs/RubikDialogPattern.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import android.app.Dialog; |
23 | 23 |
import android.content.Context; |
24 |
import android.content.DialogInterface; |
|
24 | 25 |
import android.os.Bundle; |
25 | 26 |
import androidx.annotation.NonNull; |
26 | 27 |
import androidx.fragment.app.FragmentActivity; |
... | ... | |
29 | 30 |
import androidx.appcompat.app.AppCompatDialogFragment; |
30 | 31 |
import com.google.android.material.tabs.TabLayout; |
31 | 32 |
import android.util.DisplayMetrics; |
33 |
import android.util.TypedValue; |
|
32 | 34 |
import android.view.LayoutInflater; |
33 | 35 |
import android.view.View; |
34 | 36 |
import android.view.Window; |
35 | 37 |
import android.view.WindowManager; |
38 |
import android.widget.Button; |
|
36 | 39 |
import android.widget.ImageView; |
37 | 40 |
import android.widget.TextView; |
38 | 41 |
|
39 | 42 |
import org.distorted.main.R; |
43 |
import org.distorted.main.RubikActivity; |
|
40 | 44 |
import org.distorted.objects.RubikObjectList; |
41 | 45 |
import org.distorted.patterns.RubikPatternList; |
42 | 46 |
|
... | ... | |
55 | 59 |
FragmentActivity act = getActivity(); |
56 | 60 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
57 | 61 |
|
62 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
63 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
|
64 |
final float titleSize= displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE; |
|
65 |
final float okSize = displaymetrics.widthPixels * RubikActivity.MENU_MEDIUM_TEXT_SIZE; |
|
66 |
|
|
58 | 67 |
LayoutInflater layoutInflater = act.getLayoutInflater(); |
59 | 68 |
TextView tv = (TextView) layoutInflater.inflate(R.layout.dialog_title, null); |
69 |
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize); |
|
60 | 70 |
tv.setText(R.string.choose_pattern); |
61 | 71 |
builder.setCustomTitle(tv); |
62 | 72 |
|
... | ... | |
76 | 86 |
final View view = inflater.inflate(R.layout.dialog_tabbed, null); |
77 | 87 |
builder.setView(view); |
78 | 88 |
|
89 |
// TabLayout tl = view.findViewById(R.id.sliding_tabs); |
|
90 |
|
|
91 |
|
|
79 | 92 |
ViewPager viewPager = view.findViewById(R.id.viewpager); |
80 | 93 |
TabLayout tabLayout = view.findViewById(R.id.sliding_tabs); |
81 | 94 |
mPagerAdapter = new RubikDialogPatternPagerAdapter(act, viewPager, this); |
... | ... | |
108 | 121 |
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
109 | 122 |
} |
110 | 123 |
|
124 |
dialog.setOnShowListener(new DialogInterface.OnShowListener() |
|
125 |
{ |
|
126 |
@Override |
|
127 |
public void onShow(DialogInterface dialog) |
|
128 |
{ |
|
129 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
130 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize); |
|
131 |
} |
|
132 |
}); |
|
133 |
|
|
111 | 134 |
return dialog; |
112 | 135 |
} |
113 | 136 |
|
src/main/java/org/distorted/dialogs/RubikDialogScores.java | ||
---|---|---|
28 | 28 |
import androidx.appcompat.app.AlertDialog; |
29 | 29 |
import androidx.appcompat.app.AppCompatDialogFragment; |
30 | 30 |
import com.google.android.material.tabs.TabLayout; |
31 |
|
|
32 |
import android.util.DisplayMetrics; |
|
33 |
import android.util.TypedValue; |
|
31 | 34 |
import android.view.LayoutInflater; |
32 | 35 |
import android.view.View; |
33 | 36 |
import android.view.Window; |
34 | 37 |
import android.view.WindowManager; |
38 |
import android.widget.Button; |
|
35 | 39 |
import android.widget.ImageView; |
36 | 40 |
import android.widget.TextView; |
37 | 41 |
|
38 | 42 |
import org.distorted.main.R; |
43 |
import org.distorted.main.RubikActivity; |
|
39 | 44 |
import org.distorted.objects.RubikObjectList; |
40 | 45 |
|
41 | 46 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
53 | 58 |
FragmentActivity act = getActivity(); |
54 | 59 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
55 | 60 |
|
61 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
62 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
|
63 |
final float titleSize= displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE; |
|
64 |
final float okSize = displaymetrics.widthPixels * RubikActivity.MENU_MEDIUM_TEXT_SIZE; |
|
65 |
|
|
56 | 66 |
LayoutInflater layoutInflater = act.getLayoutInflater(); |
57 | 67 |
TextView tv = (TextView) layoutInflater.inflate(R.layout.dialog_title, null); |
68 |
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize); |
|
58 | 69 |
tv.setText(R.string.scores); |
59 | 70 |
builder.setCustomTitle(tv); |
60 | 71 |
|
... | ... | |
122 | 133 |
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
123 | 134 |
} |
124 | 135 |
|
136 |
dialog.setOnShowListener(new DialogInterface.OnShowListener() |
|
137 |
{ |
|
138 |
@Override |
|
139 |
public void onShow(DialogInterface dialog) |
|
140 |
{ |
|
141 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
142 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize); |
|
143 |
} |
|
144 |
}); |
|
145 |
|
|
125 | 146 |
return dialog; |
126 | 147 |
} |
127 | 148 |
} |
src/main/res/layout/dialog_tabbed.xml | ||
---|---|---|
8 | 8 |
<com.google.android.material.tabs.TabLayout |
9 | 9 |
android:id="@+id/sliding_tabs" |
10 | 10 |
android:layout_width="match_parent" |
11 |
android:layout_height="32dp"
|
|
11 |
android:layout_height="wrap_content"
|
|
12 | 12 |
android:theme="@style/Theme.AppCompat.NoActionBar"> |
13 | 13 |
</com.google.android.material.tabs.TabLayout> |
14 | 14 |
|
Also available in: Unified diff
Improvements to the UI - make it proportional regardless of the physical screen size. (Part 7 - last 2 Dialogs)