Revision 1c04d054
Added by Leszek Koltunski almost 2 years ago
| build.gradle | ||
|---|---|---|
| 15 | 15 |
applicationId "org.distorted.magic" |
| 16 | 16 |
minSdkVersion 21 |
| 17 | 17 |
targetSdkVersion 34 |
| 18 |
versionCode 86
|
|
| 19 |
versionName "1.13.4"
|
|
| 18 |
versionCode 87
|
|
| 19 |
versionName "2.0.0"
|
|
| 20 | 20 |
} |
| 21 | 21 |
|
| 22 | 22 |
buildTypes {
|
| src/main/AndroidManifest.xml | ||
|---|---|---|
| 20 | 20 |
android:value="${crashlyticsCollectionEnabled}"
|
| 21 | 21 |
/> |
| 22 | 22 |
|
| 23 |
<activity android:name="org.distorted.main.RubikActivity" android:exported="true" android:screenOrientation="portrait">
|
|
| 23 |
<activity android:name="org.distorted.main.MainActivity" android:exported="true" android:screenOrientation="portrait">
|
|
| 24 | 24 |
<intent-filter> |
| 25 | 25 |
<action android:name="android.intent.action.MAIN" /> |
| 26 | 26 |
<category android:name="android.intent.category.LAUNCHER" /> |
| src/main/java/org/distorted/bandaged/BandagedCreatorActivity.java | ||
|---|---|---|
| 31 | 31 |
import org.distorted.dialogs.RubikDialogError; |
| 32 | 32 |
import org.distorted.external.RubikFiles; |
| 33 | 33 |
import org.distorted.library.main.DistortedLibrary; |
| 34 |
import org.distorted.main.MainActivity; |
|
| 34 | 35 |
import org.distorted.main.R; |
| 35 |
import org.distorted.main.RubikActivity; |
|
| 36 |
import org.distorted.main_old.RubikActivity;
|
|
| 36 | 37 |
import org.distorted.objectlib.main.InitAssets; |
| 37 | 38 |
import org.distorted.objectlib.main.TwistyJson; |
| 38 | 39 |
import org.distorted.objectlib.main.TwistyObject; |
| ... | ... | |
| 43 | 44 |
public class BandagedCreatorActivity extends AppCompatActivity |
| 44 | 45 |
{
|
| 45 | 46 |
private static final int ACTIVITY_NUMBER = 3; |
| 46 |
private static final float RATIO_BAR = 0.10f;
|
|
| 47 |
private static final float RATIO_BAR = MainActivity.RATIO_BAR;
|
|
| 47 | 48 |
private static final float RATIO_BUT = 0.07f; |
| 48 | 49 |
static final float RATIO_SCROLL = 0.30f; |
| 49 | 50 |
public static final float SPINNER_TEXT_SIZE = 0.03f; |
| src/main/java/org/distorted/bandaged/BandagedCreatorObjectView.java | ||
|---|---|---|
| 18 | 18 |
import org.distorted.helpers.TransparentButton; |
| 19 | 19 |
import org.distorted.helpers.TransparentImageButton; |
| 20 | 20 |
import org.distorted.main.R; |
| 21 |
import org.distorted.main.RubikActivity; |
|
| 22 | 21 |
|
| 23 | 22 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 24 | 23 |
|
| src/main/java/org/distorted/bandaged/BandagedCreatorScreen.java | ||
|---|---|---|
| 29 | 29 |
import org.distorted.external.RubikFiles; |
| 30 | 30 |
import org.distorted.helpers.TransparentImageButton; |
| 31 | 31 |
import org.distorted.main.R; |
| 32 |
import org.distorted.main.RubikActivity; |
|
| 32 |
import org.distorted.main_old.RubikActivity;
|
|
| 33 | 33 |
import org.distorted.objectlib.bandaged.LocallyBandagedList; |
| 34 | 34 |
|
| 35 | 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/bandaged/BandagedPlayActivity.java | ||
|---|---|---|
| 25 | 25 |
import org.distorted.dialogs.RubikDialogError; |
| 26 | 26 |
import org.distorted.external.RubikFiles; |
| 27 | 27 |
import org.distorted.library.main.DistortedLibrary; |
| 28 |
import org.distorted.main.MainActivity; |
|
| 28 | 29 |
import org.distorted.main.R; |
| 29 |
import org.distorted.main.RubikActivity; |
|
| 30 |
import org.distorted.main_old.RubikActivity;
|
|
| 30 | 31 |
import org.distorted.objectlib.main.InitAssets; |
| 31 | 32 |
import org.distorted.objectlib.main.ObjectControl; |
| 32 | 33 |
import org.distorted.objectlib.main.TwistyObject; |
| ... | ... | |
| 38 | 39 |
public class BandagedPlayActivity extends AppCompatActivity |
| 39 | 40 |
{
|
| 40 | 41 |
private static final int ACTIVITY_NUMBER = 4; |
| 41 |
private static final float RATIO_BAR = 0.10f;
|
|
| 42 |
private static final float RATIO_BAR = MainActivity.RATIO_BAR;
|
|
| 42 | 43 |
private static final float RATIO_INSET = 0.09f; |
| 43 | 44 |
public static final int FLAGS = RubikActivity.FLAGS; |
| 44 | 45 |
|
| src/main/java/org/distorted/config/ConfigActivity.java | ||
|---|---|---|
| 21 | 21 |
import androidx.appcompat.app.AppCompatActivity; |
| 22 | 22 |
|
| 23 | 23 |
import org.distorted.library.main.DistortedLibrary; |
| 24 |
import org.distorted.main.RubikActivity; |
|
| 24 |
import org.distorted.main.MainActivity; |
|
| 25 |
import org.distorted.main_old.RubikActivity; |
|
| 25 | 26 |
import org.distorted.objectlib.main.InitAssets; |
| 26 | 27 |
import org.distorted.objectlib.main.ObjectControl; |
| 27 | 28 |
import org.distorted.main.R; |
| ... | ... | |
| 35 | 36 |
public class ConfigActivity extends AppCompatActivity |
| 36 | 37 |
{
|
| 37 | 38 |
private static final int ACTIVITY_NUMBER = 2; |
| 38 |
private static final float RATIO_BAR = 0.10f;
|
|
| 39 |
private static final float RATIO_BAR = MainActivity.RATIO_BAR;
|
|
| 39 | 40 |
public static final int FLAGS = RubikActivity.FLAGS; |
| 40 | 41 |
|
| 41 | 42 |
private static int mScreenWidth, mScreenHeight; |
| src/main/java/org/distorted/config/ConfigScreen.java | ||
|---|---|---|
| 24 | 24 |
|
| 25 | 25 |
import org.distorted.helpers.TransparentImageButton; |
| 26 | 26 |
import org.distorted.main.R; |
| 27 |
import org.distorted.main.RubikActivity; |
|
| 27 |
import org.distorted.main_old.RubikActivity;
|
|
| 28 | 28 |
import org.distorted.objects.RubikObject; |
| 29 | 29 |
import org.distorted.objects.RubikObjectList; |
| 30 | 30 |
|
| src/main/java/org/distorted/dialogs/RubikDialogAbandon.java | ||
|---|---|---|
| 15 | 15 |
import androidx.fragment.app.FragmentActivity; |
| 16 | 16 |
|
| 17 | 17 |
import org.distorted.main.R; |
| 18 |
import org.distorted.main.RubikActivity; |
|
| 18 |
import org.distorted.main_old.RubikActivity;
|
|
| 19 | 19 |
import org.distorted.screens.ScreenList; |
| 20 | 20 |
|
| 21 | 21 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/dialogs/RubikDialogAbout.java | ||
|---|---|---|
| 9 | 9 |
|
| 10 | 10 |
package org.distorted.dialogs; |
| 11 | 11 |
|
| 12 |
import android.app.Activity; |
|
| 12 | 13 |
import android.app.Dialog; |
| 13 | 14 |
import android.content.Intent; |
| 14 | 15 |
import android.content.pm.PackageInfo; |
| ... | ... | |
| 26 | 27 |
|
| 27 | 28 |
import org.distorted.main.BuildConfig; |
| 28 | 29 |
import org.distorted.main.R; |
| 29 |
import org.distorted.main.RubikActivity; |
|
| 30 | 30 |
|
| 31 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 32 | 32 |
|
| 33 | 33 |
public class RubikDialogAbout extends RubikDialogAbstract |
| 34 | 34 |
{
|
| 35 | 35 |
private static final String WHATS_NEW = |
| 36 |
"1. Seriously lower memory usage - we were getting an increasing amount of crashes due to phones running out of memory.\n";
|
|
| 36 |
"1. New puzzle-centric UI. All actions one can do to a given puzzle in one context menu. ";
|
|
| 37 | 37 |
|
| 38 | 38 |
private static final String WHATS_COMING = |
| 39 |
"1. Next: version 2.0 with a completely new main screen and new UI.\n" +
|
|
| 39 |
"1. Improvements to the new UI - possibility to sort the puzzles by various criteria.\n" +
|
|
| 40 | 40 |
"2. Support for adjustable stickers (not only the colors, but support for texturing the whole cube with images of your choice).\n" + |
| 41 | 41 |
"3. Algorithmic solvers. (sub-optimal solvers for larger puzzles such as the 4x4)\n" + |
| 42 | 42 |
"4. iOS version (no time for this, anyone can help? Code is open-source)\n" + |
| ... | ... | |
| 55 | 55 |
{
|
| 56 | 56 |
WindowManager.LayoutParams params = window.getAttributes(); |
| 57 | 57 |
params.width = (int)Math.min( mHeight*0.60f,mWidth*0.90f ); |
| 58 |
// params.height = (int)(mHeight*0.85f);
|
|
| 58 |
params.height = (int)(mHeight*0.90f);
|
|
| 59 | 59 |
window.setAttributes(params); |
| 60 | 60 |
} |
| 61 | 61 |
} |
| ... | ... | |
| 72 | 72 |
|
| 73 | 73 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 74 | 74 |
|
| 75 |
private String findCurrentVersion(RubikActivity act)
|
|
| 75 |
private String findCurrentVersion(Activity act) |
|
| 76 | 76 |
{
|
| 77 | 77 |
String version; |
| 78 | 78 |
try |
| ... | ... | |
| 91 | 91 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 92 | 92 |
|
| 93 | 93 |
@Override |
| 94 |
String getTitleString(FragmentActivity act) |
|
| 94 |
String getTitleString(FragmentActivity fact)
|
|
| 95 | 95 |
{
|
| 96 | 96 |
Resources res= getResources(); |
| 97 |
RubikActivity ract= (RubikActivity) getContext();
|
|
| 98 |
String version= ract!=null ? findCurrentVersion(ract) : "unknown";
|
|
| 97 |
Activity act= (Activity) getContext();
|
|
| 98 |
String version= act!=null ? findCurrentVersion(act) : "unknown";
|
|
| 99 | 99 |
return res.getString(R.string.ab_placeholder,version); |
| 100 | 100 |
} |
| 101 | 101 |
|
| ... | ... | |
| 170 | 170 |
{
|
| 171 | 171 |
Resources res = act.getResources(); |
| 172 | 172 |
String[] email = { res.getString(R.string.email_address) };
|
| 173 |
String version = findCurrentVersion((RubikActivity)act);
|
|
| 173 |
String version = findCurrentVersion((Activity)act); |
|
| 174 | 174 |
String name = res.getString(R.string.app_name); |
| 175 | 175 |
|
| 176 | 176 |
Intent intent = new Intent(Intent.ACTION_SENDTO); |
| src/main/java/org/distorted/dialogs/RubikDialogAbstract.java | ||
|---|---|---|
| 26 | 26 |
import androidx.fragment.app.FragmentActivity; |
| 27 | 27 |
|
| 28 | 28 |
import org.distorted.main.R; |
| 29 |
import org.distorted.main.RubikActivity; |
|
| 29 |
import org.distorted.main_old.RubikActivity;
|
|
| 30 | 30 |
|
| 31 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 32 | 32 |
|
| src/main/java/org/distorted/dialogs/RubikDialogCreatorView.java | ||
|---|---|---|
| 16 | 16 |
import android.widget.LinearLayout; |
| 17 | 17 |
import android.widget.TextView; |
| 18 | 18 |
|
| 19 |
import org.distorted.main.MainActivity; |
|
| 19 | 20 |
import org.distorted.main.R; |
| 20 |
import org.distorted.main.RubikActivity; |
|
| 21 | 21 |
|
| 22 | 22 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 23 | 23 |
|
| ... | ... | |
| 27 | 27 |
|
| 28 | 28 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 29 | 29 |
|
| 30 |
public RubikDialogCreatorView(final RubikActivity act, final RubikDialogCreators dialog,
|
|
| 30 |
public RubikDialogCreatorView(final MainActivity act, final RubikDialogCreators dialog,
|
|
| 31 | 31 |
final int index, int icon, int title, int desc, int padding, int fontSize, |
| 32 | 32 |
LinearLayout.LayoutParams pView, LinearLayout.LayoutParams pText, LinearLayout.LayoutParams pButt ) |
| 33 | 33 |
{
|
| src/main/java/org/distorted/dialogs/RubikDialogCreators.java | ||
|---|---|---|
| 18 | 18 |
|
| 19 | 19 |
import androidx.fragment.app.FragmentActivity; |
| 20 | 20 |
|
| 21 |
import org.distorted.main.MainActivity; |
|
| 21 | 22 |
import org.distorted.main.R; |
| 22 |
import org.distorted.main.RubikActivity; |
|
| 23 | 23 |
|
| 24 | 24 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 25 | 25 |
|
| ... | ... | |
| 88 | 88 |
{
|
| 89 | 89 |
WindowManager.LayoutParams params = window.getAttributes(); |
| 90 | 90 |
params.width = (int)Math.min( mHeight*0.65f,mWidth*0.98f ); |
| 91 |
params.height = (int)( mHeight*0.90f); |
|
| 91 | 92 |
window.setAttributes(params); |
| 92 | 93 |
} |
| 93 | 94 |
} |
| ... | ... | |
| 125 | 126 |
pB.setMargins(0,2*margin,0,0); |
| 126 | 127 |
|
| 127 | 128 |
int num = BandagedObjectDescription.NUM_OBJECTS; |
| 128 |
RubikActivity ract = (RubikActivity) getContext();
|
|
| 129 |
MainActivity ract = (MainActivity) getContext();
|
|
| 129 | 130 |
|
| 130 | 131 |
for(int i=0; i<num; i++) |
| 131 | 132 |
{
|
| src/main/java/org/distorted/dialogs/RubikDialogExit.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2023 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Magic Cube. // |
|
| 5 |
// // |
|
| 6 |
// Magic Cube is proprietary software licensed under an EULA which you should have received // |
|
| 7 |
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html // |
|
| 8 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 9 |
|
|
| 10 |
package org.distorted.dialogs; |
|
| 11 |
|
|
| 12 |
import android.app.Activity; |
|
| 13 |
import android.app.Dialog; |
|
| 14 |
import android.view.View; |
|
| 15 |
|
|
| 16 |
import androidx.fragment.app.FragmentActivity; |
|
| 17 |
|
|
| 18 |
import org.distorted.main.R; |
|
| 19 |
|
|
| 20 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 21 |
|
|
| 22 |
public class RubikDialogExit extends RubikDialogAbstract |
|
| 23 |
{
|
|
| 24 |
public int getResource() { return R.layout.exit_app; }
|
|
| 25 |
public int getTitleResource() { return -1; }
|
|
| 26 |
public boolean hasArgument() { return false; }
|
|
| 27 |
public int getPositive() { return R.string.yes; }
|
|
| 28 |
public int getNegative() { return R.string.no; }
|
|
| 29 |
public void negativeAction() { }
|
|
| 30 |
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size) { }
|
|
| 31 |
|
|
| 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 33 |
|
|
| 34 |
public void positiveAction() |
|
| 35 |
{
|
|
| 36 |
final Activity act = (Activity)getContext(); |
|
| 37 |
if( act!=null ) act.finish(); |
|
| 38 |
} |
|
| 39 |
} |
|
| src/main/java/org/distorted/dialogs/RubikDialogNewRecord.java | ||
|---|---|---|
| 18 | 18 |
import android.widget.TextView; |
| 19 | 19 |
|
| 20 | 20 |
import org.distorted.main.R; |
| 21 |
import org.distorted.main.RubikActivity; |
|
| 21 |
import org.distorted.main_old.RubikActivity;
|
|
| 22 | 22 |
import org.distorted.external.RubikScores; |
| 23 | 23 |
import org.distorted.screens.ScreenList; |
| 24 | 24 |
|
| src/main/java/org/distorted/dialogs/RubikDialogPattern.java | ||
|---|---|---|
| 21 | 21 |
import android.widget.ImageView; |
| 22 | 22 |
|
| 23 | 23 |
import org.distorted.main.R; |
| 24 |
import org.distorted.main.RubikActivity; |
|
| 24 |
import org.distorted.main_old.RubikActivity;
|
|
| 25 | 25 |
import org.distorted.objects.RubikObject; |
| 26 | 26 |
import org.distorted.objects.RubikObjectList; |
| 27 | 27 |
import org.distorted.objectlib.patterns.RubikPatternList; |
| src/main/java/org/distorted/dialogs/RubikDialogPatternListAdapter.java | ||
|---|---|---|
| 17 | 17 |
import android.widget.BaseExpandableListAdapter; |
| 18 | 18 |
import android.widget.TextView; |
| 19 | 19 |
|
| 20 |
import org.distorted.main.RubikActivity; |
|
| 20 |
import org.distorted.main_old.RubikActivity;
|
|
| 21 | 21 |
import org.distorted.objectlib.patterns.RubikPattern; |
| 22 | 22 |
import org.distorted.main.R; |
| 23 | 23 |
|
| src/main/java/org/distorted/dialogs/RubikDialogPatternView.java | ||
|---|---|---|
| 21 | 21 |
import org.distorted.objectlib.patterns.RubikPatternList; |
| 22 | 22 |
|
| 23 | 23 |
import org.distorted.main.R; |
| 24 |
import org.distorted.main.RubikActivity; |
|
| 24 |
import org.distorted.main_old.RubikActivity;
|
|
| 25 | 25 |
import org.distorted.screens.ScreenList; |
| 26 | 26 |
import org.distorted.screens.RubikScreenPattern; |
| 27 | 27 |
|
| src/main/java/org/distorted/dialogs/RubikDialogPrivacy.java | ||
|---|---|---|
| 18 | 18 |
import androidx.fragment.app.FragmentActivity; |
| 19 | 19 |
|
| 20 | 20 |
import org.distorted.main.R; |
| 21 |
import org.distorted.main.RubikActivity; |
|
| 22 | 21 |
|
| 23 | 22 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 24 | 23 |
|
| src/main/java/org/distorted/dialogs/RubikDialogScores.java | ||
|---|---|---|
| 21 | 21 |
import android.widget.ImageView; |
| 22 | 22 |
|
| 23 | 23 |
import org.distorted.main.R; |
| 24 |
import org.distorted.main.RubikActivity; |
|
| 24 |
import org.distorted.main_old.RubikActivity;
|
|
| 25 | 25 |
import org.distorted.objects.RubikObject; |
| 26 | 26 |
import org.distorted.objects.RubikObjectList; |
| 27 | 27 |
|
| ... | ... | |
| 44 | 44 |
{
|
| 45 | 45 |
WindowManager.LayoutParams params = window.getAttributes(); |
| 46 | 46 |
params.width = (int)Math.min( mHeight*0.65f,mWidth*0.98f ); |
| 47 |
params.height = (int)( mHeight*0.77f);
|
|
| 47 |
params.height = (int)( mHeight*0.90f);
|
|
| 48 | 48 |
window.setAttributes(params); |
| 49 | 49 |
} |
| 50 | 50 |
} |
| src/main/java/org/distorted/dialogs/RubikDialogScoresView.java | ||
|---|---|---|
| 21 | 21 |
import android.widget.TextView; |
| 22 | 22 |
|
| 23 | 23 |
import org.distorted.main.R; |
| 24 |
import org.distorted.main.RubikActivity; |
|
| 24 |
import org.distorted.main_old.RubikActivity;
|
|
| 25 | 25 |
import org.distorted.external.RubikScores; |
| 26 | 26 |
|
| 27 | 27 |
import static org.distorted.external.RubikNetwork.MAX_PLACES; |
| src/main/java/org/distorted/dialogs/RubikDialogSetName.java | ||
|---|---|---|
| 23 | 23 |
import android.widget.TextView; |
| 24 | 24 |
|
| 25 | 25 |
import org.distorted.main.R; |
| 26 |
import org.distorted.main.RubikActivity; |
|
| 26 |
import org.distorted.main_old.RubikActivity;
|
|
| 27 | 27 |
import org.distorted.external.RubikScores; |
| 28 | 28 |
import org.distorted.screens.ScreenList; |
| 29 | 29 |
|
| src/main/java/org/distorted/dialogs/RubikDialogSolved.java | ||
|---|---|---|
| 17 | 17 |
import android.widget.TextView; |
| 18 | 18 |
|
| 19 | 19 |
import org.distorted.main.R; |
| 20 |
import org.distorted.main.RubikActivity; |
|
| 20 |
import org.distorted.main_old.RubikActivity;
|
|
| 21 | 21 |
import org.distorted.screens.ScreenList; |
| 22 | 22 |
|
| 23 | 23 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/dialogs/RubikDialogSolverView.java | ||
|---|---|---|
| 17 | 17 |
import android.widget.TextView; |
| 18 | 18 |
|
| 19 | 19 |
import org.distorted.main.R; |
| 20 |
import org.distorted.main.RubikActivity; |
|
| 20 |
import org.distorted.main_old.RubikActivity;
|
|
| 21 | 21 |
import org.distorted.objects.RubikObject; |
| 22 | 22 |
import org.distorted.objects.RubikObjectList; |
| 23 | 23 |
import org.distorted.screens.ScreenList; |
| src/main/java/org/distorted/dialogs/RubikDialogSolvers.java | ||
|---|---|---|
| 19 | 19 |
import androidx.fragment.app.FragmentActivity; |
| 20 | 20 |
|
| 21 | 21 |
import org.distorted.main.R; |
| 22 |
import org.distorted.main.RubikActivity; |
|
| 22 |
import org.distorted.main_old.RubikActivity;
|
|
| 23 | 23 |
import org.distorted.solvers.ImplementedSolversList; |
| 24 | 24 |
|
| 25 | 25 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/dialogs/RubikDialogTutorial.java | ||
|---|---|---|
| 22 | 22 |
import com.google.android.material.tabs.TabLayout; |
| 23 | 23 |
|
| 24 | 24 |
import org.distorted.main.R; |
| 25 |
import org.distorted.main.RubikActivity; |
|
| 25 |
import org.distorted.main_old.RubikActivity;
|
|
| 26 | 26 |
import org.distorted.objects.RubikObject; |
| 27 | 27 |
import org.distorted.objects.RubikObjectList; |
| 28 | 28 |
|
| src/main/java/org/distorted/dialogs/RubikDialogTutorialView.java | ||
|---|---|---|
| 27 | 27 |
|
| 28 | 28 |
import org.distorted.main.BuildConfig; |
| 29 | 29 |
import org.distorted.main.R; |
| 30 |
import org.distorted.main.RubikActivity; |
|
| 30 |
import org.distorted.main_old.RubikActivity;
|
|
| 31 | 31 |
import org.distorted.objectlib.json.JsonReader; |
| 32 | 32 |
import org.distorted.objects.RubikObject; |
| 33 | 33 |
import org.distorted.objects.RubikObjectList; |
| src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java | ||
|---|---|---|
| 31 | 31 |
import org.distorted.external.RubikUpdates; |
| 32 | 32 |
import org.distorted.objectlib.json.JsonReader; |
| 33 | 33 |
import org.distorted.objects.RubikObjectList; |
| 34 |
import org.distorted.screens.RubikScreenPlay; |
|
| 35 |
import org.distorted.screens.ScreenList; |
|
| 36 | 34 |
|
| 37 |
import static org.distorted.main.RubikActivity.SHOW_DOWNLOADED_DEBUG; |
|
| 35 |
import static org.distorted.main_old.RubikActivity.SHOW_DOWNLOADED_DEBUG;
|
|
| 38 | 36 |
|
| 39 | 37 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 40 | 38 |
|
| ... | ... | |
| 231 | 229 |
|
| 232 | 230 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "3");
|
| 233 | 231 |
|
| 234 |
RubikScreenPlay play = (RubikScreenPlay)ScreenList.PLAY.getScreenClass(); |
|
| 235 |
play.recreatePopup(); |
|
| 236 |
|
|
| 237 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "4");
|
|
| 238 |
|
|
| 239 | 232 |
makeProgress(100,R.string.success); |
| 240 | 233 |
|
| 241 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "5");
|
|
| 234 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "4");
|
|
| 242 | 235 |
} |
| 243 | 236 |
else |
| 244 | 237 |
{
|
| src/main/java/org/distorted/dialogs/RubikDialogUpdates.java | ||
|---|---|---|
| 170 | 170 |
if( act!=null ) mText.setText(act.getString(R.string.networkError)); |
| 171 | 171 |
} |
| 172 | 172 |
|
| 173 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 174 |
|
|
| 175 |
public void objectDownloaded(String shortName) |
|
| 176 |
{
|
|
| 177 |
|
|
| 178 |
} |
|
| 179 |
|
|
| 180 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 181 |
|
|
| 182 |
public int getType() |
|
| 183 |
{
|
|
| 184 |
return 1; |
|
| 185 |
} |
|
| 186 |
|
|
| 173 | 187 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 174 | 188 |
|
| 175 | 189 |
public void iconDownloaded(int ordinal, Bitmap icon, boolean downloaded) |
| src/main/java/org/distorted/external/RubikNetwork.java | ||
|---|---|---|
| 18 | 18 |
import java.net.UnknownHostException; |
| 19 | 19 |
import java.security.MessageDigest; |
| 20 | 20 |
import java.security.NoSuchAlgorithmException; |
| 21 |
import java.util.ArrayList; |
|
| 21 | 22 |
|
| 22 | 23 |
import android.app.Activity; |
| 23 | 24 |
import android.content.Context; |
| ... | ... | |
| 26 | 27 |
import android.graphics.Bitmap; |
| 27 | 28 |
import android.graphics.BitmapFactory; |
| 28 | 29 |
|
| 29 |
import org.distorted.library.main.DistortedLibrary; |
|
| 30 | 30 |
import org.distorted.objectlib.json.JsonWriter; |
| 31 | 31 |
import org.distorted.objects.RubikObjectList; |
| 32 | 32 |
|
| 33 |
import static org.distorted.main.RubikActivity.SHOW_DOWNLOADED_DEBUG; |
|
| 33 |
import static org.distorted.main_old.RubikActivity.SHOW_DOWNLOADED_DEBUG;
|
|
| 34 | 34 |
import static org.distorted.screens.RubikScreenPlay.LEVELS_SHOWN; |
| 35 | 35 |
|
| 36 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 51 | 51 |
|
| 52 | 52 |
public interface Updatee |
| 53 | 53 |
{
|
| 54 |
int getType(); |
|
| 54 | 55 |
void receiveUpdate(RubikUpdates update); |
| 56 |
void objectDownloaded(String shortName); |
|
| 55 | 57 |
void errorUpdate(); |
| 56 | 58 |
} |
| 57 | 59 |
|
| ... | ... | |
| 62 | 64 |
|
| 63 | 65 |
public static final int MAX_PLACES = 10; |
| 64 | 66 |
|
| 65 |
private static final int REND_ADRENO= 0; |
|
| 66 |
private static final int REND_MALI = 1; |
|
| 67 |
private static final int REND_POWER = 2; |
|
| 68 |
private static final int REND_OTHER = 3; |
|
| 69 |
|
|
| 70 |
private static final int DEBUG_RUNNING = 1; |
|
| 71 |
private static final int DEBUG_SUCCESS = 2; |
|
| 72 |
private static final int DEBUG_FAILURE = 3; |
|
| 67 |
private static final int UPDATES_RUNNING = 1; |
|
| 68 |
private static final int UPDATES_SUCCESS = 2; |
|
| 69 |
private static final int UPDATES_FAILURE = 3; |
|
| 73 | 70 |
|
| 74 | 71 |
private final String[] hex = {
|
| 75 | 72 |
"%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", |
| ... | ... | |
| 116 | 113 |
private static RubikNetwork mThis; |
| 117 | 114 |
private static String mScores = ""; |
| 118 | 115 |
private static boolean mRunning = false; |
| 119 |
private static Updatee mUpdatee;
|
|
| 116 |
private static ArrayList<Updatee> mUpdateeList;
|
|
| 120 | 117 |
private static String mVersion; |
| 121 | 118 |
private static int mNumObjects; |
| 122 | 119 |
private static RubikUpdates mUpdates; |
| 123 |
private static int mDebugState;
|
|
| 120 |
private static int mUpdatesState;
|
|
| 124 | 121 |
|
| 125 | 122 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 126 | 123 |
|
| ... | ... | |
| 285 | 282 |
} |
| 286 | 283 |
} |
| 287 | 284 |
|
| 288 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 289 |
|
|
| 290 |
private int getRendererType(String renderer) |
|
| 291 |
{
|
|
| 292 |
if( renderer.contains("Adreno") ) return REND_ADRENO;
|
|
| 293 |
if( renderer.contains("Mali") ) return REND_MALI;
|
|
| 294 |
if( renderer.contains("PowerVR") ) return REND_POWER;
|
|
| 295 |
|
|
| 296 |
return REND_OTHER; |
|
| 297 |
} |
|
| 298 |
|
|
| 299 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 300 |
|
|
| 301 |
private String parseRenderer(final int type, String renderer) |
|
| 302 |
{
|
|
| 303 |
if( type==REND_ADRENO || type==REND_POWER ) |
|
| 304 |
{
|
|
| 305 |
int lastSpace = renderer.lastIndexOf(' ');
|
|
| 306 |
String ret = renderer.substring(lastSpace+1); |
|
| 307 |
return URLencode(ret); |
|
| 308 |
} |
|
| 309 |
|
|
| 310 |
if( type==REND_MALI ) |
|
| 311 |
{
|
|
| 312 |
int firstHyphen = renderer.indexOf('-');
|
|
| 313 |
String ret = renderer.substring(firstHyphen+1); |
|
| 314 |
return URLencode(ret); |
|
| 315 |
} |
|
| 316 |
|
|
| 317 |
return "other"; |
|
| 318 |
} |
|
| 319 |
|
|
| 320 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 321 |
|
|
| 322 |
private String parseVersion(final int type, String version) |
|
| 323 |
{
|
|
| 324 |
switch(type) |
|
| 325 |
{
|
|
| 326 |
case REND_ADRENO: int aMonkey = version.indexOf('@');
|
|
| 327 |
int aDot = version.indexOf('.', aMonkey);
|
|
| 328 |
String ret1 = aDot>=3 ? version.substring(aDot-3,aDot) : ""; |
|
| 329 |
return URLencode(ret1); |
|
| 330 |
case REND_MALI : int mV1 = version.indexOf("v1");
|
|
| 331 |
int mHyphen = version.indexOf('-', mV1);
|
|
| 332 |
String ret2 = mHyphen>mV1+3 && mV1>=0 ? version.substring(mV1+3,mHyphen) : ""; |
|
| 333 |
return URLencode(ret2); |
|
| 334 |
case REND_POWER : int pMonkey = version.indexOf('@');
|
|
| 335 |
int pSpace = version.lastIndexOf(' ');
|
|
| 336 |
String ret3 = pSpace>=0 && pMonkey>pSpace+1 ? version.substring(pSpace+1,pMonkey) : ""; |
|
| 337 |
return URLencode(ret3); |
|
| 338 |
default : return ""; |
|
| 339 |
} |
|
| 340 |
} |
|
| 341 |
|
|
| 342 | 285 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 343 | 286 |
|
| 344 | 287 |
private String URLencode(String s) |
| ... | ... | |
| 456 | 399 |
|
| 457 | 400 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 458 | 401 |
|
| 459 |
private String constructDebugURL()
|
|
| 402 |
private String constructUpdatesURL()
|
|
| 460 | 403 |
{
|
| 461 |
RubikScores scores = RubikScores.getInstance(); |
|
| 462 |
String name = URLencode(scores.getName()); |
|
| 463 |
int numRuns = scores.getNumRuns(); |
|
| 464 |
int numPlay = scores.getNumPlays(); |
|
| 465 |
String country = scores.getCountry(); |
|
| 466 |
String renderer = DistortedLibrary.getDriverRenderer(); |
|
| 467 |
String version = DistortedLibrary.getDriverVersion(); |
|
| 404 |
RubikScores sco = RubikScores.getInstance(); |
|
| 405 |
String name = URLencode(sco.getName()); |
|
| 406 |
int numRuns = sco.getNumRuns(); |
|
| 407 |
int numPlay = sco.getNumPlays(); |
|
| 408 |
String country = sco.getCountry(); |
|
| 468 | 409 |
int objectAPI = JsonWriter.VERSION_OBJECT_APP; |
| 469 | 410 |
int tutorialAPI = JsonWriter.VERSION_EXTRAS_APP; |
| 470 |
int numStars = scores.getNumStars(); |
|
| 471 |
|
|
| 472 |
renderer = URLencode(renderer); |
|
| 473 |
version = URLencode(version); |
|
| 474 | 411 |
|
| 475 |
String url=SERVER+"debugs.cgi"; |
|
| 476 |
url += "?n="+name+"&r="+numRuns+"&p="+numPlay+"&c="+country+"&e="+mVersion+"d"; |
|
| 477 |
url += "&d="+renderer+"&v="+version+"&a="+objectAPI+"&b="+tutorialAPI+"&s="+numStars; |
|
| 412 |
String url=SERVER+"updates.cgi"; |
|
| 413 |
url += "?n="+name+"&r="+numRuns+"&p="+numPlay+"&c="+country+"&e="+mVersion+"d"+"&a="+objectAPI+"&b="+tutorialAPI; |
|
| 478 | 414 |
|
| 479 | 415 |
return url; |
| 480 | 416 |
} |
| ... | ... | |
| 507 | 443 |
long epoch = System.currentTimeMillis(); |
| 508 | 444 |
String salt = "cuboid"; |
| 509 | 445 |
|
| 510 |
String renderer = DistortedLibrary.getDriverRenderer(); |
|
| 511 |
String version = DistortedLibrary.getDriverVersion(); |
|
| 512 |
|
|
| 513 |
int type = getRendererType(renderer); |
|
| 514 |
renderer = parseRenderer(type,renderer); |
|
| 515 |
version = parseVersion(type,version); |
|
| 516 |
|
|
| 517 | 446 |
String url1=SERVER+"submit.cgi"; |
| 518 | 447 |
String url2 = "n="+name+"&v="+veri+"&r="+numRuns+"&p="+numPlay+"&i="+deviceID+"&e="+mVersion; |
| 519 |
url2 += "&d="+renderer+"&s="+version+reclist+"&c="+country+"&f="+epoch;
|
|
| 448 |
url2 += reclist+"&c="+country+"&f="+epoch; |
|
| 520 | 449 |
String hash = computeHash( url2, salt.getBytes() ); |
| 521 | 450 |
|
| 522 | 451 |
return url1 + "?" + url2 + "&h=" + hash; |
| ... | ... | |
| 608 | 537 |
|
| 609 | 538 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 610 | 539 |
|
| 611 |
private void debugThread()
|
|
| 540 |
private void updatesThread()
|
|
| 612 | 541 |
{
|
| 613 |
String url = constructDebugURL();
|
|
| 542 |
String url = constructUpdatesURL();
|
|
| 614 | 543 |
|
| 615 | 544 |
try |
| 616 | 545 |
{
|
| ... | ... | |
| 628 | 557 |
BufferedReader r = new BufferedReader(new InputStreamReader(is)); |
| 629 | 558 |
StringBuilder answer = new StringBuilder(); |
| 630 | 559 |
|
| 631 |
for (String line; (line = r.readLine()) != null; )
|
|
| 560 |
for( String line; (line = r.readLine()) != null; )
|
|
| 632 | 561 |
{
|
| 633 | 562 |
answer.append(line).append('\n');
|
| 634 | 563 |
} |
| ... | ... | |
| 637 | 566 |
conn.disconnect(); |
| 638 | 567 |
mUpdates.parse(updates); |
| 639 | 568 |
|
| 640 |
if( mUpdatee!=null ) mUpdatee.receiveUpdate(mUpdates); |
|
| 641 |
mDebugState = DEBUG_SUCCESS; |
|
| 569 |
if( mUpdateeList!=null ) |
|
| 570 |
{
|
|
| 571 |
int numUpdatees = mUpdateeList.size(); |
|
| 572 |
|
|
| 573 |
for(int u=0; u<numUpdatees; u++) |
|
| 574 |
{
|
|
| 575 |
Updatee upd = mUpdateeList.get(u); |
|
| 576 |
upd.receiveUpdate(mUpdates); |
|
| 577 |
} |
|
| 578 |
} |
|
| 579 |
|
|
| 580 |
mUpdatesState = UPDATES_SUCCESS; |
|
| 642 | 581 |
} |
| 643 | 582 |
catch( final Exception e ) |
| 644 | 583 |
{
|
| 645 |
if( mUpdatee!=null ) mUpdatee.errorUpdate(); |
|
| 646 |
mDebugState = DEBUG_FAILURE; |
|
| 584 |
if( mUpdateeList!=null ) |
|
| 585 |
{
|
|
| 586 |
int numUpdatees = mUpdateeList.size(); |
|
| 587 |
|
|
| 588 |
for(int u=0; u<numUpdatees; u++) |
|
| 589 |
{
|
|
| 590 |
Updatee upd = mUpdateeList.get(u); |
|
| 591 |
upd.errorUpdate(); |
|
| 592 |
} |
|
| 593 |
} |
|
| 594 |
|
|
| 595 |
mUpdatesState = UPDATES_FAILURE; |
|
| 647 | 596 |
} |
| 648 | 597 |
} |
| 649 | 598 |
|
| ... | ... | |
| 846 | 795 |
public static void onPause() |
| 847 | 796 |
{
|
| 848 | 797 |
mRunning = false; |
| 798 |
mUpdateeList.clear(); |
|
| 799 |
mUpdatesState = UPDATES_RUNNING; |
|
| 849 | 800 |
} |
| 850 | 801 |
|
| 851 | 802 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 894 | 845 |
|
| 895 | 846 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 896 | 847 |
|
| 897 |
public void debug(final Activity act)
|
|
| 848 |
public void downloadUpdates(final Activity act)
|
|
| 898 | 849 |
{
|
| 899 | 850 |
initializeStatics(); |
| 900 | 851 |
figureOutVersion(act); |
| 901 |
mDebugState = DEBUG_RUNNING;
|
|
| 852 |
mUpdatesState = UPDATES_RUNNING;
|
|
| 902 | 853 |
|
| 903 | 854 |
Thread thread = new Thread() |
| 904 | 855 |
{
|
| 905 | 856 |
public void run() |
| 906 | 857 |
{
|
| 907 |
debugThread();
|
|
| 858 |
updatesThread();
|
|
| 908 | 859 |
} |
| 909 | 860 |
}; |
| 910 | 861 |
|
| ... | ... | |
| 947 | 898 |
} |
| 948 | 899 |
|
| 949 | 900 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 950 |
// Yes it can happen that the second Updatee registers before we sent an update to the first one |
|
| 951 |
// and, as a result, the update never gets sent to the first one. This is not a problem (now, when |
|
| 952 |
// there are only two updatees - the RubikStatePlay and the UpdateDialog) |
|
| 953 |
// |
|
| 954 |
// Yes, there is also a remote possibility that the two threads executing this function and executing |
|
| 955 |
// the sendDebug() get swapped exactly in unlucky moment and the update never gets to the updatee. |
|
| 956 |
// We don't care about such remote possibility, then the app simply would signal that there are no |
|
| 957 |
// updates available. |
|
| 958 | 901 |
|
| 959 | 902 |
public void signUpForUpdates(Updatee updatee) |
| 960 | 903 |
{
|
| 961 |
if( mDebugState==DEBUG_SUCCESS ) updatee.receiveUpdate(mUpdates); |
|
| 962 |
else if( mDebugState==DEBUG_FAILURE ) updatee.errorUpdate(); |
|
| 963 |
else mUpdatee = updatee; |
|
| 904 |
if( mUpdateeList==null ) mUpdateeList = new ArrayList<>(); |
|
| 905 |
|
|
| 906 |
int numUpdatees = mUpdateeList.size(); |
|
| 907 |
int type = updatee.getType(); |
|
| 908 |
|
|
| 909 |
for(int u=0; u<numUpdatees; u++) |
|
| 910 |
{
|
|
| 911 |
Updatee upd = mUpdateeList.get(u); |
|
| 912 |
|
|
| 913 |
if( upd.getType()==type ) |
|
| 914 |
{
|
|
| 915 |
mUpdateeList.remove(u); |
|
| 916 |
break; |
|
| 917 |
} |
|
| 918 |
} |
|
| 919 |
|
|
| 920 |
mUpdateeList.add(updatee); |
|
| 921 |
|
|
| 922 |
if( mUpdatesState==UPDATES_SUCCESS ) |
|
| 923 |
{
|
|
| 924 |
updatee.receiveUpdate(mUpdates); |
|
| 925 |
} |
|
| 926 |
else if( mUpdatesState==UPDATES_FAILURE ) |
|
| 927 |
{
|
|
| 928 |
updatee.errorUpdate(); |
|
| 929 |
} |
|
| 964 | 930 |
} |
| 965 | 931 |
|
| 966 | 932 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 1003 | 969 |
{
|
| 1004 | 970 |
mUpdates.updateDone(shortName); |
| 1005 | 971 |
mScores = ""; |
| 972 |
|
|
| 973 |
if( mUpdateeList!=null ) |
|
| 974 |
{
|
|
| 975 |
int numUpdatees = mUpdateeList.size(); |
|
| 976 |
|
|
| 977 |
for(int u=0; u<numUpdatees; u++) |
|
| 978 |
{
|
|
| 979 |
Updatee upd = mUpdateeList.get(u); |
|
| 980 |
upd.objectDownloaded(shortName); |
|
| 981 |
} |
|
| 982 |
} |
|
| 1006 | 983 |
} |
| 1007 | 984 |
} |
| src/main/java/org/distorted/external/RubikUpdates.java | ||
|---|---|---|
| 17 | 17 |
import android.graphics.Bitmap; |
| 18 | 18 |
import org.distorted.objects.RubikObjectList; |
| 19 | 19 |
|
| 20 |
import static org.distorted.main.RubikActivity.SHOW_DOWNLOADED_DEBUG; |
|
| 20 |
import static org.distorted.main_old.RubikActivity.SHOW_DOWNLOADED_DEBUG;
|
|
| 21 | 21 |
|
| 22 | 22 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 23 | 23 |
|
| src/main/java/org/distorted/main/MainActivity.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2023 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Magic Cube. // |
|
| 5 |
// // |
|
| 6 |
// Magic Cube is proprietary software licensed under an EULA which you should have received // |
|
| 7 |
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html // |
|
| 8 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 9 |
|
|
| 10 |
package org.distorted.main; |
|
| 11 |
|
|
| 12 |
import android.content.Intent; |
|
| 13 |
import android.content.SharedPreferences; |
|
| 14 |
import android.content.pm.PackageInfo; |
|
| 15 |
import android.content.pm.PackageManager; |
|
| 16 |
import android.os.Build; |
|
| 17 |
import android.os.Bundle; |
|
| 18 |
import android.util.DisplayMetrics; |
|
| 19 |
import android.util.TypedValue; |
|
| 20 |
import android.view.DisplayCutout; |
|
| 21 |
import android.view.View; |
|
| 22 |
import android.view.ViewGroup; |
|
| 23 |
import android.view.WindowManager; |
|
| 24 |
import android.widget.LinearLayout; |
|
| 25 |
import android.widget.ScrollView; |
|
| 26 |
import android.widget.TextView; |
|
| 27 |
|
|
| 28 |
import androidx.appcompat.app.AppCompatActivity; |
|
| 29 |
import androidx.preference.PreferenceManager; |
|
| 30 |
|
|
| 31 |
import com.google.firebase.analytics.FirebaseAnalytics; |
|
| 32 |
import com.google.firebase.inappmessaging.FirebaseInAppMessaging; |
|
| 33 |
|
|
| 34 |
import org.distorted.bandaged.BandagedCreatorActivity; |
|
| 35 |
import org.distorted.config.ConfigActivity; |
|
| 36 |
import org.distorted.dialogs.RubikDialogAbout; |
|
| 37 |
import org.distorted.dialogs.RubikDialogCreators; |
|
| 38 |
import org.distorted.dialogs.RubikDialogExit; |
|
| 39 |
import org.distorted.dialogs.RubikDialogScores; |
|
| 40 |
import org.distorted.dialogs.RubikDialogUpdates; |
|
| 41 |
import org.distorted.external.RubikNetwork; |
|
| 42 |
import org.distorted.external.RubikScores; |
|
| 43 |
import org.distorted.external.RubikUpdates; |
|
| 44 |
import org.distorted.messaging.RubikInAppMessanging; |
|
| 45 |
import org.distorted.objects.RubikObjectList; |
|
| 46 |
import org.distorted.purchase.PurchaseActivity; |
|
| 47 |
import org.distorted.tutorials.TutorialActivity; |
|
| 48 |
|
|
| 49 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 50 |
|
|
| 51 |
public class MainActivity extends AppCompatActivity implements RubikNetwork.Updatee |
|
| 52 |
{
|
|
| 53 |
public static final float RATIO_BAR = 0.080f; |
|
| 54 |
public static final int FLAGS = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
| 55 |
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
| 56 |
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
|
| 57 |
| View.SYSTEM_UI_FLAG_FULLSCREEN |
|
| 58 |
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; |
|
| 59 |
|
|
| 60 |
private static final float RATIO_INSET= 0.09f; |
|
| 61 |
|
|
| 62 |
private boolean mJustStarted; |
|
| 63 |
private FirebaseAnalytics mFirebaseAnalytics; |
|
| 64 |
private static int mScreenWidth, mScreenHeight; |
|
| 65 |
private int mCurrentApiVersion; |
|
| 66 |
private int mHeightUpperBar; |
|
| 67 |
private String mOldVersion, mCurrVersion; |
|
| 68 |
private int mSolverIndex; |
|
| 69 |
private TextView mBubbleUpdates; |
|
| 70 |
private int mNumUpdates; |
|
| 71 |
private MainScrollGrid mGrid; |
|
| 72 |
|
|
| 73 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 74 |
|
|
| 75 |
@Override |
|
| 76 |
protected void onCreate(Bundle savedState) |
|
| 77 |
{
|
|
| 78 |
super.onCreate(savedState); |
|
| 79 |
setTheme(R.style.MaterialThemeNoActionBar); |
|
| 80 |
setContentView(R.layout.new_main); |
|
| 81 |
hideNavigationBar(); |
|
| 82 |
|
|
| 83 |
mJustStarted = true; |
|
| 84 |
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); |
|
| 85 |
|
|
| 86 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 87 |
getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics); |
|
| 88 |
mScreenWidth =displaymetrics.widthPixels; |
|
| 89 |
mScreenHeight=displaymetrics.heightPixels; |
|
| 90 |
|
|
| 91 |
cutoutHack(); |
|
| 92 |
computeHeights(); |
|
| 93 |
|
|
| 94 |
mCurrVersion = getAppVers(); |
|
| 95 |
mSolverIndex = 0; |
|
| 96 |
|
|
| 97 |
Thread thread = new Thread() |
|
| 98 |
{
|
|
| 99 |
public void run() |
|
| 100 |
{
|
|
| 101 |
RubikInAppMessanging listener = new RubikInAppMessanging(); |
|
| 102 |
FirebaseInAppMessaging.getInstance().addClickListener(listener); |
|
| 103 |
} |
|
| 104 |
}; |
|
| 105 |
|
|
| 106 |
thread.start(); |
|
| 107 |
} |
|
| 108 |
|
|
| 109 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 110 |
// this does not include possible insets |
|
| 111 |
|
|
| 112 |
private void computeHeights() |
|
| 113 |
{
|
|
| 114 |
int barHeight = (int)(mScreenHeight*RATIO_BAR); |
|
| 115 |
int scrollHeight = (int)(mScreenHeight*(1-2*RATIO_BAR)); |
|
| 116 |
mHeightUpperBar = barHeight; |
|
| 117 |
|
|
| 118 |
LinearLayout layoutTop = findViewById(R.id.upperBar); |
|
| 119 |
ViewGroup.LayoutParams paramsTop = layoutTop.getLayoutParams(); |
|
| 120 |
paramsTop.height = barHeight; |
|
| 121 |
layoutTop.setLayoutParams(paramsTop); |
|
| 122 |
|
|
| 123 |
LinearLayout layoutBot = findViewById(R.id.lowerBar); |
|
| 124 |
ViewGroup.LayoutParams paramsBot = layoutBot.getLayoutParams(); |
|
| 125 |
paramsBot.height = barHeight; |
|
| 126 |
layoutBot.setLayoutParams(paramsBot); |
|
| 127 |
|
|
| 128 |
ScrollView scroll = findViewById(R.id.objectScroll); |
|
| 129 |
ViewGroup.LayoutParams paramsScroll = scroll.getLayoutParams(); |
|
| 130 |
paramsScroll.height = scrollHeight; |
|
| 131 |
scroll.setLayoutParams(paramsScroll); |
|
| 132 |
} |
|
| 133 |
|
|
| 134 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 135 |
|
|
| 136 |
private void hideNavigationBar() |
|
| 137 |
{
|
|
| 138 |
mCurrentApiVersion = Build.VERSION.SDK_INT; |
|
| 139 |
|
|
| 140 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT) |
|
| 141 |
{
|
|
| 142 |
final View decorView = getWindow().getDecorView(); |
|
| 143 |
|
|
| 144 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 145 |
|
|
| 146 |
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() |
|
| 147 |
{
|
|
| 148 |
@Override |
|
| 149 |
public void onSystemUiVisibilityChange(int visibility) |
|
| 150 |
{
|
|
| 151 |
if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) |
|
| 152 |
{
|
|
| 153 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 154 |
} |
|
| 155 |
} |
|
| 156 |
}); |
|
| 157 |
} |
|
| 158 |
} |
|
| 159 |
|
|
| 160 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 161 |
|
|
| 162 |
@Override |
|
| 163 |
public void onAttachedToWindow() |
|
| 164 |
{
|
|
| 165 |
super.onAttachedToWindow(); |
|
| 166 |
|
|
| 167 |
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.P ) |
|
| 168 |
{
|
|
| 169 |
DisplayCutout cutout = getWindow().getDecorView().getRootWindowInsets().getDisplayCutout(); |
|
| 170 |
int insetHeight = cutout!=null ? cutout.getSafeInsetTop() : 0; |
|
| 171 |
|
|
| 172 |
LinearLayout layoutHid = findViewById(R.id.hiddenBar); |
|
| 173 |
ViewGroup.LayoutParams paramsHid = layoutHid.getLayoutParams(); |
|
| 174 |
paramsHid.height = (int)(insetHeight*RATIO_INSET); |
|
| 175 |
layoutHid.setLayoutParams(paramsHid); |
|
| 176 |
mHeightUpperBar += paramsHid.height; |
|
| 177 |
} |
|
| 178 |
} |
|
| 179 |
|
|
| 180 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 181 |
// do not avoid cutouts |
|
| 182 |
|
|
| 183 |
private void cutoutHack() |
|
| 184 |
{
|
|
| 185 |
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.P ) |
|
| 186 |
{
|
|
| 187 |
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; |
|
| 188 |
} |
|
| 189 |
} |
|
| 190 |
|
|
| 191 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 192 |
|
|
| 193 |
@Override |
|
| 194 |
public void onWindowFocusChanged(boolean hasFocus) |
|
| 195 |
{
|
|
| 196 |
super.onWindowFocusChanged(hasFocus); |
|
| 197 |
|
|
| 198 |
if( mCurrentApiVersion >= Build.VERSION_CODES.KITKAT && hasFocus ) |
|
| 199 |
{
|
|
| 200 |
getWindow().getDecorView().setSystemUiVisibility(FLAGS); |
|
| 201 |
} |
|
| 202 |
} |
|
| 203 |
|
|
| 204 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 205 |
|
|
| 206 |
@Override |
|
| 207 |
protected void onPause() |
|
| 208 |
{
|
|
| 209 |
super.onPause(); |
|
| 210 |
RubikNetwork.onPause(); |
|
| 211 |
savePreferences(); |
|
| 212 |
} |
|
| 213 |
|
|
| 214 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 215 |
|
|
| 216 |
@Override |
|
| 217 |
protected void onResume() |
|
| 218 |
{
|
|
| 219 |
super.onResume(); |
|
| 220 |
|
|
| 221 |
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); |
|
| 222 |
restorePreferences(preferences,mJustStarted); |
|
| 223 |
|
|
| 224 |
mBubbleUpdates = findViewById(R.id.bubbleUpdates); |
|
| 225 |
mBubbleUpdates.setVisibility(View.INVISIBLE); |
|
| 226 |
mNumUpdates = 0; |
|
| 227 |
|
|
| 228 |
RubikNetwork network = RubikNetwork.getInstance(); |
|
| 229 |
network.signUpForUpdates(this); |
|
| 230 |
network.downloadUpdates(this); |
|
| 231 |
|
|
| 232 |
mGrid = new MainScrollGrid(); |
|
| 233 |
mGrid.createGrid(this,mScreenWidth,mScreenHeight); |
|
| 234 |
|
|
| 235 |
if( mJustStarted ) |
|
| 236 |
{
|
|
| 237 |
mJustStarted = false; |
|
| 238 |
RubikScores scores = RubikScores.getInstance(); |
|
| 239 |
scores.incrementNumRuns(); |
|
| 240 |
scores.setCountry(this); |
|
| 241 |
RubikObjectList.restoreMeshState(preferences); |
|
| 242 |
} |
|
| 243 |
|
|
| 244 |
if( !mOldVersion.equals(mCurrVersion) ) displayNovelties(); |
|
| 245 |
} |
|
| 246 |
|
|
| 247 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 248 |
|
|
| 249 |
private void displayNovelties() |
|
| 250 |
{
|
|
| 251 |
Bundle bundle = new Bundle(); |
|
| 252 |
bundle.putString("argument",mOldVersion);
|
|
| 253 |
RubikDialogAbout newDialog = new RubikDialogAbout(); |
|
| 254 |
newDialog.setArguments(bundle); |
|
| 255 |
newDialog.show(getSupportFragmentManager(), RubikDialogAbout.getDialogTag() ); |
|
| 256 |
} |
|
| 257 |
|
|
| 258 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 259 |
|
|
| 260 |
@Override |
|
| 261 |
protected void onDestroy() |
|
| 262 |
{
|
|
| 263 |
super.onDestroy(); |
|
| 264 |
} |
|
| 265 |
|
|
| 266 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 267 |
|
|
| 268 |
private String getAppVers() |
|
| 269 |
{
|
|
| 270 |
try |
|
| 271 |
{
|
|
| 272 |
PackageInfo pInfo = getPackageManager().getPackageInfo( getPackageName(), 0); |
|
| 273 |
return pInfo.versionName; |
|
| 274 |
} |
|
| 275 |
catch( PackageManager.NameNotFoundException e ) |
|
| 276 |
{
|
|
| 277 |
return "unknown"; |
|
| 278 |
} |
|
| 279 |
} |
|
| 280 |
|
|
| 281 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 282 |
|
|
| 283 |
private void savePreferences() |
|
| 284 |
{
|
|
| 285 |
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); |
|
| 286 |
SharedPreferences.Editor editor = preferences.edit(); |
|
| 287 |
|
|
| 288 |
editor.putString("appVersion", mCurrVersion );
|
|
| 289 |
editor.putInt("solverIndex", mSolverIndex );
|
|
| 290 |
|
|
| 291 |
RubikObjectList.savePreferences(editor); |
|
| 292 |
RubikObjectList.saveMeshState(editor); |
|
| 293 |
|
|
| 294 |
boolean success = editor.commit(); |
|
| 295 |
if( !success ) android.util.Log.e("D", "Failed to save preferences");
|
|
| 296 |
} |
|
| 297 |
|
|
| 298 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 299 |
|
|
| 300 |
private void restorePreferences(SharedPreferences preferences, boolean justStarted) |
|
| 301 |
{
|
|
| 302 |
mOldVersion = preferences.getString("appVersion","");
|
|
| 303 |
mSolverIndex = preferences.getInt("solverIndex",0);
|
|
| 304 |
|
|
| 305 |
RubikObjectList.restorePreferences(this,preferences,justStarted); |
|
| 306 |
RubikScores scores = RubikScores.getInstance(); |
|
| 307 |
|
|
| 308 |
if( scores.isVerified() ) |
|
| 309 |
{
|
|
| 310 |
FirebaseAnalytics analytics = getAnalytics(); |
|
| 311 |
analytics.setUserId(scores.getName()); |
|
| 312 |
} |
|
| 313 |
} |
|
| 314 |
|
|
| 315 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 316 |
// PUBLIC API |
|
| 317 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 318 |
|
|
| 319 |
public FirebaseAnalytics getAnalytics() |
|
| 320 |
{
|
|
| 321 |
return mFirebaseAnalytics; |
|
| 322 |
} |
|
| 323 |
|
|
| 324 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 325 |
|
|
| 326 |
public int getHeightUpperBar() |
|
| 327 |
{
|
|
| 328 |
return mHeightUpperBar; |
|
| 329 |
} |
|
| 330 |
|
|
| 331 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 332 |
|
|
| 333 |
public int getScreenWidthInPixels() |
|
| 334 |
{
|
|
| 335 |
return mScreenWidth; |
|
| 336 |
} |
|
| 337 |
|
|
| 338 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 339 |
|
|
| 340 |
public int getScreenHeightInPixels() |
|
| 341 |
{
|
|
| 342 |
return mScreenHeight; |
|
| 343 |
} |
|
| 344 |
|
|
| 345 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 346 |
|
|
| 347 |
public void switchToTutorial(String url, int objectOrdinal) |
|
| 348 |
{
|
|
| 349 |
Intent intent = new Intent(this, TutorialActivity.class); |
|
| 350 |
intent.putExtra("url", url);
|
|
| 351 |
intent.putExtra("obj", objectOrdinal);
|
|
| 352 |
startActivity(intent); |
|
| 353 |
} |
|
| 354 |
|
|
| 355 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 356 |
|
|
| 357 |
public void switchToConfig(int objectOrdinal) |
|
| 358 |
{
|
|
| 359 |
Intent intent = new Intent(this, ConfigActivity.class); |
|
| 360 |
intent.putExtra("obj", objectOrdinal);
|
|
| 361 |
startActivity(intent); |
|
| 362 |
} |
|
| 363 |
|
|
| 364 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 365 |
|
|
| 366 |
public void switchToBandagedCreator(int objectOrdinal) |
|
| 367 |
{
|
|
| 368 |
Intent intent = new Intent(this, BandagedCreatorActivity.class); |
|
| 369 |
intent.putExtra("obj", objectOrdinal);
|
|
| 370 |
startActivity(intent); |
|
| 371 |
} |
|
| 372 |
|
|
| 373 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 374 |
|
|
| 375 |
public void switchToPurchase(int objectOrdinal) |
|
| 376 |
{
|
|
| 377 |
Intent intent = new Intent(this, PurchaseActivity.class); |
|
| 378 |
intent.putExtra("obj", objectOrdinal);
|
|
| 379 |
startActivity(intent); |
|
| 380 |
} |
|
| 381 |
|
|
| 382 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 383 |
|
|
| 384 |
public void setSolverIndex(int index) |
|
| 385 |
{
|
|
| 386 |
mSolverIndex = index; |
|
| 387 |
} |
|
| 388 |
|
|
| 389 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 390 |
|
|
| 391 |
public int getSolverIndex() |
|
| 392 |
{
|
|
| 393 |
return mSolverIndex; |
|
| 394 |
} |
|
| 395 |
|
|
| 396 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 397 |
|
|
| 398 |
public void onScores(View v) |
|
| 399 |
{
|
|
| 400 |
Bundle sBundle = new Bundle(); |
|
| 401 |
sBundle.putString("argument", "false");
|
|
| 402 |
RubikDialogScores scores = new RubikDialogScores(); |
|
| 403 |
scores.setArguments(sBundle); |
|
| 404 |
scores.show(getSupportFragmentManager(), null); |
|
| 405 |
} |
|
| 406 |
|
|
| 407 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 408 |
|
|
| 409 |
public void onUpdates(View v) |
|
| 410 |
{
|
|
| 411 |
RubikDialogUpdates diag = new RubikDialogUpdates(); |
|
| 412 |
diag.show( getSupportFragmentManager(), RubikDialogUpdates.getDialogTag() ); |
|
| 413 |
} |
|
| 414 |
|
|
| 415 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 416 |
|
|
| 417 |
public void onExit(View v) |
|
| 418 |
{
|
|
| 419 |
RubikDialogExit diag = new RubikDialogExit(); |
|
| 420 |
diag.show(getSupportFragmentManager(), null); |
|
| 421 |
} |
|
| 422 |
|
|
| 423 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 424 |
|
|
| 425 |
public void onAbout(View v) |
|
| 426 |
{
|
|
| 427 |
RubikDialogAbout diag = new RubikDialogAbout(); |
|
| 428 |
diag.show(getSupportFragmentManager(), null); |
|
| 429 |
} |
|
| 430 |
|
|
| 431 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 432 |
|
|
| 433 |
public void onBandage(View v) |
|
| 434 |
{
|
|
| 435 |
RubikDialogCreators diag = new RubikDialogCreators(); |
|
| 436 |
diag.show(getSupportFragmentManager(), RubikDialogCreators.getDialogTag() ); |
|
| 437 |
} |
|
| 438 |
|
|
| 439 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 440 |
|
|
| 441 |
public void updateBubble(int num) |
|
| 442 |
{
|
|
| 443 |
runOnUiThread(new Runnable() |
|
| 444 |
{
|
|
| 445 |
@Override |
|
| 446 |
public void run() |
|
| 447 |
{
|
|
| 448 |
mNumUpdates = num; |
|
| 449 |
|
|
| 450 |
if( num>0 ) |
|
| 451 |
{
|
|
| 452 |
String shownNum = String.valueOf(num); |
|
| 453 |
mBubbleUpdates.setText(shownNum); |
|
| 454 |
mBubbleUpdates.setVisibility(View.VISIBLE); |
|
| 455 |
int height = (int)(0.05f*mScreenWidth); |
|
| 456 |
mBubbleUpdates.setTextSize(TypedValue.COMPLEX_UNIT_PX,height); |
|
| 457 |
} |
|
| 458 |
else |
|
| 459 |
{
|
|
| 460 |
mBubbleUpdates.setVisibility(View.INVISIBLE); |
|
| 461 |
} |
|
| 462 |
} |
|
| 463 |
}); |
|
| 464 |
} |
|
| 465 |
|
|
| 466 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 467 |
|
|
| 468 |
public void receiveUpdate(RubikUpdates updates) |
|
| 469 |
{
|
|
| 470 |
int num = updates.getCompletedNumber(); |
|
| 471 |
updateBubble(num); |
|
| 472 |
} |
|
| 473 |
|
|
| 474 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 475 |
|
|
| 476 |
public void objectDownloaded(String shortName) |
|
| 477 |
{
|
|
| 478 |
mNumUpdates--; |
|
| 479 |
updateBubble(mNumUpdates); |
|
| 480 |
mGrid.updateGrid(this,mScreenWidth,mScreenHeight); |
|
| 481 |
} |
|
| 482 |
|
|
| 483 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 484 |
|
|
| 485 |
public int getType() |
|
| 486 |
{
|
|
| 487 |
return 0; |
|
| 488 |
} |
|
| 489 |
|
|
| 490 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 491 |
|
|
| 492 |
public void errorUpdate() |
|
| 493 |
{
|
|
| 494 |
android.util.Log.e("D", "NewRubikActivity: Error receiving downloaded objects update");
|
|
| 495 |
} |
|
| 496 |
} |
|
| src/main/java/org/distorted/main/MainScrollGrid.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2023 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Magic Cube. // |
|
| 5 |
// // |
|
| 6 |
// Magic Cube is proprietary software licensed under an EULA which you should have received // |
|
| 7 |
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html // |
|
| 8 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 9 |
|
|
| 10 |
package org.distorted.main; |
|
| 11 |
|
|
| 12 |
import android.view.View; |
|
| 13 |
import android.widget.GridLayout; |
|
| 14 |
import android.widget.ImageButton; |
|
| 15 |
|
|
| 16 |
import org.distorted.helpers.PopupCreator; |
|
| 17 |
import org.distorted.main_old.RubikActivity; |
|
| 18 |
import org.distorted.objects.RubikObject; |
|
| 19 |
import org.distorted.objects.RubikObjectList; |
|
| 20 |
|
|
| 21 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 22 |
|
|
| 23 |
public class MainScrollGrid |
|
| 24 |
{
|
|
| 25 |
public static final int NUM_COLUMNS = 5; |
|
| 26 |
|
|
| 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 28 |
|
|
| 29 |
public void createGrid(final MainActivity act, int scrW, int scrH) |
|
| 30 |
{
|
|
| 31 |
int numObjects = RubikObjectList.getNumObjects(); |
|
| 32 |
int rowCount = (numObjects + NUM_COLUMNS-1) / NUM_COLUMNS; |
|
| 33 |
int colCount = NUM_COLUMNS; |
|
| 34 |
int objectSize = scrW / NUM_COLUMNS; |
|
| 35 |
int margin = (int)(scrH*RubikActivity.POPUP_MARGIN); |
|
| 36 |
int padding = (int)(scrH*RubikActivity.POPUP_PADDING); |
|
| 37 |
int cubeSize = objectSize - 2*margin; |
|
| 38 |
|
|
| 39 |
GridLayout objectGrid = act.findViewById(R.id.objectGrid); |
|
| 40 |
PopupCreator.createObjectGrid(objectGrid,act,rowCount,colCount,numObjects,margin,cubeSize,padding); |
|
| 41 |
|
|
| 42 |
for(int child=0; child<numObjects; child++) |
|
| 43 |
{
|
|
| 44 |
final RubikObject obj = RubikObjectList.getObject(child); |
|
| 45 |
View v = objectGrid.getChildAt(child); |
|
| 46 |
ImageButton button = PopupCreator.getButton(obj,v); |
|
| 47 |
final int ordinal = child; |
|
| 48 |
|
|
| 49 |
button.setOnClickListener( new View.OnClickListener() |
|
| 50 |
{
|
|
| 51 |
@Override |
|
| 52 |
public void onClick(View v) |
|
| 53 |
{
|
|
| 54 |
android.util.Log.e("D", "object "+ordinal+" clicked!");
|
|
| 55 |
} |
|
| 56 |
}); |
|
| 57 |
} |
|
| 58 |
} |
|
| 59 |
|
|
| 60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 61 |
|
|
| 62 |
public void updateGrid(final MainActivity act, int scrW, int scrH) |
|
| 63 |
{
|
|
| 64 |
act.runOnUiThread(new Runnable() |
|
| 65 |
{
|
|
| 66 |
@Override |
|
| 67 |
public void run() |
|
| 68 |
{
|
|
| 69 |
createGrid(act,scrW,scrH); |
|
| 70 |
} |
|
Also available in: Unified diff
Major progress to version 2.0.0.