Revision c02fa107
Added by Leszek Koltunski almost 3 years ago
| src/main/java/org/distorted/bandaged/BandagedCreatorObjectView.java | ||
|---|---|---|
| 75 | 75 |
public void onClick(View v) |
| 76 | 76 |
{
|
| 77 | 77 |
Bundle bundle = new Bundle(); |
| 78 |
bundle.putString("name", mName );
|
|
| 78 |
bundle.putString("argument", mName );
|
|
| 79 | 79 |
RubikDialogBandagedDelete dialog = new RubikDialogBandagedDelete(); |
| 80 | 80 |
dialog.setArguments(bundle); |
| 81 | 81 |
dialog.show( act.getSupportFragmentManager(), RubikDialogBandagedDelete.getDialogTag() ); |
| src/main/java/org/distorted/dialogs/RubikDialogAbandon.java | ||
|---|---|---|
| 38 | 38 |
return -1; |
| 39 | 39 |
} |
| 40 | 40 |
|
| 41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 42 |
|
|
| 43 |
public boolean hasArgument() |
|
| 44 |
{
|
|
| 45 |
return false; |
|
| 46 |
} |
|
| 47 |
|
|
| 41 | 48 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 42 | 49 |
|
| 43 | 50 |
public void setPositive(AlertDialog.Builder builder) |
| ... | ... | |
| 80 | 87 |
|
| 81 | 88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 82 | 89 |
|
| 83 |
public void prepareBody(View view, FragmentActivity act, float size) |
|
| 90 |
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
|
|
| 84 | 91 |
{
|
| 85 | 92 |
|
| 86 | 93 |
} |
| src/main/java/org/distorted/dialogs/RubikDialogAbout.java | ||
|---|---|---|
| 42 | 42 |
return R.string.about; |
| 43 | 43 |
} |
| 44 | 44 |
|
| 45 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 46 |
|
|
| 47 |
public boolean hasArgument() |
|
| 48 |
{
|
|
| 49 |
return false; |
|
| 50 |
} |
|
| 51 |
|
|
| 45 | 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 46 | 53 |
|
| 47 | 54 |
public void setPositive(AlertDialog.Builder builder) |
| ... | ... | |
| 73 | 80 |
|
| 74 | 81 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 75 | 82 |
|
| 76 |
public void prepareBody(View view, FragmentActivity act, float size) |
|
| 83 |
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
|
|
| 77 | 84 |
{
|
| 78 | 85 |
TextView text = view.findViewById(R.id.about_version); |
| 79 | 86 |
String appName = getString(R.string.app_name); |
| src/main/java/org/distorted/dialogs/RubikDialogAbstract.java | ||
|---|---|---|
| 32 | 32 |
abstract public class RubikDialogAbstract extends AppCompatDialogFragment |
| 33 | 33 |
{
|
| 34 | 34 |
protected float mTitleSize, mButSize, mTextSize; |
| 35 |
protected int mWidth, mHeight; |
|
| 36 |
protected String mArgument; |
|
| 35 | 37 |
|
| 36 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 37 | 39 |
|
| 38 | 40 |
abstract int getResource(); |
| 39 | 41 |
abstract int getTitleResource(); |
| 42 |
abstract boolean hasArgument(); |
|
| 40 | 43 |
abstract void setPositive(AlertDialog.Builder builder); |
| 41 | 44 |
abstract void setNegative(AlertDialog.Builder builder); |
| 42 | 45 |
abstract void onShowDialog(DialogInterface dialog, float size); |
| 43 |
abstract void prepareBody(View view, FragmentActivity act, float size); |
|
| 46 |
abstract void prepareBody(Dialog dialog, View view, FragmentActivity act, float size);
|
|
| 44 | 47 |
|
| 45 | 48 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 46 | 49 |
|
| ... | ... | |
| 54 | 57 |
|
| 55 | 58 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
| 56 | 59 |
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; |
|
| 60 |
mWidth = displaymetrics.widthPixels; |
|
| 61 |
mHeight = displaymetrics.heightPixels; |
|
| 62 |
mTitleSize= mHeight*0.032f; |
|
| 63 |
mButSize = mHeight*0.040f; |
|
| 64 |
mTextSize = mHeight*0.025f; |
|
| 65 |
|
|
| 66 |
if( hasArgument() ) |
|
| 67 |
{
|
|
| 68 |
Bundle args = getArguments(); |
|
| 69 |
|
|
| 70 |
try |
|
| 71 |
{
|
|
| 72 |
mArgument = args!=null ? args.getString("argument") : "";
|
|
| 73 |
} |
|
| 74 |
catch(Exception e) |
|
| 75 |
{
|
|
| 76 |
mArgument = ""; |
|
| 77 |
} |
|
| 78 |
} |
|
| 79 |
else mArgument = ""; |
|
| 61 | 80 |
|
| 62 | 81 |
final View view = inflater.inflate(getResource(), null); |
| 63 | 82 |
builder.setView(view); |
| ... | ... | |
| 74 | 93 |
|
| 75 | 94 |
setPositive(builder); |
| 76 | 95 |
setNegative(builder); |
| 77 |
prepareBody(view,act,mTextSize); |
|
| 78 | 96 |
|
| 79 | 97 |
Dialog dialog = builder.create(); |
| 80 | 98 |
dialog.setCanceledOnTouchOutside(false); |
| 99 |
|
|
| 100 |
prepareBody(dialog,view,act,mTextSize); |
|
| 101 |
|
|
| 81 | 102 |
Window window = dialog.getWindow(); |
| 82 | 103 |
|
| 83 | 104 |
if( window!=null ) |
| src/main/java/org/distorted/dialogs/RubikDialogBandagedDelete.java | ||
|---|---|---|
| 11 | 11 |
|
| 12 | 12 |
import android.app.Dialog; |
| 13 | 13 |
import android.content.DialogInterface; |
| 14 |
import android.os.Bundle; |
|
| 15 | 14 |
import android.util.TypedValue; |
| 16 | 15 |
import android.view.View; |
| 17 | 16 |
import android.widget.Button; |
| ... | ... | |
| 41 | 40 |
|
| 42 | 41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 43 | 42 |
|
| 44 |
public void setPositive(AlertDialog.Builder builder)
|
|
| 43 |
public boolean hasArgument()
|
|
| 45 | 44 |
{
|
| 46 |
Bundle args = getArguments();
|
|
| 47 |
String name;
|
|
| 45 |
return true;
|
|
| 46 |
}
|
|
| 48 | 47 |
|
| 49 |
try |
|
| 50 |
{
|
|
| 51 |
name = args.getString("name");
|
|
| 52 |
} |
|
| 53 |
catch(Exception e) |
|
| 54 |
{
|
|
| 55 |
name = ""; |
|
| 56 |
} |
|
| 57 |
final String objectName = name; |
|
| 48 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 49 |
|
|
| 50 |
public void setPositive(AlertDialog.Builder builder) |
|
| 51 |
{
|
|
| 52 |
final String objectName = mArgument; |
|
| 58 | 53 |
|
| 59 | 54 |
builder.setPositiveButton( R.string.yes, new DialogInterface.OnClickListener() |
| 60 | 55 |
{
|
| ... | ... | |
| 93 | 88 |
|
| 94 | 89 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 95 | 90 |
|
| 96 |
public void prepareBody(View view, FragmentActivity act, float size) |
|
| 91 |
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
|
|
| 97 | 92 |
{
|
| 98 | 93 |
TextView save = view.findViewById(R.id.delete_object_text); |
| 99 | 94 |
save.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
| src/main/java/org/distorted/dialogs/RubikDialogBandagedSave.java | ||
|---|---|---|
| 39 | 39 |
return R.string.save_object; |
| 40 | 40 |
} |
| 41 | 41 |
|
| 42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 43 |
|
|
| 44 |
public boolean hasArgument() |
|
| 45 |
{
|
|
| 46 |
return false; |
|
| 47 |
} |
|
| 48 |
|
|
| 42 | 49 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 43 | 50 |
|
| 44 | 51 |
public void setPositive(AlertDialog.Builder builder) |
| ... | ... | |
| 85 | 92 |
|
| 86 | 93 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 87 | 94 |
|
| 88 |
public void prepareBody(View view, FragmentActivity act, float size) |
|
| 95 |
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
|
|
| 89 | 96 |
{
|
| 90 | 97 |
TextView save = view.findViewById(R.id.save_object_text); |
| 91 | 98 |
save.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
| src/main/java/org/distorted/dialogs/RubikDialogEffects.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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 androidx.annotation.NonNull; |
|
| 16 |
import androidx.fragment.app.FragmentActivity; |
|
| 17 |
import androidx.core.content.ContextCompat; |
|
| 18 |
import androidx.appcompat.app.AlertDialog; |
|
| 19 |
import androidx.appcompat.app.AppCompatDialogFragment; |
|
| 20 |
import android.util.DisplayMetrics; |
|
| 21 |
import android.util.TypedValue; |
|
| 22 |
import android.view.Gravity; |
|
| 23 |
import android.view.LayoutInflater; |
|
| 24 |
import android.view.View; |
|
| 25 |
import android.view.ViewGroup; |
|
| 26 |
import android.view.Window; |
|
| 27 |
import android.widget.AdapterView; |
|
| 28 |
import android.widget.ArrayAdapter; |
|
| 29 |
import android.widget.Button; |
|
| 30 |
import android.widget.LinearLayout; |
|
| 31 |
import android.widget.SeekBar; |
|
| 32 |
import android.widget.Spinner; |
|
| 33 |
import android.widget.TextView; |
|
| 34 |
|
|
| 35 |
import org.distorted.objectlib.effects.BaseEffect; |
|
| 36 |
import org.distorted.main.R; |
|
| 37 |
import org.distorted.main.RubikActivity; |
|
| 38 |
|
|
| 39 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 40 |
|
|
| 41 |
public class RubikDialogEffects extends AppCompatDialogFragment implements SeekBar.OnSeekBarChangeListener, AdapterView.OnItemSelectedListener |
|
| 42 |
{
|
|
| 43 |
private final TextView[] mDurationText; |
|
| 44 |
private float mTextSize; |
|
| 45 |
|
|
| 46 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 47 |
|
|
| 48 |
private void addSettingsSection(FragmentActivity act, LinearLayout layout, int index) |
|
| 49 |
{
|
|
| 50 |
BaseEffect.Type beType = BaseEffect.Type.getType(index); |
|
| 51 |
|
|
| 52 |
int textH= (int)(1.35f*mTextSize); |
|
| 53 |
float A= 1.2f; |
|
| 54 |
float B= 0.25f; |
|
| 55 |
|
|
| 56 |
///// OUTER LAYOUT /////////////////////////////////////////////////////////////////// |
|
| 57 |
|
|
| 58 |
int margin = (int)(B*textH); |
|
| 59 |
int color = ContextCompat.getColor(act, R.color.grey); |
|
| 60 |
LinearLayout outerLayout = new LinearLayout(act); |
|
| 61 |
LinearLayout.LayoutParams outerLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT, 0.5f); |
|
| 62 |
outerLayoutParams.topMargin = index>0 ? margin : 0; |
|
| 63 |
outerLayoutParams.bottomMargin = 0; |
|
| 64 |
outerLayoutParams.leftMargin = margin; |
|
| 65 |
outerLayoutParams.rightMargin = margin; |
|
| 66 |
|
|
| 67 |
outerLayout.setLayoutParams(outerLayoutParams); |
|
| 68 |
outerLayout.setGravity(Gravity.CENTER|Gravity.FILL_HORIZONTAL); |
|
| 69 |
outerLayout.setBackgroundColor(color); |
|
| 70 |
outerLayout.setOrientation(LinearLayout.VERTICAL); |
|
| 71 |
layout.addView(outerLayout); |
|
| 72 |
|
|
| 73 |
///// TEXT /////////////////////////////////////////////////////////////////////////// |
|
| 74 |
|
|
| 75 |
int layoutHeight = (int)(A*textH); |
|
| 76 |
int padding = (int)(B*textH); |
|
| 77 |
|
|
| 78 |
LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,layoutHeight); |
|
| 79 |
|
|
| 80 |
TextView textView = new TextView(act); |
|
| 81 |
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); |
|
| 82 |
textView.setText(beType.getText()); |
|
| 83 |
textView.setLayoutParams(textParams); |
|
| 84 |
textView.setGravity(Gravity.CENTER); |
|
| 85 |
textView.setPadding(padding,0,padding,0); |
|
| 86 |
outerLayout.addView(textView); |
|
| 87 |
|
|
| 88 |
///// INNER LAYOUT1 ////////////////////////////////////////////////////////////////// |
|
| 89 |
|
|
| 90 |
int innerLayout1Height = (int)((A+B)*textH); |
|
| 91 |
LinearLayout innerLayout1 = new LinearLayout(act); |
|
| 92 |
LinearLayout.LayoutParams innerLayout1Params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,innerLayout1Height); |
|
| 93 |
|
|
| 94 |
innerLayout1.setLayoutParams(innerLayout1Params); |
|
| 95 |
innerLayout1.setGravity(Gravity.CENTER|Gravity.FILL_HORIZONTAL); |
|
| 96 |
innerLayout1.setOrientation(LinearLayout.HORIZONTAL); |
|
| 97 |
outerLayout.addView(innerLayout1); |
|
| 98 |
|
|
| 99 |
///// STUFF INSIDE INNER LAYOUT1 ///////////////////////////////////////////////////// |
|
| 100 |
|
|
| 101 |
int text1Padding = (int)(B*textH); |
|
| 102 |
LinearLayout.LayoutParams text1LayoutParams = new LinearLayout.LayoutParams(0,layoutHeight,0.25f); |
|
| 103 |
|
|
| 104 |
TextView text1View = new TextView(act); |
|
| 105 |
text1View.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); |
|
| 106 |
text1View.setText(R.string.duration); |
|
| 107 |
text1View.setLayoutParams(text1LayoutParams); |
|
| 108 |
text1View.setGravity(Gravity.START|Gravity.CENTER); |
|
| 109 |
text1View.setPadding(text1Padding,0,text1Padding,0); |
|
| 110 |
innerLayout1.addView(text1View); |
|
| 111 |
////////////////////////////////////////////////////////////////// |
|
| 112 |
int text2Padding = (int)(B*textH); |
|
| 113 |
LinearLayout.LayoutParams text2LayoutParams = new LinearLayout.LayoutParams(0,layoutHeight,0.25f); |
|
| 114 |
|
|
| 115 |
mDurationText[index] = new TextView(act); |
|
| 116 |
mDurationText[index].setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); |
|
| 117 |
mDurationText[index].setLayoutParams(text2LayoutParams); |
|
| 118 |
mDurationText[index].setGravity(Gravity.START|Gravity.CENTER); |
|
| 119 |
mDurationText[index].setPadding(text2Padding,0,text2Padding,0); |
|
| 120 |
innerLayout1.addView(mDurationText[index]); |
|
| 121 |
////////////////////////////////////////////////////////////////// |
|
| 122 |
int seekPadding = (int)(B*textH); |
|
| 123 |
LinearLayout.LayoutParams seekLayoutParams = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,0.5f); |
|
| 124 |
|
|
| 125 |
SeekBar seekBar = new SeekBar(act); |
|
| 126 |
seekBar.setLayoutParams(seekLayoutParams); |
|
| 127 |
seekBar.setPadding(seekPadding,0,seekPadding,0); |
|
| 128 |
seekBar.setId(index); |
|
| 129 |
innerLayout1.addView(seekBar); |
|
| 130 |
|
|
| 131 |
seekBar.setOnSeekBarChangeListener(this); |
|
| 132 |
seekBar.setProgress(beType.getCurrentPos()); |
|
| 133 |
|
|
| 134 |
///// INNER LAYOUT2 ////////////////////////////////////////////////////////////////// |
|
| 135 |
|
|
| 136 |
int innerLayout2Height = (int)((A+B)*textH); |
|
| 137 |
LinearLayout innerLayout2 = new LinearLayout(act); |
|
| 138 |
LinearLayout.LayoutParams innerLayout2Params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,innerLayout2Height); |
|
| 139 |
|
|
| 140 |
innerLayout2.setLayoutParams(innerLayout2Params); |
|
| 141 |
innerLayout2.setGravity(Gravity.CENTER|Gravity.FILL_HORIZONTAL); |
|
| 142 |
innerLayout2.setOrientation(LinearLayout.HORIZONTAL); |
|
| 143 |
outerLayout.addView(innerLayout2); |
|
| 144 |
|
|
| 145 |
///// STUFF INSIDE INNER LAYOUT2 ///////////////////////////////////////////////////// |
|
| 146 |
|
|
| 147 |
int text3Padding = (int)(B*textH); |
|
| 148 |
LinearLayout.LayoutParams text3LayoutParams = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,0.25f); |
|
| 149 |
|
|
| 150 |
TextView text3View = new TextView(act); |
|
| 151 |
text3View.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); |
|
| 152 |
text3View.setText(R.string.type); |
|
| 153 |
text3View.setLayoutParams(text3LayoutParams); |
|
| 154 |
text3View.setGravity(Gravity.START|Gravity.CENTER); |
|
| 155 |
text3View.setPadding(text3Padding,0,text3Padding,0); |
|
| 156 |
innerLayout2.addView(text3View); |
|
| 157 |
////////////////////////////////////////////////////////////////// |
|
| 158 |
int spinnerPadding = (int)(B*textH); |
|
| 159 |
int spinnerMargin = (int)(B*0.5f*textH); |
|
| 160 |
LinearLayout.LayoutParams spinnerLayoutParams = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,0.75f); |
|
| 161 |
spinnerLayoutParams.topMargin = spinnerMargin; |
|
| 162 |
spinnerLayoutParams.bottomMargin = spinnerMargin; |
|
| 163 |
spinnerLayoutParams.leftMargin = spinnerMargin; |
|
| 164 |
spinnerLayoutParams.rightMargin = 2*spinnerMargin; |
|
| 165 |
|
|
| 166 |
Spinner spinner = new Spinner(act); |
|
| 167 |
spinner.setLayoutParams(spinnerLayoutParams); |
|
| 168 |
spinner.setPadding(spinnerPadding,0,spinnerPadding,0); |
|
| 169 |
spinner.setBackgroundResource(R.drawable.ui_small_spinner); |
|
| 170 |
spinner.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START); |
|
| 171 |
spinner.setId(index+BaseEffect.Type.LENGTH); |
|
| 172 |
innerLayout2.addView(spinner); |
|
| 173 |
|
|
| 174 |
spinner.setOnItemSelectedListener(this); |
|
| 175 |
String[] appear = BaseEffect.Type.getType(index).getNames(); |
|
| 176 |
|
|
| 177 |
ArrayAdapter<String> adapterType = new ArrayAdapter<String>(act, android.R.layout.simple_spinner_item, appear) |
|
| 178 |
{
|
|
| 179 |
@NonNull |
|
| 180 |
public View getView(int position, View convertView, @NonNull ViewGroup parent) |
|
| 181 |
{
|
|
| 182 |
View v = super.getView(position, convertView, parent); |
|
| 183 |
TextView tv = ((TextView) v); |
|
| 184 |
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); |
|
| 185 |
return v; |
|
| 186 |
} |
|
| 187 |
}; |
|
| 188 |
|
|
| 189 |
adapterType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|
| 190 |
spinner.setAdapter(adapterType); |
|
| 191 |
spinner.setSelection(beType.getCurrentType()); |
|
| 192 |
} |
|
| 193 |
|
|
| 194 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 195 |
// PUBLIC API |
|
| 196 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 197 |
|
|
| 198 |
public RubikDialogEffects() |
|
| 199 |
{
|
|
| 200 |
mDurationText = new TextView[BaseEffect.Type.LENGTH]; |
|
| 201 |
} |
|
| 202 |
|
|
| 203 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 204 |
|
|
| 205 |
@NonNull |
|
| 206 |
@Override |
|
| 207 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
|
| 208 |
{
|
|
| 209 |
FragmentActivity act = getActivity(); |
|
| 210 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
| 211 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
|
| 212 |
TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null); |
|
| 213 |
|
|
| 214 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 215 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
|
| 216 |
final float titleSize= displaymetrics.widthPixels * RubikActivity.BIG_TEXT_SIZE; |
|
| 217 |
final float okSize = displaymetrics.widthPixels * RubikActivity.DIALOG_BUTTON_SIZE; |
|
| 218 |
|
|
| 219 |
mTextSize = displaymetrics.widthPixels * RubikActivity.SMALL_TEXT_SIZE; |
|
| 220 |
|
|
| 221 |
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize); |
|
| 222 |
tv.setText(R.string.effects); |
|
| 223 |
builder.setCustomTitle(tv); |
|
| 224 |
|
|
| 225 |
builder.setCancelable(true); |
|
| 226 |
builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() |
|
| 227 |
{
|
|
| 228 |
@Override |
|
| 229 |
public void onClick(DialogInterface dialog, int which) |
|
| 230 |
{
|
|
| 231 |
|
|
| 232 |
} |
|
| 233 |
}); |
|
| 234 |
|
|
| 235 |
final View view = inflater.inflate(R.layout.dialog_effects, null); |
|
| 236 |
builder.setView(view); |
|
| 237 |
|
|
| 238 |
LinearLayout linearLayout = view.findViewById(R.id.settingsLayout); |
|
| 239 |
|
|
| 240 |
if( linearLayout!=null ) |
|
| 241 |
{
|
|
| 242 |
for (int i=0; i< BaseEffect.Type.LENGTH; i++) |
|
| 243 |
{
|
|
| 244 |
addSettingsSection(act,linearLayout,i); |
|
| 245 |
} |
|
| 246 |
} |
|
| 247 |
else |
|
| 248 |
{
|
|
| 249 |
android.util.Log.e("dialog_settings", "linearLayout NULL!");
|
|
| 250 |
} |
|
| 251 |
|
|
| 252 |
Dialog dialog = builder.create(); |
|
| 253 |
dialog.setCanceledOnTouchOutside(false); |
|
| 254 |
Window window = dialog.getWindow(); |
|
| 255 |
|
|
| 256 |
if( window!=null ) |
|
| 257 |
{
|
|
| 258 |
window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS); |
|
| 259 |
} |
|
| 260 |
|
|
| 261 |
dialog.setOnShowListener(new DialogInterface.OnShowListener() |
|
| 262 |
{
|
|
| 263 |
@Override |
|
| 264 |
public void onShow(DialogInterface dialog) |
|
| 265 |
{
|
|
| 266 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
| 267 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize); |
|
| 268 |
} |
|
| 269 |
}); |
|
| 270 |
|
|
| 271 |
return dialog; |
|
| 272 |
} |
|
| 273 |
|
|
| 274 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 275 |
|
|
| 276 |
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) |
|
| 277 |
{
|
|
| 278 |
int parentID = parent.getId(); |
|
| 279 |
int len = BaseEffect.Type.LENGTH; |
|
| 280 |
|
|
| 281 |
if( parentID>=len && parentID< 2*len) // ith spinner's ID is equal to i+LENGTH (see createSettingSection) |
|
| 282 |
{
|
|
| 283 |
BaseEffect.Type.getType(parentID-len).setCurrentType(pos); |
|
| 284 |
} |
|
| 285 |
} |
|
| 286 |
|
|
| 287 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 288 |
|
|
| 289 |
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) |
|
| 290 |
{
|
|
| 291 |
int barID = bar.getId(); |
|
| 292 |
|
|
| 293 |
if( barID>=0 && barID< BaseEffect.Type.LENGTH) // ith seekbar's ID is equal to i (see createSettingSection) |
|
| 294 |
{
|
|
| 295 |
BaseEffect.Type.getType(barID).setCurrentPos(progress); |
|
| 296 |
int ms = BaseEffect.Type.translatePos(progress); |
|
| 297 |
mDurationText[barID].setText(getString(R.string.ms_placeholder,ms)); |
|
| 298 |
} |
|
| 299 |
} |
|
| 300 |
|
|
| 301 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 302 |
|
|
| 303 |
public void onNothingSelected(AdapterView<?> parent) { }
|
|
| 304 |
public void onStartTrackingTouch(SeekBar bar) { }
|
|
| 305 |
public void onStopTrackingTouch(SeekBar bar) { }
|
|
| 306 |
} |
|
| src/main/java/org/distorted/dialogs/RubikDialogError.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.main.R; |
| 29 |
import org.distorted.main.RubikActivity; |
|
| 30 | 23 |
|
| 31 | 24 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 32 | 25 |
|
| 33 |
public class RubikDialogError extends AppCompatDialogFragment
|
|
| 26 |
public class RubikDialogError extends RubikDialogAbstract
|
|
| 34 | 27 |
{
|
| 35 |
@NonNull |
|
| 36 |
@Override |
|
| 37 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
|
| 28 |
public int getResource() |
|
| 38 | 29 |
{
|
| 39 |
final FragmentActivity act = getActivity(); |
|
| 40 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
| 41 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
|
| 30 |
return R.layout.dialog_error; |
|
| 31 |
} |
|
| 42 | 32 |
|
| 43 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 44 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
|
| 45 |
int h = displaymetrics.heightPixels; |
|
| 46 |
final float titleSize= h * 0.032f; |
|
| 47 |
final float okSize = h * 0.040f; |
|
| 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 48 | 34 |
|
| 49 |
TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null);
|
|
| 50 |
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
|
|
| 51 |
tv.setText(R.string.opengl_error);
|
|
| 52 |
builder.setCustomTitle(tv);
|
|
| 35 |
public int getTitleResource()
|
|
| 36 |
{
|
|
| 37 |
return R.string.opengl_error;
|
|
| 38 |
}
|
|
| 53 | 39 |
|
| 54 |
final View view = inflater.inflate(R.layout.dialog_error, null); |
|
| 55 |
TextView text = view.findViewById(R.id.error_string); |
|
| 56 |
text.setText(R.string.opengl_error_text); |
|
| 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 41 |
|
|
| 42 |
public boolean hasArgument() |
|
| 43 |
{
|
|
| 44 |
return false; |
|
| 45 |
} |
|
| 46 |
|
|
| 47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 48 |
|
|
| 49 |
public void setPositive(AlertDialog.Builder builder) |
|
| 50 |
{
|
|
| 51 |
final FragmentActivity act = getActivity(); |
|
| 57 | 52 |
|
| 58 | 53 |
builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() |
| 59 | 54 |
{
|
| 60 | 55 |
@Override |
| 61 | 56 |
public void onClick(DialogInterface dialog, int which) |
| 62 | 57 |
{
|
| 63 |
act.finish(); |
|
| 58 |
if( act!=null ) act.finish();
|
|
| 64 | 59 |
} |
| 65 | 60 |
}); |
| 61 |
} |
|
| 66 | 62 |
|
| 67 |
builder.setView(view);
|
|
| 63 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
| 68 | 64 |
|
| 69 |
final Dialog dialog = builder.create();
|
|
| 70 |
dialog.setCanceledOnTouchOutside(false);
|
|
| 65 |
public void setNegative(AlertDialog.Builder builder)
|
|
| 66 |
{
|
|
| 71 | 67 |
|
| 72 |
Window window = dialog.getWindow();
|
|
| 68 |
}
|
|
| 73 | 69 |
|
| 74 |
if( window!=null ) |
|
| 75 |
{
|
|
| 76 |
window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS); |
|
| 77 |
} |
|
| 70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 78 | 71 |
|
| 79 |
dialog.setOnShowListener(new DialogInterface.OnShowListener() |
|
| 80 |
{
|
|
| 81 |
@Override |
|
| 82 |
public void onShow(DialogInterface dialog) |
|
| 83 |
{
|
|
| 84 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
| 85 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize); |
|
| 86 |
} |
|
| 87 |
}); |
|
| 72 |
public void onShowDialog(DialogInterface dialog, float size) |
|
| 73 |
{
|
|
| 74 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
| 75 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 76 |
} |
|
| 77 |
|
|
| 78 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 88 | 79 |
|
| 89 |
return dialog; |
|
| 80 |
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size) |
|
| 81 |
{
|
|
| 82 |
TextView text = view.findViewById(R.id.error_string); |
|
| 83 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 84 |
text.setText(R.string.opengl_error_text); |
|
| 90 | 85 |
} |
| 91 | 86 |
} |
| src/main/java/org/distorted/dialogs/RubikDialogNewRecord.java | ||
|---|---|---|
| 12 | 12 |
import android.app.Dialog; |
| 13 | 13 |
import android.content.DialogInterface; |
| 14 | 14 |
import android.os.Bundle; |
| 15 |
import androidx.annotation.NonNull; |
|
| 16 | 15 |
import androidx.fragment.app.FragmentActivity; |
| 17 | 16 |
import androidx.appcompat.app.AlertDialog; |
| 18 |
import androidx.appcompat.app.AppCompatDialogFragment; |
|
| 19 | 17 |
|
| 20 |
import android.util.DisplayMetrics; |
|
| 21 | 18 |
import android.util.TypedValue; |
| 22 |
import android.view.LayoutInflater; |
|
| 23 | 19 |
import android.view.View; |
| 24 |
import android.view.Window; |
|
| 25 | 20 |
import android.widget.Button; |
| 26 | 21 |
import android.widget.TextView; |
| 27 | 22 |
|
| 28 | 23 |
import org.distorted.main.R; |
| 29 | 24 |
import org.distorted.main.RubikActivity; |
| 30 | 25 |
import org.distorted.external.RubikScores; |
| 31 |
import org.distorted.objects.RubikObjectList; |
|
| 32 | 26 |
import org.distorted.screens.ScreenList; |
| 33 | 27 |
|
| 34 | 28 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 35 | 29 |
|
| 36 |
public class RubikDialogNewRecord extends AppCompatDialogFragment
|
|
| 30 |
public class RubikDialogNewRecord extends RubikDialogAbstract
|
|
| 37 | 31 |
{
|
| 38 |
@NonNull |
|
| 39 |
@Override |
|
| 40 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
|
| 32 |
public int getResource() |
|
| 41 | 33 |
{
|
| 42 |
FragmentActivity act = getActivity();
|
|
| 43 |
LayoutInflater inflater = act.getLayoutInflater();
|
|
| 44 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
|
| 45 |
|
|
| 46 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 47 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
|
|
| 48 |
int h = displaymetrics.heightPixels;
|
|
| 49 |
final float titleSize= h*0.032f;
|
|
| 50 |
final float okSize = h*0.040f;
|
|
| 51 |
final float textSize = h*0.032f; |
|
| 52 |
|
|
| 53 |
TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null); |
|
| 54 |
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
|
|
| 55 |
tv.setText(R.string.new_record);
|
|
| 56 |
builder.setCustomTitle(tv);
|
|
| 57 |
builder.setCancelable(true);
|
|
| 34 |
return R.layout.dialog_new_record;
|
|
| 35 |
}
|
|
| 36 |
|
|
| 37 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 38 |
|
|
| 39 |
public int getTitleResource()
|
|
| 40 |
{
|
|
| 41 |
return R.string.new_record;
|
|
| 42 |
}
|
|
| 43 |
|
|
| 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 45 |
|
|
| 46 |
public boolean hasArgument()
|
|
| 47 |
{
|
|
| 48 |
return true;
|
|
| 49 |
}
|
|
| 58 | 50 |
|
| 51 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 52 |
|
|
| 53 |
public void setPositive(AlertDialog.Builder builder) |
|
| 54 |
{
|
|
| 59 | 55 |
builder.setPositiveButton( R.string.yes, new DialogInterface.OnClickListener() |
| 60 | 56 |
{
|
| 61 | 57 |
@Override |
| ... | ... | |
| 69 | 65 |
|
| 70 | 66 |
if( name.length()>0 ) |
| 71 | 67 |
{
|
| 72 |
int object = RubikObjectList.getCurrObject(); |
|
| 73 |
|
|
| 74 |
bundle.putInt("tab", object );
|
|
| 75 |
bundle.putBoolean("submitting", true);
|
|
| 76 |
|
|
| 68 |
bundle.putString("argument", "true");
|
|
| 77 | 69 |
RubikDialogScores scoresDiag = new RubikDialogScores(); |
| 78 | 70 |
scoresDiag.setArguments(bundle); |
| 79 | 71 |
scoresDiag.show(act.getSupportFragmentManager(), null); |
| 80 | 72 |
} |
| 81 | 73 |
else |
| 82 | 74 |
{
|
| 83 |
bundle.putString("name", name );
|
|
| 84 |
|
|
| 75 |
bundle.putString("argument", name );
|
|
| 85 | 76 |
RubikDialogSetName nameDiag = new RubikDialogSetName(); |
| 86 | 77 |
nameDiag.setArguments(bundle); |
| 87 | 78 |
nameDiag.show(act.getSupportFragmentManager(), null); |
| 88 | 79 |
} |
| 89 | 80 |
} |
| 90 | 81 |
}); |
| 82 |
} |
|
| 91 | 83 |
|
| 84 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 85 |
|
|
| 86 |
public void setNegative(AlertDialog.Builder builder) |
|
| 87 |
{
|
|
| 92 | 88 |
builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() |
| 93 | 89 |
{
|
| 94 | 90 |
@Override |
| ... | ... | |
| 98 | 94 |
ScreenList.switchScreen(act, ScreenList.PLAY); |
| 99 | 95 |
} |
| 100 | 96 |
}); |
| 97 |
} |
|
| 101 | 98 |
|
| 102 |
Bundle args = getArguments(); |
|
| 103 |
long time; |
|
| 99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 104 | 100 |
|
| 105 |
try |
|
| 106 |
{
|
|
| 107 |
time = args.getLong("time");
|
|
| 108 |
} |
|
| 109 |
catch(Exception e) |
|
| 110 |
{
|
|
| 111 |
time = 0; |
|
| 112 |
} |
|
| 101 |
public void onShowDialog(DialogInterface dialog, float size) |
|
| 102 |
{
|
|
| 103 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
| 104 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 105 |
Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE); |
|
| 106 |
btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 107 |
} |
|
| 113 | 108 |
|
| 114 |
final View view = inflater.inflate(R.layout.dialog_new_record, null); |
|
| 115 |
TextView text = view.findViewById(R.id.new_record_time); |
|
| 116 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
| 117 |
text.setText(getString(R.string.ti_placeholder, (time/10)/100.0f)); |
|
| 118 |
builder.setView(view); |
|
| 109 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 119 | 110 |
|
| 111 |
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size) |
|
| 112 |
{
|
|
| 113 |
TextView text = view.findViewById(R.id.new_record_time); |
|
| 114 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 115 |
text.setText(getString(R.string.ti_placeholder, mArgument)); |
|
| 120 | 116 |
TextView submit = view.findViewById(R.id.new_record_submit); |
| 121 |
submit.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
| 122 |
|
|
| 123 |
Dialog dialog = builder.create(); |
|
| 124 |
dialog.setCanceledOnTouchOutside(false); |
|
| 125 |
Window window = dialog.getWindow(); |
|
| 126 |
|
|
| 127 |
if( window!=null ) |
|
| 128 |
{
|
|
| 129 |
window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS); |
|
| 130 |
} |
|
| 131 |
|
|
| 132 |
dialog.setOnShowListener(new DialogInterface.OnShowListener() |
|
| 133 |
{
|
|
| 134 |
@Override |
|
| 135 |
public void onShow(DialogInterface dialog) |
|
| 136 |
{
|
|
| 137 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
| 138 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize); |
|
| 139 |
Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE); |
|
| 140 |
btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize); |
|
| 141 |
} |
|
| 142 |
}); |
|
| 143 |
|
|
| 144 |
return dialog; |
|
| 117 |
submit.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 145 | 118 |
} |
| 146 | 119 |
|
| 147 | 120 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/dialogs/RubikDialogPrivacy.java | ||
|---|---|---|
| 11 | 11 |
|
| 12 | 12 |
import android.app.Dialog; |
| 13 | 13 |
import android.content.DialogInterface; |
| 14 |
import android.os.Bundle; |
|
| 15 | 14 |
import android.text.method.LinkMovementMethod; |
| 16 | 15 |
import android.text.method.MovementMethod; |
| 17 |
import android.util.DisplayMetrics; |
|
| 18 | 16 |
import android.util.TypedValue; |
| 19 |
import android.view.LayoutInflater; |
|
| 20 | 17 |
import android.view.View; |
| 21 |
import android.view.Window; |
|
| 22 | 18 |
import android.widget.Button; |
| 23 | 19 |
import android.widget.TextView; |
| 24 | 20 |
|
| 25 |
import androidx.annotation.NonNull; |
|
| 26 | 21 |
import androidx.appcompat.app.AlertDialog; |
| 27 |
import androidx.appcompat.app.AppCompatDialogFragment; |
|
| 28 | 22 |
import androidx.fragment.app.FragmentActivity; |
| 29 | 23 |
|
| 30 | 24 |
import org.distorted.main.R; |
| ... | ... | |
| 32 | 26 |
|
| 33 | 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 34 | 28 |
|
| 35 |
public class RubikDialogPrivacy extends AppCompatDialogFragment
|
|
| 29 |
public class RubikDialogPrivacy extends RubikDialogAbstract
|
|
| 36 | 30 |
{
|
| 37 |
@NonNull |
|
| 38 |
@Override |
|
| 39 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
|
| 31 |
public int getResource() |
|
| 40 | 32 |
{
|
| 41 |
final RubikActivity ract = (RubikActivity)getContext(); |
|
| 33 |
return R.layout.dialog_privacy; |
|
| 34 |
} |
|
| 42 | 35 |
|
| 43 |
FragmentActivity act = getActivity(); |
|
| 44 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
| 45 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
|
| 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 46 | 37 |
|
| 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 butSize = h*0.040f; |
|
| 38 |
public int getTitleResource() |
|
| 39 |
{
|
|
| 40 |
return R.string.privacy_policy; |
|
| 41 |
} |
|
| 52 | 42 |
|
| 53 |
TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null); |
|
| 54 |
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize); |
|
| 55 |
tv.setText(R.string.privacy_policy); |
|
| 56 |
builder.setCustomTitle(tv); |
|
| 43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 57 | 44 |
|
| 58 |
MovementMethod mm = LinkMovementMethod.getInstance(); |
|
| 59 |
final View view = inflater.inflate(R.layout.dialog_privacy, null); |
|
| 60 |
TextView text = view.findViewById(R.id.privacy_string); |
|
| 61 |
text.setMovementMethod(mm); |
|
| 45 |
public boolean hasArgument() |
|
| 46 |
{
|
|
| 47 |
return false; |
|
| 48 |
} |
|
| 49 |
|
|
| 50 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 62 | 51 |
|
| 63 |
builder.setCancelable(true); |
|
| 52 |
public void setPositive(AlertDialog.Builder builder) |
|
| 53 |
{
|
|
| 54 |
final RubikActivity ract = (RubikActivity)getContext(); |
|
| 64 | 55 |
|
| 65 | 56 |
builder.setPositiveButton( R.string.accept, new DialogInterface.OnClickListener() |
| 66 | 57 |
{
|
| ... | ... | |
| 70 | 61 |
if( ract!=null ) ract.acceptPrivacy(); |
| 71 | 62 |
} |
| 72 | 63 |
}); |
| 64 |
} |
|
| 65 |
|
|
| 66 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 67 |
|
|
| 68 |
public void setNegative(AlertDialog.Builder builder) |
|
| 69 |
{
|
|
| 70 |
final RubikActivity ract = (RubikActivity)getContext(); |
|
| 73 | 71 |
|
| 74 | 72 |
builder.setNegativeButton( R.string.decline, new DialogInterface.OnClickListener() |
| 75 | 73 |
{
|
| ... | ... | |
| 79 | 77 |
if( ract!=null ) ract.declinePrivacy(); |
| 80 | 78 |
} |
| 81 | 79 |
}); |
| 80 |
} |
|
| 82 | 81 |
|
| 83 |
builder.setView(view); |
|
| 84 |
|
|
| 85 |
final Dialog dialog = builder.create(); |
|
| 86 |
dialog.setCanceledOnTouchOutside(false); |
|
| 87 |
Window window = dialog.getWindow(); |
|
| 82 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 88 | 83 |
|
| 89 |
if( window!=null ) |
|
| 90 |
{
|
|
| 91 |
window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS); |
|
| 92 |
} |
|
| 84 |
public void onShowDialog(DialogInterface dialog, float size) |
|
| 85 |
{
|
|
| 86 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
| 87 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 88 |
Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE); |
|
| 89 |
btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 90 |
} |
|
| 93 | 91 |
|
| 94 |
dialog.setOnShowListener(new DialogInterface.OnShowListener() |
|
| 95 |
{
|
|
| 96 |
@Override |
|
| 97 |
public void onShow(DialogInterface dialog) |
|
| 98 |
{
|
|
| 99 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
| 100 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, butSize); |
|
| 101 |
Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE); |
|
| 102 |
btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, butSize); |
|
| 103 |
} |
|
| 104 |
}); |
|
| 92 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 105 | 93 |
|
| 106 |
return dialog; |
|
| 94 |
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size) |
|
| 95 |
{
|
|
| 96 |
MovementMethod mm = LinkMovementMethod.getInstance(); |
|
| 97 |
TextView text = view.findViewById(R.id.privacy_string); |
|
| 98 |
text.setMovementMethod(mm); |
|
| 107 | 99 |
} |
| 108 | 100 |
} |
| src/main/java/org/distorted/dialogs/RubikDialogScores.java | ||
|---|---|---|
| 77 | 77 |
}); |
| 78 | 78 |
|
| 79 | 79 |
Bundle args = getArguments(); |
| 80 |
int curTab; |
|
| 81 |
boolean isSubmitting; |
|
| 80 |
String submitting; |
|
| 82 | 81 |
|
| 83 | 82 |
try |
| 84 | 83 |
{
|
| 85 |
curTab = args.getInt("tab");
|
|
| 86 |
isSubmitting = args.getBoolean("submitting");
|
|
| 84 |
submitting = args.getString("argument");
|
|
| 87 | 85 |
} |
| 88 | 86 |
catch(Exception e) |
| 89 | 87 |
{
|
| 90 |
curTab = 0; |
|
| 91 |
isSubmitting = false; |
|
| 88 |
submitting = ""; |
|
| 92 | 89 |
} |
| 93 | 90 |
|
| 94 | 91 |
LayoutInflater inflater = act.getLayoutInflater(); |
| ... | ... | |
| 97 | 94 |
|
| 98 | 95 |
ViewPager viewPager = view.findViewById(R.id.viewpager); |
| 99 | 96 |
TabLayout tabLayout = view.findViewById(R.id.sliding_tabs); |
| 100 |
mPagerAdapter = new RubikDialogScoresPagerAdapter(act,viewPager,isSubmitting, this);
|
|
| 97 |
mPagerAdapter = new RubikDialogScoresPagerAdapter(act,viewPager,submitting.equals("true"), this);
|
|
| 101 | 98 |
tabLayout.setupWithViewPager(viewPager); |
| 102 | 99 |
|
| 103 |
viewPager.setCurrentItem(curTab);
|
|
| 100 |
viewPager.setCurrentItem(RubikObjectList.getCurrObject());
|
|
| 104 | 101 |
int numObjects = RubikObjectList.getNumObjects(); |
| 105 | 102 |
ViewGroup.LayoutParams paramsView = new ViewGroup.LayoutParams( tabWidth,tabHeight ); |
| 106 | 103 |
|
| src/main/java/org/distorted/dialogs/RubikDialogScoresPagerAdapter.java | ||
|---|---|---|
| 173 | 173 |
break; |
| 174 | 174 |
case '2': RubikScores scores = RubikScores.getInstance(); |
| 175 | 175 |
Bundle bundle = new Bundle(); |
| 176 |
bundle.putString("name", scores.getName() );
|
|
| 176 |
bundle.putString("argument", scores.getName() );
|
|
| 177 | 177 |
|
| 178 | 178 |
RubikDialogSetName nameDiag = new RubikDialogSetName(); |
| 179 | 179 |
nameDiag.setArguments(bundle); |
| src/main/java/org/distorted/dialogs/RubikDialogSetName.java | ||
|---|---|---|
| 12 | 12 |
import android.app.Dialog; |
| 13 | 13 |
import android.content.DialogInterface; |
| 14 | 14 |
import android.os.Bundle; |
| 15 |
import androidx.annotation.NonNull; |
|
| 16 | 15 |
import androidx.fragment.app.FragmentActivity; |
| 17 | 16 |
import androidx.appcompat.app.AlertDialog; |
| 18 |
import androidx.appcompat.app.AppCompatDialogFragment; |
|
| 19 | 17 |
import android.text.Editable; |
| 20 | 18 |
import android.text.TextWatcher; |
| 21 |
import android.util.DisplayMetrics; |
|
| 22 | 19 |
import android.util.TypedValue; |
| 23 |
import android.view.LayoutInflater; |
|
| 24 | 20 |
import android.view.View; |
| 25 |
import android.view.Window; |
|
| 26 | 21 |
import android.view.WindowManager; |
| 27 | 22 |
import android.widget.Button; |
| 28 | 23 |
import android.widget.EditText; |
| ... | ... | |
| 31 | 26 |
import org.distorted.main.R; |
| 32 | 27 |
import org.distorted.main.RubikActivity; |
| 33 | 28 |
import org.distorted.external.RubikScores; |
| 34 |
import org.distorted.objects.RubikObjectList; |
|
| 35 | 29 |
import org.distorted.screens.ScreenList; |
| 36 | 30 |
|
| 37 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 38 | 32 |
|
| 39 |
public class RubikDialogSetName extends AppCompatDialogFragment
|
|
| 33 |
public class RubikDialogSetName extends RubikDialogAbstract
|
|
| 40 | 34 |
{
|
| 41 | 35 |
private static final int MAX_NAME_LEN = 15; |
| 42 | 36 |
private EditText mEdit; |
| ... | ... | |
| 64 | 58 |
|
| 65 | 59 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 66 | 60 |
|
| 67 |
@NonNull |
|
| 68 |
@Override |
|
| 69 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
|
| 61 |
public int getResource() |
|
| 70 | 62 |
{
|
| 71 |
FragmentActivity act = getActivity(); |
|
| 72 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
| 73 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
|
| 74 |
|
|
| 75 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 76 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
|
| 77 |
int h = displaymetrics.heightPixels; |
|
| 78 |
final float titleSize= h*0.032f; |
|
| 79 |
final float okSize = h*0.040f; |
|
| 80 |
final float textSize = h*0.022f; |
|
| 81 |
|
|
| 82 |
Bundle args = getArguments(); |
|
| 83 |
String name; |
|
| 84 |
|
|
| 85 |
try |
|
| 86 |
{
|
|
| 87 |
name = args.getString("name");
|
|
| 88 |
} |
|
| 89 |
catch(Exception e) |
|
| 90 |
{
|
|
| 91 |
name = ""; |
|
| 92 |
} |
|
| 63 |
return R.layout.dialog_set_name; |
|
| 64 |
} |
|
| 93 | 65 |
|
| 94 |
boolean first = name.length()==0;
|
|
| 66 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
| 95 | 67 |
|
| 96 |
TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null);
|
|
| 97 |
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
|
|
| 98 |
tv.setText( first ? R.string.choose_name : R.string.name_taken);
|
|
| 99 |
builder.setCustomTitle(tv);
|
|
| 68 |
public int getTitleResource()
|
|
| 69 |
{
|
|
| 70 |
return mArgument.length()==0 ? R.string.choose_name : R.string.name_taken;
|
|
| 71 |
}
|
|
| 100 | 72 |
|
| 101 |
final View view = inflater.inflate(R.layout.dialog_set_name, null); |
|
| 102 |
TextView text = view.findViewById(R.id.set_name_message); |
|
| 103 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
| 104 |
mEdit = view.findViewById(R.id.set_name); |
|
| 105 |
mEdit.setHeight( (int)(2*titleSize) ); |
|
| 106 |
mEdit.setTextSize(TypedValue.COMPLEX_UNIT_PX, 1.5f*titleSize); |
|
| 73 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 107 | 74 |
|
| 108 |
if( first ) |
|
| 109 |
{
|
|
| 110 |
text.setText(R.string.new_name); |
|
| 111 |
} |
|
| 112 |
else |
|
| 113 |
{
|
|
| 114 |
text.setText(act.getString(R.string.new_name_try_again, name)); |
|
| 115 |
} |
|
| 75 |
public boolean hasArgument() |
|
| 76 |
{
|
|
| 77 |
return true; |
|
| 78 |
} |
|
| 116 | 79 |
|
| 117 |
builder.setCancelable(true);
|
|
| 80 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
| 118 | 81 |
|
| 82 |
public void setPositive(AlertDialog.Builder builder) |
|
| 83 |
{
|
|
| 119 | 84 |
builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() |
| 120 | 85 |
{
|
| 121 | 86 |
@Override |
| ... | ... | |
| 140 | 105 |
RubikScores.getInstance().setName(name); |
| 141 | 106 |
|
| 142 | 107 |
Bundle bundle = new Bundle(); |
| 143 |
bundle.putInt("tab", RubikObjectList.getCurrObject() );
|
|
| 144 |
bundle.putBoolean("submitting", true);
|
|
| 145 |
|
|
| 108 |
bundle.putString("argument", "true");
|
|
| 146 | 109 |
RubikDialogScores scores = new RubikDialogScores(); |
| 147 | 110 |
scores.setArguments(bundle); |
| 148 | 111 |
scores.show(act.getSupportFragmentManager(), null); |
| ... | ... | |
| 154 | 117 |
} |
| 155 | 118 |
} |
| 156 | 119 |
}); |
| 120 |
} |
|
| 121 |
|
|
| 122 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 123 |
|
|
| 124 |
public void setNegative(AlertDialog.Builder builder) |
|
| 125 |
{
|
|
| 126 |
|
|
| 127 |
} |
|
| 128 |
|
|
| 129 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 130 |
|
|
| 131 |
public void onShowDialog(DialogInterface dialog, float size) |
|
| 132 |
{
|
|
| 133 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
| 134 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 135 |
} |
|
| 136 |
|
|
| 137 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 138 |
|
|
| 139 |
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size) |
|
| 140 |
{
|
|
| 141 |
TextView text = view.findViewById(R.id.set_name_message); |
|
| 142 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 143 |
mEdit = view.findViewById(R.id.set_name); |
|
| 144 |
mEdit.setHeight( (int)(2*mTitleSize) ); |
|
| 145 |
mEdit.setTextSize(TypedValue.COMPLEX_UNIT_PX, 1.5f*mTitleSize); |
|
| 146 |
|
|
| 147 |
if( mArgument.length()==0 ) |
|
| 148 |
{
|
|
| 149 |
text.setText(R.string.new_name); |
|
| 150 |
} |
|
| 151 |
else |
|
| 152 |
{
|
|
| 153 |
text.setText(act.getString(R.string.new_name_try_again, mArgument)); |
|
| 154 |
} |
|
| 157 | 155 |
|
| 158 |
builder.setView(view); |
|
| 159 |
final Dialog dialog = builder.create(); |
|
| 160 | 156 |
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); |
| 161 | 157 |
|
| 162 | 158 |
mEdit.requestFocus(); |
| ... | ... | |
| 175 | 171 |
((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(count>0); |
| 176 | 172 |
} |
| 177 | 173 |
}); |
| 178 |
|
|
| 179 |
dialog.setCanceledOnTouchOutside(false); |
|
| 180 |
Window window = dialog.getWindow(); |
|
| 181 |
|
|
| 182 |
if( window!=null ) |
|
| 183 |
{
|
|
| 184 |
window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS); |
|
| 185 |
} |
|
| 186 |
|
|
| 187 |
dialog.setOnShowListener(new DialogInterface.OnShowListener() |
|
| 188 |
{
|
|
| 189 |
@Override |
|
| 190 |
public void onShow(DialogInterface dialog) |
|
| 191 |
{
|
|
| 192 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
| 193 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize); |
|
| 194 |
} |
|
| 195 |
}); |
|
| 196 |
|
|
| 197 |
return dialog; |
|
| 198 | 174 |
} |
| 199 | 175 |
} |
| src/main/java/org/distorted/dialogs/RubikDialogSolved.java | ||
|---|---|---|
| 11 | 11 |
|
| 12 | 12 |
import android.app.Dialog; |
| 13 | 13 |
import android.content.DialogInterface; |
| 14 |
import android.os.Bundle; |
|
| 15 |
import androidx.annotation.NonNull; |
|
| 16 | 14 |
import androidx.fragment.app.FragmentActivity; |
| 17 | 15 |
import androidx.appcompat.app.AlertDialog; |
| 18 |
import androidx.appcompat.app.AppCompatDialogFragment; |
|
| 19 | 16 |
|
| 20 |
import android.util.DisplayMetrics; |
|
| 21 | 17 |
import android.util.TypedValue; |
| 22 |
import android.view.LayoutInflater; |
|
| 23 | 18 |
import android.view.View; |
| 24 |
import android.view.Window; |
|
| 25 | 19 |
import android.widget.Button; |
| 26 | 20 |
import android.widget.TextView; |
| 27 | 21 |
|
| ... | ... | |
| 31 | 25 |
|
| 32 | 26 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 33 | 27 |
|
| 34 |
public class RubikDialogSolved extends AppCompatDialogFragment
|
|
| 28 |
public class RubikDialogSolved extends RubikDialogAbstract
|
|
| 35 | 29 |
{
|
| 36 |
@NonNull |
|
| 37 |
@Override |
|
| 38 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
|
| 30 |
public int getResource() |
|
| 31 |
{
|
|
| 32 |
return R.layout.dialog_solved; |
|
| 33 |
} |
|
| 34 |
|
|
| 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 36 |
|
|
| 37 |
public int getTitleResource() |
|
| 38 |
{
|
|
| 39 |
return R.string.solved; |
|
| 40 |
} |
|
| 41 |
|
|
| 42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 43 |
|
|
| 44 |
public boolean hasArgument() |
|
| 45 |
{
|
|
| 46 |
return true; |
|
| 47 |
} |
|
| 48 |
|
|
| 49 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 50 |
|
|
| 51 |
public void setPositive(AlertDialog.Builder builder) |
|
| 39 | 52 |
{
|
| 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 |
final float textSize = h*0.022f; |
|
| 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.solved); |
|
| 54 |
builder.setCustomTitle(tv); |
|
| 55 |
|
|
| 56 |
builder.setCancelable(true); |
|
| 57 | 53 |
builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() |
| 58 | 54 |
{
|
| 59 | 55 |
@Override |
| ... | ... | |
| 63 | 59 |
ScreenList.switchScreen(act, ScreenList.PLAY); |
| 64 | 60 |
} |
| 65 | 61 |
}); |
| 62 |
} |
|
| 66 | 63 |
|
| 67 |
Bundle args = getArguments(); |
|
| 68 |
long time; |
|
| 64 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 69 | 65 |
|
| 70 |
try |
|
| 71 |
{
|
|
| 72 |
time = args.getLong("time");
|
|
| 73 |
} |
|
| 74 |
catch(Exception e) |
|
| 75 |
{
|
|
| 76 |
time = 0; |
|
| 77 |
} |
|
| 66 |
public void setNegative(AlertDialog.Builder builder) |
|
| 67 |
{
|
|
| 78 | 68 |
|
| 79 |
final View view = inflater.inflate(R.layout.dialog_solved, null); |
|
| 80 |
TextView text = view.findViewById(R.id.solved_time); |
|
| 81 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
| 82 |
text.setText(getString(R.string.ti_placeholder, (time/10)/100.0f)); |
|
| 83 |
builder.setView(view); |
|
| 69 |
} |
|
| 84 | 70 |
|
| 85 |
Dialog dialog = builder.create(); |
|
| 86 |
dialog.setCanceledOnTouchOutside(false); |
|
| 87 |
Window window = dialog.getWindow(); |
|
| 71 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 88 | 72 |
|
| 89 |
if( window!=null ) |
|
| 90 |
{
|
|
| 91 |
window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS); |
|
| 92 |
} |
|
| 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 |
} |
|
| 93 | 78 |
|
| 94 |
dialog.setOnShowListener(new DialogInterface.OnShowListener() |
|
| 95 |
{
|
|
| 96 |
@Override |
|
| 97 |
public void onShow(DialogInterface dialog) |
|
| 98 |
{
|
|
| 99 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
| 100 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize); |
|
| 101 |
} |
|
| 102 |
}); |
|
| 79 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 103 | 80 |
|
| 104 |
return dialog; |
|
| 81 |
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size) |
|
| 82 |
{
|
|
| 83 |
TextView text = view.findViewById(R.id.solved_time); |
|
| 84 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 85 |
text.setText(getString(R.string.ti_placeholder, mArgument)); |
|
| 105 | 86 |
} |
| 106 | 87 |
|
| 107 | 88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/dialogs/RubikDialogSolverError.java | ||
|---|---|---|
| 11 | 11 |
|
| 12 | 12 |
import android.app.Dialog; |
| 13 | 13 |
import android.content.DialogInterface; |
| 14 |
import android.os.Bundle; |
|
| 15 |
import androidx.annotation.NonNull; |
|
| 16 | 14 |
import androidx.fragment.app.FragmentActivity; |
| 17 | 15 |
import androidx.appcompat.app.AlertDialog; |
| 18 |
import androidx.appcompat.app.AppCompatDialogFragment; |
|
| 19 | 16 |
|
| 20 |
import android.util.DisplayMetrics; |
|
| 21 | 17 |
import android.util.TypedValue; |
| 22 |
import android.view.LayoutInflater; |
|
| 23 | 18 |
import android.view.View; |
| 24 |
import android.view.Window; |
|
| 25 | 19 |
import android.widget.Button; |
| 26 | 20 |
import android.widget.TextView; |
| 27 | 21 |
|
| 28 | 22 |
import org.distorted.main.R; |
| 29 |
import org.distorted.main.RubikActivity; |
|
| 30 | 23 |
|
| 31 | 24 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 32 | 25 |
|
| 33 |
public class RubikDialogSolverError extends AppCompatDialogFragment
|
|
| 26 |
public class RubikDialogSolverError extends RubikDialogAbstract
|
|
| 34 | 27 |
{
|
| 35 |
@NonNull |
|
| 36 |
@Override |
|
| 37 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
|
| 28 |
public int getResource() |
|
| 29 |
{
|
|
| 30 |
return R.layout.dialog_solver_error; |
|
| 31 |
} |
|
| 32 |
|
|
| 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 34 |
|
|
| 35 |
public int getTitleResource() |
|
| 36 |
{
|
|
| 37 |
return R.string.error; |
|
| 38 |
} |
|
| 39 |
|
|
| 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 41 |
|
|
| 42 |
public boolean hasArgument() |
|
| 43 |
{
|
|
| 44 |
return true; |
|
| 45 |
} |
|
| 46 |
|
|
| 47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 48 |
|
|
| 49 |
public void setPositive(AlertDialog.Builder builder) |
|
| 38 | 50 |
{
|
| 39 |
FragmentActivity act = getActivity(); |
|
| 40 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
| 41 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
|
| 42 |
|
|
| 43 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 44 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
|
| 45 |
int h = displaymetrics.heightPixels; |
|
| 46 |
final float titleSize= h * 0.030f; |
|
| 47 |
final float okSize = h * 0.040f; |
|
| 48 |
final float textSize = h * 0.033f; |
|
| 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.error); |
|
| 53 |
builder.setCustomTitle(tv); |
|
| 54 |
|
|
| 55 |
builder.setCancelable(true); |
|
| 56 | 51 |
builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() |
| 57 | 52 |
{
|
| 58 | 53 |
@Override |
| ... | ... | |
| 61 | 56 |
|
| 62 | 57 |
} |
| 63 | 58 |
}); |
| 59 |
} |
|
| 64 | 60 |
|
| 65 |
Bundle args = getArguments(); |
|
| 66 |
String errorStr; |
|
| 61 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 67 | 62 |
|
| 68 |
try |
|
| 69 |
{
|
|
| 70 |
errorStr = args.getString("error");
|
|
| 71 |
} |
|
| 72 |
catch(Exception e) |
|
| 73 |
{
|
|
| 74 |
errorStr = "Error"; |
|
| 75 |
} |
|
| 63 |
public void setNegative(AlertDialog.Builder builder) |
|
| 64 |
{
|
|
| 76 | 65 |
|
| 77 |
final View view = inflater.inflate(R.layout.dialog_solver_error, null); |
|
| 78 |
TextView text = view.findViewById(R.id.solver_error); |
|
| 79 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
| 80 |
text.setText(errorStr); |
|
| 81 |
builder.setView(view); |
|
| 66 |
} |
|
| 82 | 67 |
|
| 83 |
Dialog dialog = builder.create(); |
|
| 84 |
dialog.setCanceledOnTouchOutside(false); |
|
| 85 |
Window window = dialog.getWindow(); |
|
| 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 86 | 69 |
|
| 87 |
if( window!=null ) |
|
| 88 |
{
|
|
| 89 |
window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS); |
|
| 90 |
} |
|
| 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 |
} |
|
| 91 | 75 |
|
| 92 |
dialog.setOnShowListener(new DialogInterface.OnShowListener() |
|
| 93 |
{
|
|
| 94 |
@Override |
|
| 95 |
public void onShow(DialogInterface dialog) |
|
| 96 |
{
|
|
| 97 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
| 98 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize); |
|
| 99 |
} |
|
| 100 |
}); |
|
| 76 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 101 | 77 |
|
| 102 |
return dialog; |
|
| 78 |
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size) |
|
| 79 |
{
|
|
| 80 |
TextView text = view.findViewById(R.id.solver_error); |
|
| 81 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 82 |
text.setText(mArgument); |
|
| 103 | 83 |
} |
| 104 | 84 |
} |
Also available in: Unified diff
Continue unifying all the dialogs under one RubikDialogAbstract.