Project

General

Profile

« Previous | Next » 

Revision 5a4ee169

Added by Leszek Koltunski over 1 year ago

Progress with Bandaged UI.

View differences:

src/main/java/org/distorted/bandaged/BandagedCreatorActivity.java
59 59
    private int mCurrentApiVersion;
60 60
    private BandagedCreatorScreen mScreen;
61 61
    private boolean mRTL;
62
    private int mObjectOrdinal;
62 63

  
63 64
///////////////////////////////////////////////////////////////////////////////////////////////////
64 65

  
......
79 80
      final int layoutDirection = config.getLayoutDirection();
80 81
      mRTL = layoutDirection==LAYOUT_DIRECTION_RTL;
81 82

  
83
      Bundle b = getIntent().getExtras();
84
      mObjectOrdinal = (b != null) ? b.getInt("obj") : 0;
85

  
82 86
      hideNavigationBar();
83 87
      cutoutHack();
84 88
      computeHeights();
......
338 342

  
339 343
    public int getObjectOrdinal()
340 344
      {
341
      return 0;
345
      return mObjectOrdinal;
342 346
      }
343 347

  
344 348
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/dialogs/RubikDialogCreatorView.java
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.util.TypedValue;
13
import android.view.View;
14
import android.widget.Button;
15
import android.widget.ImageView;
16
import android.widget.LinearLayout;
17
import android.widget.TextView;
18

  
19
import org.distorted.main.R;
20
import org.distorted.main.RubikActivity;
21

  
22
///////////////////////////////////////////////////////////////////////////////////////////////////
23

  
24
public class RubikDialogCreatorView
25
  {
26
  private final View mView;
27

  
28
///////////////////////////////////////////////////////////////////////////////////////////////////
29

  
30
  public RubikDialogCreatorView(final RubikActivity act, final RubikDialogCreators dialog,
31
                                final int index, int icon, int title, int desc, int padding, int fontSize,
32
                                LinearLayout.LayoutParams pView, LinearLayout.LayoutParams pText, LinearLayout.LayoutParams pButt )
33
    {
34
    mView = act.getLayoutInflater().inflate(R.layout.dialog_creators_pane, null);
35
    mView.setLayoutParams(pView);
36
    mView.setPadding(padding,padding,padding,padding);
37

  
38
    TextView titleView = mView.findViewById(R.id.creators_pane_title);
39
    titleView.setText(title);
40
    TextView descView = mView.findViewById(R.id.creators_pane_description);
41
    descView.setText(desc);
42

  
43
    titleView.setLayoutParams(pText);
44

  
45
    ImageView iconView = mView.findViewById(R.id.creators_pane_image);
46
    iconView.setImageResource(icon);
47

  
48
    Button button = mView.findViewById(R.id.creators_pane_button);
49

  
50
    button.setOnClickListener( new View.OnClickListener()
51
      {
52
      @Override
53
      public void onClick(View v)
54
        {
55
        dialog.dismiss();
56
        act.switchToBandagedCreator(index);
57
        }
58
      });
59

  
60
    button.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
61
    button.setLayoutParams(pButt);
62
    }
63

  
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65

  
66
  public View getView()
67
    {
68
    return mView;
69
    }
70
  }
src/main/java/org/distorted/dialogs/RubikDialogCreators.java
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
  }
src/main/java/org/distorted/main/RubikActivity.java
701 701

  
702 702
///////////////////////////////////////////////////////////////////////////////////////////////////
703 703

  
704
    public void switchToBandagedCreator()
704
    public void switchToBandagedCreator(int objectOrdinal)
705 705
      {
706 706
      Intent intent = new Intent(this, BandagedCreatorActivity.class);
707
      intent.putExtra("obj", objectOrdinal);
707 708
      startActivity(intent);
708 709
      }
709 710

  
src/main/java/org/distorted/screens/RubikScreenPlay.java
30 30
import android.widget.RelativeLayout;
31 31
import android.widget.TextView;
32 32

  
33
import org.distorted.dialogs.RubikDialogCreators;
33 34
import org.distorted.dialogs.RubikDialogSolvers;
34 35
import org.distorted.dialogs.RubikDialogStarsStatus;
35 36
import org.distorted.dialogs.RubikDialogUpdates;
......
443 444
        public void onClick(View v)
444 445
          {
445 446
          mMenuPopup.dismiss();
446
          act.switchToBandagedCreator();
447
          RubikDialogCreators creators = new RubikDialogCreators();
448
          creators.show(act.getSupportFragmentManager(), RubikDialogCreators.getDialogTag() );
447 449
          }
448 450
        });
449 451

  
src/main/res/layout/dialog_creators_pane.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<LinearLayout
3
	xmlns:android="http://schemas.android.com/apk/res/android"
4
	android:layout_width="match_parent"
5
	android:layout_height="wrap_content"
6
	android:background="@color/medium_grey"
7
	android:padding="8dp"
8
	android:orientation="horizontal">
9

  
10
    <ImageView
11
   	     android:id="@+id/creators_pane_image"
12
   	     android:scaleType="fitCenter"
13
   		 android:layout_width="0dp"
14
   		 android:layout_height="match_parent"
15
   		 android:layout_gravity="top"
16
   		 android:layout_weight="0.5"/>
17

  
18
   	<LinearLayout
19
   		android:layout_width="0dp"
20
 		android:layout_height="match_parent"
21
 		android:orientation="vertical"
22
 		android:layout_marginStart="8dp"
23
 		android:layout_weight="1.0">
24

  
25
		<TextView
26
    		android:id="@+id/creators_pane_title"
27
    		android:gravity="top|start"
28
    		android:layout_width="match_parent"
29
    		android:layout_height="wrap_content"
30
    		android:singleLine="true"
31
    		android:textStyle="bold"/>
32

  
33
        <TextView
34
    		android:id="@+id/creators_pane_description"
35
    		android:gravity="top|start"
36
    		android:layout_width="match_parent"
37
    		android:layout_height="wrap_content"/>
38

  
39
    	<Button
40
             android:id="@+id/creators_pane_button"
41
             android:layout_width="match_parent"
42
             android:layout_height="wrap_content"
43
             android:layout_gravity="bottom"
44
             android:gravity="center"
45
             android:backgroundTint="@color/black"
46
             android:insetTop="0dp"
47
             android:insetBottom="0dp"
48
             android:text="@string/use_solver"/>
49

  
50
 	</LinearLayout>
51
</LinearLayout>
src/main/res/values/strings.xml
131 131
    <string name="solver_cube3_error8">Timeout, no solution found in 20 seconds!</string>
132 132
    <string name="solver_cube3_error9">Solver interrupted!</string>
133 133

  
134

  
134 135
    <string name="color_yellow1">yellow</string>
135 136
    <string name="color_white1">white</string>
136 137
    <string name="color_blue1">blue</string>
......
223 224
    <string name="solver_cu323_description">A perfect, instantaneous solver.\nAuthor: Leszek Koltunski.</string>
224 225
    <string name="solver_cube4_description">Not implemented yet.\nAuthor: Leszek Koltunski.</string>
225 226

  
227
    <string name="creator_cuboid_title">Creator of Bandaged Cuboids</string>
228
    <string name="creator_cuboid_desc">Set up a cuboid up to size 7 and bandage it.</string>
229
    <string name="creator_pyraminx_title">Creator of Bandaged Pyraminxes</string>
230
    <string name="creator_pyraminx_desc">Set up a pyraminx up to size 7 and bandage it.</string>
231

  
226 232
    <string name="email_address" translatable="false">app.magic.cube@gmail.com</string>
227 233

  
228 234
    <string name="ns_placeholder" translatable="false">+%1$d</string>

Also available in: Unified diff