Project

General

Profile

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

magiccube / src / main / java / org / distorted / dialogs / RubikDialogPlayPopup.java @ 05f6d7bd

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

    
31
import androidx.annotation.NonNull;
32
import androidx.appcompat.app.AlertDialog;
33
import androidx.appcompat.app.AppCompatDialogFragment;
34
import androidx.fragment.app.FragmentActivity;
35

    
36
import org.distorted.main.R;
37
import org.distorted.main.RubikActivity;
38

    
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40

    
41
public class RubikDialogPlayPopup extends AppCompatDialogFragment
42
  {
43
  @NonNull
44
  @Override
45
  public Dialog onCreateDialog(Bundle savedInstanceState)
46
    {
47
    Bundle args = getArguments();
48
    int objectOrdinal;
49

    
50
    try
51
      {
52
      objectOrdinal = args.getInt("ordinal");
53
      }
54
    catch(Exception e)
55
      {
56
      objectOrdinal = 0;
57
      }
58

    
59
    FragmentActivity act = getActivity();
60
    LayoutInflater inflater = act.getLayoutInflater();
61
    AlertDialog.Builder builder = new AlertDialog.Builder(act);
62

    
63
    DisplayMetrics displaymetrics = new DisplayMetrics();
64
    act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
65
    final float titleSize= displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE;
66

    
67
    TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null);
68
    tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
69
    tv.setText(R.string.privacy_policy);
70
    builder.setCustomTitle(tv);
71

    
72
    final View view = inflater.inflate(R.layout.popup_play_new_ui, null);
73

    
74
    builder.setCancelable(true);
75
    builder.setView(view);
76

    
77
    final Dialog dialog = builder.create();
78
   // dialog.setCanceledOnTouchOutside(false);
79
    Window window = dialog.getWindow();
80

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

    
86
    return dialog;
87
    }
88
  }
(13-13/25)