1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2020 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.text.method.LinkMovementMethod;
|
15
|
import android.text.method.MovementMethod;
|
16
|
import android.util.TypedValue;
|
17
|
import android.view.View;
|
18
|
import android.widget.Button;
|
19
|
import android.widget.TextView;
|
20
|
|
21
|
import androidx.appcompat.app.AlertDialog;
|
22
|
import androidx.fragment.app.FragmentActivity;
|
23
|
|
24
|
import org.distorted.main.R;
|
25
|
import org.distorted.main.RubikActivity;
|
26
|
|
27
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
28
|
|
29
|
public class RubikDialogPrivacy extends RubikDialogAbstract
|
30
|
{
|
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
|
}
|
42
|
|
43
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
44
|
|
45
|
public boolean hasArgument()
|
46
|
{
|
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
|
});
|
80
|
}
|
81
|
|
82
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
83
|
|
84
|
public void onShowDialog(DialogInterface dialog, float size)
|
85
|
{
|
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);
|
90
|
}
|
91
|
|
92
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
93
|
|
94
|
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
|
95
|
{
|
96
|
MovementMethod mm = LinkMovementMethod.getInstance();
|
97
|
TextView text = view.findViewById(R.id.privacy_string);
|
98
|
text.setMovementMethod(mm);
|
99
|
}
|
100
|
}
|