Revision b5c2adb4
Added by Leszek Koltunski almost 3 years ago
| src/main/java/org/distorted/dialogs/RubikDialogAbandon.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; |
| 21 | 17 |
|
| 22 |
import androidx.annotation.NonNull; |
|
| 23 | 18 |
import androidx.appcompat.app.AlertDialog; |
| 24 |
import androidx.appcompat.app.AppCompatDialogFragment; |
|
| 25 | 19 |
import androidx.fragment.app.FragmentActivity; |
| 26 | 20 |
|
| 27 | 21 |
import org.distorted.main.R; |
| ... | ... | |
| 30 | 24 |
|
| 31 | 25 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 32 | 26 |
|
| 33 |
public class RubikDialogAbandon extends AppCompatDialogFragment
|
|
| 27 |
public class RubikDialogAbandon extends RubikDialogAbstract
|
|
| 34 | 28 |
{
|
| 35 |
@NonNull |
|
| 36 |
@Override |
|
| 37 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
|
| 29 |
public int getResource() |
|
| 38 | 30 |
{
|
| 39 |
final RubikActivity ract = (RubikActivity)getContext(); |
|
| 31 |
return R.layout.abandon_solve; |
|
| 32 |
} |
|
| 40 | 33 |
|
| 41 |
FragmentActivity act = getActivity(); |
|
| 42 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
| 43 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
|
| 34 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 44 | 35 |
|
| 45 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 46 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
|
| 47 |
final float butSize = displaymetrics.heightPixels * 0.04f; |
|
| 36 |
public int getTitleResource() |
|
| 37 |
{
|
|
| 38 |
return -1; |
|
| 39 |
} |
|
| 40 |
|
|
| 41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 48 | 42 |
|
| 49 |
final View view = inflater.inflate(R.layout.abandon_solve, null);
|
|
| 50 |
builder.setView(view);
|
|
| 51 |
builder.setCancelable(true);
|
|
| 43 |
public void setPositive(AlertDialog.Builder builder)
|
|
| 44 |
{
|
|
| 45 |
final RubikActivity ract = (RubikActivity)getContext();
|
|
| 52 | 46 |
|
| 53 | 47 |
builder.setPositiveButton( R.string.yes, new DialogInterface.OnClickListener() |
| 54 | 48 |
{
|
| ... | ... | |
| 58 | 52 |
ScreenList.goBack(ract); |
| 59 | 53 |
} |
| 60 | 54 |
}); |
| 55 |
} |
|
| 61 | 56 |
|
| 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 58 |
|
|
| 59 |
public void setNegative(AlertDialog.Builder builder) |
|
| 60 |
{
|
|
| 62 | 61 |
builder.setNegativeButton( R.string.no, new DialogInterface.OnClickListener() |
| 63 | 62 |
{
|
| 64 | 63 |
@Override |
| 65 | 64 |
public void onClick(DialogInterface dialog, int which) |
| 66 | 65 |
{
|
| 67 |
// empty |
|
| 66 |
|
|
| 68 | 67 |
} |
| 69 | 68 |
}); |
| 69 |
} |
|
| 70 | 70 |
|
| 71 |
final Dialog dialog = builder.create(); |
|
| 72 |
dialog.setCanceledOnTouchOutside(false); |
|
| 73 |
Window window = dialog.getWindow(); |
|
| 71 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 74 | 72 |
|
| 75 |
if( window!=null ) |
|
| 76 |
{
|
|
| 77 |
window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS); |
|
| 78 |
} |
|
| 73 |
public void onShowDialog(DialogInterface dialog, float size) |
|
| 74 |
{
|
|
| 75 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
| 76 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 77 |
Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE); |
|
| 78 |
btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 79 |
} |
|
| 79 | 80 |
|
| 80 |
dialog.setOnShowListener(new DialogInterface.OnShowListener() |
|
| 81 |
{
|
|
| 82 |
@Override |
|
| 83 |
public void onShow(DialogInterface dialog) |
|
| 84 |
{
|
|
| 85 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
| 86 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, butSize); |
|
| 87 |
Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE); |
|
| 88 |
btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, butSize); |
|
| 89 |
} |
|
| 90 |
}); |
|
| 81 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 82 |
|
|
| 83 |
public void prepareBody(View view, FragmentActivity act, float size) |
|
| 84 |
{
|
|
| 91 | 85 |
|
| 92 |
return dialog; |
|
| 93 | 86 |
} |
| 94 | 87 |
} |
| src/main/java/org/distorted/dialogs/RubikDialogAbout.java | ||
|---|---|---|
| 13 | 13 |
import android.content.DialogInterface; |
| 14 | 14 |
import android.content.pm.PackageInfo; |
| 15 | 15 |
import android.content.pm.PackageManager; |
| 16 |
import android.os.Bundle; |
|
| 17 |
import androidx.annotation.NonNull; |
|
| 18 | 16 |
import androidx.fragment.app.FragmentActivity; |
| 19 | 17 |
import androidx.appcompat.app.AlertDialog; |
| 20 |
import androidx.appcompat.app.AppCompatDialogFragment; |
|
| 21 | 18 |
|
| 22 | 19 |
import android.text.method.LinkMovementMethod; |
| 23 | 20 |
import android.text.method.MovementMethod; |
| 24 |
import android.util.DisplayMetrics; |
|
| 25 | 21 |
import android.util.TypedValue; |
| 26 |
import android.view.LayoutInflater; |
|
| 27 | 22 |
import android.view.View; |
| 28 |
import android.view.Window; |
|
| 29 | 23 |
import android.widget.Button; |
| 30 | 24 |
import android.widget.TextView; |
| 31 | 25 |
|
| ... | ... | |
| 34 | 28 |
|
| 35 | 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 36 | 30 |
|
| 37 |
public class RubikDialogAbout extends AppCompatDialogFragment
|
|
| 31 |
public class RubikDialogAbout extends RubikDialogAbstract
|
|
| 38 | 32 |
{
|
| 39 |
@NonNull |
|
| 40 |
@Override |
|
| 41 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
|
| 33 |
public int getResource() |
|
| 34 |
{
|
|
| 35 |
return R.layout.dialog_about; |
|
| 36 |
} |
|
| 37 |
|
|
| 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 39 |
|
|
| 40 |
public int getTitleResource() |
|
| 41 |
{
|
|
| 42 |
return R.string.about; |
|
| 43 |
} |
|
| 44 |
|
|
| 45 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 46 |
|
|
| 47 |
public void setPositive(AlertDialog.Builder builder) |
|
| 42 | 48 |
{
|
| 43 |
FragmentActivity act = getActivity(); |
|
| 44 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
| 45 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
|
| 46 |
|
|
| 47 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 48 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
|
| 49 |
int h = displaymetrics.heightPixels; |
|
| 50 |
final float titleSize= h * 0.032f; |
|
| 51 |
final float okSize = h * 0.040f; |
|
| 52 |
final float textSize = h * 0.025f; |
|
| 53 |
|
|
| 54 |
TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null); |
|
| 55 |
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize); |
|
| 56 |
tv.setText(R.string.about); |
|
| 57 |
builder.setCustomTitle(tv); |
|
| 58 |
|
|
| 59 |
builder.setCancelable(true); |
|
| 60 | 49 |
builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() |
| 61 | 50 |
{
|
| 62 | 51 |
@Override |
| ... | ... | |
| 65 | 54 |
|
| 66 | 55 |
} |
| 67 | 56 |
}); |
| 57 |
} |
|
| 58 |
|
|
| 59 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 60 |
|
|
| 61 |
public void setNegative(AlertDialog.Builder builder) |
|
| 62 |
{
|
|
| 63 |
|
|
| 64 |
} |
|
| 65 |
|
|
| 66 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 68 | 67 |
|
| 69 |
final View view = inflater.inflate(R.layout.dialog_about, null); |
|
| 68 |
public void onShowDialog(DialogInterface dialog, float size) |
|
| 69 |
{
|
|
| 70 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
| 71 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 72 |
} |
|
| 73 |
|
|
| 74 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 75 |
|
|
| 76 |
public void prepareBody(View view, FragmentActivity act, float size) |
|
| 77 |
{
|
|
| 70 | 78 |
TextView text = view.findViewById(R.id.about_version); |
| 71 | 79 |
String appName = getString(R.string.app_name); |
| 72 | 80 |
|
| 73 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
|
| 81 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
|
|
| 74 | 82 |
text.setText(getString(R.string.ap_placeholder,appName, getAppVers(act))); |
| 75 | 83 |
|
| 76 | 84 |
MovementMethod mm = LinkMovementMethod.getInstance(); |
| 77 | 85 |
TextView text2 = view.findViewById(R.id.about_section2); |
| 78 |
text2.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
|
| 86 |
text2.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
|
|
| 79 | 87 |
text2.setMovementMethod(mm); |
| 80 | 88 |
TextView text3 = view.findViewById(R.id.about_section3); |
| 81 |
text3.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
|
| 89 |
text3.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
|
|
| 82 | 90 |
|
| 83 | 91 |
TextView text4 = view.findViewById(R.id.about_section4); |
| 84 | 92 |
|
| 85 | 93 |
if( RubikActivity.localeIsChinese() ) |
| 86 | 94 |
{
|
| 87 |
text4.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
|
| 95 |
text4.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
|
|
| 88 | 96 |
text4.setMovementMethod(mm); |
| 89 | 97 |
} |
| 90 | 98 |
else |
| 91 | 99 |
{
|
| 92 | 100 |
text4.setVisibility(View.GONE); |
| 93 |
/* |
|
| 94 |
String version = DistortedLibrary.getDriverVersion(); |
|
| 95 |
String vendor = DistortedLibrary.getDriverVendor(); |
|
| 96 |
String renderer= DistortedLibrary.getDriverRenderer(); |
|
| 97 |
|
|
| 98 |
String mess = "Version: " + version + "\nVendor: "+vendor+"\nRenderer: "+renderer; |
|
| 99 |
text4.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
| 100 |
text4.setText(mess); |
|
| 101 |
*/ |
|
| 102 |
} |
|
| 103 |
|
|
| 104 |
builder.setView(view); |
|
| 105 |
|
|
| 106 |
Dialog dialog = builder.create(); |
|
| 107 |
dialog.setCanceledOnTouchOutside(false); |
|
| 108 |
Window window = dialog.getWindow(); |
|
| 109 |
|
|
| 110 |
if( window!=null ) |
|
| 111 |
{
|
|
| 112 |
window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS); |
|
| 113 | 101 |
} |
| 114 |
|
|
| 115 |
dialog.setOnShowListener(new DialogInterface.OnShowListener() |
|
| 116 |
{
|
|
| 117 |
@Override |
|
| 118 |
public void onShow(DialogInterface dialog) |
|
| 119 |
{
|
|
| 120 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
| 121 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize); |
|
| 122 |
} |
|
| 123 |
}); |
|
| 124 |
|
|
| 125 |
return dialog; |
|
| 126 | 102 |
} |
| 127 | 103 |
|
| 128 | 104 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/dialogs/RubikDialogAbstract.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2023 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.TextView; |
|
| 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 |
|
|
| 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 31 |
|
|
| 32 |
abstract public class RubikDialogAbstract extends AppCompatDialogFragment |
|
| 33 |
{
|
|
| 34 |
protected float mTitleSize, mButSize, mTextSize; |
|
| 35 |
|
|
| 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 37 |
|
|
| 38 |
abstract int getResource(); |
|
| 39 |
abstract int getTitleResource(); |
|
| 40 |
abstract void setPositive(AlertDialog.Builder builder); |
|
| 41 |
abstract void setNegative(AlertDialog.Builder builder); |
|
| 42 |
abstract void onShowDialog(DialogInterface dialog, float size); |
|
| 43 |
abstract void prepareBody(View view, FragmentActivity act, float size); |
|
| 44 |
|
|
| 45 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 46 |
|
|
| 47 |
@NonNull |
|
| 48 |
@Override |
|
| 49 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
|
| 50 |
{
|
|
| 51 |
FragmentActivity act = getActivity(); |
|
| 52 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
| 53 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
|
| 54 |
|
|
| 55 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 56 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
|
| 57 |
int h = displaymetrics.heightPixels; |
|
| 58 |
mTitleSize= h * 0.032f; |
|
| 59 |
mButSize = h * 0.040f; |
|
| 60 |
mTextSize = h * 0.025f; |
|
| 61 |
|
|
| 62 |
final View view = inflater.inflate(getResource(), null); |
|
| 63 |
builder.setView(view); |
|
| 64 |
builder.setCancelable(true); |
|
| 65 |
|
|
| 66 |
int title = getTitleResource(); |
|
| 67 |
if( title>=0 ) |
|
| 68 |
{
|
|
| 69 |
TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null); |
|
| 70 |
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTitleSize); |
|
| 71 |
tv.setText(title); |
|
| 72 |
builder.setCustomTitle(tv); |
|
| 73 |
} |
|
| 74 |
|
|
| 75 |
setPositive(builder); |
|
| 76 |
setNegative(builder); |
|
| 77 |
prepareBody(view,act,mTextSize); |
|
| 78 |
|
|
| 79 |
Dialog dialog = builder.create(); |
|
| 80 |
dialog.setCanceledOnTouchOutside(false); |
|
| 81 |
Window window = dialog.getWindow(); |
|
| 82 |
|
|
| 83 |
if( window!=null ) |
|
| 84 |
{
|
|
| 85 |
window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS); |
|
| 86 |
} |
|
| 87 |
|
|
| 88 |
dialog.setOnShowListener(new DialogInterface.OnShowListener() |
|
| 89 |
{
|
|
| 90 |
@Override |
|
| 91 |
public void onShow(DialogInterface dialog) |
|
| 92 |
{
|
|
| 93 |
onShowDialog(dialog,mButSize); |
|
| 94 |
} |
|
| 95 |
}); |
|
| 96 |
|
|
| 97 |
return dialog; |
|
| 98 |
} |
|
| 99 |
} |
|
| src/main/java/org/distorted/dialogs/RubikDialogBandagedDelete.java | ||
|---|---|---|
| 12 | 12 |
import android.app.Dialog; |
| 13 | 13 |
import android.content.DialogInterface; |
| 14 | 14 |
import android.os.Bundle; |
| 15 |
import android.util.DisplayMetrics; |
|
| 16 | 15 |
import android.util.TypedValue; |
| 17 |
import android.view.LayoutInflater; |
|
| 18 | 16 |
import android.view.View; |
| 19 |
import android.view.Window; |
|
| 20 | 17 |
import android.widget.Button; |
| 21 | 18 |
import android.widget.TextView; |
| 22 | 19 |
|
| 23 |
import androidx.annotation.NonNull; |
|
| 24 | 20 |
import androidx.appcompat.app.AlertDialog; |
| 25 |
import androidx.appcompat.app.AppCompatDialogFragment; |
|
| 26 | 21 |
import androidx.fragment.app.FragmentActivity; |
| 27 | 22 |
|
| 28 | 23 |
import org.distorted.bandaged.BandagedCreatorActivity; |
| 29 | 24 |
import org.distorted.main.R; |
| 30 |
import org.distorted.main.RubikActivity; |
|
| 31 | 25 |
|
| 32 | 26 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 33 | 27 |
|
| 34 |
public class RubikDialogBandagedDelete extends AppCompatDialogFragment
|
|
| 28 |
public class RubikDialogBandagedDelete extends RubikDialogAbstract
|
|
| 35 | 29 |
{
|
| 36 |
@NonNull |
|
| 37 |
@Override |
|
| 38 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
|
| 30 |
public int getResource() |
|
| 39 | 31 |
{
|
| 40 |
FragmentActivity act = getActivity(); |
|
| 41 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
| 42 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
|
| 43 |
|
|
| 44 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 45 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
|
| 46 |
int h = displaymetrics.heightPixels; |
|
| 47 |
final float titleSize= h * 0.032f; |
|
| 48 |
final float okSize = h * 0.040f; |
|
| 49 |
|
|
| 50 |
TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null); |
|
| 51 |
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize); |
|
| 52 |
tv.setText( R.string.delete_object ); |
|
| 53 |
builder.setCustomTitle(tv); |
|
| 32 |
return R.layout.dialog_delete_object; |
|
| 33 |
} |
|
| 54 | 34 |
|
| 55 |
final View view = inflater.inflate(R.layout.dialog_delete_object, null);
|
|
| 35 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
| 56 | 36 |
|
| 57 |
TextView save = view.findViewById(R.id.delete_object_text); |
|
| 58 |
save.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize); |
|
| 37 |
public int getTitleResource() |
|
| 38 |
{
|
|
| 39 |
return R.string.delete_object; |
|
| 40 |
} |
|
| 59 | 41 |
|
| 60 |
builder.setCancelable(true);
|
|
| 42 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
| 61 | 43 |
|
| 44 |
public void setPositive(AlertDialog.Builder builder) |
|
| 45 |
{
|
|
| 62 | 46 |
Bundle args = getArguments(); |
| 63 | 47 |
String name; |
| 64 | 48 |
|
| ... | ... | |
| 81 | 65 |
if( bact!=null ) bact.deleteObject(objectName); |
| 82 | 66 |
} |
| 83 | 67 |
}); |
| 68 |
} |
|
| 69 |
|
|
| 70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 84 | 71 |
|
| 72 |
public void setNegative(AlertDialog.Builder builder) |
|
| 73 |
{
|
|
| 85 | 74 |
builder.setNegativeButton( R.string.no, new DialogInterface.OnClickListener() |
| 86 | 75 |
{
|
| 87 | 76 |
@Override |
| 88 | 77 |
public void onClick(DialogInterface dialog, int which) |
| 89 | 78 |
{
|
| 90 |
// empty |
|
| 79 |
|
|
| 91 | 80 |
} |
| 92 | 81 |
}); |
| 82 |
} |
|
| 93 | 83 |
|
| 94 |
builder.setView(view); |
|
| 95 |
final Dialog dialog = builder.create(); |
|
| 96 |
|
|
| 97 |
dialog.setCanceledOnTouchOutside(false); |
|
| 98 |
Window window = dialog.getWindow(); |
|
| 84 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 99 | 85 |
|
| 100 |
if( window!=null ) |
|
| 101 |
{
|
|
| 102 |
window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS); |
|
| 103 |
} |
|
| 86 |
public void onShowDialog(DialogInterface dialog, float size) |
|
| 87 |
{
|
|
| 88 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
| 89 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 90 |
Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE); |
|
| 91 |
btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 92 |
} |
|
| 104 | 93 |
|
| 105 |
dialog.setOnShowListener(new DialogInterface.OnShowListener() |
|
| 106 |
{
|
|
| 107 |
@Override |
|
| 108 |
public void onShow(DialogInterface dialog) |
|
| 109 |
{
|
|
| 110 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
| 111 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize); |
|
| 112 |
Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE); |
|
| 113 |
btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize); |
|
| 114 |
} |
|
| 115 |
}); |
|
| 94 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 116 | 95 |
|
| 117 |
return dialog; |
|
| 96 |
public void prepareBody(View view, FragmentActivity act, float size) |
|
| 97 |
{
|
|
| 98 |
TextView save = view.findViewById(R.id.delete_object_text); |
|
| 99 |
save.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 118 | 100 |
} |
| 119 | 101 |
|
| 120 | 102 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/dialogs/RubikDialogBandagedSave.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; |
| 21 | 17 |
import android.widget.TextView; |
| 22 | 18 |
|
| 23 |
import androidx.annotation.NonNull; |
|
| 24 | 19 |
import androidx.appcompat.app.AlertDialog; |
| 25 |
import androidx.appcompat.app.AppCompatDialogFragment; |
|
| 26 | 20 |
import androidx.fragment.app.FragmentActivity; |
| 27 | 21 |
|
| 28 | 22 |
import org.distorted.bandaged.BandagedCreatorActivity; |
| 29 | 23 |
import org.distorted.bandaged.BandagedCreatorRenderer; |
| 30 | 24 |
import org.distorted.main.R; |
| 31 |
import org.distorted.main.RubikActivity; |
|
| 32 | 25 |
|
| 33 | 26 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 34 | 27 |
|
| 35 |
public class RubikDialogBandagedSave extends AppCompatDialogFragment
|
|
| 28 |
public class RubikDialogBandagedSave extends RubikDialogAbstract
|
|
| 36 | 29 |
{
|
| 37 |
@NonNull |
|
| 38 |
@Override |
|
| 39 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
|
| 30 |
public int getResource() |
|
| 40 | 31 |
{
|
| 41 |
FragmentActivity act = getActivity(); |
|
| 42 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
| 43 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
|
| 44 |
|
|
| 45 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 46 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
|
| 47 |
int h = displaymetrics.heightPixels; |
|
| 48 |
final float titleSize= h * 0.032f; |
|
| 49 |
final float okSize = h * 0.040f; |
|
| 50 |
|
|
| 51 |
TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null); |
|
| 52 |
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize); |
|
| 53 |
tv.setText( R.string.save_object ); |
|
| 54 |
builder.setCustomTitle(tv); |
|
| 32 |
return R.layout.dialog_save_object; |
|
| 33 |
} |
|
| 55 | 34 |
|
| 56 |
final View view = inflater.inflate(R.layout.dialog_save_object, null);
|
|
| 35 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
| 57 | 36 |
|
| 58 |
TextView save = view.findViewById(R.id.save_object_text); |
|
| 59 |
save.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize); |
|
| 37 |
public int getTitleResource() |
|
| 38 |
{
|
|
| 39 |
return R.string.save_object; |
|
| 40 |
} |
|
| 60 | 41 |
|
| 61 |
builder.setCancelable(true);
|
|
| 42 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
| 62 | 43 |
|
| 44 |
public void setPositive(AlertDialog.Builder builder) |
|
| 45 |
{
|
|
| 63 | 46 |
builder.setPositiveButton( R.string.yes, new DialogInterface.OnClickListener() |
| 64 | 47 |
{
|
| 65 | 48 |
@Override |
| ... | ... | |
| 74 | 57 |
} |
| 75 | 58 |
} |
| 76 | 59 |
}); |
| 60 |
} |
|
| 77 | 61 |
|
| 62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 63 |
|
|
| 64 |
public void setNegative(AlertDialog.Builder builder) |
|
| 65 |
{
|
|
| 78 | 66 |
builder.setNegativeButton( R.string.no, new DialogInterface.OnClickListener() |
| 79 | 67 |
{
|
| 80 | 68 |
@Override |
| 81 | 69 |
public void onClick(DialogInterface dialog, int which) |
| 82 | 70 |
{
|
| 83 |
// empty |
|
| 71 |
|
|
| 84 | 72 |
} |
| 85 | 73 |
}); |
| 74 |
} |
|
| 86 | 75 |
|
| 87 |
builder.setView(view); |
|
| 88 |
final Dialog dialog = builder.create(); |
|
| 89 |
|
|
| 90 |
dialog.setCanceledOnTouchOutside(false); |
|
| 91 |
Window window = dialog.getWindow(); |
|
| 76 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 92 | 77 |
|
| 93 |
if( window!=null ) |
|
| 94 |
{
|
|
| 95 |
window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS); |
|
| 96 |
} |
|
| 78 |
public void onShowDialog(DialogInterface dialog, float size) |
|
| 79 |
{
|
|
| 80 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
| 81 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 82 |
Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE); |
|
| 83 |
btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 84 |
} |
|
| 97 | 85 |
|
| 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 |
}); |
|
| 86 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 109 | 87 |
|
| 110 |
return dialog; |
|
| 88 |
public void prepareBody(View view, FragmentActivity act, float size) |
|
| 89 |
{
|
|
| 90 |
TextView save = view.findViewById(R.id.save_object_text); |
|
| 91 |
save.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 111 | 92 |
} |
| 112 | 93 |
} |
Also available in: Unified diff
Start unifying all the dialogs under one RubikDialogAbstract.