Revision 67d7fb28
Added by Leszek Koltunski almost 2 years ago
src/main/java/org/distorted/dialogs/RubikDialogSolverView.java | ||
---|---|---|
30 | 30 |
|
31 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
32 | 32 |
|
33 |
public RubikDialogSolverView(final RubikActivity act, final RubikDialogSolvers dialog, int object, int title, int desc, boolean implemented, int padding, int fontSize,
|
|
33 |
public RubikDialogSolverView(final RubikActivity act, final RubikDialogSolvers dialog, final int index, int object, int title, int desc, int padding, int fontSize,
|
|
34 | 34 |
LinearLayout.LayoutParams pView, LinearLayout.LayoutParams pText, LinearLayout.LayoutParams pButt ) |
35 | 35 |
{ |
36 | 36 |
mView = act.getLayoutInflater().inflate(R.layout.dialog_solvers_pane, null); |
... | ... | |
43 | 43 |
descView.setText(desc); |
44 | 44 |
|
45 | 45 |
titleView.setLayoutParams(pText); |
46 |
descView.setLayoutParams(pText); |
|
47 | 46 |
|
48 | 47 |
ImageView icon = mView.findViewById(R.id.solvers_pane_image); |
49 | 48 |
RubikObject robject = RubikObjectList.getObject(object); |
... | ... | |
57 | 56 |
public void onClick(View v) |
58 | 57 |
{ |
59 | 58 |
dialog.dismiss(); |
59 |
act.setSolverIndex(index); |
|
60 | 60 |
ScreenList.switchScreen(act, ScreenList.SVER); |
61 | 61 |
} |
62 | 62 |
}); |
src/main/java/org/distorted/dialogs/RubikDialogSolvers.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import android.app.Dialog; |
13 | 13 |
import android.view.View; |
14 |
import android.view.Window; |
|
15 |
import android.view.WindowManager; |
|
14 | 16 |
import android.widget.LinearLayout; |
15 | 17 |
import android.widget.TextView; |
16 | 18 |
|
... | ... | |
24 | 26 |
|
25 | 27 |
public class RubikDialogSolvers extends RubikDialogAbstract |
26 | 28 |
{ |
29 |
@Override |
|
30 |
public void onResume() |
|
31 |
{ |
|
32 |
super.onResume(); |
|
33 |
|
|
34 |
Window window = getDialog().getWindow(); |
|
35 |
|
|
36 |
if( window!=null ) |
|
37 |
{ |
|
38 |
WindowManager.LayoutParams params = window.getAttributes(); |
|
39 |
params.width = (int)Math.min( mHeight*0.65f,mWidth*0.98f ); |
|
40 |
window.setAttributes(params); |
|
41 |
} |
|
42 |
} |
|
43 |
|
|
44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
45 |
|
|
27 | 46 |
public int getResource() { return R.layout.dialog_scrollable_panes; } |
28 | 47 |
public int getTitleResource() { return R.string.solver; } |
29 | 48 |
public boolean hasArgument() { return false; } |
... | ... | |
48 | 67 |
|
49 | 68 |
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size) |
50 | 69 |
{ |
51 |
int minH = (int)(mHeight*0.25f); |
|
52 |
int margin= (int)(mHeight*0.01f); |
|
53 |
int sizeH = (int)(mHeight*0.14f); |
|
54 |
int textH = (int)(sizeH*0.27f); |
|
55 |
int buttH = (int)(sizeH*0.35f); |
|
56 |
int padd = (int)(mHeight*0.01f); |
|
57 |
int font = (int)(mHeight*0.02f); |
|
58 |
|
|
59 |
LinearLayout layout= view.findViewById(R.id.updates_main_layout); |
|
60 |
TextView text = view.findViewById(R.id.updates_message); |
|
70 |
int minH = (int)(mHeight*0.250f); |
|
71 |
int margin= (int)(mHeight*0.010f); |
|
72 |
int textH = (int)(mHeight*0.035f); |
|
73 |
int buttH = (int)(mHeight*0.060f); |
|
74 |
int padd = (int)(mHeight*0.010f); |
|
75 |
int font = (int)(mHeight*0.025f); |
|
76 |
|
|
77 |
LinearLayout layout= view.findViewById(R.id.dialog_scrollable_main_layout); |
|
78 |
TextView text = view.findViewById(R.id.dialog_scrollable_message); |
|
61 | 79 |
text.setVisibility(View.GONE); |
62 | 80 |
|
63 | 81 |
layout.setMinimumHeight(minH); |
64 | 82 |
view.setMinimumHeight(minH); |
65 | 83 |
|
66 |
LinearLayout.LayoutParams pV = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, sizeH );
|
|
84 |
LinearLayout.LayoutParams pV = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
|
67 | 85 |
pV.setMargins(margin, margin, margin, 0); |
68 | 86 |
LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, textH ); |
69 | 87 |
LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, buttH ); |
88 |
pB.setMargins(0,2*margin,0,0); |
|
70 | 89 |
|
71 | 90 |
int num = ImplementedSolversList.NUM_OBJECTS; |
72 | 91 |
RubikActivity ract = (RubikActivity) getContext(); |
... | ... | |
77 | 96 |
int object = solver.getObject(); |
78 | 97 |
int title = solver.getTitle(); |
79 | 98 |
int description = solver.getDescription(); |
80 |
boolean implemented = solver.isImplemented(); |
|
81 |
|
|
82 |
RubikDialogSolverView pane = new RubikDialogSolverView(ract,this,object,title,description,implemented, padd, font, pV,pT,pB); |
|
99 |
RubikDialogSolverView pane = new RubikDialogSolverView(ract,this,i,object,title,description, padd, font, pV,pT,pB); |
|
83 | 100 |
layout.addView(pane.getView()); |
84 | 101 |
} |
85 | 102 |
} |
src/main/java/org/distorted/dialogs/RubikDialogUpdates.java | ||
---|---|---|
15 | 15 |
import android.graphics.Bitmap; |
16 | 16 |
import android.util.TypedValue; |
17 | 17 |
import android.view.View; |
18 |
import android.view.Window; |
|
19 |
import android.view.WindowManager; |
|
18 | 20 |
import android.widget.LinearLayout; |
19 | 21 |
import android.widget.TextView; |
20 | 22 |
|
... | ... | |
33 | 35 |
private int mMargin, mSize, mFontSize, mPadding; |
34 | 36 |
private ArrayList<RubikDialogUpdateView> mPanes; |
35 | 37 |
|
38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
39 |
|
|
40 |
@Override |
|
41 |
public void onResume() |
|
42 |
{ |
|
43 |
super.onResume(); |
|
44 |
|
|
45 |
Window window = getDialog().getWindow(); |
|
46 |
|
|
47 |
if( window!=null ) |
|
48 |
{ |
|
49 |
WindowManager.LayoutParams params = window.getAttributes(); |
|
50 |
params.width = (int)Math.min( mHeight*0.65f,mWidth*0.98f ); |
|
51 |
window.setAttributes(params); |
|
52 |
} |
|
53 |
} |
|
54 |
|
|
36 | 55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
37 | 56 |
|
38 | 57 |
public int getResource() { return R.layout.dialog_scrollable_panes; } |
... | ... | |
67 | 86 |
mFontSize = (int)(mHeight*0.02f); |
68 | 87 |
mPadding = (int)(mHeight*0.01f); |
69 | 88 |
|
70 |
mLayout= view.findViewById(R.id.updates_main_layout);
|
|
71 |
mText = view.findViewById(R.id.updates_message);
|
|
89 |
mLayout= view.findViewById(R.id.dialog_scrollable_main_layout);
|
|
90 |
mText = view.findViewById(R.id.dialog_scrollable_message);
|
|
72 | 91 |
mText.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
73 | 92 |
mText.setText( act.getString(R.string.downloading) ); |
74 | 93 |
|
src/main/java/org/distorted/main/RubikActivity.java | ||
---|---|---|
102 | 102 |
private int mHeightUpperBar, mHeightLowerBar; |
103 | 103 |
private int mOldVersion1, mOldVersion2, mOldVersion3; |
104 | 104 |
private String mOldVersion, mCurrVersion; |
105 |
private int mSolverIndex; |
|
105 | 106 |
|
106 | 107 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
107 | 108 |
|
... | ... | |
128 | 129 |
computeBarHeights(); |
129 | 130 |
|
130 | 131 |
mCurrVersion = getAppVers(); |
132 |
mSolverIndex = 0; |
|
131 | 133 |
|
132 | 134 |
Thread thread = new Thread() |
133 | 135 |
{ |
... | ... | |
734 | 736 |
} |
735 | 737 |
} |
736 | 738 |
} |
739 |
|
|
740 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
741 |
|
|
742 |
public void setSolverIndex(int index) |
|
743 |
{ |
|
744 |
mSolverIndex = index; |
|
745 |
} |
|
746 |
|
|
747 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
748 |
|
|
749 |
public int getSolverIndex() |
|
750 |
{ |
|
751 |
return mSolverIndex; |
|
752 |
} |
|
753 |
|
|
737 | 754 |
} |
src/main/java/org/distorted/screens/RubikScreenSolver.java | ||
---|---|---|
24 | 24 |
import android.widget.LinearLayout; |
25 | 25 |
|
26 | 26 |
import org.distorted.objectlib.main.ObjectControl; |
27 |
import org.distorted.objectlib.main.ObjectSignatures; |
|
28 | 27 |
import org.distorted.objectlib.main.TwistyObject; |
29 | 28 |
|
30 | 29 |
import org.distorted.dialogs.RubikDialogSolverError; |
... | ... | |
74 | 73 |
mWeakAct = new WeakReference<>(act); |
75 | 74 |
mSolving = false; |
76 | 75 |
|
77 |
int currentObject= ObjectSignatures.CUBE_3;//ImplementedSolversList.getObject(0); //TODO |
|
76 |
int solverIndex= act.getSolverIndex(); |
|
77 |
ImplementedSolversList currentSolver = ImplementedSolversList.getSolver(solverIndex); |
|
78 |
int currentObject = currentSolver.getObject(); |
|
78 | 79 |
act.changeIfDifferent(currentObject,control); |
79 | 80 |
control.solveOnly(); |
80 |
|
|
81 | 81 |
RubikObjectList.setCurrObject(currentObject); |
82 | 82 |
|
83 | 83 |
generateFaceColors(); |
src/main/java/org/distorted/solvers/ImplementedSolversList.java | ||
---|---|---|
19 | 19 |
CUBE3_KOCIEMBA (ObjectSignatures.CUBE_3, R.string.solver_cube3_title, R.string.solver_cube3_description, true), |
20 | 20 |
PYRAMINX (ObjectSignatures.PYRA_3, R.string.solver_pyra3_title, R.string.solver_pyra3_description, false), |
21 | 21 |
IVY (ObjectSignatures.IVY_2 , R.string.solver_ivy_title, R.string.solver_ivy_description, false), |
22 |
TOWER (ObjectSignatures.CU_232, R.string.solver_cu232_title, R.string.solver_cu232_description, false), |
|
22 | 23 |
; |
23 | 24 |
|
24 | 25 |
public static final int NUM_OBJECTS = values().length; |
src/main/res/layout/dialog_scrollable_panes.xml | ||
---|---|---|
7 | 7 |
android:paddingRight="10dp"> |
8 | 8 |
|
9 | 9 |
<LinearLayout |
10 |
android:id="@+id/updates_main_layout"
|
|
10 |
android:id="@+id/dialog_scrollable_main_layout"
|
|
11 | 11 |
android:layout_width="match_parent" |
12 | 12 |
android:layout_height="wrap_content" |
13 | 13 |
android:background="@color/black" |
... | ... | |
15 | 15 |
android:orientation="vertical"> |
16 | 16 |
|
17 | 17 |
<TextView |
18 |
android:id="@+id/updates_message"
|
|
18 |
android:id="@+id/dialog_scrollable_message"
|
|
19 | 19 |
android:layout_width="match_parent" |
20 | 20 |
android:layout_height="match_parent" |
21 | 21 |
android:gravity="center"/> |
src/main/res/layout/dialog_solvers_pane.xml | ||
---|---|---|
7 | 7 |
android:padding="8dp" |
8 | 8 |
android:orientation="horizontal"> |
9 | 9 |
|
10 |
<LinearLayout |
|
11 |
android:layout_width="0dp" |
|
12 |
android:layout_height="match_parent" |
|
13 |
android:orientation="horizontal" |
|
14 |
android:layout_weight="0.5"> |
|
15 |
|
|
16 |
<ImageView |
|
17 |
android:id="@+id/solvers_pane_image" |
|
18 |
android:scaleType="fitCenter" |
|
19 |
android:layout_width="match_parent" |
|
20 |
android:layout_height="match_parent"/> |
|
21 |
</LinearLayout> |
|
10 |
<ImageView |
|
11 |
android:id="@+id/solvers_pane_image" |
|
12 |
android:scaleType="fitCenter" |
|
13 |
android:layout_width="0dp" |
|
14 |
android:layout_height="match_parent" |
|
15 |
android:layout_gravity="top" |
|
16 |
android:layout_weight="0.5"/> |
|
22 | 17 |
|
23 | 18 |
<LinearLayout |
24 | 19 |
android:layout_width="0dp" |
... | ... | |
38 | 33 |
<TextView |
39 | 34 |
android:id="@+id/solvers_pane_description" |
40 | 35 |
android:gravity="top|start" |
41 |
android:layout_width="wrap_content" |
|
42 |
android:layout_height="wrap_content" |
|
43 |
android:singleLine="true"/> |
|
36 |
android:layout_width="match_parent" |
|
37 |
android:layout_height="wrap_content"/> |
|
44 | 38 |
|
45 | 39 |
<Button |
46 | 40 |
android:id="@+id/solvers_pane_button" |
47 | 41 |
android:layout_width="match_parent" |
48 | 42 |
android:layout_height="wrap_content" |
43 |
android:gravity="center" |
|
49 | 44 |
android:backgroundTint="@color/black" |
50 |
android:minHeight="0dp" |
|
51 |
android:minWidth="0dp" |
|
52 | 45 |
android:insetTop="0dp" |
53 | 46 |
android:insetBottom="0dp" |
54 | 47 |
android:text="@string/use_solver"/> |
src/main/res/values/strings.xml | ||
---|---|---|
117 | 117 |
<string name="color_orange">orange</string> |
118 | 118 |
|
119 | 119 |
<string name="solver_cube3_title" translatable="false">Kociemba 3x3 Solver</string> |
120 |
<string name="solver_cube3_description" translatable="false">A near-perfect, instantaneous, two-phase 3x3x3 solver. Author: Herbert Kociemba.</string>
|
|
120 |
<string name="solver_cube3_description" translatable="false">A near-perfect, instantaneous, two-phase 3x3x3 solver.\nAuthor: Herbert Kociemba.</string>
|
|
121 | 121 |
<string name="solver_pyra3_title" translatable="false">Pyraminx Solver</string> |
122 |
<string name="solver_pyra3_description" translatable="false">A perfect, instantaneous, tablebase-based Pyraminx solver. Author: Leszek Koltunski.</string>
|
|
122 |
<string name="solver_pyra3_description" translatable="false">A perfect, instantaneous, tablebase-based Pyraminx solver.\nAuthor: Leszek Koltunski.</string>
|
|
123 | 123 |
<string name="solver_ivy_title" translatable="false">Ivy Solver</string> |
124 |
<string name="solver_ivy_description" translatable="false">A perfect, instantaneous, tablebase-based Ivy Cube solver. Author: Leszek Koltunski.</string> |
|
124 |
<string name="solver_ivy_description" translatable="false">A perfect, instantaneous, tablebase-based Ivy Cube solver.\nAuthor: Leszek Koltunski.</string> |
|
125 |
<string name="solver_cu232_title" translatable="false">2x2x3 Cuboid Solver</string> |
|
126 |
<string name="solver_cu232_description" translatable="false">A perfect, instantaneous, tablebase-based 2x2x3 Cuboid solver.\nAuthor: Leszek Koltunski.</string> |
|
125 | 127 |
|
126 | 128 |
<string name="ns_placeholder" translatable="false">+%1$d</string> |
127 | 129 |
<string name="sq_placeholder" translatable="false">%1$2d.</string> |
Also available in: Unified diff
Progress with solvers dialog.