Project

General

Profile

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

magiccube / src / main / java / org / distorted / dialogs / RubikDialogUpdates.java @ 5f3801d3

1
///////////////////////////////////////////////////////////////////////////////////////////////////
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.content.pm.PackageInfo;
25
import android.content.pm.PackageManager;
26
import android.os.Bundle;
27
import android.text.method.LinkMovementMethod;
28
import android.text.method.MovementMethod;
29
import android.util.DisplayMetrics;
30
import android.util.TypedValue;
31
import android.view.LayoutInflater;
32
import android.view.View;
33
import android.view.Window;
34
import android.widget.Button;
35
import android.widget.TextView;
36

    
37
import androidx.annotation.NonNull;
38
import androidx.appcompat.app.AlertDialog;
39
import androidx.appcompat.app.AppCompatDialogFragment;
40
import androidx.fragment.app.FragmentActivity;
41

    
42
import org.distorted.main.R;
43
import org.distorted.main.RubikActivity;
44
import org.distorted.network.RubikNetwork;
45
import org.distorted.network.RubikUpdates;
46

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

    
49
public class RubikDialogUpdates extends AppCompatDialogFragment
50
  {
51
  @NonNull
52
  @Override
53
  public Dialog onCreateDialog(Bundle savedInstanceState)
54
    {
55
    FragmentActivity act = getActivity();
56
    LayoutInflater inflater = act.getLayoutInflater();
57
    AlertDialog.Builder builder = new AlertDialog.Builder(act);
58

    
59
    DisplayMetrics displaymetrics = new DisplayMetrics();
60
    act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
61
    final float titleSize= displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE;
62
    final float okSize   = displaymetrics.widthPixels * RubikActivity.DIALOG_BUTTON_SIZE;
63

    
64
    TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null);
65
    tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
66
    tv.setText(R.string.about);
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
      });
78

    
79
    Dialog dialog = builder.create();
80
    dialog.setCanceledOnTouchOutside(false);
81
    Window window = dialog.getWindow();
82

    
83
    if( window!=null )
84
      {
85
      window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS);
86
      }
87

    
88
    dialog.setOnShowListener(new DialogInterface.OnShowListener()
89
      {
90
      @Override
91
      public void onShow(DialogInterface dialog)
92
        {
93
        Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE);
94
        btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize);
95
        }
96
      });
97

    
98
    return dialog;
99
    }
100

    
101
///////////////////////////////////////////////////////////////////////////////////////////////////
102

    
103
  public void setUpdates(RubikUpdates updates)
104
    {
105

    
106
    }
107

    
108
///////////////////////////////////////////////////////////////////////////////////////////////////
109

    
110
  public static String getDialogTag()
111
    {
112
    return "DialogUpdates";
113
    }
114
  }
(20-20/20)