Project

General

Profile

« Previous | Next » 

Revision f8a21f6b

Added by Leszek Koltunski over 1 year ago

Unify all dialogs.

View differences:

src/main/java/org/distorted/dialogs/RubikDialogAbout.java
10 10
package org.distorted.dialogs;
11 11

  
12 12
import android.app.Dialog;
13
import android.content.DialogInterface;
14 13
import android.content.pm.PackageInfo;
15 14
import android.content.pm.PackageManager;
16 15
import androidx.fragment.app.FragmentActivity;
17
import androidx.appcompat.app.AlertDialog;
18 16

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

  
26 23
import org.distorted.main.R;
......
30 27

  
31 28
public class RubikDialogAbout extends RubikDialogAbstract
32 29
  {
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
    }
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; }
51 35

  
52 36
///////////////////////////////////////////////////////////////////////////////////////////////////
53 37

  
54
  public void setPositive(AlertDialog.Builder builder)
38
  public void positiveAction()
55 39
    {
56
    builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
57
      {
58
      @Override
59
      public void onClick(DialogInterface dialog, int which)
60
        {
61 40

  
62
        }
63
      });
64 41
    }
65 42

  
66 43
///////////////////////////////////////////////////////////////////////////////////////////////////
67 44

  
68
  public void setNegative(AlertDialog.Builder builder)
45
  public void negativeAction()
69 46
    {
70 47

  
71 48
    }
72 49

  
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 50
///////////////////////////////////////////////////////////////////////////////////////////////////
82 51

  
83 52
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
......
86 55
    String appName = getString(R.string.app_name);
87 56

  
88 57
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
89
    text.setText(getString(R.string.ap_placeholder,appName, getAppVers(act)));
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));
90 71

  
91 72
    MovementMethod mm = LinkMovementMethod.getInstance();
92 73
    TextView text2 = view.findViewById(R.id.about_section2);
......
107 88
      text4.setVisibility(View.GONE);
108 89
      }
109 90
    }
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 91
  }

Also available in: Unified diff