Revision 4a6b3b53
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/dialogs/RubikDialogTutorialSingle.java | ||
---|---|---|
12 | 12 |
import static android.view.View.inflate; |
13 | 13 |
|
14 | 14 |
import android.app.Dialog; |
15 |
import android.content.Context; |
|
15 | 16 |
import android.content.res.Resources; |
17 |
import android.util.DisplayMetrics; |
|
16 | 18 |
import android.util.TypedValue; |
17 | 19 |
import android.view.View; |
18 | 20 |
import android.view.Window; |
... | ... | |
36 | 38 |
|
37 | 39 |
public class RubikDialogTutorialSingle extends RubikDialogAbstract |
38 | 40 |
{ |
39 |
public static final float PANE_HEIGHT = 0.06f; |
|
41 |
public static final float PANE_HEIGHT= 0.06f; |
|
42 |
public static final float TEXT_SIZE = 0.41f; |
|
43 |
|
|
40 | 44 |
private Dialog mDialog; |
41 | 45 |
|
42 | 46 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
51 | 55 |
if( window!=null ) |
52 | 56 |
{ |
53 | 57 |
WindowManager.LayoutParams params = window.getAttributes(); |
54 |
params.width = (int)Math.min( mHeight*0.65f,mWidth*0.98f );
|
|
58 |
params.width = (int)Math.min( mHeight*0.67f,mWidth*0.98f );
|
|
55 | 59 |
//params.height = (int)Math.min( mHeight*0.85f,mWidth*1.30f ); |
56 | 60 |
window.setAttributes(params); |
57 | 61 |
} |
... | ... | |
132 | 136 |
private View createRow(final FragmentActivity act, int countryID, final String desc, final String url, |
133 | 137 |
final String auth, int size, int colorB, int colorT, boolean last) |
134 | 138 |
{ |
135 |
float textSize = 0.43f*size;
|
|
139 |
float textSize = size*TEXT_SIZE;
|
|
136 | 140 |
View row = inflate( act, R.layout.dialog_tutorial_row, null); |
137 | 141 |
|
138 | 142 |
LinearLayout layout = row.findViewById(R.id.tutorialLayout); |
... | ... | |
171 | 175 |
|
172 | 176 |
if( last ) |
173 | 177 |
{ |
174 |
int m = 20;
|
|
178 |
int m = (int)convertDpToPixel(10,act);
|
|
175 | 179 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT); |
176 | 180 |
params.bottomMargin = m; |
177 | 181 |
params.leftMargin = m; |
... | ... | |
182 | 186 |
return row; |
183 | 187 |
} |
184 | 188 |
|
189 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
190 |
|
|
191 |
private static float convertDpToPixel(float dp, Context context) |
|
192 |
{ |
|
193 |
return dp*((float) context.getResources().getDisplayMetrics().densityDpi/DisplayMetrics.DENSITY_DEFAULT); |
|
194 |
} |
|
195 |
|
|
185 | 196 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
186 | 197 |
|
187 | 198 |
public static String getDialogTag() |
src/main/java/org/distorted/main/MainObjectPopup.java | ||
---|---|---|
49 | 49 |
mPopup.setContentView(layout); |
50 | 50 |
mPopup.setFocusable(true); |
51 | 51 |
|
52 |
boolean firstButtonShown = false; |
|
53 |
|
|
52 | 54 |
mMenuTextSize = (int)(height*MENU_TEXT_SIZE); |
53 | 55 |
int padding = (int)(height*MENU_MARGIN); |
54 | 56 |
int marginH = padding/2; |
... | ... | |
63 | 65 |
if( object!=null && object.hasSolver() ) |
64 | 66 |
{ |
65 | 67 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,levelHeight); |
66 |
params.setMargins(marginH,marginV,marginH,marginV);
|
|
68 |
params.setMargins(marginH,marginH,marginH,marginV);
|
|
67 | 69 |
b1.setLayoutParams(params); |
68 | 70 |
b1.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize); |
71 |
|
|
69 | 72 |
b1.setOnClickListener(new View.OnClickListener() |
70 | 73 |
{ |
71 | 74 |
@Override |
... | ... | |
75 | 78 |
act.switchToSolver(ordinal); |
76 | 79 |
} |
77 | 80 |
}); |
81 |
|
|
82 |
firstButtonShown = true; |
|
78 | 83 |
} |
79 | 84 |
else b1.setVisibility(GONE); |
80 | 85 |
|
... | ... | |
83 | 88 |
if( object!=null && object.hasPatterns() ) |
84 | 89 |
{ |
85 | 90 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,levelHeight); |
86 |
params.setMargins(marginH,marginV,marginH,marginV);
|
|
91 |
params.setMargins(marginH, firstButtonShown ? marginV : marginH ,marginH,marginV);
|
|
87 | 92 |
b2.setLayoutParams(params); |
88 | 93 |
b2.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize); |
94 |
|
|
89 | 95 |
b2.setOnClickListener(new View.OnClickListener() |
90 | 96 |
{ |
91 | 97 |
@Override |
... | ... | |
95 | 101 |
act.switchToPattern(ordinal); |
96 | 102 |
} |
97 | 103 |
}); |
104 |
|
|
105 |
firstButtonShown = true; |
|
98 | 106 |
} |
99 | 107 |
else b2.setVisibility(GONE); |
100 | 108 |
|
... | ... | |
103 | 111 |
if( object!=null && object.hasExtras() ) |
104 | 112 |
{ |
105 | 113 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,levelHeight); |
106 |
params.setMargins(marginH,marginV,marginH,marginV);
|
|
114 |
params.setMargins(marginH,firstButtonShown ? marginV : marginH,marginH,marginV);
|
|
107 | 115 |
b3.setLayoutParams(params); |
108 | 116 |
b3.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize); |
117 |
|
|
109 | 118 |
b3.setOnClickListener(new View.OnClickListener() |
110 | 119 |
{ |
111 | 120 |
@Override |
... | ... | |
115 | 124 |
act.switchToTutorial(ordinal); |
116 | 125 |
} |
117 | 126 |
}); |
127 |
|
|
128 |
firstButtonShown = true; |
|
118 | 129 |
} |
119 | 130 |
else b3.setVisibility(GONE); |
120 | 131 |
|
121 | 132 |
Button b4 = layout.findViewById(R.id.objectInfo); |
122 | 133 |
|
123 | 134 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,levelHeight); |
124 |
params.setMargins(marginH,marginV,marginH,marginV);
|
|
135 |
params.setMargins(marginH,firstButtonShown ? marginV : marginH,marginH,marginV);
|
|
125 | 136 |
b4.setLayoutParams(params); |
126 | 137 |
b4.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize); |
138 |
|
|
127 | 139 |
b4.setOnClickListener( new View.OnClickListener() |
128 | 140 |
{ |
129 | 141 |
@Override |
... | ... | |
178 | 190 |
level[i].setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize); |
179 | 191 |
level[i].setLayoutParams(params); |
180 | 192 |
level[i].setPadding(0,0,0,0); |
193 |
|
|
181 | 194 |
level[i].setOnClickListener( new View.OnClickListener() |
182 | 195 |
{ |
183 | 196 |
@Override |
... | ... | |
187 | 200 |
} |
188 | 201 |
}); |
189 | 202 |
} |
203 |
|
|
204 |
int index = (numScramble>=1 && numScramble<=7) ? numScramble : LEVELS_SHOWN; |
|
205 |
LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(levelWidth,levelHeight); |
|
206 |
params2.setMargins(margin,-margin,margin,margin); |
|
207 |
level[index].setLayoutParams(params2); |
|
190 | 208 |
} |
191 | 209 |
|
192 | 210 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/res/layout/object_popup.xml | ||
---|---|---|
4 | 4 |
android:layout_width="wrap_content" |
5 | 5 |
android:layout_height="wrap_content" |
6 | 6 |
android:gravity="center" |
7 |
android:layout_marginTop="0dp" |
|
8 |
android:layout_marginBottom="0dp" |
|
9 |
android:padding="0dp" |
|
10 | 7 |
android:orientation="vertical"> |
11 | 8 |
|
12 | 9 |
<Button |
Also available in: Unified diff
Progress with Tutorial activity; make the main ObjectPopup look nicer.