Project

General

Profile

« Previous | Next » 

Revision 85248b04

Added by Leszek Koltunski over 4 years ago

Finally solve the bug on Samsung Android 9 and 10 phones that the Dialogs Main & patterns wouldn't be modeless: move the setting of this flag earlier, to the 'onCreateDialog()' function.

View differences:

src/main/java/org/distorted/dialogs/RubikDialogAbout.java
38 38

  
39 39
public class RubikDialogAbout extends AppCompatDialogFragment
40 40
  {
41
  @Override
42
  public void onStart()
43
    {
44
    super.onStart();
45

  
46
    Dialog dialog = getDialog();
47

  
48
    if( dialog!=null )
49
      {
50
      dialog.setCanceledOnTouchOutside(false);
51

  
52
      Window window = dialog.getWindow();
53

  
54
      if( window!=null )
55
        {
56
        window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
57
        }
58
      }
59
    }
60

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

  
63 41
  @NonNull
64 42
  @Override
65 43
  public Dialog onCreateDialog(Bundle savedInstanceState)
......
89 67
    text.setText(getString(R.string.ap_placeholder,appName, appVers));
90 68
    builder.setView(view);
91 69

  
92
    return builder.create();
70
    Dialog dialog = builder.create();
71

  
72
    dialog.setCanceledOnTouchOutside(false);
73

  
74
    Window window = dialog.getWindow();
75

  
76
    if( window!=null )
77
      {
78
      window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
79
      }
80

  
81
    return dialog;
93 82
    }
94 83
  }
src/main/java/org/distorted/dialogs/RubikDialogEffects.java
49 49
  {
50 50
  private TextView[] mDurationText;
51 51

  
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

  
54
  @Override
55
  public void onStart()
56
    {
57
    super.onStart();
58

  
59
    Dialog dialog = getDialog();
60

  
61
    if( dialog!=null )
62
      {
63
      dialog.setCanceledOnTouchOutside(false);
64

  
65
      Window window = dialog.getWindow();
66

  
67
      if( window!=null )
68
        {
69
        window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
70
        }
71
      }
72
    }
73

  
74 52
///////////////////////////////////////////////////////////////////////////////////////////////////
75 53

  
76 54
  private void addSettingsSection(FragmentActivity act, LinearLayout layout, int index)
......
259 237
      android.util.Log.e("dialog_settings", "linearLayout NULL!");
260 238
      }
261 239

  
262
    return builder.create();
240
    Dialog dialog = builder.create();
241

  
242
    dialog.setCanceledOnTouchOutside(false);
243

  
244
    Window window = dialog.getWindow();
245

  
246
    if( window!=null )
247
      {
248
      window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
249
      }
250

  
251
    return dialog;
263 252
    }
264 253

  
265 254
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/dialogs/RubikDialogMain.java
36 36

  
37 37
public class RubikDialogMain extends AppCompatDialogFragment
38 38
  {
39
  @Override
40
  public void onStart()
41
    {
42
    super.onStart();
43

  
44
    Dialog dialog = getDialog();
45

  
46
    if( dialog!=null )
47
      {
48
      dialog.setCanceledOnTouchOutside(false);
49

  
50
      Window window = dialog.getWindow();
51

  
52
      if( window!=null )
53
        {
54
        window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
55
                        WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
56
        window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
57
        }
58
      }
59
    }
60

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

  
63 39
  @NonNull
64 40
  @Override
65 41
  public Dialog onCreateDialog(Bundle savedInstanceState)
......
70 46
    final View view = inflater.inflate(R.layout.dialog_main, null);
71 47
    builder.setView(view);
72 48

  
73
    return builder.create();
49
    Dialog dialog = builder.create();
50

  
51
    dialog.setCanceledOnTouchOutside(false);
52

  
53
    Window window = dialog.getWindow();
54

  
55
    if( window!=null )
56
      {
57
      window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
58
                      WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
59
      window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
60
      }
61

  
62
    return dialog;
74 63
    }
75 64

  
76 65
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/dialogs/RubikDialogNewRecord.java
141 141
    text.setText(getString(R.string.ti_placeholder, (time/100)/10.0f));
142 142
    builder.setView(view);
143 143

  
144
    return builder.create();
144
    Dialog dialog = builder.create();
145

  
146
    dialog.setCanceledOnTouchOutside(false);
147

  
148
    Window window = dialog.getWindow();
149

  
150
    if( window!=null )
151
      {
152
      window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
153
      }
154

  
155
    return dialog;
145 156
    }
146 157
  }
src/main/java/org/distorted/dialogs/RubikDialogPattern.java
46 46
  {
47 47
  private RubikDialogPatternPagerAdapter mPagerAdapter;
48 48

  
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50

  
51
  @Override
52
  public void onStart()
53
    {
54
    super.onStart();
55

  
56
    Dialog dialog = getDialog();
57

  
58
    if( dialog!=null )
59
      {
60
      dialog.setCanceledOnTouchOutside(false);
61

  
62
      Window window = dialog.getWindow();
63

  
64
      if( window!=null )
65
        {
66
        window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
67
                        WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
68
        window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
69
        }
70
      }
71
    }
72

  
73 49
///////////////////////////////////////////////////////////////////////////////////////////////////
74 50

  
75 51
  @NonNull
......
119 95
      if(tab!=null) tab.setCustomView(imageView);
120 96
      }
121 97

  
122
    return builder.create();
98
    Dialog dialog = builder.create();
99

  
100
    dialog.setCanceledOnTouchOutside(false);
101

  
102
    Window window = dialog.getWindow();
103

  
104
    if( window!=null )
105
      {
106
      window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
107
                      WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
108
      window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
109
      }
110

  
111
    return dialog;
123 112
    }
124 113

  
125 114
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/dialogs/RubikDialogScores.java
42 42

  
43 43
public class RubikDialogScores extends AppCompatDialogFragment
44 44
  {
45
  RubikDialogScoresPagerAdapter mPagerAdapter;
46

  
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48

  
49
  @Override
50
  public void onStart()
51
    {
52
    super.onStart();
53

  
54
    Dialog dialog = getDialog();
55

  
56
    if( dialog!=null )
57
      {
58
      dialog.setCanceledOnTouchOutside(false);
59

  
60
      Window window = dialog.getWindow();
61

  
62
      if( window!=null )
63
        {
64
        window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
65
        }
66
      }
67
    }
45
  private RubikDialogScoresPagerAdapter mPagerAdapter;
68 46

  
69 47
///////////////////////////////////////////////////////////////////////////////////////////////////
70 48

  
......
133 111
        }
134 112
      }
135 113

  
136
    return builder.create();
114
    Dialog dialog = builder.create();
115

  
116
    dialog.setCanceledOnTouchOutside(false);
117

  
118
    Window window = dialog.getWindow();
119

  
120
    if( window!=null )
121
      {
122
      window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
123
      }
124

  
125
    return dialog;
137 126
    }
138 127
  }
src/main/java/org/distorted/dialogs/RubikDialogSetName.java
49 49
  {
50 50
  private EditText mEdit;
51 51

  
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

  
54
  @Override
55
  public void onStart()
56
    {
57
    super.onStart();
58

  
59
    AlertDialog dialog = (AlertDialog) getDialog();
60

  
61
    if (dialog != null)
62
      {
63
      dialog.setCanceledOnTouchOutside(false);
64

  
65
      Window window = dialog.getWindow();
66

  
67
      if( window!=null )
68
        {
69
        window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
70
        }
71

  
72
      Button positiveButton = dialog.getButton(Dialog.BUTTON_POSITIVE);
73

  
74
      if( positiveButton!=null )
75
        {
76
        String editName = mEdit.getText().toString();
77
        positiveButton.setEnabled(editName.length()>0);
78
        }
79
      }
80
    }
81

  
82 52
///////////////////////////////////////////////////////////////////////////////////////////////////
83 53

  
84 54
  @NonNull
......
172 142
        }
173 143
      });
174 144

  
145
    dialog.setCanceledOnTouchOutside(false);
146

  
147
    Window window = dialog.getWindow();
148

  
149
    if( window!=null )
150
      {
151
      window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
152
      }
153

  
154
    Button positiveButton = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE);
155

  
156
    if( positiveButton!=null )
157
      {
158
      String editName = mEdit.getText().toString();
159
      positiveButton.setEnabled(editName.length()>0);
160
      }
161

  
175 162
    return dialog;
176 163
    }
177 164
  }
src/main/java/org/distorted/dialogs/RubikDialogSolved.java
40 40

  
41 41
public class RubikDialogSolved extends AppCompatDialogFragment
42 42
  {
43
  @Override
44
  public void onStart()
45
    {
46
    super.onStart();
47

  
48
    Dialog dialog = getDialog();
49

  
50
    if( dialog!=null )
51
      {
52
      dialog.setCanceledOnTouchOutside(false);
53

  
54
      Window window = dialog.getWindow();
55

  
56
      if( window!=null )
57
        {
58
        window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
59
        }
60
      }
61
    }
62

  
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64

  
65 43
  @NonNull
66 44
  @Override
67 45
  public Dialog onCreateDialog(Bundle savedInstanceState)
......
102 80
    text.setText(getString(R.string.ti_placeholder, (time/100)/10.0f));
103 81
    builder.setView(view);
104 82

  
105
    return builder.create();
83
    Dialog dialog = builder.create();
84

  
85
    dialog.setCanceledOnTouchOutside(false);
86

  
87
    Window window = dialog.getWindow();
88

  
89
    if( window!=null )
90
      {
91
      window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
92
      }
93

  
94
    return dialog;
106 95
    }
107 96
  }
src/main/java/org/distorted/dialogs/RubikDialogSolverError.java
38 38

  
39 39
public class RubikDialogSolverError extends AppCompatDialogFragment
40 40
  {
41
  @Override
42
  public void onStart()
43
    {
44
    super.onStart();
45

  
46
    Dialog dialog = getDialog();
47

  
48
    if( dialog!=null )
49
      {
50
      dialog.setCanceledOnTouchOutside(false);
51

  
52
      Window window = dialog.getWindow();
53

  
54
      if( window!=null )
55
        {
56
        window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
57
        }
58
      }
59
    }
60

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

  
63 41
  @NonNull
64 42
  @Override
65 43
  public Dialog onCreateDialog(Bundle savedInstanceState)
......
99 77
    text.setText(errorStr);
100 78
    builder.setView(view);
101 79

  
102
    return builder.create();
80
    Dialog dialog = builder.create();
81

  
82
    dialog.setCanceledOnTouchOutside(false);
83

  
84
    Window window = dialog.getWindow();
85

  
86
    if( window!=null )
87
      {
88
      window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
89
      }
90

  
91
    return dialog;
103 92
    }
104 93
  }

Also available in: Unified diff