Project

General

Profile

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

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

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 1780dcb0 Leszek Koltunski
import android.content.pm.PackageInfo;
14
import android.content.pm.PackageManager;
15 66e777b0 Leszek Koltunski
import androidx.fragment.app.FragmentActivity;
16 703aee64 Leszek Koltunski
17
import android.text.method.LinkMovementMethod;
18 1780dcb0 Leszek Koltunski
import android.text.method.MovementMethod;
19 2eb74743 Leszek Koltunski
import android.util.TypedValue;
20 1cbcc6bf Leszek Koltunski
import android.view.View;
21 0fd3ac1f Leszek Koltunski
import android.widget.TextView;
22 1cbcc6bf Leszek Koltunski
23 1f9772f3 Leszek Koltunski
import org.distorted.main.R;
24 2eb74743 Leszek Koltunski
import org.distorted.main.RubikActivity;
25 211b48f2 Leszek Koltunski
26 1cbcc6bf Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
27
28 b5c2adb4 Leszek Koltunski
public class RubikDialogAbout extends RubikDialogAbstract
29 1cbcc6bf Leszek Koltunski
  {
30 f8a21f6b Leszek Koltunski
  public int getResource()      { return R.layout.dialog_about; }
31
  public int getTitleResource() { return R.string.about; }
32
  public boolean hasArgument()  { return false; }
33
  public int getPositive()      { return R.string.ok; }
34
  public int getNegative()      { return -1; }
35 c02fa107 Leszek Koltunski
36 b5c2adb4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
37
38 f8a21f6b Leszek Koltunski
  public void positiveAction()
39 1cbcc6bf Leszek Koltunski
    {
40
41 b5c2adb4 Leszek Koltunski
    }
42
43
///////////////////////////////////////////////////////////////////////////////////////////////////
44
45 f8a21f6b Leszek Koltunski
  public void negativeAction()
46 b5c2adb4 Leszek Koltunski
    {
47
48
    }
49
50
///////////////////////////////////////////////////////////////////////////////////////////////////
51
52 c02fa107 Leszek Koltunski
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
53 b5c2adb4 Leszek Koltunski
    {
54 0fd3ac1f Leszek Koltunski
    TextView text = view.findViewById(R.id.about_version);
55 329c0aeb Leszek Koltunski
    String appName = getString(R.string.app_name);
56 1780dcb0 Leszek Koltunski
57 b5c2adb4 Leszek Koltunski
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
58 f8a21f6b Leszek Koltunski
59
    String version;
60
    try
61
      {
62
      PackageInfo pInfo = act.getPackageManager().getPackageInfo( act.getPackageName(), 0);
63
      version= pInfo.versionName;
64
      }
65
    catch (PackageManager.NameNotFoundException e)
66
      {
67
      version= "unknown";
68
      }
69
70
    text.setText(getString(R.string.ap_placeholder,appName, version));
71 703aee64 Leszek Koltunski
72 1780dcb0 Leszek Koltunski
    MovementMethod mm = LinkMovementMethod.getInstance();
73 703aee64 Leszek Koltunski
    TextView text2 = view.findViewById(R.id.about_section2);
74 b5c2adb4 Leszek Koltunski
    text2.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
75 1780dcb0 Leszek Koltunski
    text2.setMovementMethod(mm);
76
    TextView text3 = view.findViewById(R.id.about_section3);
77 b5c2adb4 Leszek Koltunski
    text3.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
78 703aee64 Leszek Koltunski
79 b1e9596b Leszek Koltunski
    TextView text4 = view.findViewById(R.id.about_section4);
80
81
    if( RubikActivity.localeIsChinese() )
82
      {
83 b5c2adb4 Leszek Koltunski
      text4.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
84 b1e9596b Leszek Koltunski
      text4.setMovementMethod(mm);
85
      }
86
    else
87
      {
88
      text4.setVisibility(View.GONE);
89 85248b04 Leszek Koltunski
      }
90 1cbcc6bf Leszek Koltunski
    }
91
  }