Revision 24cd23dd
Added by Leszek Koltunski almost 3 years ago
| src/main/java/org/distorted/dialogs/RubikDialogStarsStatus.java | ||
|---|---|---|
| 18 | 18 |
import android.view.View; |
| 19 | 19 |
import android.view.Window; |
| 20 | 20 |
import android.widget.Button; |
| 21 |
import android.widget.LinearLayout; |
|
| 21 | 22 |
import android.widget.TextView; |
| 22 | 23 |
|
| 23 | 24 |
import androidx.annotation.NonNull; |
| ... | ... | |
| 33 | 34 |
|
| 34 | 35 |
public class RubikDialogStarsStatus extends AppCompatDialogFragment |
| 35 | 36 |
{
|
| 37 |
private static final float LAYOUT_HEIGHT = 0.110f; |
|
| 38 |
private static final float MARGIN = 0.007f; |
|
| 39 |
|
|
| 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 41 |
|
|
| 36 | 42 |
@NonNull |
| 37 | 43 |
@Override |
| 38 | 44 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
| ... | ... | |
| 45 | 51 |
final float butSize = displaymetrics.widthPixels * RubikActivity.DIALOG_BUTTON_SIZE; |
| 46 | 52 |
final View view = inflater.inflate(R.layout.dialog_stars_status, null); |
| 47 | 53 |
|
| 54 |
int height = (int)(displaymetrics.heightPixels*LAYOUT_HEIGHT); |
|
| 55 |
int margin = (int)(displaymetrics.heightPixels*MARGIN); |
|
| 56 |
|
|
| 57 |
LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT); |
|
| 58 |
params1.setMargins(margin, margin, margin, margin); |
|
| 59 |
LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,height); |
|
| 60 |
params2.setMargins(margin, margin, margin, margin); |
|
| 61 |
|
|
| 62 |
LinearLayout lm = view.findViewById(R.id.stars_main); |
|
| 63 |
lm.setPadding(margin,margin,margin,margin); |
|
| 64 |
|
|
| 65 |
LinearLayout ls = view.findViewById(R.id.stars_strings); |
|
| 66 |
ls.setLayoutParams(params1); |
|
| 67 |
LinearLayout l1 = view.findViewById(R.id.stars_layout_1); |
|
| 68 |
l1.setLayoutParams(params2); |
|
| 69 |
LinearLayout l2 = view.findViewById(R.id.stars_layout_2); |
|
| 70 |
l2.setLayoutParams(params2); |
|
| 71 |
LinearLayout l3 = view.findViewById(R.id.stars_layout_3); |
|
| 72 |
l3.setLayoutParams(params2); |
|
| 73 |
|
|
| 48 | 74 |
fillUpNumberOfStars(view); |
| 49 | 75 |
|
| 50 | 76 |
builder.setCancelable(true); |
| src/main/java/org/distorted/main/RubikActivity.java | ||
|---|---|---|
| 86 | 86 |
public static final float TAB_WIDTH = 0.100f; |
| 87 | 87 |
public static final float TAB_HEIGHT = 0.100f; |
| 88 | 88 |
|
| 89 |
public static final float MENU_BUTTON_HEIGHT = 0.075f; |
|
| 90 |
public static final float MENU_TEXT_SIZE = 0.032f; |
|
| 91 |
|
|
| 92 | 89 |
public static final int FLAGS = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
| 93 | 90 |
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| 94 | 91 |
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
| src/main/java/org/distorted/screens/RubikScreenPlay.java | ||
|---|---|---|
| 57 | 57 |
|
| 58 | 58 |
public class RubikScreenPlay extends RubikScreenBase implements RubikNetwork.Updatee |
| 59 | 59 |
{
|
| 60 |
private static final float MENU_BUTTON_HEIGHT = 0.075f; |
|
| 61 |
private static final float MENU_TEXT_SIZE = 0.032f; |
|
| 62 |
private static final float MENU_MARGIN = 0.008f; |
|
| 63 |
|
|
| 60 | 64 |
public static final int NUM_COLUMNS = 5; |
| 61 | 65 |
public static final int LEVELS_SHOWN = 8; |
| 62 | 66 |
private static final int[] mLocation = new int[2]; |
| ... | ... | |
| 72 | 76 |
private int mUpperBarHeight; |
| 73 | 77 |
private boolean mShouldReactToEndOfScrambling; |
| 74 | 78 |
private float mScreenWidth, mScreenHeight; |
| 79 |
private int mLevelHeight, mLevelWidth; |
|
| 75 | 80 |
private int mOldNumScramble; |
| 76 | 81 |
|
| 77 | 82 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 90 | 95 |
mScreenHeight = act.getScreenHeightInPixels(); |
| 91 | 96 |
mUpperBarHeight = act.getHeightUpperBar(); |
| 92 | 97 |
|
| 93 |
mMenuButtonHeight = (int)(mScreenHeight*RubikActivity.MENU_BUTTON_HEIGHT);
|
|
| 94 |
mMenuTextSize = (int)(mScreenHeight*RubikActivity.MENU_TEXT_SIZE);
|
|
| 98 |
mMenuButtonHeight = (int)(mScreenHeight*MENU_BUTTON_HEIGHT); |
|
| 99 |
mMenuTextSize = (int)(mScreenHeight*MENU_TEXT_SIZE); |
|
| 95 | 100 |
|
| 96 | 101 |
mObjectPopup = null; |
| 97 | 102 |
mOldNumScramble = 1000; // used to remember which 'level' buttons are visible; initially all visible |
| ... | ... | |
| 102 | 107 |
|
| 103 | 108 |
setupSolveButton(act); |
| 104 | 109 |
layoutTop.addView(mSolveButton); |
| 105 |
setupMenuButton(act,mScreenWidth); |
|
| 110 |
setupMenuButton(act,mScreenWidth, mScreenHeight);
|
|
| 106 | 111 |
layoutTop.addView(mMenuButton); |
| 107 | 112 |
setupScrambleButton(act); |
| 108 | 113 |
layoutTop.addView(mScrambleButton); |
| ... | ... | |
| 146 | 151 |
|
| 147 | 152 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 148 | 153 |
|
| 149 |
private void setupMenuButton(final RubikActivity act, final float width) |
|
| 154 |
private void setupMenuButton(final RubikActivity act, final float width, final float height)
|
|
| 150 | 155 |
{
|
| 151 | 156 |
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); |
| 152 | 157 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
| ... | ... | |
| 160 | 165 |
if( mMenuPopup==null ) |
| 161 | 166 |
{
|
| 162 | 167 |
float width = act.getScreenWidthInPixels(); |
| 163 |
setupMenuWindow(act,width); |
|
| 168 |
setupMenuWindow(act,width,height);
|
|
| 164 | 169 |
} |
| 165 | 170 |
|
| 166 | 171 |
if( act.getControl().isUINotBlocked()) |
| ... | ... | |
| 335 | 340 |
|
| 336 | 341 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 337 | 342 |
|
| 338 |
private void setupMenuWindow(final RubikActivity act, final float width) |
|
| 343 |
private void setupMenuWindow(final RubikActivity act, final float width, final float height)
|
|
| 339 | 344 |
{
|
| 340 | 345 |
LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
| 341 | 346 |
final View layout = layoutInflater.inflate(R.layout.popup_menu, null); |
| ... | ... | |
| 343 | 348 |
mMenuPopup = new PopupWindow(act); |
| 344 | 349 |
mMenuPopup.setContentView(layout); |
| 345 | 350 |
mMenuPopup.setFocusable(true); |
| 346 |
int padding = (int)(width*RubikActivity.MEDIUM_MARGIN);
|
|
| 351 |
int padding = (int)(height*MENU_MARGIN);
|
|
| 347 | 352 |
int numButtons = USE_IAP ? 7 : 6; |
| 348 | 353 |
mMenuLayoutWidth = (int)(width*0.65f); |
| 349 |
mMenuLayoutHeight= padding + numButtons*(mMenuButtonHeight+padding) + 4*mMenuButtonHeight+6*padding; |
|
| 354 |
mLevelWidth = (mMenuLayoutWidth-4*padding)/3; |
|
| 355 |
mLevelHeight = (int)(mLevelWidth*0.75f); |
|
| 356 |
mMenuLayoutHeight= padding + numButtons*(mMenuButtonHeight+padding) + mLevelHeight/3 + 3*(mLevelHeight+padding); |
|
| 350 | 357 |
|
| 351 | 358 |
layout.setPadding(padding,0,padding,0); |
| 352 | 359 |
|
| ... | ... | |
| 462 | 469 |
|
| 463 | 470 |
private void setupLevelButtons(RubikActivity act, View layout, int padding) |
| 464 | 471 |
{
|
| 465 |
int sizeW = (mMenuLayoutWidth-4*padding)/3; |
|
| 466 |
int sizeH = (int)(sizeW*0.8f); |
|
| 467 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(sizeW,sizeH); |
|
| 472 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(mLevelWidth,mLevelHeight); |
|
| 468 | 473 |
params.setMargins(padding/2,0,padding/2,0); |
| 469 | 474 |
|
| 470 | 475 |
mLevel = new Button[LEVELS_SHOWN+1]; |
| src/main/res/layout/dialog_stars_status.xml | ||
|---|---|---|
| 1 | 1 |
<?xml version="1.0" encoding="utf-8"?> |
| 2 | 2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 |
android:id="@+id/stars_main" |
|
| 3 | 4 |
android:layout_width="fill_parent" |
| 4 | 5 |
android:layout_height="fill_parent" |
| 5 | 6 |
android:gravity="center|fill_horizontal" |
| 6 |
android:padding="10dp" |
|
| 7 | 7 |
android:background="@color/grey" |
| 8 | 8 |
android:orientation="vertical"> |
| 9 | 9 |
|
| 10 |
<TextView |
|
| 11 |
android:id="@+id/stars_string1" |
|
| 12 |
android:background="@color/light_grey" |
|
| 10 |
<LinearLayout |
|
| 11 |
android:id="@+id/stars_strings" |
|
| 13 | 12 |
android:layout_width="match_parent" |
| 14 |
android:layout_height="match_parent" |
|
| 15 |
android:gravity="start" |
|
| 16 |
android:textSize="21sp" |
|
| 17 |
android:padding="10dp" |
|
| 18 |
android:text="@string/buy_string1" |
|
| 19 |
/> |
|
| 20 |
<TextView |
|
| 21 |
android:id="@+id/stars_string2" |
|
| 13 |
android:layout_height="wrap_content" |
|
| 14 |
android:padding="5dp" |
|
| 15 |
android:gravity="center" |
|
| 16 |
android:layout_marginTop="10dp" |
|
| 22 | 17 |
android:background="@color/light_grey" |
| 23 |
android:layout_width="match_parent" |
|
| 24 |
android:layout_height="match_parent" |
|
| 25 |
android:gravity="start" |
|
| 26 |
android:textSize="21sp" |
|
| 27 |
android:padding="10dp" |
|
| 28 |
android:text="@string/buy_string2" |
|
| 29 |
/> |
|
| 18 |
android:orientation="vertical"> |
|
| 19 |
|
|
| 20 |
<TextView |
|
| 21 |
android:id="@+id/stars_string1" |
|
| 22 |
android:layout_width="match_parent" |
|
| 23 |
android:layout_height="wrap_content" |
|
| 24 |
android:gravity="start" |
|
| 25 |
android:textSize="21sp" |
|
| 26 |
android:layout_marginBottom="10dp" |
|
| 27 |
android:text="@string/buy_string1" |
|
| 28 |
/> |
|
| 29 |
<TextView |
|
| 30 |
android:id="@+id/stars_string2" |
|
| 31 |
android:layout_width="match_parent" |
|
| 32 |
android:layout_height="wrap_content" |
|
| 33 |
android:gravity="start" |
|
| 34 |
android:textSize="21sp" |
|
| 35 |
android:text="@string/buy_string2" |
|
| 36 |
/> |
|
| 37 |
</LinearLayout> |
|
| 30 | 38 |
|
| 31 | 39 |
<LinearLayout |
| 32 |
android:id="@+id/stars_layout_50"
|
|
| 40 |
android:id="@+id/stars_layout_1"
|
|
| 33 | 41 |
android:layout_width="fill_parent" |
| 34 | 42 |
android:layout_height="80dp" |
| 35 | 43 |
android:padding="5dp" |
| ... | ... | |
| 38 | 46 |
android:orientation="horizontal"> |
| 39 | 47 |
|
| 40 | 48 |
<ImageView |
| 41 |
android:id="@+id/stars_image_50"
|
|
| 49 |
android:id="@+id/stars_image_1"
|
|
| 42 | 50 |
android:layout_width="0dp" |
| 43 | 51 |
android:layout_height="wrap_content" |
| 44 | 52 |
android:layout_weight="1.5" |
| ... | ... | |
| 47 | 55 |
android:src="@drawable/price_50" |
| 48 | 56 |
/> |
| 49 | 57 |
<Button |
| 50 |
android:id="@+id/stars_button_50"
|
|
| 58 |
android:id="@+id/stars_button_1"
|
|
| 51 | 59 |
android:layout_width="0dp" |
| 52 | 60 |
android:layout_height="match_parent" |
| 53 | 61 |
android:layout_weight="1" |
| ... | ... | |
| 57 | 65 |
</LinearLayout> |
| 58 | 66 |
|
| 59 | 67 |
<LinearLayout |
| 60 |
android:id="@+id/stars_layout_200"
|
|
| 68 |
android:id="@+id/stars_layout_2" |
|
| 61 | 69 |
android:layout_width="fill_parent" |
| 62 | 70 |
android:layout_height="80dp" |
| 63 | 71 |
android:padding="5dp" |
| ... | ... | |
| 66 | 74 |
android:orientation="horizontal"> |
| 67 | 75 |
|
| 68 | 76 |
<ImageView |
| 69 |
android:id="@+id/stars_image_200"
|
|
| 77 |
android:id="@+id/stars_image_2" |
|
| 70 | 78 |
android:layout_width="0dp" |
| 71 | 79 |
android:layout_height="wrap_content" |
| 72 | 80 |
android:layout_weight="1.5" |
| ... | ... | |
| 75 | 83 |
android:src="@drawable/price_200" |
| 76 | 84 |
/> |
| 77 | 85 |
<Button |
| 78 |
android:id="@+id/stars_button_200"
|
|
| 86 |
android:id="@+id/stars_button_2" |
|
| 79 | 87 |
android:layout_width="0dp" |
| 80 | 88 |
android:layout_height="match_parent" |
| 81 | 89 |
android:layout_weight="1" |
| ... | ... | |
| 85 | 93 |
</LinearLayout> |
| 86 | 94 |
|
| 87 | 95 |
<LinearLayout |
| 88 |
android:id="@+id/stars_layout_600"
|
|
| 96 |
android:id="@+id/stars_layout_3"
|
|
| 89 | 97 |
android:layout_width="fill_parent" |
| 90 | 98 |
android:layout_height="80dp" |
| 91 | 99 |
android:padding="5dp" |
| ... | ... | |
| 94 | 102 |
android:orientation="horizontal"> |
| 95 | 103 |
|
| 96 | 104 |
<ImageView |
| 97 |
android:id="@+id/stars_image_600"
|
|
| 105 |
android:id="@+id/stars_image_3"
|
|
| 98 | 106 |
android:layout_width="0dp" |
| 99 | 107 |
android:layout_height="wrap_content" |
| 100 | 108 |
android:layout_weight="1.5" |
| ... | ... | |
| 103 | 111 |
android:src="@drawable/price_600" |
| 104 | 112 |
/> |
| 105 | 113 |
<Button |
| 106 |
android:id="@+id/stars_button_600"
|
|
| 114 |
android:id="@+id/stars_button_3"
|
|
| 107 | 115 |
android:layout_width="0dp" |
| 108 | 116 |
android:layout_height="match_parent" |
| 109 | 117 |
android:layout_weight="1" |
Also available in: Unified diff
Further improvements for the UI.