Project

General

Profile

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

magiccube / src / main / java / org / distorted / dialogs / RubikDialogCreators.java @ f46a7aa1

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
    MEGAMINX ( org.distorted.objectlib.R.drawable.mega_3, R.string.creator_megaminx_title, R.string.creator_megaminx_desc ),
33
    ;
34

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

    
38
    final int mIcon, mTitle, mDescription;
39

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

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

    
54
    ////////////////////////////////////////////////////////////////////////
55

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

    
61
    ////////////////////////////////////////////////////////////////////////
62

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

    
68
    ////////////////////////////////////////////////////////////////////////
69

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

    
76
///////////////////////////////////////////////////////////////////////////////////////////////////
77

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

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

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

    
93
///////////////////////////////////////////////////////////////////////////////////////////////////
94

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

    
101
///////////////////////////////////////////////////////////////////////////////////////////////////
102

    
103
  public void positiveAction()
104
    {
105

    
106
    }
107

    
108
///////////////////////////////////////////////////////////////////////////////////////////////////
109

    
110
  public void negativeAction()
111
    {
112

    
113
    }
114

    
115
///////////////////////////////////////////////////////////////////////////////////////////////////
116

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

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

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

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

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

    
149
///////////////////////////////////////////////////////////////////////////////////////////////////
150

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