Revision 6e3fcb91
Added by Leszek Koltunski almost 4 years ago
| src/main/java/org/distorted/config/ConfigScreen.java | ||
|---|---|---|
| 19 | 19 |
|
| 20 | 20 |
package org.distorted.config; |
| 21 | 21 |
|
| 22 |
import android.content.res.Resources; |
|
| 23 |
import android.graphics.drawable.BitmapDrawable; |
|
| 24 | 22 |
import android.os.Build; |
| 25 | 23 |
import android.util.TypedValue; |
| 26 | 24 |
import android.view.Gravity; |
| ... | ... | |
| 46 | 44 |
|
| 47 | 45 |
public class ConfigScreen |
| 48 | 46 |
{
|
| 49 |
private static final int NUM_COLUMNS = 4;
|
|
| 47 |
private static final int NUM_COLUMNS = 5;
|
|
| 50 | 48 |
private static final int[] mLocation = new int[2]; |
| 51 | 49 |
|
| 52 | 50 |
private TransparentImageButton mBackButton, mObjectButton, mPrevButton, mNextButton; |
| ... | ... | |
| 63 | 61 |
|
| 64 | 62 |
private void setupObjectWindow(final ConfigActivity act, final float width, final float height) |
| 65 | 63 |
{
|
| 66 |
int icon = RubikActivity.getDrawable(R.drawable.cube_2s,R.drawable.cube_2m, R.drawable.cube_2b, R.drawable.cube_2h); |
|
| 67 |
|
|
| 68 |
Resources res = act.getResources(); |
|
| 69 |
BitmapDrawable bd = (BitmapDrawable)res.getDrawable(icon); |
|
| 70 |
int cubeWidth = bd.getIntrinsicWidth(); |
|
| 64 |
int cubeWidth = (int)(width/9); |
|
| 71 | 65 |
int margin = (int)(width*RubikActivity.LARGE_MARGIN); |
| 72 | 66 |
mObjectSize = (int)(cubeWidth + 2*margin + 0.5f); |
| 73 | 67 |
mMaxRowCount = (int)((height-mBarHeight)/mObjectSize); |
| ... | ... | |
| 103 | 97 |
{
|
| 104 | 98 |
final int ordinal = object; |
| 105 | 99 |
RubikObject rubikObject = RubikObjectList.getObject(ordinal); |
| 106 |
int iconSize = RubikActivity.getDrawableSize(); |
|
| 107 |
int icons = rubikObject.getIconID(iconSize); |
|
| 100 |
int icons = rubikObject.getIconID(); |
|
| 108 | 101 |
int row = object/NUM_COLUMNS; |
| 109 | 102 |
|
| 110 | 103 |
ImageButton button = new ImageButton(act); |
| ... | ... | |
| 132 | 125 |
params.leftMargin = margin; |
| 133 | 126 |
params.rightMargin = margin; |
| 134 | 127 |
|
| 128 |
params.width = cubeWidth; |
|
| 129 |
params.height= cubeWidth; |
|
| 130 |
|
|
| 135 | 131 |
nextInRow[row]++; |
| 136 | 132 |
|
| 137 | 133 |
objectGrid.addView(button, params); |
| ... | ... | |
| 183 | 179 |
int rowCount = Math.min(mMaxRowCount,mRowCount); |
| 184 | 180 |
View popupView = mObjectPopup.getContentView(); |
| 185 | 181 |
popupView.setSystemUiVisibility(RubikActivity.FLAGS); |
| 186 |
displayPopup(act,view,mObjectPopup,mObjectSize*mColCount,mObjectSize*rowCount,margin,margin); |
|
| 182 |
displayPopup(act,view,mObjectPopup,mObjectSize*mColCount,mObjectSize*rowCount+4*margin,margin,margin);
|
|
| 187 | 183 |
} |
| 188 | 184 |
} |
| 189 | 185 |
}); |
| src/main/java/org/distorted/dialogs/RubikDialogPattern.java | ||
|---|---|---|
| 33 | 33 |
import android.util.TypedValue; |
| 34 | 34 |
import android.view.LayoutInflater; |
| 35 | 35 |
import android.view.View; |
| 36 |
import android.view.ViewGroup; |
|
| 36 | 37 |
import android.view.Window; |
| 37 | 38 |
import android.view.WindowManager; |
| 38 | 39 |
import android.widget.Button; |
| ... | ... | |
| 64 | 65 |
|
| 65 | 66 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
| 66 | 67 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
| 67 |
final float titleSize= displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE; |
|
| 68 |
final float okSize = displaymetrics.widthPixels * RubikActivity.DIALOG_BUTTON_SIZE; |
|
| 68 |
|
|
| 69 |
int scrWidth = displaymetrics.widthPixels; |
|
| 70 |
final float titleSize= scrWidth*RubikActivity.MENU_BIG_TEXT_SIZE; |
|
| 71 |
final float okSize = scrWidth*RubikActivity.DIALOG_BUTTON_SIZE; |
|
| 72 |
final int tabHeight= (int)(scrWidth*RubikActivity.TAB_HEIGHT); |
|
| 73 |
final int tabWidth = (int)(scrWidth*RubikActivity.TAB_WIDTH); |
|
| 69 | 74 |
|
| 70 | 75 |
LayoutInflater layoutInflater = act.getLayoutInflater(); |
| 71 | 76 |
TextView tv = (TextView) layoutInflater.inflate(R.layout.dialog_title, null); |
| ... | ... | |
| 92 | 97 |
tabLayout.setupWithViewPager(viewPager); |
| 93 | 98 |
viewPager.setCurrentItem(getPatternOrdinal()); |
| 94 | 99 |
|
| 100 |
ViewGroup.LayoutParams paramsView = new ViewGroup.LayoutParams( tabWidth,tabHeight ); |
|
| 101 |
|
|
| 95 | 102 |
for(int i=0; i< RubikPatternList.NUM_OBJECTS; i++) |
| 96 | 103 |
{
|
| 97 |
int ordinal = RubikPatternList.getObject(i);
|
|
| 104 |
int ordinal = RubikPatternList.getObject(i); |
|
| 98 | 105 |
RubikObject object = RubikObjectList.getObject(ordinal); |
| 99 |
int iconSize= RubikActivity.getDrawableSize(); |
|
| 100 |
int iconID = object==null ? 0 : object.getIconID(iconSize); |
|
| 106 |
int iconID = object==null ? 0 : object.getIconID(); |
|
| 101 | 107 |
|
| 102 | 108 |
ImageView imageView = new ImageView(act); |
| 103 | 109 |
imageView.setImageResource(iconID); |
| 110 |
imageView.setLayoutParams(paramsView); |
|
| 104 | 111 |
TabLayout.Tab tab = tabLayout.getTabAt(i); |
| 105 | 112 |
if(tab!=null) tab.setCustomView(imageView); |
| 106 | 113 |
} |
| src/main/java/org/distorted/dialogs/RubikDialogScores.java | ||
|---|---|---|
| 33 | 33 |
import android.util.TypedValue; |
| 34 | 34 |
import android.view.LayoutInflater; |
| 35 | 35 |
import android.view.View; |
| 36 |
import android.view.ViewGroup; |
|
| 36 | 37 |
import android.view.Window; |
| 37 | 38 |
import android.widget.Button; |
| 38 | 39 |
import android.widget.ImageView; |
| ... | ... | |
| 60 | 61 |
|
| 61 | 62 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
| 62 | 63 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
| 63 |
final float titleSize= displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE; |
|
| 64 |
final float okSize = displaymetrics.widthPixels * RubikActivity.DIALOG_BUTTON_SIZE; |
|
| 64 |
|
|
| 65 |
int scrWidth = displaymetrics.widthPixels; |
|
| 66 |
final float titleSize= scrWidth*RubikActivity.MENU_BIG_TEXT_SIZE; |
|
| 67 |
final float okSize = scrWidth*RubikActivity.DIALOG_BUTTON_SIZE; |
|
| 68 |
final int tabHeight= (int)(scrWidth*RubikActivity.TAB_HEIGHT); |
|
| 69 |
final int tabWidth = (int)(scrWidth*RubikActivity.TAB_WIDTH); |
|
| 65 | 70 |
|
| 66 | 71 |
LayoutInflater layoutInflater = act.getLayoutInflater(); |
| 67 | 72 |
TextView tv = (TextView) layoutInflater.inflate(R.layout.dialog_title, null); |
| ... | ... | |
| 104 | 109 |
tabLayout.setupWithViewPager(viewPager); |
| 105 | 110 |
|
| 106 | 111 |
viewPager.setCurrentItem(curTab); |
| 107 |
int iconSize = RubikActivity.getDrawableSize(); |
|
| 108 | 112 |
int numObjects = RubikObjectList.getNumObjects(); |
| 113 |
ViewGroup.LayoutParams paramsView = new ViewGroup.LayoutParams( tabWidth,tabHeight ); |
|
| 109 | 114 |
|
| 110 | 115 |
for (int object=0; object<numObjects; object++) |
| 111 | 116 |
{
|
| 112 | 117 |
RubikObject robject = RubikObjectList.getObject(object); |
| 113 |
int iconID = robject==null ? 0 : robject.getIconID(iconSize);
|
|
| 118 |
int iconID = robject==null ? 0 : robject.getIconID(); |
|
| 114 | 119 |
ImageView imageView = new ImageView(act); |
| 115 | 120 |
imageView.setImageResource(iconID); |
| 121 |
imageView.setLayoutParams(paramsView); |
|
| 116 | 122 |
TabLayout.Tab tab = tabLayout.getTabAt(object); |
| 117 | 123 |
if(tab!=null) tab.setCustomView(imageView); |
| 118 | 124 |
} |
| src/main/java/org/distorted/dialogs/RubikDialogTutorial.java | ||
|---|---|---|
| 27 | 27 |
import android.util.TypedValue; |
| 28 | 28 |
import android.view.LayoutInflater; |
| 29 | 29 |
import android.view.View; |
| 30 |
import android.view.ViewGroup; |
|
| 30 | 31 |
import android.view.Window; |
| 31 | 32 |
import android.view.WindowManager; |
| 32 | 33 |
import android.widget.Button; |
| ... | ... | |
| 44 | 45 |
import org.distorted.main.R; |
| 45 | 46 |
import org.distorted.main.RubikActivity; |
| 46 | 47 |
import org.distorted.objects.RubikObjectList; |
| 47 |
import org.distorted.screens.RubikScreenPlay; |
|
| 48 |
import org.distorted.screens.ScreenList; |
|
| 49 | 48 |
import org.distorted.tutorials.TutorialList; |
| 50 | 49 |
|
| 51 | 50 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 65 | 64 |
|
| 66 | 65 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
| 67 | 66 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
| 68 |
final float titleSize= displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE; |
|
| 69 |
final float okSize = displaymetrics.widthPixels * RubikActivity.DIALOG_BUTTON_SIZE; |
|
| 67 |
int scrWidth = displaymetrics.widthPixels; |
|
| 68 |
final float titleSize= scrWidth*RubikActivity.MENU_BIG_TEXT_SIZE; |
|
| 69 |
final float okSize = scrWidth*RubikActivity.DIALOG_BUTTON_SIZE; |
|
| 70 |
final int tabHeight= (int)(scrWidth*RubikActivity.TAB_HEIGHT); |
|
| 71 |
final int tabWidth = (int)(scrWidth*RubikActivity.TAB_WIDTH); |
|
| 70 | 72 |
|
| 71 | 73 |
LayoutInflater layoutInflater = act.getLayoutInflater(); |
| 72 | 74 |
TextView tv = (TextView) layoutInflater.inflate(R.layout.dialog_title, null); |
| ... | ... | |
| 93 | 95 |
tabLayout.setupWithViewPager(viewPager); |
| 94 | 96 |
viewPager.setCurrentItem(getTutorialOrdinal()); |
| 95 | 97 |
|
| 98 |
ViewGroup.LayoutParams paramsView = new ViewGroup.LayoutParams( tabWidth,tabHeight ); |
|
| 99 |
|
|
| 96 | 100 |
for(int i=0; i<TutorialList.NUM_OBJECTS; i++) |
| 97 | 101 |
{
|
| 98 | 102 |
TutorialList list = TutorialList.getObject(i); |
| 99 | 103 |
int iconID = list.getIconID(); |
| 100 | 104 |
ImageView imageView = new ImageView(act); |
| 105 |
imageView.setLayoutParams(paramsView); |
|
| 101 | 106 |
imageView.setImageResource(iconID); |
| 102 | 107 |
TabLayout.Tab tab = tabLayout.getTabAt(i); |
| 103 | 108 |
if(tab!=null) tab.setCustomView(imageView); |
| src/main/java/org/distorted/main/RubikActivity.java | ||
|---|---|---|
| 84 | 84 |
public static final float MENU_BIG_TEXT_SIZE = 0.05f; |
| 85 | 85 |
public static final float MENU_MED_TEXT_SIZE = 0.04f; |
| 86 | 86 |
public static final float MENU_SMALL_TEXT_SIZE= 0.035f; |
| 87 |
public static final float TAB_WIDTH = 0.100f; |
|
| 88 |
public static final float TAB_HEIGHT = 0.100f; |
|
| 87 | 89 |
|
| 88 | 90 |
public static final int FLAGS = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
| 89 | 91 |
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| src/main/java/org/distorted/objects/RubikObject.java | ||
|---|---|---|
| 30 | 30 |
|
| 31 | 31 |
public class RubikObject |
| 32 | 32 |
{
|
| 33 |
private static final int NUM = 4; |
|
| 34 |
|
|
| 35 | 33 |
private final String mName; |
| 36 | 34 |
private final int mNumScramble; |
| 37 | 35 |
private final int mOrdinal; |
| 38 | 36 |
private final int mJsonID, mMeshID; |
| 39 |
private final int[] mIconID;
|
|
| 37 |
private final int mIconID; |
|
| 40 | 38 |
private final String[][] mPatterns; |
| 41 | 39 |
|
| 42 | 40 |
private int mMeshState; |
| ... | ... | |
| 45 | 43 |
|
| 46 | 44 |
RubikObject(ObjectType type) |
| 47 | 45 |
{
|
| 48 |
mIconID = new int[NUM]; |
|
| 49 |
for(int i=0; i<NUM; i++) mIconID[i] = type.getIconID(i); |
|
| 50 |
|
|
| 46 |
mIconID = type.getIconID(); |
|
| 51 | 47 |
mName = type.name(); |
| 52 | 48 |
mNumScramble = type.getNumScramble(); |
| 53 | 49 |
mOrdinal = type.ordinal(); |
| ... | ... | |
| 84 | 80 |
|
| 85 | 81 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 86 | 82 |
|
| 87 |
public int getIconID(int size)
|
|
| 83 |
public int getIconID() |
|
| 88 | 84 |
{
|
| 89 |
return size>=0 && size<NUM ? mIconID[size] : 0;
|
|
| 85 |
return mIconID;
|
|
| 90 | 86 |
} |
| 91 | 87 |
|
| 92 | 88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/screens/RubikScreenPlay.java | ||
|---|---|---|
| 55 | 55 |
|
| 56 | 56 |
public class RubikScreenPlay extends RubikScreenBase |
| 57 | 57 |
{
|
| 58 |
public static final int NUM_COLUMNS = 4;
|
|
| 58 |
public static final int NUM_COLUMNS = 5;
|
|
| 59 | 59 |
public static final int LEVELS_SHOWN = 10; |
| 60 | 60 |
|
| 61 | 61 |
private static final int[] BUTTON_LABELS = { R.string.scores,
|
| ... | ... | |
| 78 | 78 |
private int mColCount, mRowCount, mMaxRowCount; |
| 79 | 79 |
private int mUpperBarHeight; |
| 80 | 80 |
private boolean mShouldReactToEndOfScrambling; |
| 81 |
private int mBottomHeight; |
|
| 81 | 82 |
|
| 82 | 83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 83 | 84 |
|
| ... | ... | |
| 124 | 125 |
private void setupObjectButton(final RubikActivity act, final float width) |
| 125 | 126 |
{
|
| 126 | 127 |
final int margin = (int)(width*RubikActivity.MARGIN); |
| 128 |
final int lMargin = (int)(width*RubikActivity.LARGE_MARGIN); |
|
| 127 | 129 |
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); |
| 128 | 130 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
| 129 | 131 |
mObjButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params); |
| ... | ... | |
| 145 | 147 |
int rowCount = Math.min(mMaxRowCount,mRowCount); |
| 146 | 148 |
View popupView = mObjectPopup.getContentView(); |
| 147 | 149 |
popupView.setSystemUiVisibility(RubikActivity.FLAGS); |
| 148 |
displayPopup(act,view,mObjectPopup,mObjectSize*mColCount,mObjectSize*rowCount,margin,margin); |
|
| 150 |
displayPopup(act,view,mObjectPopup,mObjectSize*mColCount,mObjectSize*rowCount+mBottomHeight+2*lMargin,margin,margin);
|
|
| 149 | 151 |
} |
| 150 | 152 |
} |
| 151 | 153 |
}); |
| ... | ... | |
| 222 | 224 |
|
| 223 | 225 |
private void setupObjectWindow(final RubikActivity act, final float width, final float height) |
| 224 | 226 |
{
|
| 225 |
int icon = RubikActivity.getDrawable(R.drawable.cube_2s,R.drawable.cube_2m, R.drawable.cube_2b, R.drawable.cube_2h); |
|
| 226 |
|
|
| 227 |
Resources res = act.getResources(); |
|
| 228 |
BitmapDrawable bd = (BitmapDrawable)res.getDrawable(icon); |
|
| 229 |
int cubeWidth = bd.getIntrinsicWidth(); |
|
| 227 |
int cubeWidth = (int)(width/9); |
|
| 230 | 228 |
int margin = (int)(width*RubikActivity.LARGE_MARGIN); |
| 231 | 229 |
mObjectSize = (int)(cubeWidth + 2*margin + 0.5f); |
| 232 | 230 |
mMaxRowCount = (int)((height-1.8f*mUpperBarHeight)/mObjectSize); |
| ... | ... | |
| 241 | 239 |
objectGrid.setRowCount(mRowCount); |
| 242 | 240 |
|
| 243 | 241 |
LinearLayout bottomLayout = view.findViewById(R.id.bottomLayout); |
| 244 |
setupBottomLayout(act,bottomLayout,2*mObjectSize);
|
|
| 242 |
setupBottomLayout(act,bottomLayout,(NUM_COLUMNS-2)*mObjectSize);
|
|
| 245 | 243 |
|
| 246 | 244 |
mObjectPopup = new PopupWindow(act); |
| 247 | 245 |
mObjectPopup.setFocusable(true); |
| ... | ... | |
| 264 | 262 |
for(int object=0; object<numObjects; object++) |
| 265 | 263 |
{
|
| 266 | 264 |
final RubikObject robject = RubikObjectList.getObject(object); |
| 267 |
int iconSize = RubikActivity.getDrawableSize(); |
|
| 268 |
int icons = robject==null ? 0 : robject.getIconID(iconSize); |
|
| 265 |
int icons = robject==null ? 0 : robject.getIconID(); |
|
| 269 | 266 |
int row = object/NUM_COLUMNS; |
| 270 | 267 |
final int ordinal = robject==null ? 0 : robject.getOrdinal(); |
| 271 | 268 |
|
| ... | ... | |
| 294 | 291 |
params.leftMargin = margin; |
| 295 | 292 |
params.rightMargin = margin; |
| 296 | 293 |
|
| 294 |
params.width = cubeWidth; |
|
| 295 |
params.height= cubeWidth; |
|
| 296 |
|
|
| 297 | 297 |
nextInRow[row]++; |
| 298 | 298 |
|
| 299 | 299 |
objectGrid.addView(button, params); |
| ... | ... | |
| 317 | 317 |
|
| 318 | 318 |
buttonNul.setWidth(width); |
| 319 | 319 |
|
| 320 |
Resources res = act.getResources(); |
|
| 321 |
BitmapDrawable bd = (BitmapDrawable)res.getDrawable(iconD); |
|
| 322 |
mBottomHeight = bd.getIntrinsicHeight(); |
|
| 323 |
|
|
| 320 | 324 |
TypedValue outValue = new TypedValue(); |
| 321 | 325 |
act.getTheme().resolveAttribute(android.R.attr.selectableItemBackgroundBorderless, outValue, true); |
| 322 | 326 |
buttonTut.setBackgroundResource(outValue.resourceId); |
| src/main/java/org/distorted/tutorials/TutorialList.java | ||
|---|---|---|
| 551 | 551 |
public int getIconID() |
| 552 | 552 |
{
|
| 553 | 553 |
RubikObject object = RubikObjectList.getObject(mObject); |
| 554 |
int iconSize = RubikActivity.getDrawableSize(); |
|
| 555 |
return object==null ? 0 : object.getIconID(iconSize); |
|
| 554 |
return object==null ? 0 : object.getIconID(); |
|
| 556 | 555 |
} |
| 557 | 556 |
|
| 558 | 557 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Remove 3 out of 4 object icons.