1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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
|
import android.view.Window;
|
15
|
import android.view.WindowManager;
|
16
|
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
|
@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
|
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
|
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
|
text.setVisibility(View.GONE);
|
77
|
|
78
|
LinearLayout.LayoutParams pV = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
79
|
pV.setMargins(margin, margin, margin, 0);
|
80
|
LinearLayout.LayoutParams pL = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
81
|
pL.setMargins(margin, margin, margin, margin);
|
82
|
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
|
pB.setMargins(0,2*margin,0,0);
|
86
|
|
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
|
RubikDialogSolverView pane = new RubikDialogSolverView(ract,this,i,object,title,description, padd, font, (i==num-1?pL:pV),pT,pB);
|
97
|
layout.addView(pane.getView());
|
98
|
}
|
99
|
}
|
100
|
|
101
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
102
|
|
103
|
public static String getDialogTag()
|
104
|
{
|
105
|
return "DialogSolvers";
|
106
|
}
|
107
|
}
|