1 |
3bedda30
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 |
7e9d918b
|
leszek
|
import org.distorted.solvers.SolverActivity;
|
26 |
94ce8e53
|
leszek
|
import org.distorted.objectlib.solvers.verifiers.SolvingList;
|
27 |
3bedda30
|
leszek
|
|
28 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
29 |
|
|
|
30 |
8477cf44
|
leszek
|
public class DialogSolvers extends DialogAbstract
|
31 |
3bedda30
|
leszek
|
{
|
32 |
|
|
@Override
|
33 |
|
|
public void onResume()
|
34 |
|
|
{
|
35 |
|
|
super.onResume();
|
36 |
|
|
|
37 |
|
|
Window window = getDialog().getWindow();
|
38 |
|
|
|
39 |
|
|
if( window!=null )
|
40 |
|
|
{
|
41 |
|
|
WindowManager.LayoutParams params = window.getAttributes();
|
42 |
|
|
params.width = (int)Math.min( mHeight*0.60f,mWidth*0.75f );
|
43 |
|
|
window.setAttributes(params);
|
44 |
|
|
}
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
48 |
|
|
|
49 |
|
|
public int getResource() { return R.layout.dialog_scrollable_panes; }
|
50 |
d00b5346
|
leszek
|
public int getTitleResource() { return R.string.solvers; }
|
51 |
3bedda30
|
leszek
|
public boolean hasArgument() { return true; }
|
52 |
|
|
public int getPositive() { return -1; }
|
53 |
|
|
public int getNegative() { return -1; }
|
54 |
|
|
public static String getDialogTag() { return "DialogSolvers"; }
|
55 |
|
|
public void positiveAction() { }
|
56 |
|
|
public void negativeAction() { }
|
57 |
|
|
|
58 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
59 |
|
|
|
60 |
|
|
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
|
61 |
|
|
{
|
62 |
|
|
int margin= (int)(mHeight*0.010f);
|
63 |
|
|
int padd = (int)(mHeight*0.010f);
|
64 |
|
|
int font = (int)(mHeight*0.025f);
|
65 |
|
|
|
66 |
|
|
LinearLayout layout= view.findViewById(R.id.dialog_scrollable_main_layout);
|
67 |
|
|
TextView text = view.findViewById(R.id.dialog_scrollable_message);
|
68 |
|
|
text.setVisibility(View.GONE);
|
69 |
|
|
|
70 |
|
|
DisplayMetrics metrics = new DisplayMetrics();
|
71 |
|
|
act.getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
72 |
|
|
float logicalDensity = metrics.density;
|
73 |
|
|
int px = (int) Math.ceil(10*logicalDensity);
|
74 |
|
|
ScrollView scroll = view.findViewById(R.id.updates_scroll);
|
75 |
|
|
scroll.setPadding(px,0,px,px);
|
76 |
|
|
|
77 |
|
|
LinearLayout.LayoutParams pV = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
78 |
|
|
pV.setMargins(margin, margin, margin, 0);
|
79 |
|
|
LinearLayout.LayoutParams pL = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
80 |
|
|
pL.setMargins(margin, margin, margin, margin);
|
81 |
|
|
LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
82 |
|
|
pT.setMargins(0,0,0,2*margin);
|
83 |
|
|
LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
84 |
|
|
pB.setMargins(0,2*margin,0,0);
|
85 |
|
|
|
86 |
|
|
SolverActivity sact = (SolverActivity) getContext();
|
87 |
|
|
int objectOrdinal = ListObjects.getObjectIndex(mArgument);
|
88 |
|
|
int[] solverOrdinals = SolvingList.getSolverOrdinals(objectOrdinal);
|
89 |
|
|
int len = solverOrdinals==null ? 0 : solverOrdinals.length;
|
90 |
|
|
|
91 |
|
|
for(int o=0; o<len; o++ )
|
92 |
|
|
{
|
93 |
|
|
int ord = solverOrdinals[o];
|
94 |
|
|
SolvingList solver = SolvingList.getSolver(ord);
|
95 |
|
|
int title = solver.getTitle();
|
96 |
|
|
int description = solver.getDescription();
|
97 |
8477cf44
|
leszek
|
DialogSolverView pane = new DialogSolverView(sact,this,ord,title,description, padd, font, (o==len-1?pL:pV),pT,pB);
|
98 |
3bedda30
|
leszek
|
layout.addView(pane.getView());
|
99 |
|
|
}
|
100 |
|
|
}
|
101 |
|
|
}
|