Project

General

Profile

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

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

1 1cbcc6bf Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4 fdec60a3 Leszek Koltunski
// This file is part of Magic Cube.                                                              //
5 1cbcc6bf Leszek Koltunski
//                                                                                               //
6 fdec60a3 Leszek Koltunski
// Magic Cube is free software: you can redistribute it and/or modify                            //
7 1cbcc6bf Leszek Koltunski
// 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 fdec60a3 Leszek Koltunski
// Magic Cube is distributed in the hope that it will be useful,                                 //
12 1cbcc6bf Leszek Koltunski
// 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 fdec60a3 Leszek Koltunski
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18 1cbcc6bf Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
19
20 1f9772f3 Leszek Koltunski
package org.distorted.dialogs;
21 1cbcc6bf Leszek Koltunski
22
import android.app.Dialog;
23
import android.content.DialogInterface;
24
import android.os.Bundle;
25 66e777b0 Leszek Koltunski
import androidx.annotation.NonNull;
26
import androidx.fragment.app.FragmentActivity;
27
import androidx.appcompat.app.AlertDialog;
28
import androidx.appcompat.app.AppCompatDialogFragment;
29 703aee64 Leszek Koltunski
30
import android.text.method.LinkMovementMethod;
31 1cbcc6bf Leszek Koltunski
import android.view.LayoutInflater;
32
import android.view.View;
33 4235de9b Leszek Koltunski
import android.view.Window;
34
import android.view.WindowManager;
35 0fd3ac1f Leszek Koltunski
import android.widget.TextView;
36 1cbcc6bf Leszek Koltunski
37 1f9772f3 Leszek Koltunski
import org.distorted.main.R;
38 211b48f2 Leszek Koltunski
39 1cbcc6bf Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
40
41 0fd3ac1f Leszek Koltunski
public class RubikDialogAbout extends AppCompatDialogFragment
42 1cbcc6bf Leszek Koltunski
  {
43
  @NonNull
44
  @Override
45
  public Dialog onCreateDialog(Bundle savedInstanceState)
46
    {
47
    FragmentActivity act = getActivity();
48 0fd3ac1f Leszek Koltunski
    LayoutInflater inflater = act.getLayoutInflater();
49 1cbcc6bf Leszek Koltunski
    AlertDialog.Builder builder = new AlertDialog.Builder(act);
50
51 0fd3ac1f Leszek Koltunski
    TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null);
52 4235de9b Leszek Koltunski
    tv.setText(R.string.about);
53 0fd3ac1f Leszek Koltunski
    builder.setCustomTitle(tv);
54
55
    builder.setCancelable(true);
56 1cbcc6bf Leszek Koltunski
    builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
57
      {
58
      @Override
59
      public void onClick(DialogInterface dialog, int which)
60
        {
61
62
        }
63
      });
64
65 0fd3ac1f Leszek Koltunski
    final View view = inflater.inflate(R.layout.dialog_about, null);
66
    TextView text = view.findViewById(R.id.about_version);
67 329c0aeb Leszek Koltunski
    String appName = getString(R.string.app_name);
68
    String appVers = getString(R.string.app_version);
69
    text.setText(getString(R.string.ap_placeholder,appName, appVers));
70 703aee64 Leszek Koltunski
71
    TextView text1 = view.findViewById(R.id.about_section1);
72
    text1.setMovementMethod(LinkMovementMethod.getInstance());
73
    TextView text2 = view.findViewById(R.id.about_section2);
74
    text2.setMovementMethod(LinkMovementMethod.getInstance());
75
76 1cbcc6bf Leszek Koltunski
    builder.setView(view);
77
78 85248b04 Leszek Koltunski
    Dialog dialog = builder.create();
79
80
    dialog.setCanceledOnTouchOutside(false);
81
82
    Window window = dialog.getWindow();
83
84
    if( window!=null )
85
      {
86
      window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
87
      }
88
89
    return dialog;
90 1cbcc6bf Leszek Koltunski
    }
91
  }