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/RubikDialogPrivacy.java
10 10
package org.distorted.dialogs;
11 11

  
12 12
import android.app.Dialog;
13
import android.content.DialogInterface;
14 13
import android.text.method.LinkMovementMethod;
15 14
import android.text.method.MovementMethod;
16
import android.util.TypedValue;
17 15
import android.view.View;
18
import android.widget.Button;
19 16
import android.widget.TextView;
20 17

  
21
import androidx.appcompat.app.AlertDialog;
22 18
import androidx.fragment.app.FragmentActivity;
23 19

  
24 20
import org.distorted.main.R;
......
28 24

  
29 25
public class RubikDialogPrivacy extends RubikDialogAbstract
30 26
  {
31
  public int getResource()
32
    {
33
    return R.layout.dialog_privacy;
34
    }
35

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

  
38
  public int getTitleResource()
39
    {
40
    return R.string.privacy_policy;
41
    }
27
  public int getResource()      { return R.layout.dialog_privacy; }
28
  public int getTitleResource() { return R.string.privacy_policy; }
29
  public boolean hasArgument()  { return false; }
30
  public int getPositive()      { return R.string.accept; }
31
  public int getNegative()      { return R.string.decline; }
42 32

  
43 33
///////////////////////////////////////////////////////////////////////////////////////////////////
44 34

  
45
  public boolean hasArgument()
35
  public void positiveAction()
46 36
    {
47
    return false;
48
    }
49

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

  
52
  public void setPositive(AlertDialog.Builder builder)
53
    {
54
    final RubikActivity ract = (RubikActivity)getContext();
55

  
56
    builder.setPositiveButton( R.string.accept, new DialogInterface.OnClickListener()
57
      {
58
      @Override
59
      public void onClick(DialogInterface dialog, int which)
60
        {
61
        if( ract!=null ) ract.acceptPrivacy();
62
        }
63
      });
64
    }
65

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

  
68
  public void setNegative(AlertDialog.Builder builder)
69
    {
70
    final RubikActivity ract = (RubikActivity)getContext();
71

  
72
    builder.setNegativeButton( R.string.decline, new DialogInterface.OnClickListener()
73
      {
74
      @Override
75
      public void onClick(DialogInterface dialog, int which)
76
        {
77
        if( ract!=null ) ract.declinePrivacy();
78
        }
79
      });
37
    final RubikActivity act = (RubikActivity)getContext();
38
    if( act!=null ) act.acceptPrivacy();
80 39
    }
81 40

  
82 41
///////////////////////////////////////////////////////////////////////////////////////////////////
83 42

  
84
  public void onShowDialog(DialogInterface dialog, float size)
43
  public void negativeAction()
85 44
    {
86
    Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE);
87
    btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
88
    Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE);
89
    btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
45
    final RubikActivity act = (RubikActivity)getContext();
46
    if( act!=null ) act.declinePrivacy();
90 47
    }
91 48

  
92 49
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff