Project

General

Profile

« Previous | Next » 

Revision 41aff64e

Added by Leszek Koltunski 3 days ago

change one of objlib's APIs from 'onReplaceModeUP/Down' (which only comes when TouchControl is in REPLACE mode) to 'onStickerTouched/Untouched' (which reports the same thing, but comes always)

View differences:

src/main/java/org/distorted/phasedsolver/SolverActivity.java
40 40
  private InitAssets mAsset;
41 41
  private SharedPreferences mPreferences;
42 42
  private SolverLowerPane mLowerPane;
43
  private TextView mText;
43
  private TextView mTextMoves, mTextStickers;
44 44
  private SolvedObject mObject;
45 45
  private String mMoves;
46 46
  private int mNumMoves;
47
  private String mStickers;
48
  private int mNumStickers;
47 49
  private int mCurrSolver;
48 50
  private PhasedSolverAbstract mSolver;
49 51
  private long mTime;
......
60 62
    SolverSurfaceView view = findViewById(R.id.solverView);
61 63
    OSInterface os = view.getInterface();
62 64
    mAsset = new InitAssets(null, null, os);
63
    mText = findViewById(R.id.solverMoves);
65
    mTextMoves = findViewById(R.id.solverMoves);
66
    mTextStickers = findViewById(R.id.solverStickers);
64 67
    mMoves = "";
65 68
    mNumMoves = 0;
69
    mStickers = "";
70
    mNumStickers = 0;
66 71
    Spinner objectSpinner = findViewById(R.id.solverSpinner);
67 72
    objectSpinner.setOnItemSelectedListener(this);
68 73

  
......
258 263
      });
259 264
    }
260 265

  
266
///////////////////////////////////////////////////////////////////////////////////////////////////
267

  
268
  private void resetTexts()
269
    {
270
    mNumMoves = 0;
271
    mMoves = "";
272
    mTextMoves.setText(mMoves);
273
    mNumStickers = 0;
274
    mStickers = "";
275
    mTextStickers.setText(mStickers);
276
    }
277

  
261 278
///////////////////////////////////////////////////////////////////////////////////////////////////
262 279

  
263 280
  public void Scramble(View v)
......
265 282
    ObjectControl control = getControl();
266 283
    control.fastScrambleObject(1000,20);
267 284
    mLowerPane.clearMoves();
268

  
269
    mNumMoves = 0;
270
    mMoves = "";
271
    mText.setText(mMoves);
285
    resetTexts();
272 286
    }
273 287

  
274 288
///////////////////////////////////////////////////////////////////////////////////////////////////
......
278 292
    ObjectControl control = getControl();
279 293
    control.solveObject();
280 294
    mLowerPane.clearMoves();
295
    resetTexts();
296
    }
281 297

  
282
    mNumMoves = 0;
283
    mMoves = "";
284
    mText.setText(mMoves);
298
///////////////////////////////////////////////////////////////////////////////////////////////////
299

  
300
  void addSticker(int cubit, int face)
301
    {
302
    mStickers += ("("+cubit+" "+face+") ");
303
    mNumStickers++;
304

  
305
    if( mNumStickers>6 )
306
      {
307
      int space = mStickers.indexOf(')');
308
      mStickers = mStickers.substring(space+1);
309
      mNumStickers--;
310
      }
311

  
312
    runOnUiThread(new Runnable()
313
      {
314
      @Override
315
      public void run() { mTextStickers.setText(mStickers); }
316
      });
285 317
    }
286 318

  
287 319
///////////////////////////////////////////////////////////////////////////////////////////////////
......
302 334
    runOnUiThread(new Runnable()
303 335
      {
304 336
      @Override
305
      public void run() { mText.setText(mMoves); }
337
      public void run() { mTextMoves.setText(mMoves); }
306 338
      });
307 339
    }
308 340
}
src/main/java/org/distorted/phasedsolver/SolverObjectLibInterface.java
30 30
  public void failedToDrag() { }
31 31
  public void reportBlockProblem(int type, int place, long pause, long resume, long time) { }
32 32
  public void reportProblem(String problem, boolean reportException) {}
33
  public void onReplaceModeDown(int cubit, int face) { }
34
  public void onReplaceModeUp() { }
33
  public void onStickerUntouched() { }
35 34
  public void reportJSONError(String error, int ordinal) { }
36 35

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

  
38
  public void onStickerTouched(int cubit, int face)
39
    {
40
    SolverActivity act = mAct.get();
41
    act.addSticker(cubit,face);
42
    }
43

  
37 44
///////////////////////////////////////////////////////////////////////////////////////////////////
38 45

  
39 46
  public void onRemoveRotation(int axis, int row, int angle)
src/main/res/layout/mainlayout.xml
24 24
            android:id="@+id/solverReset"
25 25
            android:layout_width="0dp"
26 26
            android:layout_height="match_parent"
27
            android:layout_weight="1.0"
27
            android:layout_weight="0.9"
28 28
            android:gravity="center_vertical|center"
29 29
            android:text="@string/reset"
30 30
            android:onClick="Reset"
......
46 46
            android:id="@+id/solverSolve"
47 47
            android:layout_width="0dp"
48 48
            android:layout_height="match_parent"
49
            android:layout_weight="1.0"
49
            android:layout_weight="0.9"
50 50
            android:gravity="center_vertical|center"
51 51
            android:text="@string/solve"
52 52
            android:onClick="Solve"
53 53
            android:textAppearance="?android:attr/textAppearanceMedium"
54 54
            android:layout_gravity="center_vertical"/>
55

  
56
    </LinearLayout>
57

  
58
    <LinearLayout
59
        android:id="@+id/middleBar"
60
        android:layout_below="@id/upperBar"
61
        android:layout_width="match_parent"
62
        android:layout_height="50dp"
63
        android:gravity="center"
64
        android:orientation="horizontal"
65
        android:background="@android:color/transparent">
66

  
67
        <TextView
68
            android:id="@+id/solverMoves"
69
            android:layout_width="0dp"
70
            android:layout_height="match_parent"
71
            android:layout_weight="2"
72
            android:background="@color/white"
73
            android:textColor="@color/black"
74
            android:layout_marginStart="4dp"
75
            android:layout_marginEnd="4dp"
76
            android:layout_marginTop="3dp"
77
            android:layout_marginBottom="5dp"
78
            android:textAppearance="?android:attr/textAppearanceLarge"
79
            android:gravity="center_vertical|start"/>
80 55
        <Spinner
81 56
            android:id="@+id/solverSpinner"
82 57
            android:layout_width="0dp"
83 58
            android:layout_height="match_parent"
84
            android:layout_weight="1"/>
85

  
59
            android:layout_weight="1.0"/>
86 60
    </LinearLayout>
87 61

  
62
    <TextView
63
        android:id="@+id/solverMoves"
64
        android:layout_below="@id/upperBar"
65
        android:layout_width="match_parent"
66
        android:layout_height="50dp"
67
        android:singleLine="true"
68
        android:background="@color/white"
69
        android:textColor="@color/black"
70
        android:layout_marginStart="3dp"
71
        android:layout_marginEnd="3dp"
72
        android:layout_marginTop="3dp"
73
        android:layout_marginBottom="5dp"
74
        android:textAppearance="?android:attr/textAppearanceLarge"
75
        android:gravity="center_vertical|start"/>
76

  
77
    <TextView
78
        android:id="@+id/solverStickers"
79
        android:layout_below="@id/solverMoves"
80
        android:layout_width="match_parent"
81
        android:layout_height="50dp"
82
        android:singleLine="true"
83
        android:background="@color/white"
84
        android:textColor="@color/black"
85
        android:layout_marginStart="3dp"
86
        android:layout_marginEnd="3dp"
87
        android:layout_marginTop="3dp"
88
        android:layout_marginBottom="5dp"
89
        android:textAppearance="?android:attr/textAppearanceLarge"
90
        android:gravity="center_vertical|start"/>
91

  
88 92
    <LinearLayout
89 93
        android:id="@+id/phaseBar"
90 94
        android:layout_above="@id/lowerBar"

Also available in: Unified diff