Revision c651024f
Added by Leszek Koltunski almost 3 years ago
src/main/java/org/distorted/config/ConfigScreen.java | ||
---|---|---|
158 | 158 |
|
159 | 159 |
private void setupObjectButton(final ConfigActivity act, final int width) |
160 | 160 |
{ |
161 |
final int margin= (int)(width*RubikActivity.MARGIN); |
|
161 |
final int margin= (int)(width*RubikActivity.SMALL_MARGIN);
|
|
162 | 162 |
final int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_menu,R.drawable.ui_medium_cube_menu, R.drawable.ui_big_cube_menu, R.drawable.ui_huge_cube_menu); |
163 | 163 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
164 | 164 |
mObjectButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params); |
... | ... | |
297 | 297 |
private void setupTextView(final ConfigActivity act, final float width, int numObjects) |
298 | 298 |
{ |
299 | 299 |
int padding = (int)(width*RubikActivity.PADDING); |
300 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
300 |
int margin = (int)(width*RubikActivity.SMALL_MARGIN);
|
|
301 | 301 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,2.0f); |
302 | 302 |
params.topMargin = margin; |
303 | 303 |
params.bottomMargin = margin; |
src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java | ||
---|---|---|
20 | 20 |
package org.distorted.dialogs; |
21 | 21 |
|
22 | 22 |
import android.app.Activity; |
23 |
import android.util.TypedValue; |
|
23 | 24 |
import android.view.View; |
24 | 25 |
import android.widget.Button; |
25 | 26 |
import android.widget.ImageView; |
27 |
import android.widget.LinearLayout; |
|
26 | 28 |
import android.widget.TextView; |
27 | 29 |
|
28 | 30 |
import org.distorted.main.R; |
... | ... | |
44 | 46 |
|
45 | 47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
46 | 48 |
|
47 |
public View createView(Activity act, RubikUpdates.UpdateInfo info, boolean isNew) |
|
49 |
public View createView(Activity act, RubikUpdates.UpdateInfo info, int fontSize, boolean isNew, |
|
50 |
LinearLayout.LayoutParams pImage, LinearLayout.LayoutParams pView, |
|
51 |
LinearLayout.LayoutParams pText, LinearLayout.LayoutParams pButt ) |
|
48 | 52 |
{ |
49 | 53 |
int layoutID = R.layout.dialog_updates_pane; |
50 | 54 |
mView = act.getLayoutInflater().inflate(layoutID, null); |
51 |
Button install = mView.findViewById(R.id.updates_pane_button); |
|
52 | 55 |
|
53 |
install.setOnClickListener( new View.OnClickListener() |
|
56 |
Button button = mView.findViewById(R.id.updates_pane_button); |
|
57 |
|
|
58 |
button.setOnClickListener( new View.OnClickListener() |
|
54 | 59 |
{ |
55 | 60 |
@Override |
56 | 61 |
public void onClick(View v) |
... | ... | |
63 | 68 |
title.setText(info.mObjectLongName); |
64 | 69 |
TextView version = mView.findViewById(R.id.updates_pane_version); |
65 | 70 |
String strVersion = info.mUpdateObject |
66 |
? JsonWriter.VERSION_OBJECT_MAJOR+"."+info.mObjectMinorVersion |
|
67 |
: JsonWriter.VERSION_EXTRAS_MAJOR+"."+info.mExtrasMinorVersion; |
|
71 |
? "v. "+JsonWriter.VERSION_OBJECT_MAJOR+"."+info.mObjectMinorVersion
|
|
72 |
: "v. "+JsonWriter.VERSION_EXTRAS_MAJOR+"."+info.mExtrasMinorVersion;
|
|
68 | 73 |
version.setText(strVersion); |
69 | 74 |
TextView description = mView.findViewById(R.id.updates_pane_description); |
70 | 75 |
description.setText(info.mDescription); |
... | ... | |
72 | 77 |
ImageView image = mView.findViewById(R.id.updates_pane_image); |
73 | 78 |
image.setBackgroundResource(R.drawable.unknown_icon); |
74 | 79 |
|
80 |
image.setLayoutParams(pImage); |
|
81 |
mView.setLayoutParams(pView); |
|
82 |
|
|
83 |
title.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize); |
|
84 |
version.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize); |
|
85 |
description.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize); |
|
86 |
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize); |
|
87 |
|
|
88 |
title.setLayoutParams(pText); |
|
89 |
version.setLayoutParams(pText); |
|
90 |
description.setLayoutParams(pText); |
|
91 |
button.setLayoutParams(pButt); |
|
92 |
|
|
75 | 93 |
return mView; |
76 | 94 |
} |
77 | 95 |
} |
src/main/java/org/distorted/dialogs/RubikDialogUpdates.java | ||
---|---|---|
51 | 51 |
private TextView mText; |
52 | 52 |
private ScrollView mScroll; |
53 | 53 |
private LinearLayout mLayout; |
54 |
private int mMargin, mSize, mFontSize; |
|
54 | 55 |
|
55 | 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
56 | 57 |
|
... | ... | |
79 | 80 |
|
80 | 81 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
81 | 82 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
82 |
final float titleSize= displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE; |
|
83 |
final float okSize = displaymetrics.widthPixels * RubikActivity.DIALOG_BUTTON_SIZE; |
|
83 |
int w= displaymetrics.widthPixels; |
|
84 |
int h= displaymetrics.heightPixels; |
|
85 |
final float titleSize= w*RubikActivity.MENU_BIG_TEXT_SIZE; |
|
86 |
final float okSize = w*RubikActivity.DIALOG_BUTTON_SIZE; |
|
87 |
mMargin = (int)(w*RubikActivity.MEDIUM_MARGIN); |
|
88 |
mSize = (int)(h*0.19f); |
|
89 |
mFontSize = (int)(h*0.02f); |
|
84 | 90 |
|
85 | 91 |
TextView title = (TextView) inflater.inflate(R.layout.dialog_title, null); |
86 | 92 |
title.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize); |
... | ... | |
119 | 125 |
} |
120 | 126 |
}); |
121 | 127 |
|
128 |
RubikNetwork network = RubikNetwork.getInstance(); |
|
129 |
network.signUpForUpdates(this); |
|
130 |
|
|
122 | 131 |
return dialog; |
123 | 132 |
} |
124 | 133 |
|
... | ... | |
129 | 138 |
{ |
130 | 139 |
super.onResume(); |
131 | 140 |
|
132 |
RubikNetwork network = RubikNetwork.getInstance(); |
|
133 |
network.signUpForUpdates(this); |
|
134 |
|
|
135 | 141 |
Window window = getDialog().getWindow(); |
136 | 142 |
Context context = getContext(); |
137 | 143 |
|
... | ... | |
145 | 151 |
params.height = (int)(0.75f*height); |
146 | 152 |
window.setAttributes(params); |
147 | 153 |
|
148 |
int textHeight = (int)(0.8f*params.height);
|
|
154 |
int textHeight = (int)(0.75f*params.height);
|
|
149 | 155 |
mText.setHeight(textHeight); |
156 |
mLayout.setMinimumHeight(textHeight); |
|
150 | 157 |
} |
151 | 158 |
} |
152 | 159 |
|
... | ... | |
166 | 173 |
} |
167 | 174 |
else |
168 | 175 |
{ |
176 |
//mScroll.setVerticalScrollBarEnabled(false); |
|
177 |
//mText.setText(act.getString(R.string.no_updates)); |
|
178 |
|
|
179 |
int imagH = (int)(mSize*0.52f); |
|
180 |
int textH = (int)(mSize*0.20f); |
|
181 |
int buttH = (int)(mSize*0.35f); |
|
182 |
|
|
183 |
LinearLayout.LayoutParams pI = new LinearLayout.LayoutParams( imagH,imagH ); |
|
184 |
pI.setMargins(mMargin/2, mMargin/2, mMargin/2, mMargin/2 ); |
|
185 |
LinearLayout.LayoutParams pV = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, mSize ); |
|
186 |
pV.setMargins(mMargin, mMargin, mMargin, 0); |
|
187 |
LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, textH ); |
|
188 |
LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, buttH ); |
|
189 |
|
|
169 | 190 |
mText.setVisibility(View.GONE); |
170 | 191 |
|
171 | 192 |
if( mLayout!=null ) |
... | ... | |
174 | 195 |
{ |
175 | 196 |
RubikUpdates.UpdateInfo info = updates.getNewUpdate(i); |
176 | 197 |
RubikDialogUpdateView rubikView = new RubikDialogUpdateView(); |
177 |
View pane = rubikView.createView(act,info,true);
|
|
198 |
View pane = rubikView.createView(act,info,mFontSize,true,pI,pV,pT,pB);
|
|
178 | 199 |
mLayout.addView(pane); |
179 | 200 |
} |
180 | 201 |
for(int i=0; i<numU; i++) |
181 | 202 |
{ |
182 | 203 |
RubikUpdates.UpdateInfo info = updates.getUpdUpdate(i); |
183 | 204 |
RubikDialogUpdateView rubikView = new RubikDialogUpdateView(); |
184 |
View pane = rubikView.createView(act,info,false);
|
|
205 |
View pane = rubikView.createView(act,info,mFontSize,false,pI,pV,pT,pB);
|
|
185 | 206 |
mLayout.addView(pane); |
186 | 207 |
} |
187 | 208 |
} |
src/main/java/org/distorted/main/RubikActivity.java | ||
---|---|---|
68 | 68 |
public class RubikActivity extends AppCompatActivity |
69 | 69 |
{ |
70 | 70 |
public static final float PADDING = 0.01f; |
71 |
public static final float MARGIN = 0.004f; |
|
71 |
public static final float SMALL_MARGIN = 0.004f; |
|
72 |
public static final float MEDIUM_MARGIN = 0.015f; |
|
72 | 73 |
public static final float LARGE_MARGIN = 0.025f; |
73 | 74 |
public static final float BUTTON_TEXT_SIZE = 0.05f; |
74 | 75 |
public static final float TITLE_TEXT_SIZE = 0.06f; |
src/main/java/org/distorted/screens/RubikScreenPattern.java | ||
---|---|---|
207 | 207 |
private void setupTextView(final RubikActivity act, final float width) |
208 | 208 |
{ |
209 | 209 |
int padding = (int)(width*RubikActivity.PADDING); |
210 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
210 |
int margin = (int)(width*RubikActivity.SMALL_MARGIN);
|
|
211 | 211 |
|
212 | 212 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,2.0f); |
213 | 213 |
params.topMargin = margin; |
src/main/java/org/distorted/screens/RubikScreenPlay.java | ||
---|---|---|
131 | 131 |
|
132 | 132 |
private void setupObjectButton(final RubikActivity act, final float width) |
133 | 133 |
{ |
134 |
final int margin = (int)(width*RubikActivity.MARGIN); |
|
134 |
final int margin = (int)(width*RubikActivity.SMALL_MARGIN);
|
|
135 | 135 |
final int lMargin = (int)(width*RubikActivity.LARGE_MARGIN); |
136 | 136 |
final int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_menu,R.drawable.ui_medium_cube_menu, R.drawable.ui_big_cube_menu, R.drawable.ui_huge_cube_menu); |
137 | 137 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
... | ... | |
164 | 164 |
|
165 | 165 |
private void setupPlayButton(final RubikActivity act, final float width) |
166 | 166 |
{ |
167 |
final int margin = (int)(width*RubikActivity.MARGIN); |
|
167 |
final int margin = (int)(width*RubikActivity.SMALL_MARGIN);
|
|
168 | 168 |
|
169 | 169 |
mPlayButton = new TransparentButton(act, R.string.play, mButtonSize); |
170 | 170 |
|
... | ... | |
201 | 201 |
|
202 | 202 |
private void setupMenuButton(final RubikActivity act, final float width) |
203 | 203 |
{ |
204 |
final int margin = (int)(width*RubikActivity.MARGIN); |
|
204 |
final int margin = (int)(width*RubikActivity.SMALL_MARGIN);
|
|
205 | 205 |
final int icon = RubikActivity.getDrawable(R.drawable.ui_small_menu,R.drawable.ui_medium_menu, R.drawable.ui_big_menu, R.drawable.ui_huge_menu); |
206 | 206 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
207 | 207 |
mMenuButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params); |
... | ... | |
384 | 384 |
mMenuPopup = new PopupWindow(act); |
385 | 385 |
mMenuPopup.setContentView(layout); |
386 | 386 |
mMenuPopup.setFocusable(true); |
387 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
387 |
int margin = (int)(width*RubikActivity.SMALL_MARGIN);
|
|
388 | 388 |
int padding = (int)(width*RubikActivity.PADDING); |
389 | 389 |
|
390 | 390 |
mMenuLayoutWidth = (int)(width/2); |
... | ... | |
637 | 637 |
} |
638 | 638 |
|
639 | 639 |
float width = act.getScreenWidthInPixels(); |
640 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
640 |
int margin = (int)(width*RubikActivity.SMALL_MARGIN);
|
|
641 | 641 |
int padding = (int)(width*RubikActivity.PADDING); |
642 | 642 |
int butWidth = mPlayLayoutWidth - 2*padding; |
643 | 643 |
int butHeight= (int)mMenuItemSize; |
src/main/java/org/distorted/screens/RubikScreenSolution.java | ||
---|---|---|
152 | 152 |
private void setupTextView(final RubikActivity act, final float width) |
153 | 153 |
{ |
154 | 154 |
int padding = (int)(width*RubikActivity.PADDING); |
155 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
155 |
int margin = (int)(width*RubikActivity.SMALL_MARGIN);
|
|
156 | 156 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,2.0f); |
157 | 157 |
params.topMargin = margin; |
158 | 158 |
params.bottomMargin = margin; |
src/main/java/org/distorted/screens/RubikScreenSolver.java | ||
---|---|---|
178 | 178 |
{ |
179 | 179 |
mColorButton = new ImageButton[mNumFaces]; |
180 | 180 |
int padding = (int)(width*RubikActivity.PADDING); |
181 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
181 |
int margin = (int)(width*RubikActivity.SMALL_MARGIN);
|
|
182 | 182 |
|
183 | 183 |
for(int i=0; i<mNumFaces; i++) |
184 | 184 |
{ |
src/main/res/layout/dialog_updates.xml | ||
---|---|---|
10 | 10 |
android:id="@+id/updates_main_layout" |
11 | 11 |
android:layout_width="match_parent" |
12 | 12 |
android:layout_height="wrap_content" |
13 |
android:gravity="center|fill_horizontal" |
|
14 | 13 |
android:background="@color/black" |
15 |
android:paddingLeft="10dp" |
|
16 |
android:paddingRight="10dp" |
|
17 |
android:paddingTop="10dp" |
|
18 | 14 |
android:paddingBottom="10dp" |
19 | 15 |
android:orientation="vertical"> |
20 | 16 |
|
src/main/res/layout/dialog_updates_pane.xml | ||
---|---|---|
3 | 3 |
xmlns:android="http://schemas.android.com/apk/res/android" |
4 | 4 |
android:layout_width="match_parent" |
5 | 5 |
android:layout_height="wrap_content" |
6 |
android:layout_margin="10dp" |
|
7 | 6 |
android:background="@color/grey" |
7 |
android:padding="8dp" |
|
8 | 8 |
android:orientation="horizontal"> |
9 | 9 |
|
10 | 10 |
<ImageView |
11 |
android:id="@+id/updates_pane_image" |
|
11 |
android:id="@+id/updates_pane_image" |
|
12 |
android:scaleType="fitCenter" |
|
12 | 13 |
android:layout_width="wrap_content" |
13 |
android:layout_height="wrap_content" |
|
14 |
android:layout_margin="10dp"/> |
|
14 |
android:layout_height="wrap_content"/> |
|
15 | 15 |
|
16 | 16 |
<LinearLayout |
17 | 17 |
android:layout_width="match_parent" |
18 |
android:layout_height="wrap_content"
|
|
18 |
android:layout_height="match_parent"
|
|
19 | 19 |
android:orientation="vertical" |
20 |
android:layout_marginStart="8dp" |
|
21 |
|
|
20 | 22 |
android:layout_gravity="center_vertical"> |
21 | 23 |
|
22 | 24 |
<TextView |
23 | 25 |
android:id="@+id/updates_pane_title" |
26 |
android:gravity="center_vertical" |
|
24 | 27 |
android:layout_width="match_parent" |
25 | 28 |
android:layout_height="wrap_content" |
26 | 29 |
android:textStyle="bold"/> |
27 | 30 |
<TextView |
28 | 31 |
android:id="@+id/updates_pane_version" |
32 |
android:gravity="center_vertical" |
|
29 | 33 |
android:layout_width="wrap_content" |
30 | 34 |
android:layout_height="wrap_content"/> |
31 |
<TextView |
|
35 |
|
|
36 |
<TextView |
|
32 | 37 |
android:id="@+id/updates_pane_description" |
38 |
android:gravity="center_vertical" |
|
33 | 39 |
android:layout_width="wrap_content" |
34 | 40 |
android:layout_height="wrap_content"/> |
41 |
|
|
35 | 42 |
<Button |
36 | 43 |
android:id="@+id/updates_pane_button" |
37 | 44 |
android:layout_width="match_parent" |
38 | 45 |
android:layout_height="wrap_content" |
39 | 46 |
android:backgroundTint="@color/black" |
40 |
android:layout_marginEnd="10dp" |
|
41 | 47 |
android:text="@string/install" |
42 |
android:gravity="center_vertical"/> |
|
48 |
android:gravity="center"/> |
|
49 |
|
|
43 | 50 |
</LinearLayout> |
44 | 51 |
</LinearLayout> |
Also available in: Unified diff
Downloading updates: dialog progress.