Project

General

Profile

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

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

1 61a7b812 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6 68191e7d Leszek Koltunski
// 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 61a7b812 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
9
10
package org.distorted.dialogs;
11
12
import android.app.Dialog;
13
import android.content.DialogInterface;
14
import android.util.TypedValue;
15
import android.view.View;
16
import android.widget.Button;
17
import android.widget.TextView;
18
19
import androidx.appcompat.app.AlertDialog;
20
import androidx.fragment.app.FragmentActivity;
21
22 72e386ef Leszek Koltunski
import org.distorted.bandaged.BandagedCreatorActivity;
23
import org.distorted.bandaged.BandagedCreatorRenderer;
24 61a7b812 Leszek Koltunski
import org.distorted.main.R;
25
26
///////////////////////////////////////////////////////////////////////////////////////////////////
27
28 b5c2adb4 Leszek Koltunski
public class RubikDialogBandagedSave extends RubikDialogAbstract
29 61a7b812 Leszek Koltunski
  {
30 b5c2adb4 Leszek Koltunski
  public int getResource()
31 61a7b812 Leszek Koltunski
    {
32 b5c2adb4 Leszek Koltunski
    return R.layout.dialog_save_object;
33
    }
34 61a7b812 Leszek Koltunski
35 b5c2adb4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
36 61a7b812 Leszek Koltunski
37 b5c2adb4 Leszek Koltunski
  public int getTitleResource()
38
    {
39
    return R.string.save_object;
40
    }
41 fa52fe5d Leszek Koltunski
42 c02fa107 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
43
44
  public boolean hasArgument()
45
    {
46
    return false;
47
    }
48
49 b5c2adb4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
50 61a7b812 Leszek Koltunski
51 b5c2adb4 Leszek Koltunski
  public void setPositive(AlertDialog.Builder builder)
52
    {
53 61a7b812 Leszek Koltunski
    builder.setPositiveButton( R.string.yes, new DialogInterface.OnClickListener()
54
      {
55
      @Override
56
      public void onClick(DialogInterface dialog, int which)
57
        {
58 72e386ef Leszek Koltunski
        BandagedCreatorActivity bact = (BandagedCreatorActivity)getContext();
59 61a7b812 Leszek Koltunski
60 72e386ef Leszek Koltunski
        if( bact!=null )
61
          {
62
          BandagedCreatorRenderer rend = bact.getRenderer();
63
          rend.saveObject();
64
          }
65 61a7b812 Leszek Koltunski
        }
66
      });
67 b5c2adb4 Leszek Koltunski
    }
68 61a7b812 Leszek Koltunski
69 b5c2adb4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
70
71
  public void setNegative(AlertDialog.Builder builder)
72
    {
73 61a7b812 Leszek Koltunski
    builder.setNegativeButton( R.string.no, new DialogInterface.OnClickListener()
74
      {
75
      @Override
76
      public void onClick(DialogInterface dialog, int which)
77
        {
78 b5c2adb4 Leszek Koltunski
79 61a7b812 Leszek Koltunski
        }
80
      });
81 b5c2adb4 Leszek Koltunski
    }
82 61a7b812 Leszek Koltunski
83 b5c2adb4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
84 61a7b812 Leszek Koltunski
85 b5c2adb4 Leszek Koltunski
  public void onShowDialog(DialogInterface dialog, float size)
86
    {
87
    Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE);
88
    btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
89
    Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE);
90
    btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
91
    }
92 61a7b812 Leszek Koltunski
93 b5c2adb4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
94 61a7b812 Leszek Koltunski
95 c02fa107 Leszek Koltunski
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
96 b5c2adb4 Leszek Koltunski
    {
97
    TextView save = view.findViewById(R.id.save_object_text);
98
    save.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
99 61a7b812 Leszek Koltunski
    }
100
  }