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_old.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
|
public static String getDialogTag() { return "DialogSolvers"; }
|
52
|
public void positiveAction() { }
|
53
|
public void negativeAction() { }
|
54
|
|
55
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
56
|
|
57
|
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
|
58
|
{
|
59
|
int margin= (int)(mHeight*0.010f);
|
60
|
int padd = (int)(mHeight*0.010f);
|
61
|
int font = (int)(mHeight*0.025f);
|
62
|
|
63
|
LinearLayout layout= view.findViewById(R.id.dialog_scrollable_main_layout);
|
64
|
TextView text = view.findViewById(R.id.dialog_scrollable_message);
|
65
|
text.setVisibility(View.GONE);
|
66
|
|
67
|
LinearLayout.LayoutParams pV = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
68
|
pV.setMargins(margin, margin, margin, 0);
|
69
|
LinearLayout.LayoutParams pL = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
70
|
pL.setMargins(margin, margin, margin, margin);
|
71
|
LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
72
|
pT.setMargins(0,0,0,2*margin);
|
73
|
LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
74
|
pB.setMargins(0,2*margin,0,0);
|
75
|
|
76
|
int num = ImplementedSolversList.NUM_OBJECTS;
|
77
|
RubikActivity ract = (RubikActivity) getContext();
|
78
|
|
79
|
for(int i=0; i<num; i++)
|
80
|
{
|
81
|
ImplementedSolversList solver = ImplementedSolversList.getSolver(i);
|
82
|
int object = solver.getObject();
|
83
|
int title = solver.getTitle();
|
84
|
int description = solver.getDescription();
|
85
|
RubikDialogSolverView pane = new RubikDialogSolverView(ract,this,i,object,title,description, padd, font, (i==num-1?pL:pV),pT,pB);
|
86
|
layout.addView(pane.getView());
|
87
|
}
|
88
|
}
|
89
|
}
|