1 |
d05e7629
|
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 |
|
|
import android.view.Window;
|
15 |
b6cce523
|
Leszek Koltunski
|
import android.view.WindowManager;
|
16 |
24cd23dd
|
Leszek Koltunski
|
import android.widget.LinearLayout;
|
17 |
4d6327a1
|
Leszek Koltunski
|
import android.widget.TextView;
|
18 |
d05e7629
|
Leszek Koltunski
|
|
19 |
|
|
import androidx.fragment.app.FragmentActivity;
|
20 |
|
|
|
21 |
4d6327a1
|
Leszek Koltunski
|
import org.distorted.external.RubikScores;
|
22 |
d05e7629
|
Leszek Koltunski
|
import org.distorted.main.R;
|
23 |
|
|
|
24 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
25 |
|
|
|
26 |
c02fa107
|
Leszek Koltunski
|
public class RubikDialogStarsStatus extends RubikDialogAbstract
|
27 |
d05e7629
|
Leszek Koltunski
|
{
|
28 |
|
|
@Override
|
29 |
c02fa107
|
Leszek Koltunski
|
public void onResume()
|
30 |
d05e7629
|
Leszek Koltunski
|
{
|
31 |
c02fa107
|
Leszek Koltunski
|
super.onResume();
|
32 |
24cd23dd
|
Leszek Koltunski
|
|
33 |
c02fa107
|
Leszek Koltunski
|
Window window = getDialog().getWindow();
|
34 |
24cd23dd
|
Leszek Koltunski
|
|
35 |
f8a21f6b
|
Leszek Koltunski
|
if( window!=null )
|
36 |
c02fa107
|
Leszek Koltunski
|
{
|
37 |
|
|
WindowManager.LayoutParams params = window.getAttributes();
|
38 |
|
|
params.width = (int)Math.min( mHeight*0.65f,mWidth*0.95f );
|
39 |
|
|
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
40 |
|
|
window.setAttributes(params);
|
41 |
|
|
}
|
42 |
|
|
}
|
43 |
24cd23dd
|
Leszek Koltunski
|
|
44 |
c02fa107
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
45 |
24cd23dd
|
Leszek Koltunski
|
|
46 |
f8a21f6b
|
Leszek Koltunski
|
public int getResource() { return R.layout.dialog_stars_status; }
|
47 |
|
|
public int getTitleResource() { return -1; }
|
48 |
|
|
public boolean hasArgument() { return false; }
|
49 |
|
|
public int getPositive() { return R.string.ok; }
|
50 |
|
|
public int getNegative() { return -1; }
|
51 |
d05e7629
|
Leszek Koltunski
|
|
52 |
c02fa107
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
53 |
d05e7629
|
Leszek Koltunski
|
|
54 |
f8a21f6b
|
Leszek Koltunski
|
public void positiveAction()
|
55 |
c02fa107
|
Leszek Koltunski
|
{
|
56 |
|
|
|
57 |
d05e7629
|
Leszek Koltunski
|
}
|
58 |
4d6327a1
|
Leszek Koltunski
|
|
59 |
b6cce523
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
60 |
|
|
|
61 |
f8a21f6b
|
Leszek Koltunski
|
public void negativeAction()
|
62 |
b6cce523
|
Leszek Koltunski
|
{
|
63 |
|
|
|
64 |
c02fa107
|
Leszek Koltunski
|
}
|
65 |
b6cce523
|
Leszek Koltunski
|
|
66 |
4d6327a1
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
67 |
|
|
|
68 |
c02fa107
|
Leszek Koltunski
|
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
|
69 |
4d6327a1
|
Leszek Koltunski
|
{
|
70 |
c02fa107
|
Leszek Koltunski
|
int height = (int)(mHeight*0.110f);
|
71 |
|
|
int margin = (int)(mHeight*0.007f);
|
72 |
|
|
|
73 |
|
|
LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);
|
74 |
|
|
params1.setMargins(margin, margin, margin, margin);
|
75 |
|
|
LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,height);
|
76 |
|
|
params2.setMargins(margin, margin, margin, margin);
|
77 |
|
|
|
78 |
|
|
LinearLayout lm = view.findViewById(R.id.stars_main);
|
79 |
|
|
lm.setPadding(margin,margin,margin,margin);
|
80 |
|
|
|
81 |
|
|
LinearLayout ls = view.findViewById(R.id.stars_strings);
|
82 |
|
|
ls.setLayoutParams(params1);
|
83 |
|
|
LinearLayout l1 = view.findViewById(R.id.stars_layout_1);
|
84 |
|
|
l1.setLayoutParams(params2);
|
85 |
|
|
LinearLayout l2 = view.findViewById(R.id.stars_layout_2);
|
86 |
|
|
l2.setLayoutParams(params2);
|
87 |
|
|
LinearLayout l3 = view.findViewById(R.id.stars_layout_3);
|
88 |
|
|
l3.setLayoutParams(params2);
|
89 |
|
|
|
90 |
4d6327a1
|
Leszek Koltunski
|
int number = RubikScores.getInstance().getNumStars();
|
91 |
|
|
TextView v = view.findViewById(R.id.stars_string1);
|
92 |
|
|
v.setText(getString(R.string.buy_string1,number));
|
93 |
|
|
}
|
94 |
d05e7629
|
Leszek Koltunski
|
}
|