Revision 34d6b123
Added by Leszek Koltunski over 2 years ago
| src/main/java/org/distorted/dialogs/RubikDialogAbout.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.Dialog; |
|
| 13 |
import android.content.pm.PackageInfo; |
|
| 14 |
import android.content.pm.PackageManager; |
|
| 15 |
import androidx.fragment.app.FragmentActivity; |
|
| 16 |
|
|
| 17 |
import android.text.method.LinkMovementMethod; |
|
| 18 |
import android.text.method.MovementMethod; |
|
| 19 |
import android.util.TypedValue; |
|
| 20 |
import android.view.View; |
|
| 21 |
import android.widget.TextView; |
|
| 22 |
|
|
| 23 |
import org.distorted.main.R; |
|
| 24 |
import org.distorted.main.RubikActivity; |
|
| 25 |
|
|
| 26 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 27 |
|
|
| 28 |
public class RubikDialogAbout extends RubikDialogAbstract |
|
| 29 |
{
|
|
| 30 |
public int getResource() { return R.layout.dialog_about; }
|
|
| 31 |
public int getTitleResource() { return R.string.about; }
|
|
| 32 |
public boolean hasArgument() { return false; }
|
|
| 33 |
public int getPositive() { return R.string.ok; }
|
|
| 34 |
public int getNegative() { return -1; }
|
|
| 35 |
|
|
| 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 37 |
|
|
| 38 |
public void positiveAction() |
|
| 39 |
{
|
|
| 40 |
|
|
| 41 |
} |
|
| 42 |
|
|
| 43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 44 |
|
|
| 45 |
public void negativeAction() |
|
| 46 |
{
|
|
| 47 |
|
|
| 48 |
} |
|
| 49 |
|
|
| 50 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 51 |
|
|
| 52 |
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size) |
|
| 53 |
{
|
|
| 54 |
TextView text = view.findViewById(R.id.about_version); |
|
| 55 |
String appName = getString(R.string.app_name); |
|
| 56 |
|
|
| 57 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 58 |
|
|
| 59 |
String version; |
|
| 60 |
try |
|
| 61 |
{
|
|
| 62 |
PackageInfo pInfo = act.getPackageManager().getPackageInfo( act.getPackageName(), 0); |
|
| 63 |
version= pInfo.versionName; |
|
| 64 |
} |
|
| 65 |
catch (PackageManager.NameNotFoundException e) |
|
| 66 |
{
|
|
| 67 |
version= "unknown"; |
|
| 68 |
} |
|
| 69 |
|
|
| 70 |
text.setText(getString(R.string.ap_placeholder,appName, version)); |
|
| 71 |
|
|
| 72 |
MovementMethod mm = LinkMovementMethod.getInstance(); |
|
| 73 |
TextView text2 = view.findViewById(R.id.about_section2); |
|
| 74 |
text2.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 75 |
text2.setMovementMethod(mm); |
|
| 76 |
TextView text3 = view.findViewById(R.id.about_section3); |
|
| 77 |
text3.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 78 |
|
|
| 79 |
TextView text4 = view.findViewById(R.id.about_section4); |
|
| 80 |
|
|
| 81 |
if( RubikActivity.localeIsChinese() ) |
|
| 82 |
{
|
|
| 83 |
text4.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 84 |
text4.setMovementMethod(mm); |
|
| 85 |
} |
|
| 86 |
else |
|
| 87 |
{
|
|
| 88 |
text4.setVisibility(View.GONE); |
|
| 89 |
} |
|
| 90 |
} |
|
| 91 |
} |
|
| src/main/java/org/distorted/dialogs/RubikDialogSolvers.java | ||
|---|---|---|
| 68 | 68 |
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size) |
| 69 | 69 |
{
|
| 70 | 70 |
int margin= (int)(mHeight*0.010f); |
| 71 |
int textH = (int)(mHeight*0.035f); |
|
| 72 |
int buttH = (int)(mHeight*0.060f); |
|
| 73 | 71 |
int padd = (int)(mHeight*0.010f); |
| 74 | 72 |
int font = (int)(mHeight*0.025f); |
| 75 | 73 |
|
| src/main/java/org/distorted/dialogs/RubikDialogWhatsNew.java | ||
|---|---|---|
| 10 | 10 |
package org.distorted.dialogs; |
| 11 | 11 |
|
| 12 | 12 |
import android.app.Dialog; |
| 13 |
import android.content.pm.PackageInfo; |
|
| 14 |
import android.content.pm.PackageManager; |
|
| 13 | 15 |
import android.view.View; |
| 14 | 16 |
import android.view.Window; |
| 15 | 17 |
import android.view.WindowManager; |
| ... | ... | |
| 27 | 29 |
{
|
| 28 | 30 |
private static final String[] MESSAGES = |
| 29 | 31 |
{
|
| 30 |
"1.11.6",
|
|
| 32 |
"1.12.0",
|
|
| 31 | 33 |
|
| 32 | 34 |
"1. This dialog :)\n" + |
| 33 | 35 |
"2. UI ready for NEW SOLVERS\n" + |
| 34 | 36 |
"3. Important fix for a bug which used to let players solve any scramble with just one move\n" + |
| 35 |
"4. UI fixes for squarish screens\n" +
|
|
| 36 |
"5. Preparation for Penrose Cubes.\n",
|
|
| 37 |
"4. Support for curved walls of cubies (preparation for Penrose Cubes)\n" +
|
|
| 38 |
"5. Support for scrambling algorithms (preparation for AI Cube & Camouflage Cubes)",
|
|
| 37 | 39 |
|
| 38 |
"current", |
|
| 39 |
}; |
|
| 40 |
"Coming", |
|
| 40 | 41 |
|
| 41 |
private int mLowerVersion, mUpperVersion; |
|
| 42 |
"1. Implemented Pyraminx, Ivy, 2x2x3, Skewb Diamond solvers.\n" + |
|
| 43 |
"2. More solvers (2x2x2?)\n" + |
|
| 44 |
"2. Support for adjustable stickers.\n" + |
|
| 45 |
"3. In-game currency (stars)\n" + |
|
| 46 |
"4. More objects (Camouflage Cubes, AI Cube, Burr Cube, Penrose Cubes, the Double-Crazy)" |
|
| 47 |
}; |
|
| 42 | 48 |
|
| 43 | 49 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 44 | 50 |
|
| ... | ... | |
| 92 | 98 |
text.setVisibility(View.GONE); |
| 93 | 99 |
|
| 94 | 100 |
LinearLayout.LayoutParams pV = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT ); |
| 95 |
pV.setMargins(margin, margin, margin, margin);
|
|
| 101 |
pV.setMargins(margin, margin, margin, 0);
|
|
| 96 | 102 |
LinearLayout.LayoutParams pL = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT ); |
| 97 | 103 |
pL.setMargins(margin, margin, margin, margin); |
| 98 | 104 |
LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, titleH ); |
| 99 | 105 |
LinearLayout.LayoutParams pM = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT ); |
| 100 | 106 |
pM.setMargins(0,2*margin,0,0); |
| 101 | 107 |
|
| 102 |
parseArgument(mArgument); |
|
| 103 | 108 |
RubikActivity ract = (RubikActivity) getContext(); |
| 109 |
int start = findVersion(mArgument); |
|
| 110 |
int numMessages= MESSAGES.length/2; |
|
| 111 |
String thisVersion = findCurrentVersion(ract); |
|
| 104 | 112 |
|
| 105 |
for(int i=mLowerVersion; i<mUpperVersion; i+=2)
|
|
| 113 |
for(int i=0; i<numMessages; i++)
|
|
| 106 | 114 |
{
|
| 107 |
String lower = MESSAGES[i];
|
|
| 108 |
String message = MESSAGES[i+1]; |
|
| 109 |
String upper = MESSAGES[i+2];
|
|
| 115 |
String version = MESSAGES[start+2*i];
|
|
| 116 |
String message = MESSAGES[start+2*i+1];
|
|
| 117 |
boolean isCurrent = version.equals(thisVersion);
|
|
| 110 | 118 |
|
| 111 |
RubikDialogWhatsNewView pane = new RubikDialogWhatsNewView(ract,lower,upper,message,padd,(i==mUpperVersion-1 ? pL:pV),pT,pM);
|
|
| 119 |
RubikDialogWhatsNewView pane = new RubikDialogWhatsNewView(ract,version,message,padd, isCurrent, (i==(numMessages-1) ? pL:pV),pT,pM);
|
|
| 112 | 120 |
layout.addView(pane.getView()); |
| 113 | 121 |
} |
| 114 | 122 |
} |
| 115 | 123 |
|
| 116 | 124 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 117 | 125 |
|
| 118 |
private void parseArgument(String argument)
|
|
| 126 |
private String findCurrentVersion(RubikActivity act)
|
|
| 119 | 127 |
{
|
| 120 |
String[] parts = argument.split(" ");
|
|
| 121 |
|
|
| 122 |
if( parts.length==2 ) |
|
| 128 |
String version; |
|
| 129 |
try |
|
| 123 | 130 |
{
|
| 124 |
mLowerVersion = findVersion(parts[0]);
|
|
| 125 |
mUpperVersion = findVersion(parts[1]);
|
|
| 131 |
PackageInfo pInfo = act.getPackageManager().getPackageInfo( act.getPackageName(), 0);
|
|
| 132 |
version= pInfo.versionName;
|
|
| 126 | 133 |
} |
| 134 |
catch (PackageManager.NameNotFoundException e) |
|
| 135 |
{
|
|
| 136 |
version= "unknown"; |
|
| 137 |
} |
|
| 138 |
|
|
| 139 |
return version; |
|
| 127 | 140 |
} |
| 128 | 141 |
|
| 129 | 142 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 137 | 150 |
if( MESSAGES[i].equals(version) ) return i; |
| 138 | 151 |
} |
| 139 | 152 |
|
| 140 |
return len-1;
|
|
| 153 |
return 0;
|
|
| 141 | 154 |
} |
| 142 | 155 |
|
| 143 | 156 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/dialogs/RubikDialogWhatsNewView.java | ||
|---|---|---|
| 24 | 24 |
|
| 25 | 25 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 26 | 26 |
|
| 27 |
public RubikDialogWhatsNewView(final RubikActivity act, String lower, String upper, String message, int padding,
|
|
| 27 |
public RubikDialogWhatsNewView(final RubikActivity act, String version, String message, int padding, boolean isCurrent,
|
|
| 28 | 28 |
LinearLayout.LayoutParams pView, LinearLayout.LayoutParams pTitle, LinearLayout.LayoutParams pMessage ) |
| 29 | 29 |
{
|
| 30 | 30 |
mView = act.getLayoutInflater().inflate(R.layout.dialog_whatsnew_pane, null); |
| ... | ... | |
| 32 | 32 |
mView.setPadding(padding,padding,padding,padding); |
| 33 | 33 |
|
| 34 | 34 |
TextView titleView = mView.findViewById(R.id.whatsnew_pane_title); |
| 35 |
titleView.setText(lower+" -> "+upper);
|
|
| 35 |
titleView.setText( isCurrent ? act.getString(R.string.tv_placeholder,version) : version );
|
|
| 36 | 36 |
titleView.setLayoutParams(pTitle); |
| 37 | 37 |
|
| 38 | 38 |
TextView messView = mView.findViewById(R.id.whatsnew_pane_message); |
| src/main/java/org/distorted/main/RubikActivity.java | ||
|---|---|---|
| 298 | 298 |
private void displayNovelties() |
| 299 | 299 |
{
|
| 300 | 300 |
Bundle bundle = new Bundle(); |
| 301 |
bundle.putString("argument",mOldVersion+" "+mCurrVersion);
|
|
| 301 |
bundle.putString("argument",mOldVersion);
|
|
| 302 | 302 |
RubikDialogWhatsNew newDialog = new RubikDialogWhatsNew(); |
| 303 | 303 |
newDialog.setArguments(bundle); |
| 304 | 304 |
newDialog.show(getSupportFragmentManager(), RubikDialogWhatsNew.getDialogTag() ); |
| src/main/java/org/distorted/screens/RubikScreenPlay.java | ||
|---|---|---|
| 33 | 33 |
import org.distorted.dialogs.RubikDialogSolvers; |
| 34 | 34 |
import org.distorted.dialogs.RubikDialogStarsStatus; |
| 35 | 35 |
import org.distorted.dialogs.RubikDialogUpdates; |
| 36 |
import org.distorted.dialogs.RubikDialogWhatsNew; |
|
| 36 | 37 |
import org.distorted.external.RubikNetwork; |
| 37 | 38 |
import org.distorted.external.RubikScores; |
| 38 | 39 |
import org.distorted.external.RubikUpdates; |
| ... | ... | |
| 40 | 41 |
import org.distorted.helpers.PopupCreator; |
| 41 | 42 |
import org.distorted.main.R; |
| 42 | 43 |
import org.distorted.main.RubikActivity; |
| 43 |
import org.distorted.dialogs.RubikDialogAbout; |
|
| 44 | 44 |
import org.distorted.dialogs.RubikDialogPattern; |
| 45 | 45 |
import org.distorted.dialogs.RubikDialogScores; |
| 46 | 46 |
import org.distorted.dialogs.RubikDialogTutorial; |
| ... | ... | |
| 447 | 447 |
} |
| 448 | 448 |
}); |
| 449 | 449 |
|
| 450 |
Button about = layout.findViewById(R.id.menuAbout);
|
|
| 451 |
about.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
|
|
| 452 |
about.setOnClickListener( new View.OnClickListener()
|
|
| 450 |
Button whatsNew = layout.findViewById(R.id.menuNew);
|
|
| 451 |
whatsNew.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
|
|
| 452 |
whatsNew.setOnClickListener( new View.OnClickListener()
|
|
| 453 | 453 |
{
|
| 454 | 454 |
@Override |
| 455 | 455 |
public void onClick(View v) |
| 456 | 456 |
{
|
| 457 | 457 |
mMenuPopup.dismiss(); |
| 458 |
RubikDialogAbout aDiag = new RubikDialogAbout();
|
|
| 458 |
RubikDialogWhatsNew aDiag = new RubikDialogWhatsNew();
|
|
| 459 | 459 |
aDiag.show(act.getSupportFragmentManager(), null); |
| 460 | 460 |
} |
| 461 | 461 |
}); |
| src/main/res/layout/popup_menu.xml | ||
|---|---|---|
| 79 | 79 |
android:gravity="center"/> |
| 80 | 80 |
|
| 81 | 81 |
<Button |
| 82 |
android:id="@+id/menuAbout"
|
|
| 83 |
android:text="@string/about"
|
|
| 82 |
android:id="@+id/menuNew"
|
|
| 83 |
android:text="@string/whatsnew"
|
|
| 84 | 84 |
android:layout_width="match_parent" |
| 85 | 85 |
android:layout_height="0dp" |
| 86 | 86 |
android:layout_weight="1.0" |
| src/main/res/values/strings.xml | ||
|---|---|---|
| 138 | 138 |
<string name="ms_placeholder">%1$d ms</string> |
| 139 | 139 |
<string name="lv_placeholder">Level %1$d</string> |
| 140 | 140 |
<string name="ti_placeholder">%1$s seconds</string> |
| 141 |
<string name="tv_placeholder">This version (%1$s)</string> |
|
| 141 | 142 |
|
| 142 | 143 |
</resources> |
Also available in: Unified diff
What's New dialog: improvements.
Remove the About dialog.