Project

General

Profile

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

magiccube / src / main / java / org / distorted / dialogs / RubikDialogUpdates.java @ c99db493

1 5f3801d3 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 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
import android.util.DisplayMetrics;
26
import android.util.TypedValue;
27
import android.view.LayoutInflater;
28
import android.view.Window;
29
import android.widget.Button;
30
import android.widget.TextView;
31
32
import androidx.annotation.NonNull;
33
import androidx.appcompat.app.AlertDialog;
34
import androidx.appcompat.app.AppCompatDialogFragment;
35
import androidx.fragment.app.FragmentActivity;
36
37
import org.distorted.main.R;
38
import org.distorted.main.RubikActivity;
39
import org.distorted.network.RubikNetwork;
40
import org.distorted.network.RubikUpdates;
41
42
///////////////////////////////////////////////////////////////////////////////////////////////////
43
44 c99db493 Leszek Koltunski
public class RubikDialogUpdates extends AppCompatDialogFragment implements RubikNetwork.Updatee
45 5f3801d3 Leszek Koltunski
  {
46
  @NonNull
47
  @Override
48
  public Dialog onCreateDialog(Bundle savedInstanceState)
49
    {
50
    FragmentActivity act = getActivity();
51
    LayoutInflater inflater = act.getLayoutInflater();
52
    AlertDialog.Builder builder = new AlertDialog.Builder(act);
53
54
    DisplayMetrics displaymetrics = new DisplayMetrics();
55
    act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
56
    final float titleSize= displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE;
57
    final float okSize   = displaymetrics.widthPixels * RubikActivity.DIALOG_BUTTON_SIZE;
58
59
    TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null);
60
    tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
61
    tv.setText(R.string.about);
62
    builder.setCustomTitle(tv);
63
64
    builder.setCancelable(true);
65
    builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
66
      {
67
      @Override
68
      public void onClick(DialogInterface dialog, int which)
69
        {
70
71
        }
72
      });
73
74
    Dialog dialog = builder.create();
75
    dialog.setCanceledOnTouchOutside(false);
76
    Window window = dialog.getWindow();
77
78
    if( window!=null )
79
      {
80
      window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS);
81
      }
82
83
    dialog.setOnShowListener(new DialogInterface.OnShowListener()
84
      {
85
      @Override
86
      public void onShow(DialogInterface dialog)
87
        {
88
        Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE);
89
        btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize);
90
        }
91
      });
92
93
    return dialog;
94
    }
95
96
///////////////////////////////////////////////////////////////////////////////////////////////////
97
98 c99db493 Leszek Koltunski
  public void receiveUpdate(RubikUpdates updates)
99 5f3801d3 Leszek Koltunski
    {
100
101
    }
102
103 c99db493 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
104
105
  public void errorUpdate()
106
    {
107
    android.util.Log.e("D", "Dialog: Error receiving update");
108
    }
109
110 5f3801d3 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
111
112
  public static String getDialogTag()
113
    {
114
    return "DialogUpdates";
115
    }
116
  }