Project

General

Profile

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

magiccube / src / main / java / org / distorted / dialogs / RubikDialogCreators.java @ 5a4ee169

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2023 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.view.View;
14
import android.view.Window;
15
import android.view.WindowManager;
16
import android.widget.LinearLayout;
17
import android.widget.TextView;
18

    
19
import androidx.fragment.app.FragmentActivity;
20

    
21
import org.distorted.main.R;
22
import org.distorted.main.RubikActivity;
23

    
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25

    
26
public class RubikDialogCreators extends RubikDialogAbstract
27
  {
28
  private enum BandagedObjectDescription
29
    {
30
    CUBOID   ( org.distorted.objectlib.R.drawable.cu_232, R.string.creator_cuboid_title  , R.string.creator_cuboid_desc   ),
31
    PYRAMINX ( org.distorted.objectlib.R.drawable.pyra_3, R.string.creator_pyraminx_title, R.string.creator_pyraminx_desc ),
32
    ;
33

    
34
    public static final int NUM_OBJECTS = values().length;
35
    private static final BandagedObjectDescription[] objects;
36

    
37
    final int mIcon, mTitle, mDescription;
38

    
39
    BandagedObjectDescription(int icon, int title, int descripton)
40
      {
41
      mIcon        = icon;
42
      mTitle       = title;
43
      mDescription = descripton;
44
      }
45

    
46
    static
47
      {
48
      int i=0;
49
      objects = new BandagedObjectDescription[NUM_OBJECTS];
50
      for( BandagedObjectDescription object: BandagedObjectDescription.values() ) objects[i++] = object;
51
      }
52

    
53
    ////////////////////////////////////////////////////////////////////////
54

    
55
    static int getIcon(int ordinal)
56
      {
57
      return objects[ordinal].mIcon;
58
      }
59

    
60
    ////////////////////////////////////////////////////////////////////////
61

    
62
    static int getTitle(int ordinal)
63
      {
64
      return objects[ordinal].mTitle;
65
      }
66

    
67
    ////////////////////////////////////////////////////////////////////////
68

    
69
    static int getDescription(int ordinal)
70
      {
71
      return objects[ordinal].mDescription;
72
      }
73
    }
74

    
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76

    
77
  @Override
78
  public void onResume()
79
    {
80
    super.onResume();
81

    
82
    Window window = getDialog().getWindow();
83

    
84
    if( window!=null )
85
      {
86
      WindowManager.LayoutParams params = window.getAttributes();
87
      params.width  = (int)Math.min( mHeight*0.65f,mWidth*0.98f );
88
      window.setAttributes(params);
89
      }
90
    }
91

    
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93

    
94
  public int getResource()      { return R.layout.dialog_scrollable_panes; }
95
  public int getTitleResource() { return R.string.bandaged; }
96
  public boolean hasArgument()  { return false; }
97
  public int getPositive()      { return R.string.ok; }
98
  public int getNegative()      { return -1; }
99

    
100
///////////////////////////////////////////////////////////////////////////////////////////////////
101

    
102
  public void positiveAction()
103
    {
104

    
105
    }
106

    
107
///////////////////////////////////////////////////////////////////////////////////////////////////
108

    
109
  public void negativeAction()
110
    {
111

    
112
    }
113

    
114
///////////////////////////////////////////////////////////////////////////////////////////////////
115

    
116
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
117
    {
118
    int margin= (int)(mHeight*0.010f);
119
    int padd  = (int)(mHeight*0.010f);
120
    int font  = (int)(mHeight*0.025f);
121

    
122
    LinearLayout layout= view.findViewById(R.id.dialog_scrollable_main_layout);
123
    TextView text  = view.findViewById(R.id.dialog_scrollable_message);
124
    text.setVisibility(View.GONE);
125

    
126
    LinearLayout.LayoutParams pV = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
127
    pV.setMargins(margin, margin, margin, 0);
128
    LinearLayout.LayoutParams pL = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
129
    pL.setMargins(margin, margin, margin, margin);
130
    LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
131
    pT.setMargins(0,0,0,2*margin);
132
    LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
133
    pB.setMargins(0,2*margin,0,0);
134

    
135
    int num = BandagedObjectDescription.NUM_OBJECTS;
136
    RubikActivity ract = (RubikActivity) getContext();
137

    
138
    for(int i=0; i<num; i++)
139
      {
140
      int icon        = BandagedObjectDescription.getIcon(i);
141
      int title       = BandagedObjectDescription.getTitle(i);
142
      int description = BandagedObjectDescription.getDescription(i);
143
      RubikDialogCreatorView pane = new RubikDialogCreatorView(ract,this,i,icon,title,description, padd, font, (i==num-1?pL:pV),pT,pB);
144
      layout.addView(pane.getView());
145
      }
146
    }
147

    
148
///////////////////////////////////////////////////////////////////////////////////////////////////
149

    
150
  public static String getDialogTag()
151
    {
152
    return "DialogCreators";
153
    }
154
  }
(7-7/28)