Project

General

Profile

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

magiccube / src / main / java / org / distorted / dialogs / RubikDialogUpdates.java @ 2a2ca758

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.os.Bundle;
25
import android.util.DisplayMetrics;
26
import android.util.TypedValue;
27
import android.view.LayoutInflater;
28
import android.view.View;
29
import android.view.Window;
30
import android.widget.Button;
31
import android.widget.TextView;
32

    
33
import androidx.annotation.NonNull;
34
import androidx.appcompat.app.AlertDialog;
35
import androidx.appcompat.app.AppCompatDialogFragment;
36
import androidx.fragment.app.FragmentActivity;
37

    
38
import org.distorted.main.R;
39
import org.distorted.main.RubikActivity;
40
import org.distorted.network.RubikNetwork;
41
import org.distorted.network.RubikUpdates;
42

    
43
///////////////////////////////////////////////////////////////////////////////////////////////////
44

    
45
public class RubikDialogUpdates extends AppCompatDialogFragment implements RubikNetwork.Updatee
46
  {
47
  private View createView(LayoutInflater inflater)
48
    {
49
    final View view = inflater.inflate(R.layout.dialog_updates, null);
50

    
51
    TextView text = view.findViewById(R.id.about_version);
52
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, 50);
53
    text.setText("ggggg ruyujk j k");
54

    
55
    return view;
56
    }
57

    
58
///////////////////////////////////////////////////////////////////////////////////////////////////
59

    
60
  @NonNull
61
  @Override
62
  public Dialog onCreateDialog(Bundle savedInstanceState)
63
    {
64
    FragmentActivity act = getActivity();
65
    LayoutInflater inflater = act.getLayoutInflater();
66
    AlertDialog.Builder builder = new AlertDialog.Builder(act);
67

    
68
    DisplayMetrics displaymetrics = new DisplayMetrics();
69
    act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
70
    final float titleSize= displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE;
71
    final float okSize   = displaymetrics.widthPixels * RubikActivity.DIALOG_BUTTON_SIZE;
72

    
73
    TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null);
74
    tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
75
    tv.setText(R.string.updates);
76
    builder.setCustomTitle(tv);
77

    
78
    builder.setCancelable(true);
79
    builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
80
      {
81
      @Override
82
      public void onClick(DialogInterface dialog, int which)
83
        {
84

    
85
        }
86
      });
87

    
88
    View view = createView(inflater);
89
    builder.setView(view);
90

    
91
    Dialog dialog = builder.create();
92
    dialog.setCanceledOnTouchOutside(false);
93
    Window window = dialog.getWindow();
94

    
95
    if( window!=null )
96
      {
97
      window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS);
98
      }
99

    
100
    dialog.setOnShowListener(new DialogInterface.OnShowListener()
101
      {
102
      @Override
103
      public void onShow(DialogInterface dialog)
104
        {
105
        Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE);
106
        btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize);
107
        }
108
      });
109

    
110
    RubikNetwork network = RubikNetwork.getInstance();
111
    network.signUpForUpdates(this);
112

    
113
    return dialog;
114
    }
115

    
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117

    
118
  public void receiveUpdate(RubikUpdates updates)
119
    {
120

    
121
    }
122

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

    
125
  public void errorUpdate()
126
    {
127
    android.util.Log.e("D", "Dialog: Error receiving update");
128
    }
129

    
130
///////////////////////////////////////////////////////////////////////////////////////////////////
131

    
132
  public static String getDialogTag()
133
    {
134
    return "DialogUpdates";
135
    }
136
  }
(20-20/20)