1 |
93a1c364
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2022 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.view.View;
|
14 |
67d7fb28
|
Leszek Koltunski
|
import android.view.Window;
|
15 |
|
|
import android.view.WindowManager;
|
16 |
93a1c364
|
Leszek Koltunski
|
import android.widget.LinearLayout;
|
17 |
|
|
import android.widget.TextView;
|
18 |
|
|
|
19 |
|
|
import androidx.fragment.app.FragmentActivity;
|
20 |
|
|
|
21 |
|
|
import org.distorted.main.R;
|
22 |
|
|
import org.distorted.main.RubikActivity;
|
23 |
|
|
import org.distorted.solvers.ImplementedSolversList;
|
24 |
|
|
|
25 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
26 |
|
|
|
27 |
|
|
public class RubikDialogSolvers extends RubikDialogAbstract
|
28 |
|
|
{
|
29 |
67d7fb28
|
Leszek Koltunski
|
@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 |
|
|
|
46 |
93a1c364
|
Leszek Koltunski
|
public int getResource() { return R.layout.dialog_scrollable_panes; }
|
47 |
|
|
public int getTitleResource() { return R.string.solver; }
|
48 |
|
|
public boolean hasArgument() { return false; }
|
49 |
|
|
public int getPositive() { return R.string.ok; }
|
50 |
|
|
public int getNegative() { return -1; }
|
51 |
|
|
|
52 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
53 |
|
|
|
54 |
|
|
public void positiveAction()
|
55 |
|
|
{
|
56 |
|
|
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
60 |
|
|
|
61 |
|
|
public void negativeAction()
|
62 |
|
|
{
|
63 |
|
|
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
67 |
|
|
|
68 |
|
|
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
|
69 |
|
|
{
|
70 |
67d7fb28
|
Leszek Koltunski
|
int margin= (int)(mHeight*0.010f);
|
71 |
|
|
int padd = (int)(mHeight*0.010f);
|
72 |
|
|
int font = (int)(mHeight*0.025f);
|
73 |
|
|
|
74 |
|
|
LinearLayout layout= view.findViewById(R.id.dialog_scrollable_main_layout);
|
75 |
|
|
TextView text = view.findViewById(R.id.dialog_scrollable_message);
|
76 |
93a1c364
|
Leszek Koltunski
|
text.setVisibility(View.GONE);
|
77 |
|
|
|
78 |
67d7fb28
|
Leszek Koltunski
|
LinearLayout.LayoutParams pV = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
79 |
93a1c364
|
Leszek Koltunski
|
pV.setMargins(margin, margin, margin, 0);
|
80 |
1c89e2a7
|
Leszek Koltunski
|
LinearLayout.LayoutParams pL = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
81 |
|
|
pL.setMargins(margin, margin, margin, margin);
|
82 |
74c9fa47
|
Leszek Koltunski
|
LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
83 |
|
|
pT.setMargins(0,0,0,2*margin);
|
84 |
|
|
LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
85 |
67d7fb28
|
Leszek Koltunski
|
pB.setMargins(0,2*margin,0,0);
|
86 |
93a1c364
|
Leszek Koltunski
|
|
87 |
|
|
int num = ImplementedSolversList.NUM_OBJECTS;
|
88 |
|
|
RubikActivity ract = (RubikActivity) getContext();
|
89 |
|
|
|
90 |
|
|
for(int i=0; i<num; i++)
|
91 |
|
|
{
|
92 |
|
|
ImplementedSolversList solver = ImplementedSolversList.getSolver(i);
|
93 |
|
|
int object = solver.getObject();
|
94 |
|
|
int title = solver.getTitle();
|
95 |
|
|
int description = solver.getDescription();
|
96 |
1c89e2a7
|
Leszek Koltunski
|
RubikDialogSolverView pane = new RubikDialogSolverView(ract,this,i,object,title,description, padd, font, (i==num-1?pL:pV),pT,pB);
|
97 |
93a1c364
|
Leszek Koltunski
|
layout.addView(pane.getView());
|
98 |
|
|
}
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
102 |
|
|
|
103 |
|
|
public static String getDialogTag()
|
104 |
|
|
{
|
105 |
|
|
return "DialogSolvers";
|
106 |
|
|
}
|
107 |
|
|
}
|