Revision 61a7b812
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/bandaged/BandagedCreatorRenderer.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
import android.opengl.GLSurfaceView; |
26 | 26 |
|
27 |
import org.distorted.dialogs.RubikDialogSaveBandaged; |
|
27 | 28 |
import org.distorted.library.main.DistortedLibrary; |
28 | 29 |
import org.distorted.library.main.DistortedNode; |
29 | 30 |
import org.distorted.library.main.DistortedScreen; |
... | ... | |
316 | 317 |
|
317 | 318 |
public void saveObject() |
318 | 319 |
{ |
319 |
|
|
320 |
BandagedCreatorActivity act = (BandagedCreatorActivity)mView.getContext(); |
|
321 |
RubikDialogSaveBandaged saveDiag = new RubikDialogSaveBandaged(); |
|
322 |
saveDiag.show(act.getSupportFragmentManager(), null); |
|
320 | 323 |
} |
321 | 324 |
|
322 | 325 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/dialogs/RubikDialogSaveBandaged.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2022 Leszek Koltunski // |
|
3 |
// // |
|
4 |
// This file is part of Magic Cube. // |
|
5 |
// // |
|
6 |
// Magic Cube is free software: you can redistribute it and/or modify // |
|
7 |
// it under the terms of the GNU General Public License as published by // |
|
8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
9 |
// (at your option) any later version. // |
|
10 |
// // |
|
11 |
// Magic Cube is distributed in the hope that it will be useful, // |
|
12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
14 |
// GNU General Public License for more details. // |
|
15 |
// // |
|
16 |
// You should have received a copy of the GNU General Public License // |
|
17 |
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. // |
|
18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
19 |
|
|
20 |
package org.distorted.dialogs; |
|
21 |
|
|
22 |
import android.app.Dialog; |
|
23 |
import android.content.DialogInterface; |
|
24 |
import android.os.Bundle; |
|
25 |
import android.util.DisplayMetrics; |
|
26 |
import android.util.TypedValue; |
|
27 |
import android.view.LayoutInflater; |
|
28 |
import android.view.View; |
|
29 |
import android.view.Window; |
|
30 |
import android.view.WindowManager; |
|
31 |
import android.widget.Button; |
|
32 |
import android.widget.TextView; |
|
33 |
|
|
34 |
import androidx.annotation.NonNull; |
|
35 |
import androidx.appcompat.app.AlertDialog; |
|
36 |
import androidx.appcompat.app.AppCompatDialogFragment; |
|
37 |
import androidx.fragment.app.FragmentActivity; |
|
38 |
|
|
39 |
import org.distorted.main.R; |
|
40 |
import org.distorted.main.RubikActivity; |
|
41 |
|
|
42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
43 |
|
|
44 |
public class RubikDialogSaveBandaged extends AppCompatDialogFragment |
|
45 |
{ |
|
46 |
@NonNull |
|
47 |
@Override |
|
48 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
|
49 |
{ |
|
50 |
FragmentActivity act = getActivity(); |
|
51 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
52 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
|
53 |
|
|
54 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
55 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
|
56 |
final float titleSize= displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE; |
|
57 |
final float okSize = displaymetrics.widthPixels * RubikActivity.DIALOG_BUTTON_SIZE; |
|
58 |
|
|
59 |
TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null); |
|
60 |
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize); |
|
61 |
tv.setText( R.string.save_object ); |
|
62 |
builder.setCustomTitle(tv); |
|
63 |
|
|
64 |
final View view = inflater.inflate(R.layout.dialog_save_object, null); |
|
65 |
|
|
66 |
builder.setCancelable(true); |
|
67 |
|
|
68 |
builder.setPositiveButton( R.string.yes, new DialogInterface.OnClickListener() |
|
69 |
{ |
|
70 |
@Override |
|
71 |
public void onClick(DialogInterface dialog, int which) |
|
72 |
{ |
|
73 |
|
|
74 |
} |
|
75 |
}); |
|
76 |
|
|
77 |
builder.setNegativeButton( R.string.no, new DialogInterface.OnClickListener() |
|
78 |
{ |
|
79 |
@Override |
|
80 |
public void onClick(DialogInterface dialog, int which) |
|
81 |
{ |
|
82 |
|
|
83 |
} |
|
84 |
}); |
|
85 |
|
|
86 |
builder.setView(view); |
|
87 |
final Dialog dialog = builder.create(); |
|
88 |
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); |
|
89 |
|
|
90 |
dialog.setCanceledOnTouchOutside(false); |
|
91 |
Window window = dialog.getWindow(); |
|
92 |
|
|
93 |
if( window!=null ) |
|
94 |
{ |
|
95 |
window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS); |
|
96 |
} |
|
97 |
|
|
98 |
dialog.setOnShowListener(new DialogInterface.OnShowListener() |
|
99 |
{ |
|
100 |
@Override |
|
101 |
public void onShow(DialogInterface dialog) |
|
102 |
{ |
|
103 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
104 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize); |
|
105 |
Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE); |
|
106 |
btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize); |
|
107 |
} |
|
108 |
}); |
|
109 |
|
|
110 |
return dialog; |
|
111 |
} |
|
112 |
} |
src/main/java/org/distorted/dialogs/RubikDialogSetName.java | ||
---|---|---|
183 | 183 |
|
184 | 184 |
if( window!=null ) |
185 | 185 |
{ |
186 |
window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS2);
|
|
186 |
window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS); |
|
187 | 187 |
} |
188 | 188 |
|
189 | 189 |
dialog.setOnShowListener(new DialogInterface.OnShowListener() |
src/main/java/org/distorted/main/RubikActivity.java | ||
---|---|---|
95 | 95 |
| View.SYSTEM_UI_FLAG_FULLSCREEN |
96 | 96 |
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; |
97 | 97 |
|
98 |
public static final int FLAGS2= View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
99 |
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; |
|
100 |
|
|
101 | 98 |
private static final int ACTIVITY_NUMBER = 0; |
102 | 99 |
private static final float RATIO_BAR = 0.10f; |
103 | 100 |
private static final float RATIO_INSET= 0.09f; |
src/main/res/layout/dialog_save_object.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
android:layout_width="match_parent" |
|
4 |
android:layout_height="match_parent" |
|
5 |
android:gravity="center_horizontal" |
|
6 |
android:orientation="vertical"> |
|
7 |
|
|
8 |
<LinearLayout |
|
9 |
android:layout_width="fill_parent" |
|
10 |
android:layout_height="fill_parent" |
|
11 |
android:gravity="center|fill_horizontal" |
|
12 |
android:layout_marginLeft="10dp" |
|
13 |
android:layout_marginRight="10dp" |
|
14 |
android:layout_marginTop="0dp" |
|
15 |
android:background="@color/grey" |
|
16 |
android:orientation="vertical"> |
|
17 |
|
|
18 |
<TextView |
|
19 |
android:id="@+id/save_object_text" |
|
20 |
android:layout_width="match_parent" |
|
21 |
android:layout_height="match_parent" |
|
22 |
android:gravity="center" |
|
23 |
android:textSize="24sp" |
|
24 |
android:layout_marginTop="10dp" |
|
25 |
android:layout_marginLeft="10dp" |
|
26 |
android:layout_marginRight="10dp" |
|
27 |
android:layout_marginBottom="10dp" |
|
28 |
android:text="@string/save_object_really"/> |
|
29 |
|
|
30 |
</LinearLayout> |
|
31 |
</LinearLayout> |
src/main/res/values/strings.xml | ||
---|---|---|
38 | 38 |
<string name="success">Success</string> |
39 | 39 |
<string name="view">View</string> |
40 | 40 |
<string name="level_full">Full Scramble</string> |
41 |
<string name="save_object">Save Object</string> |
|
42 |
<string name="save_object_really">Do you want to save this Bandaged 3x3?</string> |
|
41 | 43 |
|
42 | 44 |
<string name="scores">High Scores</string> |
43 | 45 |
<string name="patterns">Pretty Patterns</string> |
Also available in: Unified diff
Bandaged 3x3: saving dialog.