Project

General

Profile

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

magiccube / src / main / java / org / distorted / dialogs / RubikDialogAbout.java @ c02fa107

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 68191e7d Leszek Koltunski
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8 1cbcc6bf Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
9
10 1f9772f3 Leszek Koltunski
package org.distorted.dialogs;
11 1cbcc6bf Leszek Koltunski
12
import android.app.Dialog;
13
import android.content.DialogInterface;
14 1780dcb0 Leszek Koltunski
import android.content.pm.PackageInfo;
15
import android.content.pm.PackageManager;
16 66e777b0 Leszek Koltunski
import androidx.fragment.app.FragmentActivity;
17
import androidx.appcompat.app.AlertDialog;
18 703aee64 Leszek Koltunski
19
import android.text.method.LinkMovementMethod;
20 1780dcb0 Leszek Koltunski
import android.text.method.MovementMethod;
21 2eb74743 Leszek Koltunski
import android.util.TypedValue;
22 1cbcc6bf Leszek Koltunski
import android.view.View;
23 2eb74743 Leszek Koltunski
import android.widget.Button;
24 0fd3ac1f Leszek Koltunski
import android.widget.TextView;
25 1cbcc6bf Leszek Koltunski
26 1f9772f3 Leszek Koltunski
import org.distorted.main.R;
27 2eb74743 Leszek Koltunski
import org.distorted.main.RubikActivity;
28 211b48f2 Leszek Koltunski
29 1cbcc6bf Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
30
31 b5c2adb4 Leszek Koltunski
public class RubikDialogAbout extends RubikDialogAbstract
32 1cbcc6bf Leszek Koltunski
  {
33 b5c2adb4 Leszek Koltunski
  public int getResource()
34
    {
35
    return R.layout.dialog_about;
36
    }
37
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39
40
  public int getTitleResource()
41
    {
42
    return R.string.about;
43
    }
44
45 c02fa107 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
46
47
  public boolean hasArgument()
48
    {
49
    return false;
50
    }
51
52 b5c2adb4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
53
54
  public void setPositive(AlertDialog.Builder builder)
55 1cbcc6bf Leszek Koltunski
    {
56
    builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
57
      {
58
      @Override
59
      public void onClick(DialogInterface dialog, int which)
60
        {
61
62
        }
63
      });
64 b5c2adb4 Leszek Koltunski
    }
65
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67
68
  public void setNegative(AlertDialog.Builder builder)
69
    {
70
71
    }
72
73
///////////////////////////////////////////////////////////////////////////////////////////////////
74 1cbcc6bf Leszek Koltunski
75 b5c2adb4 Leszek Koltunski
  public void onShowDialog(DialogInterface dialog, float size)
76
    {
77
    Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE);
78
    btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
79
    }
80
81
///////////////////////////////////////////////////////////////////////////////////////////////////
82
83 c02fa107 Leszek Koltunski
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
84 b5c2adb4 Leszek Koltunski
    {
85 0fd3ac1f Leszek Koltunski
    TextView text = view.findViewById(R.id.about_version);
86 329c0aeb Leszek Koltunski
    String appName = getString(R.string.app_name);
87 1780dcb0 Leszek Koltunski
88 b5c2adb4 Leszek Koltunski
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
89 b1e9596b Leszek Koltunski
    text.setText(getString(R.string.ap_placeholder,appName, getAppVers(act)));
90 703aee64 Leszek Koltunski
91 1780dcb0 Leszek Koltunski
    MovementMethod mm = LinkMovementMethod.getInstance();
92 703aee64 Leszek Koltunski
    TextView text2 = view.findViewById(R.id.about_section2);
93 b5c2adb4 Leszek Koltunski
    text2.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
94 1780dcb0 Leszek Koltunski
    text2.setMovementMethod(mm);
95
    TextView text3 = view.findViewById(R.id.about_section3);
96 b5c2adb4 Leszek Koltunski
    text3.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
97 703aee64 Leszek Koltunski
98 b1e9596b Leszek Koltunski
    TextView text4 = view.findViewById(R.id.about_section4);
99
100
    if( RubikActivity.localeIsChinese() )
101
      {
102 b5c2adb4 Leszek Koltunski
      text4.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
103 b1e9596b Leszek Koltunski
      text4.setMovementMethod(mm);
104
      }
105
    else
106
      {
107
      text4.setVisibility(View.GONE);
108 85248b04 Leszek Koltunski
      }
109 1cbcc6bf Leszek Koltunski
    }
110 b1e9596b Leszek Koltunski
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112
113
  private String getAppVers(FragmentActivity act)
114
    {
115
    try
116
      {
117
      PackageInfo pInfo = act.getPackageManager().getPackageInfo( act.getPackageName(), 0);
118
      return pInfo.versionName;
119
      }
120
    catch (PackageManager.NameNotFoundException e)
121
      {
122
      return "unknown";
123
      }
124
    }
125 1cbcc6bf Leszek Koltunski
  }