Project

General

Profile

« Previous | Next » 

Revision f8a21f6b

Added by Leszek Koltunski almost 2 years ago

Unify all dialogs.

View differences:

src/main/java/org/distorted/dialogs/RubikDialogAbandon.java
10 10
package org.distorted.dialogs;
11 11

  
12 12
import android.app.Dialog;
13
import android.content.DialogInterface;
14
import android.util.TypedValue;
15 13
import android.view.View;
16
import android.widget.Button;
17 14

  
18
import androidx.appcompat.app.AlertDialog;
19 15
import androidx.fragment.app.FragmentActivity;
20 16

  
21 17
import org.distorted.main.R;
......
26 22

  
27 23
public class RubikDialogAbandon extends RubikDialogAbstract
28 24
  {
29
  public int getResource()
30
    {
31
    return R.layout.abandon_solve;
32
    }
33

  
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

  
36
  public int getTitleResource()
37
    {
38
    return -1;
39
    }
40

  
41
///////////////////////////////////////////////////////////////////////////////////////////////////
42

  
43
  public boolean hasArgument()
44
    {
45
    return false;
46
    }
25
  public int getResource()      { return R.layout.abandon_solve; }
26
  public int getTitleResource() { return -1; }
27
  public boolean hasArgument()  { return false; }
28
  public int getPositive()      { return R.string.yes; }
29
  public int getNegative()      { return R.string.no; }
47 30

  
48 31
///////////////////////////////////////////////////////////////////////////////////////////////////
49 32

  
50
  public void setPositive(AlertDialog.Builder builder)
33
  public void positiveAction()
51 34
    {
52 35
    final RubikActivity ract = (RubikActivity)getContext();
53

  
54
    builder.setPositiveButton( R.string.yes, new DialogInterface.OnClickListener()
55
      {
56
      @Override
57
      public void onClick(DialogInterface dialog, int which)
58
        {
59
        ScreenList.goBack(ract);
60
        }
61
      });
36
    ScreenList.goBack(ract);
62 37
    }
63 38

  
64 39
///////////////////////////////////////////////////////////////////////////////////////////////////
65 40

  
66
  public void setNegative(AlertDialog.Builder builder)
41
  public void negativeAction()
67 42
    {
68
    builder.setNegativeButton( R.string.no, new DialogInterface.OnClickListener()
69
      {
70
      @Override
71
      public void onClick(DialogInterface dialog, int which)
72
        {
73 43

  
74
        }
75
      });
76
    }
77

  
78
///////////////////////////////////////////////////////////////////////////////////////////////////
79

  
80
  public void onShowDialog(DialogInterface dialog, float size)
81
    {
82
    Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE);
83
    btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
84
    Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE);
85
    btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
86 44
    }
87 45

  
88 46
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/dialogs/RubikDialogAbout.java
10 10
package org.distorted.dialogs;
11 11

  
12 12
import android.app.Dialog;
13
import android.content.DialogInterface;
14 13
import android.content.pm.PackageInfo;
15 14
import android.content.pm.PackageManager;
16 15
import androidx.fragment.app.FragmentActivity;
17
import androidx.appcompat.app.AlertDialog;
18 16

  
19 17
import android.text.method.LinkMovementMethod;
20 18
import android.text.method.MovementMethod;
21 19
import android.util.TypedValue;
22 20
import android.view.View;
23
import android.widget.Button;
24 21
import android.widget.TextView;
25 22

  
26 23
import org.distorted.main.R;
......
30 27

  
31 28
public class RubikDialogAbout extends RubikDialogAbstract
32 29
  {
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 boolean hasArgument()
48
    {
49
    return false;
50
    }
30
  public int getResource()      { return R.layout.dialog_about; }
31
  public int getTitleResource() { return R.string.about; }
32
  public boolean hasArgument()  { return false; }
33
  public int getPositive()      { return R.string.ok; }
34
  public int getNegative()      { return -1; }
51 35

  
52 36
///////////////////////////////////////////////////////////////////////////////////////////////////
53 37

  
54
  public void setPositive(AlertDialog.Builder builder)
38
  public void positiveAction()
55 39
    {
56
    builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
57
      {
58
      @Override
59
      public void onClick(DialogInterface dialog, int which)
60
        {
61 40

  
62
        }
63
      });
64 41
    }
65 42

  
66 43
///////////////////////////////////////////////////////////////////////////////////////////////////
67 44

  
68
  public void setNegative(AlertDialog.Builder builder)
45
  public void negativeAction()
69 46
    {
70 47

  
71 48
    }
72 49

  
73
///////////////////////////////////////////////////////////////////////////////////////////////////
74

  
75
  public void onShowDialog(DialogInterface dialog, float size)
76
    {
77
    Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE);
78
    btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
79
    }
80

  
81 50
///////////////////////////////////////////////////////////////////////////////////////////////////
82 51

  
83 52
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
......
86 55
    String appName = getString(R.string.app_name);
87 56

  
88 57
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
89
    text.setText(getString(R.string.ap_placeholder,appName, getAppVers(act)));
58

  
59
    String version;
60
    try
61
      {
62
      PackageInfo pInfo = act.getPackageManager().getPackageInfo( act.getPackageName(), 0);
63
      version= pInfo.versionName;
64
      }
65
    catch (PackageManager.NameNotFoundException e)
66
      {
67
      version= "unknown";
68
      }
69

  
70
    text.setText(getString(R.string.ap_placeholder,appName, version));
90 71

  
91 72
    MovementMethod mm = LinkMovementMethod.getInstance();
92 73
    TextView text2 = view.findViewById(R.id.about_section2);
......
107 88
      text4.setVisibility(View.GONE);
108 89
      }
109 90
    }
110

  
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112

  
113
  private String getAppVers(FragmentActivity act)
114
    {
115
    try
116
      {
117
      PackageInfo pInfo = act.getPackageManager().getPackageInfo( act.getPackageName(), 0);
118
      return pInfo.versionName;
119
      }
120
    catch (PackageManager.NameNotFoundException e)
121
      {
122
      return "unknown";
123
      }
124
    }
125 91
  }
src/main/java/org/distorted/dialogs/RubikDialogAbstract.java
17 17
import android.view.LayoutInflater;
18 18
import android.view.View;
19 19
import android.view.Window;
20
import android.widget.Button;
20 21
import android.widget.TextView;
21 22

  
22 23
import androidx.annotation.NonNull;
......
39 40

  
40 41
  abstract int getResource();
41 42
  abstract int getTitleResource();
43
  abstract int getPositive();
44
  abstract int getNegative();
42 45
  abstract boolean hasArgument();
43
  abstract void setPositive(AlertDialog.Builder builder);
44
  abstract void setNegative(AlertDialog.Builder builder);
45
  abstract void onShowDialog(DialogInterface dialog, float size);
46
  abstract void positiveAction();
47
  abstract void negativeAction();
46 48
  abstract void prepareBody(Dialog dialog, View view, FragmentActivity act, float size);
47 49

  
48 50
///////////////////////////////////////////////////////////////////////////////////////////////////
......
91 93
      builder.setCustomTitle(tv);
92 94
      }
93 95

  
94
    setPositive(builder);
95
    setNegative(builder);
96
    int positive = getPositive();
97
    if( positive>=0 )
98
      {
99
      builder.setPositiveButton( positive, new DialogInterface.OnClickListener()
100
        {
101
        @Override
102
        public void onClick(DialogInterface dialog, int which)
103
          {
104
          positiveAction();
105
          }
106
        });
107
      }
108

  
109
    int negative = getNegative();
110
    if( negative>=0 )
111
      {
112
      builder.setNegativeButton( positive, new DialogInterface.OnClickListener()
113
        {
114
        @Override
115
        public void onClick(DialogInterface dialog, int which)
116
          {
117
          negativeAction();
118
          }
119
        });
120
      }
96 121

  
97 122
    Dialog dialog = builder.create();
98 123
    dialog.setCanceledOnTouchOutside(false);
......
111 136
      @Override
112 137
      public void onShow(DialogInterface dialog)
113 138
        {
114
        onShowDialog(dialog,mButSize);
139
        if( positive>=0 )
140
          {
141
          Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE);
142
          btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, mButSize);
143
          }
144
        if( negative>=0 )
145
          {
146
          Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE);
147
          btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, mButSize);
148
          }
115 149
        }
116 150
      });
117 151

  
src/main/java/org/distorted/dialogs/RubikDialogBandagedDelete.java
10 10
package org.distorted.dialogs;
11 11

  
12 12
import android.app.Dialog;
13
import android.content.DialogInterface;
14 13
import android.util.TypedValue;
15 14
import android.view.View;
16
import android.widget.Button;
17 15
import android.widget.TextView;
18 16

  
19
import androidx.appcompat.app.AlertDialog;
20 17
import androidx.fragment.app.FragmentActivity;
21 18

  
22 19
import org.distorted.bandaged.BandagedCreatorActivity;
......
26 23

  
27 24
public class RubikDialogBandagedDelete extends RubikDialogAbstract
28 25
  {
29
  public int getResource()
30
    {
31
    return R.layout.dialog_delete_object;
32
    }
33

  
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

  
36
  public int getTitleResource()
37
    {
38
    return R.string.delete_object;
39
    }
40

  
41
///////////////////////////////////////////////////////////////////////////////////////////////////
42

  
43
  public boolean hasArgument()
44
    {
45
    return true;
46
    }
26
  public int getResource()      { return R.layout.dialog_delete_object; }
27
  public int getTitleResource() { return R.string.delete_object; }
28
  public boolean hasArgument()  { return true; }
29
  public int getPositive()      { return R.string.yes; }
30
  public int getNegative()      { return R.string.no; }
47 31

  
48 32
///////////////////////////////////////////////////////////////////////////////////////////////////
49 33

  
50
  public void setPositive(AlertDialog.Builder builder)
34
  public void positiveAction()
51 35
    {
52
    final String objectName = mArgument;
53

  
54
    builder.setPositiveButton( R.string.yes, new DialogInterface.OnClickListener()
55
      {
56
      @Override
57
      public void onClick(DialogInterface dialog, int which)
58
        {
59
        BandagedCreatorActivity bact = (BandagedCreatorActivity)getContext();
60
        if( bact!=null ) bact.deleteObject(objectName);
61
        }
62
      });
36
    BandagedCreatorActivity bact = (BandagedCreatorActivity)getContext();
37
    if( bact!=null ) bact.deleteObject(mArgument);
63 38
    }
64 39

  
65 40
///////////////////////////////////////////////////////////////////////////////////////////////////
66 41

  
67
  public void setNegative(AlertDialog.Builder builder)
42
  public void negativeAction()
68 43
    {
69
    builder.setNegativeButton( R.string.no, new DialogInterface.OnClickListener()
70
      {
71
      @Override
72
      public void onClick(DialogInterface dialog, int which)
73
        {
74 44

  
75
        }
76
      });
77
    }
78

  
79
///////////////////////////////////////////////////////////////////////////////////////////////////
80

  
81
  public void onShowDialog(DialogInterface dialog, float size)
82
    {
83
    Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE);
84
    btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
85
    Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE);
86
    btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
87 45
    }
88 46

  
89 47
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/dialogs/RubikDialogBandagedSave.java
10 10
package org.distorted.dialogs;
11 11

  
12 12
import android.app.Dialog;
13
import android.content.DialogInterface;
14 13
import android.util.TypedValue;
15 14
import android.view.View;
16
import android.widget.Button;
17 15
import android.widget.TextView;
18 16

  
19
import androidx.appcompat.app.AlertDialog;
20 17
import androidx.fragment.app.FragmentActivity;
21 18

  
22 19
import org.distorted.bandaged.BandagedCreatorActivity;
......
27 24

  
28 25
public class RubikDialogBandagedSave extends RubikDialogAbstract
29 26
  {
30
  public int getResource()
31
    {
32
    return R.layout.dialog_save_object;
33
    }
27
  public int getResource()      { return R.layout.dialog_save_object; }
28
  public int getTitleResource() { return R.string.save_object; }
29
  public boolean hasArgument()  { return false; }
30
  public int getPositive()      { return R.string.yes; }
31
  public int getNegative()      { return R.string.no; }
34 32

  
35 33
///////////////////////////////////////////////////////////////////////////////////////////////////
36 34

  
37
  public int getTitleResource()
35
  public void positiveAction()
38 36
    {
39
    return R.string.save_object;
40
    }
41

  
42
///////////////////////////////////////////////////////////////////////////////////////////////////
43

  
44
  public boolean hasArgument()
45
    {
46
    return false;
47
    }
48

  
49
///////////////////////////////////////////////////////////////////////////////////////////////////
37
    BandagedCreatorActivity bact = (BandagedCreatorActivity)getContext();
50 38

  
51
  public void setPositive(AlertDialog.Builder builder)
52
    {
53
    builder.setPositiveButton( R.string.yes, new DialogInterface.OnClickListener()
39
    if( bact!=null )
54 40
      {
55
      @Override
56
      public void onClick(DialogInterface dialog, int which)
57
        {
58
        BandagedCreatorActivity bact = (BandagedCreatorActivity)getContext();
59

  
60
        if( bact!=null )
61
          {
62
          BandagedCreatorRenderer rend = bact.getRenderer();
63
          rend.saveObject();
64
          }
65
        }
66
      });
41
      BandagedCreatorRenderer rend = bact.getRenderer();
42
      rend.saveObject();
43
      }
67 44
    }
68 45

  
69 46
///////////////////////////////////////////////////////////////////////////////////////////////////
70 47

  
71
  public void setNegative(AlertDialog.Builder builder)
48
  public void negativeAction()
72 49
    {
73
    builder.setNegativeButton( R.string.no, new DialogInterface.OnClickListener()
74
      {
75
      @Override
76
      public void onClick(DialogInterface dialog, int which)
77
        {
78 50

  
79
        }
80
      });
81
    }
82

  
83
///////////////////////////////////////////////////////////////////////////////////////////////////
84

  
85
  public void onShowDialog(DialogInterface dialog, float size)
86
    {
87
    Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE);
88
    btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
89
    Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE);
90
    btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
91 51
    }
92 52

  
93 53
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/dialogs/RubikDialogError.java
10 10
package org.distorted.dialogs;
11 11

  
12 12
import android.app.Dialog;
13
import android.content.DialogInterface;
14 13
import android.util.TypedValue;
15 14
import android.view.View;
16
import android.widget.Button;
17 15
import android.widget.TextView;
18 16

  
19
import androidx.appcompat.app.AlertDialog;
20 17
import androidx.fragment.app.FragmentActivity;
21 18

  
22 19
import org.distorted.main.R;
......
25 22

  
26 23
public class RubikDialogError extends RubikDialogAbstract
27 24
  {
28
  public int getResource()
29
    {
30
    return R.layout.dialog_error;
31
    }
32

  
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34

  
35
  public int getTitleResource()
36
    {
37
    return R.string.opengl_error;
38
    }
39

  
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41

  
42
  public boolean hasArgument()
43
    {
44
    return false;
45
    }
25
  public int getResource()      { return R.layout.dialog_error; }
26
  public int getTitleResource() { return R.string.opengl_error; }
27
  public boolean hasArgument()  { return false; }
28
  public int getPositive()      { return R.string.ok; }
29
  public int getNegative()      { return -1; }
46 30

  
47 31
///////////////////////////////////////////////////////////////////////////////////////////////////
48 32

  
49
  public void setPositive(AlertDialog.Builder builder)
33
  public void positiveAction()
50 34
    {
51 35
    final FragmentActivity act = getActivity();
52

  
53
    builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
54
      {
55
      @Override
56
      public void onClick(DialogInterface dialog, int which)
57
        {
58
        if( act!=null ) act.finish();
59
        }
60
      });
36
    if( act!=null ) act.finish();
61 37
    }
62 38

  
63 39
///////////////////////////////////////////////////////////////////////////////////////////////////
64 40

  
65
  public void setNegative(AlertDialog.Builder builder)
41
  public void negativeAction()
66 42
    {
67 43

  
68 44
    }
69 45

  
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71

  
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 46
///////////////////////////////////////////////////////////////////////////////////////////////////
79 47

  
80 48
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
src/main/java/org/distorted/dialogs/RubikDialogNewRecord.java
10 10
package org.distorted.dialogs;
11 11

  
12 12
import android.app.Dialog;
13
import android.content.DialogInterface;
14 13
import android.os.Bundle;
15 14
import androidx.fragment.app.FragmentActivity;
16
import androidx.appcompat.app.AlertDialog;
17 15

  
18 16
import android.util.TypedValue;
19 17
import android.view.View;
20
import android.widget.Button;
21 18
import android.widget.TextView;
22 19

  
23 20
import org.distorted.main.R;
......
29 26

  
30 27
public class RubikDialogNewRecord extends RubikDialogAbstract
31 28
  {
32
  public int getResource()
33
    {
34
    return R.layout.dialog_new_record;
35
    }
29
  public int getResource()      { return R.layout.dialog_new_record; }
30
  public int getTitleResource() { return R.string.new_record; }
31
  public boolean hasArgument()  { return true; }
32
  public int getPositive()      { return R.string.yes; }
33
  public int getNegative()      { return R.string.no; }
36 34

  
37 35
///////////////////////////////////////////////////////////////////////////////////////////////////
38 36

  
39
  public int getTitleResource()
37
  public void positiveAction()
40 38
    {
41
    return R.string.new_record;
42
    }
43

  
44
///////////////////////////////////////////////////////////////////////////////////////////////////
39
    RubikActivity act = (RubikActivity)getActivity();
40
    RubikScores scores = RubikScores.getInstance();
41
    String name = scores.getName();
42
    Bundle bundle = new Bundle();
43
    ScreenList.switchScreen(act, ScreenList.PLAY);
45 44

  
46
  public boolean hasArgument()
47
    {
48
    return true;
49
    }
50

  
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52

  
53
  public void setPositive(AlertDialog.Builder builder)
54
    {
55
    builder.setPositiveButton( R.string.yes, new DialogInterface.OnClickListener()
45
    if( name.length()>0 )
56 46
      {
57
      @Override
58
      public void onClick(DialogInterface dialog, int which)
59
        {
60
        RubikActivity act = (RubikActivity)getActivity();
61
        RubikScores scores = RubikScores.getInstance();
62
        String name = scores.getName();
63
        Bundle bundle = new Bundle();
64
        ScreenList.switchScreen(act, ScreenList.PLAY);
65

  
66
        if( name.length()>0 )
67
          {
68
          bundle.putString("argument", "true");
69
          RubikDialogScores scoresDiag = new RubikDialogScores();
70
          scoresDiag.setArguments(bundle);
71
          scoresDiag.show(act.getSupportFragmentManager(), null);
72
          }
73
        else
74
          {
75
          bundle.putString("argument", name );
76
          RubikDialogSetName nameDiag = new RubikDialogSetName();
77
          nameDiag.setArguments(bundle);
78
          nameDiag.show(act.getSupportFragmentManager(), null);
79
          }
80
        }
81
      });
82
    }
83

  
84
///////////////////////////////////////////////////////////////////////////////////////////////////
85

  
86
  public void setNegative(AlertDialog.Builder builder)
87
    {
88
    builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener()
47
      bundle.putString("argument", "true");
48
      RubikDialogScores scoresDiag = new RubikDialogScores();
49
      scoresDiag.setArguments(bundle);
50
      scoresDiag.show(act.getSupportFragmentManager(), null);
51
      }
52
    else
89 53
      {
90
      @Override
91
      public void onClick(DialogInterface dialog, int which)
92
        {
93
        RubikActivity act = (RubikActivity)getActivity();
94
        ScreenList.switchScreen(act, ScreenList.PLAY);
95
        }
96
      });
54
      bundle.putString("argument", name );
55
      RubikDialogSetName nameDiag = new RubikDialogSetName();
56
      nameDiag.setArguments(bundle);
57
      nameDiag.show(act.getSupportFragmentManager(), null);
58
      }
97 59
    }
98 60

  
99 61
///////////////////////////////////////////////////////////////////////////////////////////////////
100 62

  
101
  public void onShowDialog(DialogInterface dialog, float size)
63
  public void negativeAction()
102 64
    {
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);
65
    RubikActivity act = (RubikActivity)getActivity();
66
    ScreenList.switchScreen(act, ScreenList.PLAY);
107 67
    }
108 68

  
109 69
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/dialogs/RubikDialogPattern.java
10 10
package org.distorted.dialogs;
11 11

  
12 12
import android.app.Dialog;
13
import android.content.Context;
14
import android.content.DialogInterface;
15
import android.os.Bundle;
16
import androidx.annotation.NonNull;
17 13
import androidx.fragment.app.FragmentActivity;
18 14
import androidx.viewpager.widget.ViewPager;
19
import androidx.appcompat.app.AlertDialog;
20
import androidx.appcompat.app.AppCompatDialogFragment;
21 15
import com.google.android.material.tabs.TabLayout;
22
import android.util.DisplayMetrics;
23
import android.util.TypedValue;
24
import android.view.LayoutInflater;
16

  
25 17
import android.view.View;
26 18
import android.view.ViewGroup;
27 19
import android.view.Window;
28 20
import android.view.WindowManager;
29
import android.widget.Button;
30 21
import android.widget.ImageView;
31
import android.widget.TextView;
32 22

  
33 23
import org.distorted.main.R;
34 24
import org.distorted.main.RubikActivity;
......
38 28

  
39 29
///////////////////////////////////////////////////////////////////////////////////////////////////
40 30

  
41
public class RubikDialogPattern extends AppCompatDialogFragment
31
public class RubikDialogPattern extends RubikDialogAbstract
42 32
  {
43 33
  private RubikDialogPatternPagerAdapter mPagerAdapter;
44 34

  
45 35
///////////////////////////////////////////////////////////////////////////////////////////////////
46 36

  
47
  @NonNull
48 37
  @Override
49
  public Dialog onCreateDialog(Bundle savedInstanceState)
38
  public void onResume()
50 39
    {
51
    final FragmentActivity act = getActivity();
52
    AlertDialog.Builder builder = new AlertDialog.Builder(act);
40
    super.onResume();
53 41

  
54
    DisplayMetrics displaymetrics = new DisplayMetrics();
55
    act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
42
    Window window = getDialog().getWindow();
56 43

  
57
    int h = displaymetrics.heightPixels;
58
    final float titleSize= h*RubikActivity.TAB_TEXT_SIZE;
59
    final float okSize   = h*RubikActivity.TAB_BUTTON_SIZE;
60
    final int   tabHeight= (int)(h*RubikActivity.TAB_HEIGHT);
61
    final int   tabWidth = (int)(h*RubikActivity.TAB_WIDTH);
44
    if( window!=null )
45
      {
46
      WindowManager.LayoutParams params = window.getAttributes();
47
      params.width  = (int)Math.min( mHeight*0.65f,mWidth*0.98f );
48
      params.height = (int)Math.min( mHeight*0.85f,mWidth*1.30f );
49
      window.setAttributes(params);
50
      }
51
    }
62 52

  
63
    LayoutInflater layoutInflater = act.getLayoutInflater();
64
    TextView tv = (TextView) layoutInflater.inflate(R.layout.dialog_title, null);
65
    tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
66
    tv.setText(R.string.choose_pattern);
67
    builder.setCustomTitle(tv);
53
///////////////////////////////////////////////////////////////////////////////////////////////////
68 54

  
69
    builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
70
      {
71
      @Override
72
      public void onClick(DialogInterface dialog, int which)
73
        {
55
  public int getResource()      { return R.layout.dialog_tabbed; }
56
  public int getTitleResource() { return R.string.choose_pattern; }
57
  public boolean hasArgument()  { return false; }
58
  public int getPositive()      { return R.string.ok; }
59
  public int getNegative()      { return -1; }
60

  
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62

  
63
  public void positiveAction()
64
    {
65

  
66
    }
67

  
68
///////////////////////////////////////////////////////////////////////////////////////////////////
74 69

  
75
        }
76
      });
70
  public void negativeAction()
71
    {
77 72

  
78
    LayoutInflater inflater = act.getLayoutInflater();
79
    final View view = inflater.inflate(R.layout.dialog_tabbed, null);
80
    builder.setView(view);
73
    }
74

  
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76

  
77
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
78
    {
79
    final int tabHeight= (int)(mHeight*RubikActivity.TAB_HEIGHT);
80
    final int tabWidth = (int)(mHeight*RubikActivity.TAB_WIDTH);
81 81

  
82 82
    ViewPager viewPager = view.findViewById(R.id.viewpager);
83 83
    TabLayout tabLayout = view.findViewById(R.id.sliding_tabs);
84 84
    mPagerAdapter = new RubikDialogPatternPagerAdapter(act, viewPager, this);
85 85
    tabLayout.setupWithViewPager(viewPager);
86
    viewPager.setCurrentItem(getPatternOrdinal());
86

  
87
    int obj = RubikObjectList.getCurrObject();
88
    int ord = RubikPatternList.getOrdinal(obj);
89
    if( ord<0 ) ord = RubikPatternList.getOrdinal(RubikObjectList.DEF_OBJECT);
90
    viewPager.setCurrentItem(ord);
87 91

  
88 92
    ViewGroup.LayoutParams paramsView = new ViewGroup.LayoutParams( tabWidth,tabHeight );
89 93

  
......
97 101
      TabLayout.Tab tab = tabLayout.getTabAt(i);
98 102
      if(tab!=null) tab.setCustomView(imageView);
99 103
      }
100

  
101
    Dialog dialog = builder.create();
102
    dialog.setCanceledOnTouchOutside(false);
103
    Window window = dialog.getWindow();
104

  
105
    if( window!=null )
106
      {
107
      window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS);
108
      }
109

  
110
    dialog.setOnShowListener(new DialogInterface.OnShowListener()
111
      {
112
      @Override
113
      public void onShow(DialogInterface dialog)
114
        {
115
        Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE);
116
        btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize);
117
        }
118
      });
119

  
120
    return dialog;
121
    }
122

  
123
///////////////////////////////////////////////////////////////////////////////////////////////////
124

  
125
  private int getPatternOrdinal()
126
    {
127
    int obj = RubikObjectList.getCurrObject();
128
    int ret = RubikPatternList.getOrdinal(obj);
129

  
130
    if( ret<0 )
131
      {
132
      ret = RubikPatternList.getOrdinal(RubikObjectList.DEF_OBJECT);
133
      }
134

  
135
    return ret;
136
    }
137

  
138
///////////////////////////////////////////////////////////////////////////////////////////////////
139

  
140
  @Override
141
  public void onResume()
142
    {
143
    super.onResume();
144

  
145
    Window window = getDialog().getWindow();
146
    Context context = getContext();
147

  
148
    if( window!=null && context!=null )
149
      {
150
      DisplayMetrics metrics = context.getResources().getDisplayMetrics();
151
      WindowManager.LayoutParams params = window.getAttributes();
152
      params.width  = (int)Math.min( 0.65f*metrics.heightPixels,0.98f*metrics.widthPixels );
153
      params.height = (int)Math.min( 0.85f*metrics.heightPixels,1.30f*metrics.widthPixels );
154
      window.setAttributes(params);
155
      }
156 104
    }
157 105

  
158 106
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/dialogs/RubikDialogPrivacy.java
10 10
package org.distorted.dialogs;
11 11

  
12 12
import android.app.Dialog;
13
import android.content.DialogInterface;
14 13
import android.text.method.LinkMovementMethod;
15 14
import android.text.method.MovementMethod;
16
import android.util.TypedValue;
17 15
import android.view.View;
18
import android.widget.Button;
19 16
import android.widget.TextView;
20 17

  
21
import androidx.appcompat.app.AlertDialog;
22 18
import androidx.fragment.app.FragmentActivity;
23 19

  
24 20
import org.distorted.main.R;
......
28 24

  
29 25
public class RubikDialogPrivacy extends RubikDialogAbstract
30 26
  {
31
  public int getResource()
32
    {
33
    return R.layout.dialog_privacy;
34
    }
35

  
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37

  
38
  public int getTitleResource()
39
    {
40
    return R.string.privacy_policy;
41
    }
27
  public int getResource()      { return R.layout.dialog_privacy; }
28
  public int getTitleResource() { return R.string.privacy_policy; }
29
  public boolean hasArgument()  { return false; }
30
  public int getPositive()      { return R.string.accept; }
31
  public int getNegative()      { return R.string.decline; }
42 32

  
43 33
///////////////////////////////////////////////////////////////////////////////////////////////////
44 34

  
45
  public boolean hasArgument()
35
  public void positiveAction()
46 36
    {
47
    return false;
48
    }
49

  
50
///////////////////////////////////////////////////////////////////////////////////////////////////
51

  
52
  public void setPositive(AlertDialog.Builder builder)
53
    {
54
    final RubikActivity ract = (RubikActivity)getContext();
55

  
56
    builder.setPositiveButton( R.string.accept, new DialogInterface.OnClickListener()
57
      {
58
      @Override
59
      public void onClick(DialogInterface dialog, int which)
60
        {
61
        if( ract!=null ) ract.acceptPrivacy();
62
        }
63
      });
64
    }
65

  
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67

  
68
  public void setNegative(AlertDialog.Builder builder)
69
    {
70
    final RubikActivity ract = (RubikActivity)getContext();
71

  
72
    builder.setNegativeButton( R.string.decline, new DialogInterface.OnClickListener()
73
      {
74
      @Override
75
      public void onClick(DialogInterface dialog, int which)
76
        {
77
        if( ract!=null ) ract.declinePrivacy();
78
        }
79
      });
37
    final RubikActivity act = (RubikActivity)getContext();
38
    if( act!=null ) act.acceptPrivacy();
80 39
    }
81 40

  
82 41
///////////////////////////////////////////////////////////////////////////////////////////////////
83 42

  
84
  public void onShowDialog(DialogInterface dialog, float size)
43
  public void negativeAction()
85 44
    {
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);
45
    final RubikActivity act = (RubikActivity)getContext();
46
    if( act!=null ) act.declinePrivacy();
90 47
    }
91 48

  
92 49
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/dialogs/RubikDialogScores.java
10 10
package org.distorted.dialogs;
11 11

  
12 12
import android.app.Dialog;
13
import android.content.Context;
14
import android.content.DialogInterface;
15
import android.os.Bundle;
16
import androidx.annotation.NonNull;
17 13
import androidx.fragment.app.FragmentActivity;
18 14
import androidx.viewpager.widget.ViewPager;
19
import androidx.appcompat.app.AlertDialog;
20
import androidx.appcompat.app.AppCompatDialogFragment;
21 15
import com.google.android.material.tabs.TabLayout;
22 16

  
23
import android.util.DisplayMetrics;
24
import android.util.TypedValue;
25
import android.view.LayoutInflater;
26 17
import android.view.View;
27 18
import android.view.ViewGroup;
28 19
import android.view.Window;
29 20
import android.view.WindowManager;
30
import android.widget.Button;
31 21
import android.widget.ImageView;
32
import android.widget.TextView;
33 22

  
34 23
import org.distorted.main.R;
35 24
import org.distorted.main.RubikActivity;
......
38 27

  
39 28
///////////////////////////////////////////////////////////////////////////////////////////////////
40 29

  
41
public class RubikDialogScores extends AppCompatDialogFragment
30
public class RubikDialogScores extends RubikDialogAbstract
42 31
  {
43 32
  private RubikDialogScoresPagerAdapter mPagerAdapter;
44 33

  
45 34
///////////////////////////////////////////////////////////////////////////////////////////////////
46 35

  
47
  @NonNull
48 36
  @Override
49
  public Dialog onCreateDialog(Bundle savedInstanceState)
37
  public void onResume()
50 38
    {
51
    FragmentActivity act = getActivity();
52
    AlertDialog.Builder builder = new AlertDialog.Builder(act);
53

  
54
    DisplayMetrics displaymetrics = new DisplayMetrics();
55
    act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
56

  
57
    int h = displaymetrics.heightPixels;
58
    final float titleSize= h*RubikActivity.TAB_TEXT_SIZE;
59
    final float okSize   = h*RubikActivity.TAB_BUTTON_SIZE;
60
    final int   tabHeight= (int)(h*RubikActivity.TAB_HEIGHT);
61
    final int   tabWidth = (int)(h*RubikActivity.TAB_WIDTH);
62

  
63
    LayoutInflater layoutInflater = act.getLayoutInflater();
64
    TextView tv = (TextView) layoutInflater.inflate(R.layout.dialog_title, null);
65
    tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
66
    tv.setText(R.string.scores);
67
    builder.setCustomTitle(tv);
68

  
69
    builder.setCancelable(true);
70
    builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
71
      {
72
      @Override
73
      public void onClick(DialogInterface dialog, int which)
74
        {
75

  
76
        }
77
      });
39
    super.onResume();
78 40

  
79
    Bundle args = getArguments();
80
    String submitting;
41
    Window window = getDialog().getWindow();
81 42

  
82
    try
83
      {
84
      submitting = args.getString("argument");
85
      }
86
    catch(Exception e)
43
    if( window!=null )
87 44
      {
88
      submitting = "";
45
      WindowManager.LayoutParams params = window.getAttributes();
46
      params.width  = (int)Math.min( mHeight*0.65f,mWidth*0.98f );
47
      params.height = (int)( mHeight*0.77f);
48
      window.setAttributes(params);
89 49
      }
50
    }
51

  
52
///////////////////////////////////////////////////////////////////////////////////////////////////
90 53

  
91
    LayoutInflater inflater = act.getLayoutInflater();
92
    final View view = inflater.inflate(R.layout.dialog_tabbed, null);
93
    builder.setView(view);
54
  public int getResource()      { return R.layout.dialog_tabbed; }
55
  public int getTitleResource() { return R.string.scores; }
56
  public boolean hasArgument()  { return true; }
57
  public int getPositive()      { return R.string.ok; }
58
  public int getNegative()      { return -1; }
59

  
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61

  
62
  public void positiveAction()
63
    {
64

  
65
    }
66

  
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68

  
69
  public void negativeAction()
70
    {
71

  
72
    }
73

  
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75

  
76
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
77
    {
78
    final int tabHeight= (int)(mHeight*RubikActivity.TAB_HEIGHT);
79
    final int tabWidth = (int)(mHeight*RubikActivity.TAB_WIDTH);
94 80

  
95 81
    ViewPager viewPager = view.findViewById(R.id.viewpager);
96 82
    TabLayout tabLayout = view.findViewById(R.id.sliding_tabs);
97
    mPagerAdapter = new RubikDialogScoresPagerAdapter(act,viewPager,submitting.equals("true"), this);
83
    mPagerAdapter = new RubikDialogScoresPagerAdapter(act,viewPager,mArgument.equals("true"), this);
98 84
    tabLayout.setupWithViewPager(viewPager);
99 85

  
100 86
    viewPager.setCurrentItem(RubikObjectList.getCurrObject());
......
110 96
      TabLayout.Tab tab = tabLayout.getTabAt(object);
111 97
      if(tab!=null) tab.setCustomView(imageView);
112 98
      }
113

  
114
    Dialog dialog = builder.create();
115
    dialog.setCanceledOnTouchOutside(false);
116
    Window window = dialog.getWindow();
117

  
118
    if( window!=null )
119
      {
120
      window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS);
121
      }
122

  
123
    dialog.setOnShowListener(new DialogInterface.OnShowListener()
124
      {
125
      @Override
126
      public void onShow(DialogInterface dialog)
127
        {
128
        Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE);
129
        btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize);
130
        }
131
      });
132

  
133
    return dialog;
134
    }
135

  
136
///////////////////////////////////////////////////////////////////////////////////////////////////
137

  
138
  @Override
139
  public void onResume()
140
    {
141
    super.onResume();
142

  
143
    Window window = getDialog().getWindow();
144
    Context context = getContext();
145

  
146
    if( window!=null && context!=null )
147
      {
148
      DisplayMetrics metrics = context.getResources().getDisplayMetrics();
149
      WindowManager.LayoutParams params = window.getAttributes();
150
      params.width  = (int)Math.min( 0.65f*metrics.heightPixels,0.98f*metrics.widthPixels );
151
      params.height = (int)(0.77f*metrics.heightPixels);
152
      window.setAttributes(params);
153
      }
154 99
    }
155 100
  }
src/main/java/org/distorted/dialogs/RubikDialogSetName.java
10 10
package org.distorted.dialogs;
11 11

  
12 12
import android.app.Dialog;
13
import android.content.DialogInterface;
14 13
import android.os.Bundle;
15 14
import androidx.fragment.app.FragmentActivity;
16 15
import androidx.appcompat.app.AlertDialog;
......
58 57

  
59 58
///////////////////////////////////////////////////////////////////////////////////////////////////
60 59

  
61
  public int getResource()
62
    {
63
    return R.layout.dialog_set_name;
64
    }
65

  
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67

  
68
  public int getTitleResource()
69
    {
70
    return mArgument.length()==0 ? R.string.choose_name : R.string.name_taken;
71
    }
60
  public int getResource()      { return R.layout.dialog_set_name; }
61
  public int getTitleResource() { return mArgument.length()==0 ? R.string.choose_name : R.string.name_taken; }
62
  public boolean hasArgument()  { return true; }
63
  public int getPositive()      { return R.string.ok; }
64
  public int getNegative()      { return -1; }
72 65

  
73 66
///////////////////////////////////////////////////////////////////////////////////////////////////
74 67

  
75
  public boolean hasArgument()
68
  public void positiveAction()
76 69
    {
77
    return true;
78
    }
79

  
80
///////////////////////////////////////////////////////////////////////////////////////////////////
70
    String name = mEdit.getText().toString();
71
    int len = name.length();
81 72

  
82
  public void setPositive(AlertDialog.Builder builder)
83
    {
84
    builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
73
    if( len>0 )
85 74
      {
86
      @Override
87
      public void onClick(DialogInterface dialog, int which)
75
      if( len>MAX_NAME_LEN )
88 76
        {
89
        String name = mEdit.getText().toString();
90
        int len = name.length();
91

  
92
        if( len>0 )
93
          {
94
          if( len>MAX_NAME_LEN )
95
            {
96
            name = name.substring(0,MAX_NAME_LEN);
97
            }
98

  
99
          name = name.replace(' ', '_');
100

  
101
          try
102
            {
103
            RubikActivity act = (RubikActivity)getActivity();
104
            ScreenList.switchScreen(act, ScreenList.PLAY);
105
            RubikScores.getInstance().setName(name);
106

  
107
            Bundle bundle = new Bundle();
108
            bundle.putString("argument", "true");
109
            RubikDialogScores scores = new RubikDialogScores();
110
            scores.setArguments(bundle);
111
            scores.show(act.getSupportFragmentManager(), null);
112
            }
113
          catch(IllegalStateException ex)
114
            {
115
            android.util.Log.e("D", "IllegalStateException trying to display SetName");
116
            }
117
          }
77
        name = name.substring(0,MAX_NAME_LEN);
118 78
        }
119
      });
120
    }
121

  
122
///////////////////////////////////////////////////////////////////////////////////////////////////
123 79

  
124
  public void setNegative(AlertDialog.Builder builder)
125
    {
80
      name = name.replace(' ', '_');
126 81

  
82
      try
83
        {
84
        RubikActivity act = (RubikActivity)getActivity();
85
        ScreenList.switchScreen(act, ScreenList.PLAY);
86
        RubikScores.getInstance().setName(name);
87

  
88
        Bundle bundle = new Bundle();
89
        bundle.putString("argument", "true");
90
        RubikDialogScores scores = new RubikDialogScores();
91
        scores.setArguments(bundle);
92
        scores.show(act.getSupportFragmentManager(), null);
93
        }
94
      catch(IllegalStateException ex)
95
        {
96
        android.util.Log.e("D", "IllegalStateException trying to display SetName");
97
        }
98
      }
127 99
    }
128 100

  
129 101
///////////////////////////////////////////////////////////////////////////////////////////////////
130 102

  
131
  public void onShowDialog(DialogInterface dialog, float size)
103
  public void negativeAction()
132 104
    {
133
    Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE);
134
    btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
105

  
135 106
    }
136 107

  
137 108
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/dialogs/RubikDialogSolved.java
10 10
package org.distorted.dialogs;
11 11

  
12 12
import android.app.Dialog;
13
import android.content.DialogInterface;
14 13
import androidx.fragment.app.FragmentActivity;
15
import androidx.appcompat.app.AlertDialog;
16 14

  
17 15
import android.util.TypedValue;
18 16
import android.view.View;
19
import android.widget.Button;
20 17
import android.widget.TextView;
21 18

  
22 19
import org.distorted.main.R;
......
27 24

  
28 25
public class RubikDialogSolved extends RubikDialogAbstract
29 26
  {
30
  public int getResource()
31
    {
32
    return R.layout.dialog_solved;
33
    }
27
  public int getResource()      { return R.layout.dialog_solved; }
28
  public int getTitleResource() { return R.string.solved; }
29
  public boolean hasArgument()  { return true; }
30
  public int getPositive()      { return R.string.ok; }
31
  public int getNegative()      { return -1; }
34 32

  
35 33
///////////////////////////////////////////////////////////////////////////////////////////////////
36 34

  
37
  public int getTitleResource()
35
  public void positiveAction()
38 36
    {
39
    return R.string.solved;
37
    RubikActivity act = (RubikActivity)getActivity();
38
    ScreenList.switchScreen(act, ScreenList.PLAY);
40 39
    }
41 40

  
42 41
///////////////////////////////////////////////////////////////////////////////////////////////////
43 42

  
44
  public boolean hasArgument()
43
  public void negativeAction()
45 44
    {
46
    return true;
47
    }
48

  
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50 45

  
51
  public void setPositive(AlertDialog.Builder builder)
52
    {
53
    builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
54
      {
55
      @Override
56
      public void onClick(DialogInterface dialog, int which)
57
        {
58
        RubikActivity act = (RubikActivity)getActivity();
59
        ScreenList.switchScreen(act, ScreenList.PLAY);
60
        }
61
      });
62
    }
63

  
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65

  
66
  public void setNegative(AlertDialog.Builder builder)
67
    {
68

  
69
    }
70

  
71
///////////////////////////////////////////////////////////////////////////////////////////////////
72

  
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 46
    }
78 47

  
79 48
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/dialogs/RubikDialogSolverError.java
10 10
package org.distorted.dialogs;
11 11

  
12 12
import android.app.Dialog;
13
import android.content.DialogInterface;
14 13
import androidx.fragment.app.FragmentActivity;
15
import androidx.appcompat.app.AlertDialog;
16 14

  
17 15
import android.util.TypedValue;
18 16
import android.view.View;
19
import android.widget.Button;
20 17
import android.widget.TextView;
21 18

  
22 19
import org.distorted.main.R;
......
25 22

  
26 23
public class RubikDialogSolverError extends RubikDialogAbstract
27 24
  {
28
  public int getResource()
29
    {
30
    return R.layout.dialog_solver_error;
31
    }
25
  public int getResource()      { return R.layout.dialog_solver_error; }
26
  public int getTitleResource() { return R.string.error; }
27
  public boolean hasArgument()  { return true; }
28
  public int getPositive()      { return R.string.ok; }
29
  public int getNegative()      { return -1; }
32 30

  
33 31
///////////////////////////////////////////////////////////////////////////////////////////////////
34 32

  
35
  public int getTitleResource()
33
  public void positiveAction()
36 34
    {
37
    return R.string.error;
38
    }
39

  
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41 35

  
42
  public boolean hasArgument()
43
    {
44
    return true;
45 36
    }
46 37

  
47 38
///////////////////////////////////////////////////////////////////////////////////////////////////
48 39

  
49
  public void setPositive(AlertDialog.Builder builder)
40
  public void negativeAction()
50 41
    {
51
    builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
52
      {
53
      @Override
54
      public void onClick(DialogInterface dialog, int which)
55
        {
56

  
57
        }
58
      });
59
    }
60 42

  
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62

  
63
  public void setNegative(AlertDialog.Builder builder)
64
    {
65

  
66
    }
67

  
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 43
    }
75 44

  
76 45
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/dialogs/RubikDialogStarsExplain.java
10 10
package org.distorted.dialogs;
11 11

  
12 12
import android.app.Dialog;
13
import android.content.DialogInterface;
14 13
import android.util.TypedValue;
15 14
import android.view.View;
16
import android.widget.Button;
17 15
import android.widget.TextView;
18 16

  
19
import androidx.appcompat.app.AlertDialog;
20 17
import androidx.fragment.app.FragmentActivity;
21 18

  
22 19
import org.distorted.main.R;
......
25 22

  
26 23
public class RubikDialogStarsExplain extends RubikDialogAbstract
27 24
  {
28
  public int getResource()
29
    {
30
    return R.layout.dialog_stars_explain;
31
    }
25
  public int getResource()      { return R.layout.dialog_stars_explain; }
26
  public int getTitleResource() { return -1; }
27
  public boolean hasArgument()  { return false; }
28
  public int getPositive()      { return R.string.ok; }
29
  public int getNegative()      { return -1; }
32 30

  
33 31
///////////////////////////////////////////////////////////////////////////////////////////////////
34 32

  
35
  public int getTitleResource()
33
  public void positiveAction()
36 34
    {
37
    return -1;
38
    }
39

  
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41 35

  
42
  public boolean hasArgument()
43
    {
44
    return false;
45 36
    }
46 37

  
47 38
///////////////////////////////////////////////////////////////////////////////////////////////////
48 39

  
49
  public void setPositive(AlertDialog.Builder builder)
40
  public void negativeAction()
50 41
    {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff