Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// 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
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
package org.distorted.dialogs;
11

    
12
import android.app.Dialog;
13
import android.content.pm.PackageInfo;
14
import android.content.pm.PackageManager;
15
import androidx.fragment.app.FragmentActivity;
16

    
17
import android.text.method.LinkMovementMethod;
18
import android.text.method.MovementMethod;
19
import android.util.TypedValue;
20
import android.view.View;
21
import android.widget.TextView;
22

    
23
import org.distorted.main.R;
24
import org.distorted.main.RubikActivity;
25

    
26
///////////////////////////////////////////////////////////////////////////////////////////////////
27

    
28
public class RubikDialogAbout extends RubikDialogAbstract
29
  {
30
  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

    
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37

    
38
  public void positiveAction()
39
    {
40

    
41
    }
42

    
43
///////////////////////////////////////////////////////////////////////////////////////////////////
44

    
45
  public void negativeAction()
46
    {
47

    
48
    }
49

    
50
///////////////////////////////////////////////////////////////////////////////////////////////////
51

    
52
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
53
    {
54
    TextView text = view.findViewById(R.id.about_version);
55
    String appName = getString(R.string.app_name);
56

    
57
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
58

    
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

    
72
    MovementMethod mm = LinkMovementMethod.getInstance();
73
    TextView text2 = view.findViewById(R.id.about_section2);
74
    text2.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
75
    text2.setMovementMethod(mm);
76
    TextView text3 = view.findViewById(R.id.about_section3);
77
    text3.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
78

    
79
    TextView text4 = view.findViewById(R.id.about_section4);
80

    
81
    if( RubikActivity.localeIsChinese() )
82
      {
83
      text4.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
84
      text4.setMovementMethod(mm);
85
      }
86
    else
87
      {
88
      text4.setVisibility(View.GONE);
89
      }
90
    }
91
  }
(2-2/28)