Project

General

Profile

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

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

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.DialogInterface;
14
import android.content.pm.PackageInfo;
15
import android.content.pm.PackageManager;
16
import androidx.fragment.app.FragmentActivity;
17
import androidx.appcompat.app.AlertDialog;
18

    
19
import android.text.method.LinkMovementMethod;
20
import android.text.method.MovementMethod;
21
import android.util.TypedValue;
22
import android.view.View;
23
import android.widget.Button;
24
import android.widget.TextView;
25

    
26
import org.distorted.main.R;
27
import org.distorted.main.RubikActivity;
28

    
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30

    
31
public class RubikDialogAbout extends RubikDialogAbstract
32
  {
33
  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
///////////////////////////////////////////////////////////////////////////////////////////////////
46

    
47
  public boolean hasArgument()
48
    {
49
    return false;
50
    }
51

    
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

    
54
  public void setPositive(AlertDialog.Builder builder)
55
    {
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
    }
65

    
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67

    
68
  public void setNegative(AlertDialog.Builder builder)
69
    {
70

    
71
    }
72

    
73
///////////////////////////////////////////////////////////////////////////////////////////////////
74

    
75
  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
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
84
    {
85
    TextView text = view.findViewById(R.id.about_version);
86
    String appName = getString(R.string.app_name);
87

    
88
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
89
    text.setText(getString(R.string.ap_placeholder,appName, getAppVers(act)));
90

    
91
    MovementMethod mm = LinkMovementMethod.getInstance();
92
    TextView text2 = view.findViewById(R.id.about_section2);
93
    text2.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
94
    text2.setMovementMethod(mm);
95
    TextView text3 = view.findViewById(R.id.about_section3);
96
    text3.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
97

    
98
    TextView text4 = view.findViewById(R.id.about_section4);
99

    
100
    if( RubikActivity.localeIsChinese() )
101
      {
102
      text4.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
103
      text4.setMovementMethod(mm);
104
      }
105
    else
106
      {
107
      text4.setVisibility(View.GONE);
108
      }
109
    }
110

    
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
  }
(2-2/25)