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.content.DialogInterface;
|
14
|
import android.os.Bundle;
|
15
|
import android.util.DisplayMetrics;
|
16
|
import android.util.TypedValue;
|
17
|
import android.view.LayoutInflater;
|
18
|
import android.view.View;
|
19
|
import android.view.Window;
|
20
|
import android.widget.Button;
|
21
|
|
22
|
import androidx.annotation.NonNull;
|
23
|
import androidx.appcompat.app.AlertDialog;
|
24
|
import androidx.appcompat.app.AppCompatDialogFragment;
|
25
|
import androidx.fragment.app.FragmentActivity;
|
26
|
|
27
|
import org.distorted.main.R;
|
28
|
import org.distorted.main.RubikActivity;
|
29
|
import org.distorted.purchase.PurchaseScreenPane;
|
30
|
|
31
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
32
|
|
33
|
public class RubikDialogStarsSuccess extends AppCompatDialogFragment
|
34
|
{
|
35
|
@NonNull
|
36
|
@Override
|
37
|
public Dialog onCreateDialog(Bundle savedInstanceState)
|
38
|
{
|
39
|
FragmentActivity act = getActivity();
|
40
|
LayoutInflater inflater = act.getLayoutInflater();
|
41
|
AlertDialog.Builder builder = new AlertDialog.Builder(act);
|
42
|
DisplayMetrics displaymetrics = new DisplayMetrics();
|
43
|
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
|
44
|
final float butSize = displaymetrics.widthPixels * RubikActivity.DIALOG_BUTTON_SIZE;
|
45
|
final View view = inflater.inflate(R.layout.dialog_explain_stars, null);
|
46
|
|
47
|
Bundle args = getArguments();
|
48
|
String objectName;
|
49
|
|
50
|
try
|
51
|
{
|
52
|
objectName = args.getString("object");
|
53
|
}
|
54
|
catch(Exception e)
|
55
|
{
|
56
|
objectName = null;
|
57
|
}
|
58
|
|
59
|
builder.setCancelable(true);
|
60
|
|
61
|
builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
|
62
|
{
|
63
|
@Override
|
64
|
public void onClick(DialogInterface dialog, int which) { }
|
65
|
});
|
66
|
|
67
|
builder.setView(view);
|
68
|
|
69
|
final Dialog dialog = builder.create();
|
70
|
dialog.setCanceledOnTouchOutside(false);
|
71
|
Window window = dialog.getWindow();
|
72
|
|
73
|
if( window!=null )
|
74
|
{
|
75
|
window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS);
|
76
|
}
|
77
|
|
78
|
dialog.setOnShowListener(new DialogInterface.OnShowListener()
|
79
|
{
|
80
|
@Override
|
81
|
public void onShow(DialogInterface dialog)
|
82
|
{
|
83
|
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE);
|
84
|
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, butSize);
|
85
|
Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE);
|
86
|
btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, butSize);
|
87
|
}
|
88
|
});
|
89
|
|
90
|
return dialog;
|
91
|
}
|
92
|
}
|