Project

General

Profile

Download (3.87 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / dialogs / RubikDialogSolverError.java @ 801b16db

1 ca292407 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19
20
package org.distorted.dialogs;
21
22
import android.app.Dialog;
23
import android.content.DialogInterface;
24
import android.os.Bundle;
25 66e777b0 Leszek Koltunski
import androidx.annotation.NonNull;
26
import androidx.fragment.app.FragmentActivity;
27
import androidx.appcompat.app.AlertDialog;
28
import androidx.appcompat.app.AppCompatDialogFragment;
29 ca292407 Leszek Koltunski
import android.view.LayoutInflater;
30
import android.view.View;
31
import android.view.Window;
32
import android.view.WindowManager;
33
import android.widget.TextView;
34
35
import org.distorted.main.R;
36
37
///////////////////////////////////////////////////////////////////////////////////////////////////
38
39
public class RubikDialogSolverError extends AppCompatDialogFragment
40
  {
41
  @Override
42
  public void onStart()
43
    {
44
    super.onStart();
45
46 584585d0 Leszek Koltunski
    Dialog dialog = getDialog();
47
48 801b16db Leszek Koltunski
    if( dialog!=null )
49 584585d0 Leszek Koltunski
      {
50 801b16db Leszek Koltunski
      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 584585d0 Leszek Koltunski
      }
59 ca292407 Leszek Koltunski
    }
60
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62
63
  @NonNull
64
  @Override
65
  public Dialog onCreateDialog(Bundle savedInstanceState)
66
    {
67
    FragmentActivity act = getActivity();
68
    LayoutInflater inflater = act.getLayoutInflater();
69
    AlertDialog.Builder builder = new AlertDialog.Builder(act);
70
71
    TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null);
72
    tv.setText(R.string.error);
73
    builder.setCustomTitle(tv);
74
75
    builder.setCancelable(true);
76
    builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
77
      {
78
      @Override
79
      public void onClick(DialogInterface dialog, int which)
80
        {
81
82
        }
83
      });
84
85
    Bundle args = getArguments();
86
    String errorStr;
87
88
    try
89
      {
90
      errorStr = args.getString("error");
91
      }
92
    catch(Exception e)
93
      {
94
      errorStr = "Error";
95
      }
96
97
    final View view = inflater.inflate(R.layout.dialog_solver_error, null);
98
    TextView text = view.findViewById(R.id.solver_error);
99
    text.setText(errorStr);
100
    builder.setView(view);
101
102
    return builder.create();
103
    }
104
  }