Project

General

Profile

« Previous | Next » 

Revision ac4c7a1d

Added by Leszek Koltunski over 1 year ago

Separate a OSInterface from LibInterface

View differences:

src/main/java/org/distorted/bandaged/BandagedOSInterface.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.bandaged;
11

  
12
import android.util.DisplayMetrics;
13

  
14
import org.distorted.objectlib.helpers.OperatingSystemInterface;
15

  
16
import java.lang.ref.WeakReference;
17

  
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
public class BandagedOSInterface implements OperatingSystemInterface
21
{
22
  private final WeakReference<BandagedPlayActivity> mAct;
23

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

  
26
  BandagedOSInterface(BandagedPlayActivity act)
27
    {
28
    mAct = new WeakReference<>(act);
29
    }
30

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

  
33
  public int getScreenDensity()
34
    {
35
    DisplayMetrics dm = new DisplayMetrics();
36
    mAct.get().getWindowManager().getDefaultDisplay().getMetrics(dm);
37
    return dm.densityDpi;
38
    }
39
}
src/main/java/org/distorted/bandaged/BandagedPlayView.java
30 30
public class BandagedPlayView extends GLSurfaceView
31 31
{
32 32
    private ObjectControl mObjectController;
33
    private BandagedOSInterface mInterface;
33 34
    private BandagedPlayRenderer mRenderer;
34 35
    private int mScreenWidth, mScreenHeight;
35 36
    private boolean mCreated;
......
80 81
        {
81 82
        BandagedPlayActivity act = (BandagedPlayActivity)context;
82 83
        BandagedPlayLibInterface ref = new BandagedPlayLibInterface(act);
83
        mObjectController = new ObjectControl(ref);
84
        mInterface = new BandagedOSInterface(act);
85
        mObjectController = new ObjectControl(ref,mInterface);
84 86
        mObjectController.setRotateOnCreation(true);
85 87
        mRenderer = new BandagedPlayRenderer(this);
86 88

  
src/main/java/org/distorted/config/ConfigOSInterface.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.config;
11

  
12
import android.util.DisplayMetrics;
13

  
14
import org.distorted.objectlib.helpers.OperatingSystemInterface;
15

  
16
import java.lang.ref.WeakReference;
17

  
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
public class ConfigOSInterface implements OperatingSystemInterface
21
{
22
  private final WeakReference<ConfigActivity> mAct;
23

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

  
26
  ConfigOSInterface(ConfigActivity act)
27
    {
28
    mAct = new WeakReference<>(act);
29
    }
30

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

  
33
  public int getScreenDensity()
34
    {
35
    DisplayMetrics dm = new DisplayMetrics();
36
    mAct.get().getWindowManager().getDefaultDisplay().getMetrics(dm);
37
    return dm.densityDpi;
38
    }
39
}
src/main/java/org/distorted/config/ConfigObjectLibInterface.java
1 1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 Leszek Koltunski                                                               //
2
// Copyright 2023 Leszek Koltunski                                                               //
3 3
//                                                                                               //
4 4
// This file is part of Magic Cube.                                                              //
5 5
//                                                                                               //
......
9 9

  
10 10
package org.distorted.config;
11 11

  
12
import android.util.DisplayMetrics;
13

  
14 12
import com.google.firebase.crashlytics.FirebaseCrashlytics;
15 13

  
16 14
import org.distorted.library.message.EffectMessageSender;
......
18 16
import org.distorted.objectlib.helpers.BlockController;
19 17
import org.distorted.objectlib.helpers.ObjectLibInterface;
20 18

  
21
import java.lang.ref.WeakReference;
22

  
23 19
///////////////////////////////////////////////////////////////////////////////////////////////////
24 20

  
25 21
public class ConfigObjectLibInterface implements ObjectLibInterface
26 22
{
27
  private final WeakReference<ConfigActivity> mAct;
28

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

  
31 23
  public void onWinEffectFinished(long startTime, long endTime, String debug, int scrambleNum) { }
32 24
  public void onScrambleEffectFinished() { }
33 25
  public void onBeginRotation() { }
......
135 127
      case BlockController.TYPE_THREAD    : reportThreadProblem(place,pause,resume,time); break;
136 128
      }
137 129
    }
138

  
139

  
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141

  
142
  ConfigObjectLibInterface(ConfigActivity act)
143
    {
144
    mAct = new WeakReference<>(act);
145
    }
146

  
147
///////////////////////////////////////////////////////////////////////////////////////////////////
148

  
149
  public int getScreenDensity()
150
    {
151
    DisplayMetrics dm = new DisplayMetrics();
152
    mAct.get().getWindowManager().getDefaultDisplay().getMetrics(dm);
153
    return dm.densityDpi;
154
    }
155 130
}
src/main/java/org/distorted/config/ConfigSurfaceView.java
26 26
public class ConfigSurfaceView extends GLSurfaceView
27 27
{
28 28
    private ObjectControl mObjectController;
29
    private ConfigOSInterface mInterface;
29 30
    private ConfigRenderer mRenderer;
30 31
    private int mScreenWidth, mScreenHeight;
31 32
    private boolean mCreated;
......
75 76
      if(!isInEditMode())
76 77
        {
77 78
        ConfigActivity act = (ConfigActivity)context;
78
        ConfigObjectLibInterface ref = new ConfigObjectLibInterface(act);
79
        mObjectController = new ObjectControl(ref);
79
        ConfigObjectLibInterface ref = new ConfigObjectLibInterface();
80
        mInterface = new ConfigOSInterface(act);
81
        mObjectController = new ObjectControl(ref,mInterface);
80 82
        mObjectController.setRotateOnCreation(true);
81 83
        mRenderer = new ConfigRenderer(this);
82 84

  
src/main/java/org/distorted/main/RubikOSInterface.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.main;
11

  
12
import android.util.DisplayMetrics;
13

  
14
import org.distorted.objectlib.helpers.OperatingSystemInterface;
15

  
16
import java.lang.ref.WeakReference;
17

  
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
public class RubikOSInterface implements OperatingSystemInterface
21
{
22
  private final WeakReference<RubikActivity> mAct;
23

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

  
26
  RubikOSInterface(RubikActivity act)
27
    {
28
    mAct = new WeakReference<>(act);
29
    }
30

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

  
33
  public int getScreenDensity()
34
    {
35
    DisplayMetrics dm = new DisplayMetrics();
36
    mAct.get().getWindowManager().getDefaultDisplay().getMetrics(dm);
37
    return dm.densityDpi;
38
    }
39
}
src/main/java/org/distorted/main/RubikObjectLibInterface.java
10 10
package org.distorted.main;
11 11

  
12 12
import android.os.Bundle;
13
import android.util.DisplayMetrics;
14 13

  
15 14
import androidx.annotation.NonNull;
16 15

  
......
514 513
    d.setArguments(bundle);
515 514
    d.show( act.getSupportFragmentManager(), RubikDialogNewRecord.getDialogTag() );
516 515
    }
517

  
518
///////////////////////////////////////////////////////////////////////////////////////////////////
519

  
520
  public int getScreenDensity()
521
    {
522
    DisplayMetrics dm = new DisplayMetrics();
523
    mAct.get().getWindowManager().getDefaultDisplay().getMetrics(dm);
524
    return dm.densityDpi;
525
    }
526 516
}
src/main/java/org/distorted/main/RubikSurfaceView.java
33 33
public class RubikSurfaceView extends GLSurfaceView
34 34
{
35 35
    private ObjectControl mObjectController;
36
    private RubikOSInterface mInterface;
36 37
    private RubikRenderer mRenderer;
37 38
    private int mScreenWidth, mScreenHeight;
38 39
    private boolean mCreated;
......
111 112
        {
112 113
        RubikActivity act = (RubikActivity)context;
113 114
        RubikObjectLibInterface ref = new RubikObjectLibInterface(act);
114
        mObjectController = new ObjectControl(ref);
115
        mInterface = new RubikOSInterface(act);
116
        mObjectController = new ObjectControl(ref,mInterface);
115 117
        mRenderer = new RubikRenderer(this);
116 118

  
117 119
        final ActivityManager activityManager= (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
src/main/java/org/distorted/purchase/PurchaseOSInterface.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.purchase;
11

  
12
import android.util.DisplayMetrics;
13

  
14
import org.distorted.objectlib.helpers.OperatingSystemInterface;
15

  
16
import java.lang.ref.WeakReference;
17

  
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
public class PurchaseOSInterface implements OperatingSystemInterface
21
{
22
  private final WeakReference<PurchaseActivity> mAct;
23

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

  
26
  PurchaseOSInterface(PurchaseActivity act)
27
    {
28
    mAct = new WeakReference<>(act);
29
    }
30

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

  
33
  public int getScreenDensity()
34
    {
35
    DisplayMetrics dm = new DisplayMetrics();
36
    mAct.get().getWindowManager().getDefaultDisplay().getMetrics(dm);
37
    return dm.densityDpi;
38
    }
39
}
src/main/java/org/distorted/purchase/PurchaseObjectLibInterface.java
9 9

  
10 10
package org.distorted.purchase;
11 11

  
12
import android.util.DisplayMetrics;
13

  
14 12
import com.google.firebase.crashlytics.FirebaseCrashlytics;
15 13

  
16 14
import org.distorted.objectlib.BuildConfig;
17 15
import org.distorted.objectlib.helpers.ObjectLibInterface;
18 16

  
19
import java.lang.ref.WeakReference;
20

  
21 17
///////////////////////////////////////////////////////////////////////////////////////////////////
22 18

  
23 19
public class PurchaseObjectLibInterface implements ObjectLibInterface
24 20
{
25
  private final WeakReference<PurchaseActivity> mAct;
26

  
27
///////////////////////////////////////////////////////////////////////////////////////////////////
28

  
29
  PurchaseObjectLibInterface(PurchaseActivity act)
30
    {
31
    mAct = new WeakReference<>(act);
32
    }
33

  
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

  
36 21
  public void onWinEffectFinished(long startTime, long endTime, String debug, int scrambleNum) { }
37 22
  public void onScrambleEffectFinished() { }
38 23
  public void onBeginRotation() { }
......
69 54
        }
70 55
      }
71 56
    }
72

  
73
///////////////////////////////////////////////////////////////////////////////////////////////////
74

  
75
  public int getScreenDensity()
76
    {
77
    DisplayMetrics dm = new DisplayMetrics();
78
    mAct.get().getWindowManager().getDefaultDisplay().getMetrics(dm);
79
    return dm.densityDpi;
80
    }
81 57
}
src/main/java/org/distorted/purchase/PurchaseSurfaceView.java
26 26
public class PurchaseSurfaceView extends GLSurfaceView
27 27
{
28 28
    private ObjectControl mObjectController;
29
    private PurchaseOSInterface mInterface;
29 30
    private PurchaseRenderer mRenderer;
30 31
    private boolean mCreated;
31 32

  
......
72 73
      if(!isInEditMode())
73 74
        {
74 75
        PurchaseActivity act = (PurchaseActivity)context;
75
        PurchaseObjectLibInterface ref = new PurchaseObjectLibInterface(act);
76
        mObjectController = new ObjectControl(ref);
76
        PurchaseObjectLibInterface ref = new PurchaseObjectLibInterface();
77
        mInterface = new PurchaseOSInterface(act);
78
        mObjectController = new ObjectControl(ref,mInterface);
77 79
        mObjectController.setRotateOnCreation(true);
78 80
        mRenderer = new PurchaseRenderer(this);
79 81

  
src/main/java/org/distorted/tutorials/TutorialOSInterface.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.tutorials;
11

  
12
import android.util.DisplayMetrics;
13

  
14
import org.distorted.objectlib.helpers.OperatingSystemInterface;
15

  
16
import java.lang.ref.WeakReference;
17

  
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
public class TutorialOSInterface implements OperatingSystemInterface
21
{
22
  private final WeakReference<TutorialActivity> mAct;
23

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

  
26
  TutorialOSInterface(TutorialActivity act)
27
    {
28
    mAct = new WeakReference<>(act);
29
    }
30

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

  
33
  public int getScreenDensity()
34
    {
35
    DisplayMetrics dm = new DisplayMetrics();
36
    mAct.get().getWindowManager().getDefaultDisplay().getMetrics(dm);
37
    return dm.densityDpi;
38
    }
39
}
src/main/java/org/distorted/tutorials/TutorialObjectLibInterface.java
158 158
     TutorialScreen state = act.getState();
159 159
     state.reddenLock(act);
160 160
     }
161

  
162
///////////////////////////////////////////////////////////////////////////////////////////////////
163

  
164
  public int getScreenDensity()
165
    {
166
    DisplayMetrics dm = new DisplayMetrics();
167
    mAct.get().getWindowManager().getDefaultDisplay().getMetrics(dm);
168
    return dm.densityDpi;
169
    }
170 161
}
src/main/java/org/distorted/tutorials/TutorialSurfaceView.java
29 29
public class TutorialSurfaceView extends GLSurfaceView
30 30
{
31 31
    private ObjectControl mObjectController;
32
    private TutorialOSInterface mInterface;
32 33
    private TutorialRenderer mRenderer;
33 34
    private int mScreenWidth, mScreenHeight;
34 35
    private boolean mCreated;
......
85 86
        {
86 87
        TutorialActivity act = (TutorialActivity)context;
87 88
        TutorialObjectLibInterface ref = new TutorialObjectLibInterface(act);
88
        mObjectController = new ObjectControl(ref);
89
        mInterface = new TutorialOSInterface(act);
90
        mObjectController = new ObjectControl(ref,mInterface);
89 91
        mRenderer = new TutorialRenderer(this);
90 92

  
91 93
        final ActivityManager activityManager= (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);

Also available in: Unified diff