Project

General

Profile

« Previous | Next » 

Revision 5f3801d3

Added by Leszek Koltunski over 2 years ago

Progress downloading updates: dialog.

View differences:

src/main/java/org/distorted/dialogs/RubikDialogUpdates.java
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
  }
src/main/java/org/distorted/screens/RubikScreenPlay.java
37 37
import android.widget.RelativeLayout;
38 38
import android.widget.TextView;
39 39

  
40
import org.distorted.dialogs.RubikDialogUpdates;
40 41
import org.distorted.network.RubikNetwork;
41 42
import org.distorted.network.RubikUpdates;
42 43
import org.distorted.objectlib.main.ObjectControl;
......
77 78
  private PopupWindow mObjectPopup, mMenuPopup, mPlayPopup;
78 79
  private LinearLayout mPlayLayout;
79 80
  private TextView mBubbleUpdates;
81
  private RubikUpdates mUpdates;
80 82
  private int mObjectSize, mMenuLayoutWidth, mMenuLayoutHeight, mPlayLayoutWidth;
81 83
  private int mLevelValue;
82 84
  private float mButtonSize, mMenuItemSize, mMenuTextSize;
......
347 349
      @Override
348 350
      public void onClick(View v)
349 351
        {
350
        android.util.Log.e("D", "Download!!");
352
        if( mObjectPopup!=null ) mObjectPopup.dismiss();
353
        RubikDialogUpdates uDiag = new RubikDialogUpdates();
354
        uDiag.setUpdates(mUpdates);
355
        uDiag.show( act.getSupportFragmentManager(), RubikDialogUpdates.getDialogTag() );
351 356
        }
352 357
      });
353 358

  
......
701 706

  
702 707
  public void receiveUpdate(RubikUpdates updates)
703 708
    {
704
    int num = updates.getNumberOfUpdates();
709
    mUpdates = updates;
710
    int num = mUpdates.getNumberOfUpdates();
705 711

  
706 712
    if( num>0 )
707 713
      {

Also available in: Unified diff