Project

General

Profile

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

magiccube / src / main / java / org / distorted / dialogs / RubikDialogAbout.java @ 2d9fc972

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 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 androidx.annotation.NonNull;
28
import androidx.fragment.app.FragmentActivity;
29
import androidx.appcompat.app.AlertDialog;
30
import androidx.appcompat.app.AppCompatDialogFragment;
31

    
32
import android.text.method.LinkMovementMethod;
33
import android.text.method.MovementMethod;
34
import android.view.LayoutInflater;
35
import android.view.View;
36
import android.view.Window;
37
import android.view.WindowManager;
38
import android.widget.TextView;
39

    
40
import org.distorted.main.R;
41

    
42
///////////////////////////////////////////////////////////////////////////////////////////////////
43

    
44
public class RubikDialogAbout extends AppCompatDialogFragment
45
  {
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
    TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null);
55
    tv.setText(R.string.about);
56
    builder.setCustomTitle(tv);
57

    
58
    builder.setCancelable(true);
59
    builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
60
      {
61
      @Override
62
      public void onClick(DialogInterface dialog, int which)
63
        {
64

    
65
        }
66
      });
67

    
68
    final View view = inflater.inflate(R.layout.dialog_about, null);
69
    TextView text = view.findViewById(R.id.about_version);
70
    String appName = getString(R.string.app_name);
71
    String appVers;
72

    
73
    try
74
      {
75
      PackageInfo pInfo = act.getPackageManager().getPackageInfo( act.getPackageName(), 0);
76
      appVers = pInfo.versionName;
77
      }
78
    catch (PackageManager.NameNotFoundException e)
79
      {
80
      appVers = "1.1.1";
81
      }
82

    
83
    text.setText(getString(R.string.ap_placeholder,appName, appVers));
84

    
85
    MovementMethod mm = LinkMovementMethod.getInstance();
86
    TextView text1 = view.findViewById(R.id.about_section1);
87
    text1.setMovementMethod(mm);
88
    TextView text2 = view.findViewById(R.id.about_section2);
89
    text2.setMovementMethod(mm);
90
    TextView text3 = view.findViewById(R.id.about_section3);
91
    text3.setMovementMethod(mm);
92

    
93
    builder.setView(view);
94

    
95
    Dialog dialog = builder.create();
96
    dialog.setCanceledOnTouchOutside(false);
97
    Window window = dialog.getWindow();
98

    
99
    if( window!=null )
100
      {
101
      window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
102
      }
103

    
104
    return dialog;
105
    }
106
  }
(1-1/14)