Project

General

Profile

« Previous | Next » 

Revision 7bb30586

Added by Leszek Koltunski 7 months ago

Remove all old UI 1.0 classes

View differences:

src/main/java/org/distorted/bandaged/BandagedActivity.java
43 43

  
44 44
public class BandagedActivity extends AppCompatActivity
45 45
{
46
    public static final float SPINNER_TEXT_SIZE = 0.03f;
47
    public static final float PADDING           = 0.010f;
48
    public static final int FLAGS               = MainActivity.FLAGS;
49
    public static final float RATIO_SCROLL      = 0.30f;
50

  
46 51
    private static final int ACTIVITY_NUMBER    = 2;
47 52
    private static final float RATIO_BAR        = MainActivity.RATIO_BAR;
48 53
    private static final float RATIO_BUT        = 0.07f;
49
    static final float RATIO_SCROLL             = 0.30f;
50
    public static final float SPINNER_TEXT_SIZE = 0.03f;
51
    private static final float PADDING          = 0.010f;
52
    public static final int FLAGS               = MainActivity.FLAGS;
53 54
    private static final int NUM_SCRAMBLES      = 300;
54 55

  
55 56
    private static int mScreenWidth, mScreenHeight;
......
312 313
    public void playObject(String name)
313 314
      {
314 315
      Intent intent = new Intent(this, PlayActivity.class);
316
      intent.putExtra("level", 0);
315 317
      intent.putExtra("name", name);
316 318
      intent.putExtra("scrambles", NUM_SCRAMBLES);
317 319
      intent.putExtra("local", true);
src/main/java/org/distorted/bandaged/BandagedScreen.java
29 29
import org.distorted.external.RubikFiles;
30 30
import org.distorted.helpers.TransparentImageButton;
31 31
import org.distorted.main.R;
32
import org.distorted.main_old.RubikActivity;
33 32
import org.distorted.objectlib.bandaged.LocallyBandagedList;
34 33

  
35 34
///////////////////////////////////////////////////////////////////////////////////////////////////
......
151 150

  
152 151
    int width  = act.getScreenWidthInPixels();
153 152
    int height = act.getScreenHeightInPixels();
154
    int padding= (int)(height*RubikActivity.PADDING/3);
153
    int padding= (int)(height*BandagedActivity.PADDING/3);
155 154

  
156 155
    LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
157 156
    LinearLayout.LayoutParams paramsM = new LinearLayout.LayoutParams(width/2, LinearLayout.LayoutParams.MATCH_PARENT);
src/main/java/org/distorted/config/ConfigActivity.java
22 22

  
23 23
import org.distorted.library.main.DistortedLibrary;
24 24
import org.distorted.main.MainActivity;
25
import org.distorted.main_old.RubikActivity;
26 25
import org.distorted.objectlib.main.InitAssets;
27 26
import org.distorted.objectlib.main.ObjectControl;
28 27
import org.distorted.main.R;
......
37 36
{
38 37
    private static final int ACTIVITY_NUMBER = 1;
39 38
    private static final float RATIO_BAR  = MainActivity.RATIO_BAR;
40
    public static final int FLAGS = RubikActivity.FLAGS;
39
    public static final int FLAGS = MainActivity.FLAGS;
41 40

  
42 41
    private static int mScreenWidth, mScreenHeight;
43 42
    private int mCurrentApiVersion;
src/main/java/org/distorted/config/ConfigScreen.java
23 23
import org.distorted.helpers.PopupCreator;
24 24

  
25 25
import org.distorted.helpers.TransparentImageButton;
26
import org.distorted.main.MainActivity;
26 27
import org.distorted.main.R;
27
import org.distorted.main_old.RubikActivity;
28 28
import org.distorted.objects.RubikObject;
29 29
import org.distorted.objects.RubikObjectList;
30 30

  
......
39 39
  private static final float MARGIN    = 0.0024f;
40 40
  private static final int NUM_COLUMNS = 5;
41 41
  private static final int[] mLocation = new int[2];
42
  private static final float POPUP_PADDING = 0.028f;
43
  private static final float POPUP_MARGIN  = 0.016f;
42 44

  
43 45
  private TransparentImageButton mBackButton, mObjectButton, mPrevButton, mNextButton;
44 46
  private TextView mMovesText;
......
59 61
    mColCount = NUM_COLUMNS;
60 62

  
61 63
    int cubeSize  = (int)( (Math.min(width,(int)(height*0.7f))) / 9 );
62
    int margin    = (int)(height*RubikActivity.POPUP_MARGIN);
63
    int padding   = (int)(height*RubikActivity.POPUP_PADDING);
64
    int margin    = (int)(height*POPUP_MARGIN);
65
    int padding   = (int)(height*POPUP_PADDING);
64 66
    mObjectSize   = (int)(cubeSize + 2*margin + 0.5f);
65 67
    mMaxRowCount  = (int)((height-mBarHeight)/mObjectSize);
66 68

  
......
136 138

  
137 139
        int rowCount = Math.min(mMaxRowCount,mRowCount);
138 140
        View popupView = mObjectPopup.getContentView();
139
        popupView.setSystemUiVisibility(RubikActivity.FLAGS);
141
        popupView.setSystemUiVisibility(MainActivity.FLAGS);
140 142
        displayPopup(act,view,mObjectPopup,mObjectSize*mColCount,mObjectSize*rowCount+5*margin,margin,margin);
141 143
        }
142 144
      });
src/main/java/org/distorted/dialogs/RubikDialogAbandon.java
15 15
import androidx.fragment.app.FragmentActivity;
16 16

  
17 17
import org.distorted.main.R;
18
import org.distorted.main_old.RubikActivity;
19
import org.distorted.screens.ScreenList;
18
import org.distorted.playui.PlayActivity;
19
import org.distorted.playui.ScreenList;
20 20

  
21 21
///////////////////////////////////////////////////////////////////////////////////////////////////
22 22

  
......
27 27
  public boolean hasArgument()  { return false; }
28 28
  public int getPositive()      { return R.string.yes; }
29 29
  public int getNegative()      { return R.string.no; }
30
  public void negativeAction()  { }
31
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size) { }
30 32

  
31 33
///////////////////////////////////////////////////////////////////////////////////////////////////
32 34

  
33 35
  public void positiveAction()
34 36
    {
35
    final RubikActivity ract = (RubikActivity)getContext();
36
    ScreenList.goBack(ract);
37
    }
38

  
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40

  
41
  public void negativeAction()
42
    {
43

  
44
    }
45

  
46
///////////////////////////////////////////////////////////////////////////////////////////////////
47

  
48
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
49
    {
50

  
37
    final PlayActivity act = (PlayActivity)getContext();
38
    ScreenList.goBack(act);
51 39
    }
52 40
  }
src/main/java/org/distorted/dialogs/RubikDialogAbstract.java
25 25
import androidx.appcompat.app.AppCompatDialogFragment;
26 26
import androidx.fragment.app.FragmentActivity;
27 27

  
28
import org.distorted.main.MainActivity;
28 29
import org.distorted.main.R;
29
import org.distorted.main_old.RubikActivity;
30 30

  
31 31
///////////////////////////////////////////////////////////////////////////////////////////////////
32 32

  
......
147 147

  
148 148
    if( window!=null )
149 149
      {
150
      window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS);
150
      window.getDecorView().setSystemUiVisibility(MainActivity.FLAGS);
151 151
      }
152 152

  
153 153
    dialog.setOnShowListener(new DialogInterface.OnShowListener()
src/main/java/org/distorted/dialogs/RubikDialogNewRecord.java
56 56
        nameDiag.setArguments(bundle);
57 57
        nameDiag.show(act.getSupportFragmentManager(), null);
58 58
        }
59

  
60
      act.finish();
61 59
      }
62 60
    }
63 61

  
src/main/java/org/distorted/dialogs/RubikDialogPattern.java
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 androidx.fragment.app.FragmentActivity;
14
import androidx.viewpager.widget.ViewPager;
15
import com.google.android.material.tabs.TabLayout;
16

  
17
import android.view.View;
18
import android.view.ViewGroup;
19
import android.view.Window;
20
import android.view.WindowManager;
21
import android.widget.ImageView;
22

  
23
import org.distorted.main.R;
24
import org.distorted.main_old.RubikActivity;
25
import org.distorted.objects.RubikObject;
26
import org.distorted.objects.RubikObjectList;
27
import org.distorted.objectlib.patterns.RubikPatternList;
28

  
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30

  
31
public class RubikDialogPattern extends RubikDialogAbstract
32
  {
33
  private RubikDialogPatternPagerAdapter mPagerAdapter;
34

  
35
///////////////////////////////////////////////////////////////////////////////////////////////////
36

  
37
  @Override
38
  public void onResume()
39
    {
40
    super.onResume();
41

  
42
    Window window = getDialog().getWindow();
43

  
44
    if( window!=null )
45
      {
46
      WindowManager.LayoutParams params = window.getAttributes();
47
      params.width  = (int)Math.min( mHeight*0.65f,mWidth*0.98f );
48
      params.height = (int)Math.min( mHeight*0.85f,mWidth*1.30f );
49
      window.setAttributes(params);
50
      }
51
    }
52

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

  
55
  public int getResource()      { return R.layout.dialog_tabbed; }
56
  public int getTitleResource() { return R.string.choose_pattern; }
57
  public boolean hasArgument()  { return false; }
58
  public int getPositive()      { return R.string.ok; }
59
  public int getNegative()      { return -1; }
60
  public void positiveAction()  { }
61
  public void negativeAction()  { }
62

  
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64

  
65
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
66
    {
67
    final int tabHeight= (int)(mHeight*RubikActivity.TAB_HEIGHT);
68
    final int tabWidth = (int)(mHeight*RubikActivity.TAB_WIDTH);
69

  
70
    ViewPager viewPager = view.findViewById(R.id.viewpager);
71
    TabLayout tabLayout = view.findViewById(R.id.sliding_tabs);
72
    mPagerAdapter = new RubikDialogPatternPagerAdapter(act, viewPager, this);
73
    tabLayout.setupWithViewPager(viewPager);
74

  
75
    int obj = RubikObjectList.getCurrObject();
76
    int ord = RubikPatternList.getOrdinal(obj);
77
    if( ord<0 ) ord = RubikPatternList.getOrdinal(RubikObjectList.DEF_OBJECT);
78
    viewPager.setCurrentItem(ord);
79

  
80
    ViewGroup.LayoutParams paramsView = new ViewGroup.LayoutParams( tabWidth,tabHeight );
81

  
82
    for(int i=0; i< RubikPatternList.NUM_OBJECTS; i++)
83
      {
84
      int ordinal = RubikPatternList.getObject(i);
85
      RubikObject object = RubikObjectList.getObject(ordinal);
86
      ImageView imageView = new ImageView(act);
87
      if( object!=null ) object.setIconTo(act,imageView);
88
      imageView.setLayoutParams(paramsView);
89
      TabLayout.Tab tab = tabLayout.getTabAt(i);
90
      if(tab!=null) tab.setCustomView(imageView);
91
      }
92
    }
93

  
94
///////////////////////////////////////////////////////////////////////////////////////////////////
95

  
96
  public void rememberState()
97
    {
98
    mPagerAdapter.rememberState();
99
    }
100

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

  
103
  public static String getDialogTag()
104
    {
105
    return "DialogPattern";
106
    }
107
  }
src/main/java/org/distorted/dialogs/RubikDialogPatternListAdapter.java
1 1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
2
// Copyright 2023 Leszek Koltunski                                                               //
3 3
//                                                                                               //
4 4
// This file is part of Magic Cube.                                                              //
5 5
//                                                                                               //
6 6
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7 7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8

  
8 9
///////////////////////////////////////////////////////////////////////////////////////////////////
9 10

  
10 11
package org.distorted.dialogs;
......
16 17
import android.view.ViewGroup;
17 18
import android.widget.BaseExpandableListAdapter;
18 19
import android.widget.TextView;
19

  
20 20
import org.distorted.objectlib.patterns.RubikPattern;
21 21
import org.distorted.main.R;
22 22

  
......
26 26
  {
27 27
  private static final float PATTERN_CHILD_TEXT  = 0.038f;
28 28
  private static final float PATTERN_GROUP_TEXT  = 0.060f;
29

  
30 29
  private final Context mContext;
31 30
  private final int mTab, mWidth;
32 31

  
......
70 69
      }
71 70

  
72 71
    int size = (int)(mWidth*PATTERN_CHILD_TEXT);
73

  
74 72
    TextView childItem = view.findViewById(R.id.child);
75 73
    childItem.setText(childName);
76 74
    childItem.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
77

  
78 75
    return view;
79 76
    }
80 77

  
......
127 124
      }
128 125

  
129 126
    int size = (int)(mWidth*PATTERN_GROUP_TEXT);
130

  
131 127
    TextView heading = view.findViewById(R.id.heading);
132 128
    heading.setText(groupName);
133 129
    heading.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
134

  
135 130
    RubikPattern pattern = RubikPattern.getInstance();
136 131
    int numPatterns = pattern.getNumPatterns(mTab,groupPosition);
137 132
    TextView counter = view.findViewById(R.id.counter);
138 133
    counter.setText(String.format("%d", numPatterns));
139 134
    counter.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
140

  
141 135
    return view;
142 136
    }
143 137

  
src/main/java/org/distorted/dialogs/RubikDialogPatternPagerAdapter.java
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 androidx.annotation.NonNull;
13
import androidx.fragment.app.FragmentActivity;
14
import androidx.viewpager.widget.PagerAdapter;
15
import androidx.viewpager.widget.ViewPager;
16
import android.view.View;
17
import android.view.ViewGroup;
18

  
19
import org.distorted.objectlib.patterns.RubikPattern;
20
import org.distorted.objectlib.patterns.RubikPatternList;
21

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

  
24
class RubikDialogPatternPagerAdapter extends PagerAdapter
25
  {
26
  private final FragmentActivity mAct;
27
  private final RubikDialogPatternView[] mViews;
28
  private final RubikDialogPattern mDialog;
29
  private final int mNumTabs;
30

  
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

  
33
  RubikDialogPatternPagerAdapter(FragmentActivity act, ViewPager viewPager, RubikDialogPattern dialog)
34
    {
35
    mAct = act;
36
    mDialog = dialog;
37
    mNumTabs = RubikPatternList.NUM_OBJECTS;
38
    mViews = new RubikDialogPatternView[mNumTabs];
39

  
40
    viewPager.setAdapter(this);
41
    viewPager.setOffscreenPageLimit(mNumTabs-1);
42
    }
43

  
44
///////////////////////////////////////////////////////////////////////////////////////////////////
45

  
46
  void rememberState()
47
    {
48
    RubikPattern pattern = RubikPattern.getInstance();
49

  
50
    for(int i=0; i<mNumTabs; i++)
51
      {
52
      int cat = mViews[i].getCurrentCategory();
53
      int pos = mViews[i].getCurrentVisiblePos();
54
      int exp = mViews[i].getExpanded();
55
      pattern.rememberState(i,cat,pos,exp);
56
      }
57
    }
58

  
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60

  
61
  @Override
62
  @NonNull
63
  public Object instantiateItem(@NonNull ViewGroup collection, final int position)
64
    {
65
    mViews[position] = new RubikDialogPatternView(mAct, mDialog, position);
66
    collection.addView(mViews[position]);
67

  
68
    return mViews[position];
69
    }
70

  
71
///////////////////////////////////////////////////////////////////////////////////////////////////
72

  
73
  @Override
74
  public void destroyItem(ViewGroup collection, int position, @NonNull Object view)
75
    {
76
    collection.removeView((View) view);
77
    mViews[position] = null;
78
    }
79

  
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81

  
82
  @Override
83
  public int getCount()
84
    {
85
    return mNumTabs;
86
    }
87

  
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89

  
90
  @Override
91
  public boolean isViewFromObject(@NonNull View view, @NonNull Object object)
92
    {
93
    return view == object;
94
    }
95
  }
src/main/java/org/distorted/dialogs/RubikDialogPatternView.java
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.content.Context;
13
import androidx.fragment.app.FragmentActivity;
14
import android.util.AttributeSet;
15
import android.view.View;
16
import android.widget.ExpandableListView;
17
import android.widget.FrameLayout;
18

  
19
import org.distorted.objectlib.main.ObjectControl;
20
import org.distorted.objectlib.patterns.RubikPattern;
21
import org.distorted.objectlib.patterns.RubikPatternList;
22

  
23
import org.distorted.main.R;
24
import org.distorted.main_old.RubikActivity;
25
import org.distorted.screens.ScreenList;
26
import org.distorted.screens.RubikScreenPattern;
27

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

  
30
public class RubikDialogPatternView extends FrameLayout
31
  {
32
  private ExpandableListView mListView;
33
  private RubikDialogPattern mDialog;
34
  private int mTab, mPos;
35
  private int mExpandedGroup;
36

  
37
///////////////////////////////////////////////////////////////////////////////////////////////////
38

  
39
  public RubikDialogPatternView(Context context, AttributeSet attrs, int defStyle)
40
    {
41
    super(context, attrs, defStyle);
42
    }
43

  
44
///////////////////////////////////////////////////////////////////////////////////////////////////
45

  
46
  public RubikDialogPatternView(Context context, AttributeSet attrs)
47
    {
48
    super(context, attrs);
49
    }
50

  
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52

  
53
  public RubikDialogPatternView(FragmentActivity act, RubikDialogPattern dialog, int position)
54
    {
55
    super(act);
56

  
57
    final RubikActivity ract = (RubikActivity)getContext();
58
    final ObjectControl control = ract.getControl();
59

  
60
    mTab = position;
61
    mDialog = dialog;
62

  
63
    RubikPattern pattern = RubikPattern.getInstance();
64
    mExpandedGroup = pattern.recallExpanded(position);
65

  
66
    View tab = inflate( act, R.layout.dialog_pattern_tab, null);
67

  
68
    mListView = tab.findViewById(R.id.patternListView);
69
    RubikDialogPatternListAdapter listAdapter = new RubikDialogPatternListAdapter(act,mTab, ract.getScreenWidthInPixels());
70
    mListView.setAdapter(listAdapter);
71

  
72
    if( mExpandedGroup>=0 )
73
      {
74
      mListView.expandGroup(mExpandedGroup);
75
      }
76

  
77
    int visible = pattern.recallVisiblePos(mTab);
78
    mListView.setSelectionFromTop(visible,0);
79

  
80
    mListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener()
81
      {
82
      @Override
83
      public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id)
84
        {
85
        RubikPattern pattern = RubikPattern.getInstance();
86
        int[][] moves   = pattern.reInitialize(mTab, groupPosition, childPosition);
87
        int object = RubikPatternList.getObject(mTab);
88
        ract.changeIfDifferent(object,control);
89
        control.initializeObject(moves);
90

  
91
        ScreenList.switchScreen(ract, ScreenList.PATT);
92
        RubikScreenPattern state = (RubikScreenPattern) ScreenList.PATT.getScreenClass();
93
        state.setPattern(ract, mTab, groupPosition, childPosition);
94

  
95
        mDialog.rememberState();
96
        mDialog.dismiss();
97

  
98
        return false;
99
        }
100
      });
101

  
102
    mListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener()
103
      {
104
      @Override
105
      public void onGroupExpand(int groupPosition)
106
        {
107
        if(mExpandedGroup!=-1 && groupPosition!=mExpandedGroup)
108
          {
109
          mListView.collapseGroup(mExpandedGroup);
110
          }
111

  
112
        mExpandedGroup = groupPosition;
113
        }
114
      });
115

  
116
    addView(tab);
117
    }
118

  
119
///////////////////////////////////////////////////////////////////////////////////////////////////
120

  
121
  int getCurrentCategory()
122
    {
123
    return mPos;
124
    }
125

  
126
///////////////////////////////////////////////////////////////////////////////////////////////////
127

  
128
  int getCurrentVisiblePos()
129
    {
130
    return mListView.getFirstVisiblePosition();
131
    }
132

  
133
///////////////////////////////////////////////////////////////////////////////////////////////////
134

  
135
  int getExpanded()
136
    {
137
    return mExpandedGroup;
138
    }
139
  }
src/main/java/org/distorted/dialogs/RubikDialogPrivacy.java
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.text.method.LinkMovementMethod;
14
import android.text.method.MovementMethod;
15
import android.view.View;
16
import android.widget.TextView;
17

  
18
import androidx.fragment.app.FragmentActivity;
19

  
20
import org.distorted.main.R;
21

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

  
24
public class RubikDialogPrivacy extends RubikDialogAbstract
25
  {
26
  public int getResource()      { return R.layout.dialog_privacy; }
27
  public int getTitleResource() { return R.string.privacy_policy; }
28
  public boolean hasArgument()  { return false; }
29
  public int getPositive()      { return R.string.accept; }
30
  public int getNegative()      { return R.string.decline; }
31

  
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

  
34
  public void positiveAction()
35
    {
36
    //final RubikActivity act = (RubikActivity)getContext();
37
    //if( act!=null ) act.acceptPrivacy();
38
    }
39

  
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41

  
42
  public void negativeAction()
43
    {
44
    //final RubikActivity act = (RubikActivity)getContext();
45
    //if( act!=null ) act.declinePrivacy();
46
    }
47

  
48
///////////////////////////////////////////////////////////////////////////////////////////////////
49

  
50
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
51
    {
52
    MovementMethod mm = LinkMovementMethod.getInstance();
53
    TextView text = view.findViewById(R.id.privacy_string);
54
    text.setMovementMethod(mm);
55
    }
56
  }
src/main/java/org/distorted/dialogs/RubikDialogScores.java
21 21
import android.widget.ImageView;
22 22

  
23 23
import org.distorted.main.R;
24
import org.distorted.main_old.RubikActivity;
25 24
import org.distorted.objects.RubikObject;
26 25
import org.distorted.objects.RubikObjectList;
27 26

  
......
29 28

  
30 29
public class RubikDialogScores extends RubikDialogAbstract
31 30
  {
31
  private static final float TAB_WIDTH = 0.066f;
32
  private static final float TAB_HEIGHT= 0.066f;
33

  
32 34
  private RubikDialogScoresPagerAdapter mPagerAdapter;
33 35

  
34 36
///////////////////////////////////////////////////////////////////////////////////////////////////
......
63 65

  
64 66
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
65 67
    {
66
    final int tabHeight= (int)(mHeight*RubikActivity.TAB_HEIGHT);
67
    final int tabWidth = (int)(mHeight*RubikActivity.TAB_WIDTH);
68
    final int tabHeight= (int)(mHeight*TAB_HEIGHT);
69
    final int tabWidth = (int)(mHeight*TAB_WIDTH);
68 70

  
69 71
    ViewPager viewPager = view.findViewById(R.id.viewpager);
70 72
    TabLayout tabLayout = view.findViewById(R.id.sliding_tabs);
src/main/java/org/distorted/dialogs/RubikDialogScoresPagerAdapter.java
18 18
import android.util.DisplayMetrics;
19 19
import android.view.View;
20 20
import android.view.ViewGroup;
21
import android.widget.LinearLayout;
22 21

  
23 22
import org.distorted.main.R;
24 23
import org.distorted.external.RubikScores;
25 24
import org.distorted.external.RubikNetwork;
26 25
import org.distorted.objects.RubikObject;
27 26
import org.distorted.objects.RubikObjectList;
28
import org.distorted.screens.RubikScreenPlay;
27
import static org.distorted.external.RubikScores.LEVELS_SHOWN;
29 28

  
30 29
///////////////////////////////////////////////////////////////////////////////////////////////////
31 30

  
......
138 137
      {
139 138
      RubikObject object = RubikObjectList.getObject(i);
140 139
      int numScramble = object==null ? 1 : object.getNumScramble();
141
      mNumLevels[i] = Math.min(numScramble-1, RubikScreenPlay.LEVELS_SHOWN);
140
      mNumLevels[i] = Math.min(numScramble-1,LEVELS_SHOWN);
142 141
      }
143 142

  
144 143
    viewPager.setAdapter(this);
src/main/java/org/distorted/dialogs/RubikDialogScoresView.java
21 21
import android.widget.TextView;
22 22

  
23 23
import org.distorted.main.R;
24
import org.distorted.main_old.RubikActivity;
25 24
import org.distorted.external.RubikScores;
26 25

  
27 26
import static org.distorted.external.RubikNetwork.MAX_PLACES;
......
30 29

  
31 30
public class RubikDialogScoresView extends FrameLayout
32 31
  {
32
  private static final float SCORES_LEVEL_TEXT = 0.035f;
33
  private static final float SCORES_ITEM_TEXT  = 0.025f;
34

  
33 35
  private LinearLayout mLayout=null;
34 36
  private int mHeight;
35 37

  
......
72 74
    TextView text = levelLayout.findViewById(R.id.scoresScrambleTitle);
73 75
    text.setText(title);
74 76

  
75
    int size = (int)(mHeight*RubikActivity.SCORES_LEVEL_TEXT);
77
    int size = (int)(mHeight*SCORES_LEVEL_TEXT);
76 78
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
77 79

  
78 80
    Resources res = act.getResources();
......
88 90
    String theirTime;
89 91
    int theirCountryID;
90 92

  
91
    int height = (int)(mHeight* RubikActivity.SCORES_ITEM_TEXT);
93
    int height = (int)(mHeight*SCORES_ITEM_TEXT);
92 94
    int white = res.getColor(R.color.white);
93 95
    int red   = res.getColor(R.color.red);
94 96
    boolean equals;
src/main/java/org/distorted/dialogs/RubikDialogSetName.java
23 23
import android.widget.TextView;
24 24

  
25 25
import org.distorted.main.R;
26
import org.distorted.main_old.RubikActivity;
27 26
import org.distorted.external.RubikScores;
28
import org.distorted.screens.ScreenList;
27
import org.distorted.playui.PlayActivity;
29 28

  
30 29
///////////////////////////////////////////////////////////////////////////////////////////////////
31 30

  
......
81 80

  
82 81
      try
83 82
        {
84
        RubikActivity act = (RubikActivity)getActivity();
85
        ScreenList.switchScreen(act, ScreenList.PLAY);
83
        PlayActivity act = (PlayActivity)getActivity();
86 84
        RubikScores.getInstance().setName(name);
87

  
88 85
        Bundle bundle = new Bundle();
89 86
        bundle.putString("argument", "true");
90 87
        RubikDialogScores scores = new RubikDialogScores();
src/main/java/org/distorted/dialogs/RubikDialogSolved.java
17 17
import android.widget.TextView;
18 18

  
19 19
import org.distorted.main.R;
20
import org.distorted.main_old.RubikActivity;
21
import org.distorted.screens.ScreenList;
20
import org.distorted.playui.PlayActivity;
22 21

  
23 22
///////////////////////////////////////////////////////////////////////////////////////////////////
24 23

  
......
34 33

  
35 34
  public void positiveAction()
36 35
    {
37
    RubikActivity act = (RubikActivity)getActivity();
38
    ScreenList.switchScreen(act, ScreenList.PLAY);
36
    PlayActivity act = (PlayActivity)getActivity();
37
    if( act!=null ) act.finish();
39 38
    }
40 39

  
41 40
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/dialogs/RubikDialogSolverView.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_old.RubikActivity;
21
import org.distorted.objects.RubikObject;
22
import org.distorted.objects.RubikObjectList;
23
import org.distorted.screens.ScreenList;
24

  
25
///////////////////////////////////////////////////////////////////////////////////////////////////
26

  
27
public class RubikDialogSolverView
28
  {
29
  private final View mView;
30

  
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

  
33
  public RubikDialogSolverView(final RubikActivity act, final RubikDialogSolvers dialog, int index, int object,
34
                               int title, int desc, int padding, int fontSize, LinearLayout.LayoutParams pView,
35
                               LinearLayout.LayoutParams pText, LinearLayout.LayoutParams pButt )
36
    {
37
    mView = act.getLayoutInflater().inflate(R.layout.dialog_solvers_pane, null);
38
    mView.setLayoutParams(pView);
39
    mView.setPadding(padding,padding,padding,padding);
40

  
41
    TextView titleView = mView.findViewById(R.id.solvers_pane_title);
42
    titleView.setText(title);
43
    TextView descView = mView.findViewById(R.id.solvers_pane_description);
44
    descView.setText(desc);
45

  
46
    titleView.setLayoutParams(pText);
47

  
48
    ImageView icon = mView.findViewById(R.id.solvers_pane_image);
49
    RubikObject robject = RubikObjectList.getObject(object);
50
    if( robject!=null ) robject.setIconTo(act,icon);
51

  
52
    Button button = mView.findViewById(R.id.solvers_pane_button);
53

  
54
    button.setOnClickListener( new View.OnClickListener()
55
      {
56
      @Override
57
      public void onClick(View v)
58
        {
59
        dialog.dismiss();
60
        act.setSolverIndex(index);
61
        ScreenList.switchScreen(act, ScreenList.SVER);
62
        }
63
      });
64

  
65
    button.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
66
    button.setLayoutParams(pButt);
67
    }
68

  
69
///////////////////////////////////////////////////////////////////////////////////////////////////
70

  
71
  public View getView()
72
    {
73
    return mView;
74
    }
75
  }
src/main/java/org/distorted/dialogs/RubikDialogSolvers.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 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_old.RubikActivity;
23
import org.distorted.solvers.ImplementedSolversList;
24

  
25
///////////////////////////////////////////////////////////////////////////////////////////////////
26

  
27
public class RubikDialogSolvers extends RubikDialogAbstract
28
  {
29
  @Override
30
  public void onResume()
31
    {
32
    super.onResume();
33

  
34
    Window window = getDialog().getWindow();
35

  
36
    if( window!=null )
37
      {
38
      WindowManager.LayoutParams params = window.getAttributes();
39
      params.width  = (int)Math.min( mHeight*0.65f,mWidth*0.98f );
40
      window.setAttributes(params);
41
      }
42
    }
43

  
44
///////////////////////////////////////////////////////////////////////////////////////////////////
45

  
46
  public int getResource()            { return R.layout.dialog_scrollable_panes; }
47
  public int getTitleResource()       { return R.string.solver; }
48
  public boolean hasArgument()        { return false; }
49
  public int getPositive()            { return R.string.ok; }
50
  public int getNegative()            { return -1; }
51
  public static String getDialogTag() { return "DialogSolvers"; }
52
  public void positiveAction()        { }
53
  public void negativeAction()        { }
54

  
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56

  
57
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
58
    {
59
    int margin= (int)(mHeight*0.010f);
60
    int padd  = (int)(mHeight*0.010f);
61
    int font  = (int)(mHeight*0.025f);
62

  
63
    LinearLayout layout= view.findViewById(R.id.dialog_scrollable_main_layout);
64
    TextView text  = view.findViewById(R.id.dialog_scrollable_message);
65
    text.setVisibility(View.GONE);
66

  
67
    LinearLayout.LayoutParams pV = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
68
    pV.setMargins(margin, margin, margin, 0);
69
    LinearLayout.LayoutParams pL = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
70
    pL.setMargins(margin, margin, margin, margin);
71
    LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
72
    pT.setMargins(0,0,0,2*margin);
73
    LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
74
    pB.setMargins(0,2*margin,0,0);
75

  
76
    int num = ImplementedSolversList.NUM_OBJECTS;
77
    RubikActivity ract = (RubikActivity) getContext();
78

  
79
    for(int i=0; i<num; i++)
80
      {
81
      ImplementedSolversList solver = ImplementedSolversList.getSolver(i);
82
      int object = solver.getObject();
83
      int title  = solver.getTitle();
84
      int description = solver.getDescription();
85
      RubikDialogSolverView pane = new RubikDialogSolverView(ract,this,i,object,title,description, padd, font, (i==num-1?pL:pV),pT,pB);
86
      layout.addView(pane.getView());
87
      }
88
    }
89
  }
src/main/java/org/distorted/dialogs/RubikDialogTutorial.java
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.view.View;
14
import android.view.ViewGroup;
15
import android.view.Window;
16
import android.view.WindowManager;
17
import android.widget.ImageView;
18

  
19
import androidx.fragment.app.FragmentActivity;
20
import androidx.viewpager.widget.ViewPager;
21

  
22
import com.google.android.material.tabs.TabLayout;
23

  
24
import org.distorted.main.R;
25
import org.distorted.main_old.RubikActivity;
26
import org.distorted.objects.RubikObject;
27
import org.distorted.objects.RubikObjectList;
28

  
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30

  
31
public class RubikDialogTutorial extends RubikDialogAbstract
32
  {
33
  private RubikDialogTutorialPagerAdapter mPagerAdapter;
34

  
35
///////////////////////////////////////////////////////////////////////////////////////////////////
36

  
37
  @Override
38
  public void onResume()
39
    {
40
    super.onResume();
41

  
42
    if( mPagerAdapter!=null ) mPagerAdapter.clickPossible();
43

  
44
    Window window = getDialog().getWindow();
45

  
46
    if( window!=null )
47
      {
48
      WindowManager.LayoutParams params = window.getAttributes();
49
      params.width  = (int)Math.min( mHeight*0.65f,mWidth*0.98f );
50
      params.height = (int)Math.min( mHeight*0.85f,mWidth*1.30f );
51
      window.setAttributes(params);
52
      }
53
    }
54

  
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56

  
57
  public int getResource()      { return R.layout.dialog_tabbed; }
58
  public int getTitleResource() { return R.string.tutorials; }
59
  public boolean hasArgument()  { return false; }
60
  public int getPositive()      { return R.string.ok; }
61
  public int getNegative()      { return -1; }
62
  public void positiveAction()  { }
63
  public void negativeAction()  { }
64

  
65
///////////////////////////////////////////////////////////////////////////////////////////////////
66

  
67
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
68
    {
69
    final int tabHeight= (int)(mHeight*RubikActivity.TAB_HEIGHT);
70
    final int tabWidth = (int)(mHeight*RubikActivity.TAB_WIDTH);
71

  
72
    ViewPager viewPager = view.findViewById(R.id.viewpager);
73
    TabLayout tabLayout = view.findViewById(R.id.sliding_tabs);
74
    mPagerAdapter = new RubikDialogTutorialPagerAdapter(act,viewPager);
75
    tabLayout.setupWithViewPager(viewPager);
76
    int obj = RubikObjectList.getCurrObject();
77
    int ord = RubikObjectList.getTutorialOrdinal(obj);
78
    viewPager.setCurrentItem(ord);
79

  
80
    ViewGroup.LayoutParams paramsView = new ViewGroup.LayoutParams( tabWidth,tabHeight );
81
    int numObjects = RubikObjectList.getNumTutorialObjects();
82

  
83
    for(int i=0; i<numObjects; i++)
84
      {
85
      int oOrdinal = RubikObjectList.getObjectOrdinal(i);
86
      RubikObject object = RubikObjectList.getObject(oOrdinal);
87
      ImageView imageView = new ImageView(act);
88
      imageView.setLayoutParams(paramsView);
89
      if( object!=null ) object.setIconTo(act,imageView);
90
      TabLayout.Tab tab = tabLayout.getTabAt(i);
91
      if(tab!=null) tab.setCustomView(imageView);
92
      }
93
    }
94

  
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96

  
97
  public static String getDialogTag()
98
    {
99
    return "DialogTutorial";
100
    }
101
  }
src/main/java/org/distorted/dialogs/RubikDialogTutorialPagerAdapter.java
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.util.DisplayMetrics;
13
import android.view.View;
14
import android.view.ViewGroup;
15

  
16
import androidx.annotation.NonNull;
17
import androidx.fragment.app.FragmentActivity;
18
import androidx.viewpager.widget.PagerAdapter;
19
import androidx.viewpager.widget.ViewPager;
20

  
21
import org.distorted.objects.RubikObjectList;
22

  
23
///////////////////////////////////////////////////////////////////////////////////////////////////
24

  
25
class RubikDialogTutorialPagerAdapter extends PagerAdapter
26
  {
27
  private final FragmentActivity mAct;
28
  private final RubikDialogTutorialView[] mViews;
29
  private final int mNumTabs;
30

  
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

  
33
  RubikDialogTutorialPagerAdapter(FragmentActivity act, ViewPager viewPager)
34
    {
35
    mAct     = act;
36
    mNumTabs = RubikObjectList.getNumTutorialObjects();
37
    mViews   = new RubikDialogTutorialView[mNumTabs];
38

  
39
    viewPager.setAdapter(this);
40
    viewPager.setOffscreenPageLimit(1);
41
    }
42

  
43
///////////////////////////////////////////////////////////////////////////////////////////////////
44

  
45
  void clickPossible()
46
    {
47
    for(int i=0; i<mNumTabs; i++)
48
      {
49
      if( mViews[i]!=null )
50
        {
51
        mViews[i].clickPossible(true);
52
        }
53
      }
54
    }
55

  
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57

  
58
  @Override
59
  @NonNull
60
  public Object instantiateItem(@NonNull ViewGroup collection, final int position)
61
    {
62
    DisplayMetrics metrics = mAct.getResources().getDisplayMetrics();
63

  
64
    mViews[position] = new RubikDialogTutorialView(mAct, metrics.heightPixels, position);
65
    collection.addView(mViews[position]);
66

  
67
    return mViews[position];
68
    }
69

  
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71

  
72
  @Override
73
  public void destroyItem(ViewGroup collection, int position, @NonNull Object view)
74
    {
75
    collection.removeView((View) view);
76
    mViews[position] = null;
77
    }
78

  
79
///////////////////////////////////////////////////////////////////////////////////////////////////
80

  
81
  @Override
82
  public int getCount()
83
    {
84
    return mNumTabs;
85
    }
86

  
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88

  
89
  @Override
90
  public boolean isViewFromObject(@NonNull View view, @NonNull Object object)
91
    {
92
    return view == object;
93
    }
94
  }
src/main/java/org/distorted/dialogs/RubikDialogTutorialView.java
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.content.Context;
13
import android.content.res.Resources;
14
import android.os.Bundle;
15
import android.util.AttributeSet;
16
import android.util.TypedValue;
17
import android.view.View;
18
import android.widget.Button;
19
import android.widget.FrameLayout;
20
import android.widget.ImageView;
21
import android.widget.LinearLayout;
22
import android.widget.TextView;
23

  
24
import androidx.fragment.app.FragmentActivity;
25

  
26
import com.google.firebase.analytics.FirebaseAnalytics;
27

  
28
import org.distorted.main.BuildConfig;
29
import org.distorted.main.R;
30
import org.distorted.main_old.RubikActivity;
31
import org.distorted.objectlib.json.JsonReader;
32
import org.distorted.objects.RubikObject;
33
import org.distorted.objects.RubikObjectList;
34

  
35
import java.io.InputStream;
36

  
37
///////////////////////////////////////////////////////////////////////////////////////////////////
38

  
39
public class RubikDialogTutorialView extends FrameLayout
40
  {
41
  public static final float PANE_HEIGHT  = 0.06f;
42
  private boolean mCanClick;
43

  
44
///////////////////////////////////////////////////////////////////////////////////////////////////
45

  
46
  public RubikDialogTutorialView(Context context, AttributeSet attrs, int defStyle)
47
    {
48
    super(context, attrs, defStyle);
49
    }
50

  
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52

  
53
  public RubikDialogTutorialView(Context context, AttributeSet attrs)
54
    {
55
    super(context, attrs);
56
    }
57

  
58
///////////////////////////////////////////////////////////////////////////////////////////////////
59

  
60
  public RubikDialogTutorialView(FragmentActivity act, int height, int position)
61
    {
62
    super(act);
63

  
64
    int objectOrdinal = RubikObjectList.getObjectOrdinal(position);
65
    RubikObject robject = RubikObjectList.getObject(objectOrdinal);
66
    InputStream jsonStream = robject==null ? null : robject.getExtrasStream(act);
67
    String[][] tutorials=null;
68

  
69
    if( jsonStream!=null )
70
      {
71
      try
72
        {
73
        JsonReader reader = new JsonReader();
74
        reader.parseJsonTutorial(jsonStream);
75
        tutorials = reader.getTutorials();
76
        }
77
      catch(Exception ignored) { }
78
      }
79

  
80
    if( tutorials!=null )
81
      {
82
      clickPossible(true);
83
      int size = (int)(height*PANE_HEIGHT);
84

  
85
      RubikActivity ract = (RubikActivity)getContext();
86
      Resources res = act.getResources();
87
      String packageName = act.getPackageName();
88

  
89
      View tab = inflate( act, R.layout.dialog_tutorial_tab, null);
90
      LinearLayout layout = tab.findViewById(R.id.tabLayout);
91

  
92
      int colorB = getResources().getColor(R.color.light_grey);
93
      int colorT = getResources().getColor(R.color.white);
94

  
95
      for (String[] tutorial : tutorials)
96
        {
97
        String coun = tutorial[0];
98
        String url  = tutorial[1];
99
        String desc = tutorial[2];
100
        String auth = tutorial[3];
101

  
102
        int countryID = res.getIdentifier(coun, "drawable", packageName);
103

  
104
        View row = createRow(ract, countryID, desc, url, auth, size, objectOrdinal, colorB, colorT);
105
        layout.addView(row);
106
        }
107

  
108
      addView(tab);
109
      }
110
    }
111

  
112
///////////////////////////////////////////////////////////////////////////////////////////////////
113

  
114
  void clickPossible(boolean click)
115
    {
116
    mCanClick = click;
117
    }
118

  
119
///////////////////////////////////////////////////////////////////////////////////////////////////
120

  
121
  private View createRow(final RubikActivity act, int countryID, final String desc, final String url,
122
                         final String auth, int size, final int obj, int colorB, int colorT)
123
    {
124
    float textSize = 0.43f*size;
125
    View row = inflate( act, R.layout.dialog_tutorial_row, null);
126

  
127
    LinearLayout layout = row.findViewById(R.id.tutorialLayout);
128
    layout.setMinimumHeight(size);
129

  
130
    Button butt = row.findViewById(R.id.tutorialButton);
131
    butt.setText(R.string.view);
132
    butt.setTextColor(colorT);
133
    butt.setBackgroundColor(colorB);
134
    butt.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
135
    butt.setHeight(size);
136

  
137
    butt.setOnClickListener( new View.OnClickListener()
138
      {
139
      @Override
140
      public void onClick(View v)
141
        {
142
        if( mCanClick )
143
          {
144
          act.switchToTutorial(url,obj);
145
          analyticsReport(act,desc,auth,obj);
146
          clickPossible(false);
147
          }
148
        }
149
      });
150

  
151
    ImageView image = row.findViewById(R.id.tutorialCountry);
152
    int id = countryID!=0 ? countryID : org.distorted.flags.R.drawable.unknown;
153
    image.setImageResource(id);
154

  
155
    TextView author = row.findViewById(R.id.tutorialAuthor);
156
    author.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
157
    author.setText(auth);
158

  
159
    TextView title  = row.findViewById(R.id.tutorialTitle);
160
    title.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
161
    title.setText(desc);
162

  
163
    return row;
164
    }
165

  
166
///////////////////////////////////////////////////////////////////////////////////////////////////
167

  
168
  private void analyticsReport(RubikActivity act, String desc, String author, int obj)
169
    {
170
    String message = desc+" ("+author+")";
171

  
172
    if( BuildConfig.DEBUG )
173
       {
174
       android.util.Log.d("tutorial", message);
175
       }
176
    else
177
      {
178
      FirebaseAnalytics analytics = act.getAnalytics();
179

  
180
      if( analytics!=null )
181
        {
182
        RubikObject object = RubikObjectList.getObject(obj);
183

  
184
        Bundle bundle = new Bundle();
185
        bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, message);
186
        bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, object==null ? "NULL" : object.getLowerName() );
187
        analytics.logEvent(FirebaseAnalytics.Event.TUTORIAL_BEGIN, bundle);
188
        }
189
      }
190
    }
191
  }
src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java
32 32
import org.distorted.objectlib.json.JsonReader;
33 33
import org.distorted.objects.RubikObjectList;
34 34

  
35
import static org.distorted.main_old.RubikActivity.SHOW_DOWNLOADED_DEBUG;
35
import static org.distorted.objects.RubikObjectList.SHOW_DOWNLOADED_DEBUG;
36 36

  
37 37
///////////////////////////////////////////////////////////////////////////////////////////////////
38 38

  
src/main/java/org/distorted/external/RubikNetwork.java
30 30
import org.distorted.objectlib.json.JsonWriter;
31 31
import org.distorted.objects.RubikObjectList;
32 32

  
33
import static org.distorted.main_old.RubikActivity.SHOW_DOWNLOADED_DEBUG;
34
import static org.distorted.screens.RubikScreenPlay.LEVELS_SHOWN;
33
import static org.distorted.objects.RubikObjectList.SHOW_DOWNLOADED_DEBUG;
34
import static org.distorted.external.RubikScores.LEVELS_SHOWN;
35 35

  
36 36
///////////////////////////////////////////////////////////////////////////////////////////////////
37 37

  
src/main/java/org/distorted/external/RubikScores.java
21 21
import org.distorted.main.BuildConfig;
22 22
import org.distorted.objects.RubikObject;
23 23
import org.distorted.objects.RubikObjectList;
24
import org.distorted.screens.RubikScreenPlay;
25 24

  
26 25
import static org.distorted.objectlib.main.ObjectType.MAX_SCRAMBLES;
27
import static org.distorted.screens.RubikScreenPlay.LEVELS_SHOWN;
28 26

  
29 27
///////////////////////////////////////////////////////////////////////////////////////////////////
30 28
// hold my own scores, and some other statistics.
31 29

  
32 30
public class RubikScores
33 31
  {
32
  public static final int LEVELS_SHOWN   = 8;
34 33
  public static final int RECORD_FIRST   = 0;
35 34
  public static final int RECORD_NEW     = 1;
36 35
  public static final int RECORD_NOT_NEW = 2;
......
259 258

  
260 259
    for(int obj=0; obj<numObjects; obj++)
261 260
      {
262
      for(int level=0; level<=RubikScreenPlay.LEVELS_SHOWN; level++)
261
      for(int level=0; level<=LEVELS_SHOWN; level++)
263 262
        {
264 263
        if( isSolved(obj,level) )
265 264
          {
......
504 503
  public int numberOfSolvedMAXes()
505 504
    {
506 505
    int numObjects = RubikObjectList.getNumObjects();
507
    int ret=0, level = RubikScreenPlay.LEVELS_SHOWN;
506
    int ret=0;
508 507

  
509 508
    for(int obj=0; obj<numObjects; obj++)
510 509
      {
511
      if( isSolved(obj,level) ) ret++;
510
      if( isSolved(obj,LEVELS_SHOWN) ) ret++;
512 511
      }
513 512

  
514 513
    return ret;
src/main/java/org/distorted/external/RubikUpdates.java
17 17
import android.graphics.Bitmap;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff