Project

General

Profile

« Previous | Next » 

Revision ada8ab26

Added by Leszek Koltunski about 1 year ago

Cleanups in the Activities.

View differences:

build.gradle
55 55
    implementation ('com.google.firebase:firebase-inappmessaging-display')
56 56
    implementation ('com.google.android.play:core:1.10.3')
57 57
    implementation ('androidx.appcompat:appcompat:1.6.1')
58
    implementation ('androidx.preference:preference:1.2.1')
58 59
    implementation ('androidx.work:work-runtime:2.8.1')
59 60
    implementation ('com.google.android.material:material:1.10.0')
60 61
    //implementation "com.android.billingclient:billing:5.1.0"
src/main/java/org/distorted/bandaged/BandagedCreatorActivity.java
19 19
import android.graphics.Bitmap;
20 20
import android.os.Build;
21 21
import android.os.Bundle;
22
import android.preference.PreferenceManager;
23 22
import android.util.DisplayMetrics;
24 23
import android.view.View;
25 24
import android.view.ViewGroup;
......
27 26
import android.widget.LinearLayout;
28 27

  
29 28
import androidx.appcompat.app.AppCompatActivity;
29
import androidx.preference.PreferenceManager;
30 30

  
31 31
import org.distorted.dialogs.RubikDialogError;
32 32
import org.distorted.external.RubikFiles;
......
42 42

  
43 43
public class BandagedCreatorActivity extends AppCompatActivity
44 44
{
45
    private static final int ACTIVITY_NUMBER = 3;
46
    private static final float RATIO_BAR   = 0.10f;
47
    private static final float RATIO_BUT   = 0.07f;
48
    static final float RATIO_SCROLL= 0.30f;
49

  
50
    public static final float SPINNER_TEXT_SIZE  = 0.03f;
51

  
52
    public static final int FLAGS =  View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
53
                                   | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
54
                                   | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
55
                                   | View.SYSTEM_UI_FLAG_FULLSCREEN
56
                                   | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
45
    private static final int ACTIVITY_NUMBER    = 3;
46
    private static final float RATIO_BAR        = 0.10f;
47
    private static final float RATIO_BUT        = 0.07f;
48
    static final float RATIO_SCROLL             = 0.30f;
49
    public static final float SPINNER_TEXT_SIZE = 0.03f;
50
    public static final int FLAGS               = RubikActivity.FLAGS;
57 51

  
58 52
    private static int mScreenWidth, mScreenHeight;
59 53
    private int mCurrentApiVersion;
src/main/java/org/distorted/bandaged/BandagedPlayActivity.java
12 12
import android.content.SharedPreferences;
13 13
import android.os.Build;
14 14
import android.os.Bundle;
15
import android.preference.PreferenceManager;
16 15
import android.util.DisplayMetrics;
17 16
import android.view.DisplayCutout;
18 17
import android.view.View;
......
21 20
import android.widget.LinearLayout;
22 21

  
23 22
import androidx.appcompat.app.AppCompatActivity;
23
import androidx.preference.PreferenceManager;
24 24

  
25 25
import org.distorted.dialogs.RubikDialogError;
26 26
import org.distorted.external.RubikFiles;
27 27
import org.distorted.library.main.DistortedLibrary;
28 28
import org.distorted.main.R;
29
import org.distorted.main.RubikActivity;
29 30
import org.distorted.objectlib.main.InitAssets;
30 31
import org.distorted.objectlib.main.ObjectControl;
31 32
import org.distorted.objectlib.main.TwistyObject;
......
37 38
public class BandagedPlayActivity extends AppCompatActivity
38 39
{
39 40
    private static final int ACTIVITY_NUMBER = 4;
40
    private static final float RATIO_BAR  = 0.10f;
41
    private static final float RATIO_INSET= 0.09f;
42

  
43
    public static final int FLAGS =  View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
44
                                   | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
45
                                   | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
46
                                   | View.SYSTEM_UI_FLAG_FULLSCREEN
47
                                   | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
41
    private static final float RATIO_BAR     = 0.10f;
42
    private static final float RATIO_INSET   = 0.09f;
43
    public static final int FLAGS            = RubikActivity.FLAGS;
48 44

  
49 45
    private static int mScreenWidth, mScreenHeight;
50 46
    private int mCurrentApiVersion;
......
277 273
      {
278 274
      return mScreen;
279 275
      }
280

  
281
///////////////////////////////////////////////////////////////////////////////////////////////////
282

  
283
    public boolean isVertical()
284
      {
285
      BandagedPlayView view = findViewById(R.id.bandagedPlayView);
286
      return view.isVertical();
287
      }
288 276
}
src/main/java/org/distorted/config/ConfigActivity.java
21 21
import androidx.appcompat.app.AppCompatActivity;
22 22

  
23 23
import org.distorted.library.main.DistortedLibrary;
24
import org.distorted.main.RubikActivity;
24 25
import org.distorted.objectlib.main.InitAssets;
25 26
import org.distorted.objectlib.main.ObjectControl;
26 27
import org.distorted.main.R;
......
35 36
{
36 37
    private static final int ACTIVITY_NUMBER = 2;
37 38
    private static final float RATIO_BAR  = 0.10f;
38

  
39
    public static final int FLAGS =  View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
40
                                   | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
41
                                   | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
42
                                   | View.SYSTEM_UI_FLAG_FULLSCREEN
43
                                   | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
39
    public static final int FLAGS = RubikActivity.FLAGS;
44 40

  
45 41
    private static int mScreenWidth, mScreenHeight;
46 42
    private int mCurrentApiVersion;
......
260 256
      ConfigSurfaceView view = findViewById(R.id.configSurfaceView);
261 257
      return view.getObjectControl();
262 258
      }
263

  
264
///////////////////////////////////////////////////////////////////////////////////////////////////
265

  
266
    public boolean isVertical()
267
      {
268
      ConfigSurfaceView view = findViewById(R.id.configSurfaceView);
269
      return view.isVertical();
270
      }
271 259
}
src/main/java/org/distorted/dialogs/RubikDialogPrivacy.java
34 34

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

  
41 41
///////////////////////////////////////////////////////////////////////////////////////////////////
42 42

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

  
49 49
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/dialogs/RubikDialogTutorialView.java
141 141
        {
142 142
        if( mCanClick )
143 143
          {
144
          act.switchTutorial(url,obj);
144
          act.switchToTutorial(url,obj);
145 145
          analyticsReport(act,desc,auth,obj);
146 146
          clickPossible(false);
147 147
          }
src/main/java/org/distorted/main/RubikActivity.java
18 18
import android.content.pm.PackageManager;
19 19
import android.os.Build;
20 20
import android.os.Bundle;
21
import android.preference.PreferenceManager;
22 21

  
23 22
import android.util.DisplayMetrics;
24 23
import android.view.DisplayCutout;
......
28 27
import android.widget.LinearLayout;
29 28

  
30 29
import androidx.appcompat.app.AppCompatActivity;
30
import androidx.preference.PreferenceManager;
31 31

  
32 32
import com.google.firebase.analytics.FirebaseAnalytics;
33 33
import com.google.firebase.inappmessaging.FirebaseInAppMessaging;
......
96 96
    private boolean mJustStarted;
97 97
    private FirebaseAnalytics mFirebaseAnalytics;
98 98
    private static int mScreenWidth, mScreenHeight;
99
    private boolean mPolicyAccepted;
100 99
    private int mCurrentApiVersion;
101 100
    private int mHeightUpperBar;
102 101
    private int mOldVersion1, mOldVersion2, mOldVersion3;
......
122 121
      mScreenWidth =displaymetrics.widthPixels;
123 122
      mScreenHeight=displaymetrics.heightPixels;
124 123

  
125

  
126 124
      cutoutHack();
127 125
      computeBarHeights();
128 126

  
......
193 191
      {
194 192
      super.onAttachedToWindow();
195 193

  
196
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
194
      if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.P )
197 195
        {
198 196
        DisplayCutout cutout = getWindow().getDecorView().getRootWindowInsets().getDisplayCutout();
199 197
        int insetHeight = cutout!=null ? cutout.getSafeInsetTop() : 0;
......
211 209

  
212 210
    private void cutoutHack()
213 211
      {
214
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
212
      if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.P )
215 213
        {
216 214
        getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
217 215
        }
......
224 222
      {
225 223
      super.onWindowFocusChanged(hasFocus);
226 224

  
227
      if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT && hasFocus)
225
      if( mCurrentApiVersion >= Build.VERSION_CODES.KITKAT && hasFocus )
228 226
        {
229 227
        getWindow().getDecorView().setSystemUiVisibility(FLAGS);
230 228
        }
......
270 268
      int object = RubikObjectList.getCurrObject();
271 269
      changeIfDifferent(object,view.getObjectControl());
272 270

  
273
      // switch this off - we are not present in China anymore.
274
      // if( mIsChinese && !mPolicyAccepted ) privacyPolicy();
275
      // else
276
        {
277
        if( !mOldVersion.equals(mCurrVersion) )
278
          {
279
          displayNovelties();
280
          }
281
        else
282
          {
283
          if( USE_IAP ) view.setShowStars();
284
          }
285
        }
271
      if( !mOldVersion.equals(mCurrVersion) ) displayNovelties();
272
      else if( USE_IAP ) view.setShowStars();
286 273
      }
287 274

  
288 275
///////////////////////////////////////////////////////////////////////////////////////////////////
......
327 314
      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
328 315
      SharedPreferences.Editor editor = preferences.edit();
329 316

  
330
      editor.putBoolean("policyAccepted", mPolicyAccepted);
331 317
      editor.putString("appVersion", mCurrVersion );
332 318
      editor.putInt("solverIndex", mSolverIndex );
333 319

  
334
      for (int i = 0; i< ScreenList.LENGTH; i++)
320
      for( int i=0; i< ScreenList.LENGTH; i++ )
335 321
        {
336 322
        ScreenList.getScreen(i).getScreenClass().savePreferences(editor);
337 323
        }
......
365 351

  
366 352
    private void restorePreferences(SharedPreferences preferences, boolean justStarted)
367 353
      {
368
      mPolicyAccepted = preferences.getBoolean("policyAccepted", false);
369 354
      mOldVersion = preferences.getString("appVersion","");
370 355
      mSolverIndex = preferences.getInt("solverIndex",0);
371 356

  
......
600 585

  
601 586
///////////////////////////////////////////////////////////////////////////////////////////////////
602 587

  
603
    public void acceptPrivacy()
604
      {
605
      mPolicyAccepted = true;
606
      }
607

  
608
///////////////////////////////////////////////////////////////////////////////////////////////////
609

  
610
    public void declinePrivacy()
611
      {
612
      finish();
613
      }
614

  
615
///////////////////////////////////////////////////////////////////////////////////////////////////
616

  
617
    public boolean isVertical()
618
      {
619
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
620
      return view.isVertical();
621
      }
622

  
623
///////////////////////////////////////////////////////////////////////////////////////////////////
624

  
625
    public void switchTutorial(String url, int objectOrdinal)
588
    public void switchToTutorial(String url, int objectOrdinal)
626 589
      {
627 590
      Intent intent = new Intent(this, TutorialActivity.class);
628 591
      intent.putExtra("url", url);
......
632 595

  
633 596
///////////////////////////////////////////////////////////////////////////////////////////////////
634 597

  
635
    public void switchConfig(int objectOrdinal)
598
    public void switchToConfig(int objectOrdinal)
636 599
      {
637 600
      Intent intent = new Intent(this, ConfigActivity.class);
638 601
      intent.putExtra("obj", objectOrdinal);
src/main/java/org/distorted/purchase/PurchaseActivity.java
12 12
import android.content.SharedPreferences;
13 13
import android.os.Build;
14 14
import android.os.Bundle;
15
import android.preference.PreferenceManager;
16 15
import android.util.DisplayMetrics;
17 16
import android.view.View;
18 17
import android.view.ViewGroup;
19 18
import android.view.WindowManager;
20 19

  
21 20
import androidx.appcompat.app.AppCompatActivity;
21
import androidx.preference.PreferenceManager;
22 22

  
23 23
import org.distorted.dialogs.RubikDialogError;
24 24
import org.distorted.external.RubikScores;
25 25
import org.distorted.library.main.DistortedLibrary;
26 26
import org.distorted.main.R;
27
import org.distorted.main.RubikActivity;
27 28
import org.distorted.objectlib.main.InitAssets;
28 29
import org.distorted.objectlib.main.ObjectControl;
29 30
import org.distorted.objectlib.main.TwistyObject;
......
40 41
    private static final float RATIO_UBAR = 0.14f;
41 42
    private static final float RATIO_LBAR = 0.10f;
42 43
    private static final float RATIO_VIEW = 0.50f;
43

  
44
    public static final int FLAGS =  View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
45
                                   | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
46
                                   | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
47
                                   | View.SYSTEM_UI_FLAG_FULLSCREEN
48
                                   | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
44
    public static final int FLAGS = RubikActivity.FLAGS;
49 45

  
50 46
    private static int mScreenWidth, mScreenHeight;
51 47
    private int mCurrentApiVersion;
src/main/java/org/distorted/screens/RubikScreenPlay.java
292 292
        {
293 293
        if( mObjectPopup!=null ) mObjectPopup.dismiss();
294 294
        int currObject = RubikObjectList.getCurrObject();
295
        act.switchConfig(currObject);
295
        act.switchToConfig(currObject);
296 296
        }
297 297
      });
298 298

  
src/main/java/org/distorted/tutorials/TutorialActivity.java
25 25

  
26 26
import org.distorted.library.main.DistortedLibrary;
27 27

  
28
import org.distorted.main.RubikActivity;
28 29
import org.distorted.objectlib.main.InitAssets;
29 30
import org.distorted.objectlib.main.ObjectControl;
30 31
import org.distorted.objectlib.main.TwistyObject;
......
43 44
public class TutorialActivity extends AppCompatActivity
44 45
{
45 46
    private static final String URL = "https://www.youtube.com/embed/";
46

  
47 47
    private static final int ACTIVITY_NUMBER = 1;
48 48
    public static final float BAR_RATIO = 0.17f;
49

  
50
    public static final int FLAGS =  View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
51
                                   | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
52
                                   | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
53
                                   | View.SYSTEM_UI_FLAG_FULLSCREEN
54
                                   | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
49
    public static final int FLAGS = RubikActivity.FLAGS;
55 50

  
56 51
    private static int mScreenWidth, mScreenHeight;
57 52
    private int mCurrentApiVersion;
......
279 274
      intent.putExtra("obj", mObjectOrdinal);
280 275
      startActivity(intent);
281 276
      }
282

  
283
///////////////////////////////////////////////////////////////////////////////////////////////////
284

  
285
    public boolean isVertical()
286
      {
287
      TutorialSurfaceView view = findViewById(R.id.tutorialSurfaceView);
288
      return view.isVertical();
289
      }
290 277
}

Also available in: Unified diff