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.util.DisplayMetrics;
|
14
|
import android.view.View;
|
15
|
import android.view.Window;
|
16
|
import android.view.WindowManager;
|
17
|
import android.widget.LinearLayout;
|
18
|
import android.widget.ScrollView;
|
19
|
import android.widget.TextView;
|
20
|
|
21
|
import androidx.fragment.app.FragmentActivity;
|
22
|
|
23
|
import org.distorted.main.R;
|
24
|
import org.distorted.objectlib.metadata.ListObjects;
|
25
|
import org.distorted.solvers.SolverActivity;
|
26
|
import org.distorted.objectlib.solvers.verifiers.ImplementedVerifierList;
|
27
|
import org.distorted.solvers.SolverDescriptions;
|
28
|
|
29
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
30
|
|
31
|
public class DialogSolvers extends DialogAbstract
|
32
|
{
|
33
|
@Override
|
34
|
public void onResume()
|
35
|
{
|
36
|
super.onResume();
|
37
|
|
38
|
Window window = getDialog().getWindow();
|
39
|
|
40
|
if( window!=null )
|
41
|
{
|
42
|
WindowManager.LayoutParams params = window.getAttributes();
|
43
|
params.width = (int)Math.min( mHeight*0.60f,mWidth*0.75f );
|
44
|
window.setAttributes(params);
|
45
|
}
|
46
|
}
|
47
|
|
48
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
49
|
|
50
|
public int getResource() { return R.layout.dialog_scrollable_panes; }
|
51
|
public int getTitleResource() { return R.string.solvers; }
|
52
|
public boolean hasArgument() { return true; }
|
53
|
public int getPositive() { return -1; }
|
54
|
public int getNegative() { return -1; }
|
55
|
public static String getDialogTag() { return "DialogSolvers"; }
|
56
|
public void positiveAction() { }
|
57
|
public void negativeAction() { }
|
58
|
|
59
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
60
|
|
61
|
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
|
62
|
{
|
63
|
int margin= (int)(mHeight*0.010f);
|
64
|
int padd = (int)(mHeight*0.010f);
|
65
|
int font = (int)(mHeight*0.025f);
|
66
|
|
67
|
LinearLayout layout= view.findViewById(R.id.dialog_scrollable_main_layout);
|
68
|
TextView text = view.findViewById(R.id.dialog_scrollable_message);
|
69
|
text.setVisibility(View.GONE);
|
70
|
|
71
|
DisplayMetrics metrics = new DisplayMetrics();
|
72
|
act.getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
73
|
float logicalDensity = metrics.density;
|
74
|
int px = (int) Math.ceil(10*logicalDensity);
|
75
|
ScrollView scroll = view.findViewById(R.id.updates_scroll);
|
76
|
scroll.setPadding(px,0,px,px);
|
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
|
SolverActivity sact = (SolverActivity) getContext();
|
88
|
int objectOrdinal = ListObjects.getObjectIndex(mArgument);
|
89
|
int[] solverOrdinals = ImplementedVerifierList.getSolverOrdinals(objectOrdinal);
|
90
|
int len = solverOrdinals==null ? 0 : solverOrdinals.length;
|
91
|
|
92
|
for(int o=0; o<len; o++ )
|
93
|
{
|
94
|
int ord = solverOrdinals[o];
|
95
|
SolverDescriptions description = SolverDescriptions.getDescription(ord);
|
96
|
|
97
|
if( description!=null )
|
98
|
{
|
99
|
int title=description.getTitle();
|
100
|
int desc=description.getDescription();
|
101
|
DialogSolverView pane=new DialogSolverView(sact, this, ord, title, desc, padd, font, (o == len - 1 ? pL : pV), pT, pB);
|
102
|
layout.addView(pane.getView());
|
103
|
}
|
104
|
}
|
105
|
}
|
106
|
}
|