Revision c02fa107
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/dialogs/RubikDialogStarsExplain.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import android.app.Dialog; |
13 | 13 |
import android.content.DialogInterface; |
14 |
import android.os.Bundle; |
|
15 |
import android.util.DisplayMetrics; |
|
16 | 14 |
import android.util.TypedValue; |
17 |
import android.view.LayoutInflater; |
|
18 | 15 |
import android.view.View; |
19 |
import android.view.Window; |
|
20 | 16 |
import android.widget.Button; |
17 |
import android.widget.TextView; |
|
21 | 18 |
|
22 |
import androidx.annotation.NonNull; |
|
23 | 19 |
import androidx.appcompat.app.AlertDialog; |
24 |
import androidx.appcompat.app.AppCompatDialogFragment; |
|
25 | 20 |
import androidx.fragment.app.FragmentActivity; |
26 | 21 |
|
27 | 22 |
import org.distorted.main.R; |
28 |
import org.distorted.main.RubikActivity; |
|
29 | 23 |
|
30 | 24 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
31 | 25 |
|
32 |
public class RubikDialogStarsExplain extends AppCompatDialogFragment
|
|
26 |
public class RubikDialogStarsExplain extends RubikDialogAbstract
|
|
33 | 27 |
{ |
34 |
@NonNull |
|
35 |
@Override |
|
36 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
|
28 |
public int getResource() |
|
37 | 29 |
{ |
38 |
FragmentActivity act = getActivity(); |
|
39 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
40 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
|
41 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
42 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
|
43 |
final float butSize = displaymetrics.heightPixels * 0.04f; |
|
44 |
final View view = inflater.inflate(R.layout.dialog_stars_explain, null); |
|
30 |
return R.layout.dialog_stars_explain; |
|
31 |
} |
|
45 | 32 |
|
46 |
builder.setCancelable(true);
|
|
33 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
47 | 34 |
|
48 |
builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() |
|
49 |
{ |
|
50 |
@Override |
|
51 |
public void onClick(DialogInterface dialog, int which) { } |
|
52 |
}); |
|
35 |
public int getTitleResource() |
|
36 |
{ |
|
37 |
return -1; |
|
38 |
} |
|
53 | 39 |
|
54 |
builder.setView(view);
|
|
40 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
55 | 41 |
|
56 |
final Dialog dialog = builder.create(); |
|
57 |
dialog.setCanceledOnTouchOutside(false); |
|
58 |
Window window = dialog.getWindow(); |
|
42 |
public boolean hasArgument() |
|
43 |
{ |
|
44 |
return false; |
|
45 |
} |
|
59 | 46 |
|
60 |
if( window!=null ) |
|
61 |
{ |
|
62 |
window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS); |
|
63 |
} |
|
47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
64 | 48 |
|
65 |
dialog.setOnShowListener(new DialogInterface.OnShowListener() |
|
49 |
public void setPositive(AlertDialog.Builder builder) |
|
50 |
{ |
|
51 |
builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() |
|
66 | 52 |
{ |
67 | 53 |
@Override |
68 |
public void onShow(DialogInterface dialog)
|
|
54 |
public void onClick(DialogInterface dialog, int which)
|
|
69 | 55 |
{ |
70 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
71 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, butSize); |
|
56 |
|
|
72 | 57 |
} |
73 | 58 |
}); |
59 |
} |
|
60 |
|
|
61 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
62 |
|
|
63 |
public void setNegative(AlertDialog.Builder builder) |
|
64 |
{ |
|
65 |
|
|
66 |
} |
|
74 | 67 |
|
75 |
return dialog; |
|
68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
69 |
|
|
70 |
public void onShowDialog(DialogInterface dialog, float size) |
|
71 |
{ |
|
72 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
73 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
74 |
} |
|
75 |
|
|
76 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
77 |
|
|
78 |
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size) |
|
79 |
{ |
|
80 |
TextView text = view.findViewById(R.id.stars_dialog_explain); |
|
81 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
76 | 82 |
} |
77 | 83 |
} |
Also available in: Unified diff
Continue unifying all the dialogs under one RubikDialogAbstract.