1 |
1cbcc6bf
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2019 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
fdec60a3
|
Leszek Koltunski
|
// This file is part of Magic Cube. //
|
5 |
1cbcc6bf
|
Leszek Koltunski
|
// //
|
6 |
68191e7d
|
Leszek Koltunski
|
// 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 |
1cbcc6bf
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9 |
|
|
|
10 |
1f9772f3
|
Leszek Koltunski
|
package org.distorted.dialogs;
|
11 |
1cbcc6bf
|
Leszek Koltunski
|
|
12 |
|
|
import android.app.Dialog;
|
13 |
|
|
import android.content.DialogInterface;
|
14 |
1780dcb0
|
Leszek Koltunski
|
import android.content.pm.PackageInfo;
|
15 |
|
|
import android.content.pm.PackageManager;
|
16 |
1cbcc6bf
|
Leszek Koltunski
|
import android.os.Bundle;
|
17 |
66e777b0
|
Leszek Koltunski
|
import androidx.annotation.NonNull;
|
18 |
|
|
import androidx.fragment.app.FragmentActivity;
|
19 |
|
|
import androidx.appcompat.app.AlertDialog;
|
20 |
|
|
import androidx.appcompat.app.AppCompatDialogFragment;
|
21 |
703aee64
|
Leszek Koltunski
|
|
22 |
|
|
import android.text.method.LinkMovementMethod;
|
23 |
1780dcb0
|
Leszek Koltunski
|
import android.text.method.MovementMethod;
|
24 |
2eb74743
|
Leszek Koltunski
|
import android.util.DisplayMetrics;
|
25 |
|
|
import android.util.TypedValue;
|
26 |
1cbcc6bf
|
Leszek Koltunski
|
import android.view.LayoutInflater;
|
27 |
|
|
import android.view.View;
|
28 |
4235de9b
|
Leszek Koltunski
|
import android.view.Window;
|
29 |
2eb74743
|
Leszek Koltunski
|
import android.widget.Button;
|
30 |
0fd3ac1f
|
Leszek Koltunski
|
import android.widget.TextView;
|
31 |
1cbcc6bf
|
Leszek Koltunski
|
|
32 |
1f9772f3
|
Leszek Koltunski
|
import org.distorted.main.R;
|
33 |
2eb74743
|
Leszek Koltunski
|
import org.distorted.main.RubikActivity;
|
34 |
211b48f2
|
Leszek Koltunski
|
|
35 |
1cbcc6bf
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
36 |
|
|
|
37 |
0fd3ac1f
|
Leszek Koltunski
|
public class RubikDialogAbout extends AppCompatDialogFragment
|
38 |
1cbcc6bf
|
Leszek Koltunski
|
{
|
39 |
|
|
@NonNull
|
40 |
|
|
@Override
|
41 |
|
|
public Dialog onCreateDialog(Bundle savedInstanceState)
|
42 |
|
|
{
|
43 |
|
|
FragmentActivity act = getActivity();
|
44 |
0fd3ac1f
|
Leszek Koltunski
|
LayoutInflater inflater = act.getLayoutInflater();
|
45 |
1cbcc6bf
|
Leszek Koltunski
|
AlertDialog.Builder builder = new AlertDialog.Builder(act);
|
46 |
|
|
|
47 |
2eb74743
|
Leszek Koltunski
|
DisplayMetrics displaymetrics = new DisplayMetrics();
|
48 |
|
|
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
|
49 |
|
|
final float titleSize= displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE;
|
50 |
eb376d3a
|
Leszek Koltunski
|
final float okSize = displaymetrics.widthPixels * RubikActivity.DIALOG_BUTTON_SIZE;
|
51 |
2eb74743
|
Leszek Koltunski
|
final float textSize = displaymetrics.widthPixels * RubikActivity.MENU_SMALL_TEXT_SIZE;
|
52 |
|
|
|
53 |
0fd3ac1f
|
Leszek Koltunski
|
TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null);
|
54 |
2eb74743
|
Leszek Koltunski
|
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
|
55 |
4235de9b
|
Leszek Koltunski
|
tv.setText(R.string.about);
|
56 |
0fd3ac1f
|
Leszek Koltunski
|
builder.setCustomTitle(tv);
|
57 |
|
|
|
58 |
|
|
builder.setCancelable(true);
|
59 |
1cbcc6bf
|
Leszek Koltunski
|
builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
|
60 |
|
|
{
|
61 |
|
|
@Override
|
62 |
|
|
public void onClick(DialogInterface dialog, int which)
|
63 |
|
|
{
|
64 |
|
|
|
65 |
|
|
}
|
66 |
|
|
});
|
67 |
|
|
|
68 |
0fd3ac1f
|
Leszek Koltunski
|
final View view = inflater.inflate(R.layout.dialog_about, null);
|
69 |
|
|
TextView text = view.findViewById(R.id.about_version);
|
70 |
329c0aeb
|
Leszek Koltunski
|
String appName = getString(R.string.app_name);
|
71 |
1780dcb0
|
Leszek Koltunski
|
|
72 |
2eb74743
|
Leszek Koltunski
|
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
73 |
b1e9596b
|
Leszek Koltunski
|
text.setText(getString(R.string.ap_placeholder,appName, getAppVers(act)));
|
74 |
703aee64
|
Leszek Koltunski
|
|
75 |
1780dcb0
|
Leszek Koltunski
|
MovementMethod mm = LinkMovementMethod.getInstance();
|
76 |
703aee64
|
Leszek Koltunski
|
TextView text2 = view.findViewById(R.id.about_section2);
|
77 |
2eb74743
|
Leszek Koltunski
|
text2.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
78 |
1780dcb0
|
Leszek Koltunski
|
text2.setMovementMethod(mm);
|
79 |
|
|
TextView text3 = view.findViewById(R.id.about_section3);
|
80 |
2eb74743
|
Leszek Koltunski
|
text3.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
81 |
703aee64
|
Leszek Koltunski
|
|
82 |
b1e9596b
|
Leszek Koltunski
|
TextView text4 = view.findViewById(R.id.about_section4);
|
83 |
|
|
|
84 |
|
|
if( RubikActivity.localeIsChinese() )
|
85 |
|
|
{
|
86 |
|
|
text4.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
87 |
|
|
text4.setMovementMethod(mm);
|
88 |
|
|
}
|
89 |
|
|
else
|
90 |
|
|
{
|
91 |
|
|
text4.setVisibility(View.GONE);
|
92 |
6a083c6a
|
Leszek Koltunski
|
/*
|
93 |
|
|
String version = DistortedLibrary.getDriverVersion();
|
94 |
5d5ed376
|
Leszek Koltunski
|
String vendor = DistortedLibrary.getDriverVendor();
|
95 |
|
|
String renderer= DistortedLibrary.getDriverRenderer();
|
96 |
|
|
|
97 |
|
|
String mess = "Version: " + version + "\nVendor: "+vendor+"\nRenderer: "+renderer;
|
98 |
|
|
text4.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
99 |
|
|
text4.setText(mess);
|
100 |
6a083c6a
|
Leszek Koltunski
|
*/
|
101 |
b1e9596b
|
Leszek Koltunski
|
}
|
102 |
|
|
|
103 |
1cbcc6bf
|
Leszek Koltunski
|
builder.setView(view);
|
104 |
|
|
|
105 |
85248b04
|
Leszek Koltunski
|
Dialog dialog = builder.create();
|
106 |
|
|
dialog.setCanceledOnTouchOutside(false);
|
107 |
|
|
Window window = dialog.getWindow();
|
108 |
|
|
|
109 |
|
|
if( window!=null )
|
110 |
|
|
{
|
111 |
ffd68f35
|
Leszek Koltunski
|
window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS);
|
112 |
85248b04
|
Leszek Koltunski
|
}
|
113 |
|
|
|
114 |
2eb74743
|
Leszek Koltunski
|
dialog.setOnShowListener(new DialogInterface.OnShowListener()
|
115 |
|
|
{
|
116 |
|
|
@Override
|
117 |
|
|
public void onShow(DialogInterface dialog)
|
118 |
|
|
{
|
119 |
|
|
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE);
|
120 |
|
|
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize);
|
121 |
|
|
}
|
122 |
|
|
});
|
123 |
|
|
|
124 |
85248b04
|
Leszek Koltunski
|
return dialog;
|
125 |
1cbcc6bf
|
Leszek Koltunski
|
}
|
126 |
b1e9596b
|
Leszek Koltunski
|
|
127 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
128 |
|
|
|
129 |
|
|
private String getAppVers(FragmentActivity act)
|
130 |
|
|
{
|
131 |
|
|
try
|
132 |
|
|
{
|
133 |
|
|
PackageInfo pInfo = act.getPackageManager().getPackageInfo( act.getPackageName(), 0);
|
134 |
|
|
return pInfo.versionName;
|
135 |
|
|
}
|
136 |
|
|
catch (PackageManager.NameNotFoundException e)
|
137 |
|
|
{
|
138 |
|
|
return "unknown";
|
139 |
|
|
}
|
140 |
|
|
}
|
141 |
1cbcc6bf
|
Leszek Koltunski
|
}
|