diff --git a/app/build.gradle b/app/build.gradle index dbf911e..a96291f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "org.secuso.privacyfriendlydicer" minSdkVersion 16 targetSdkVersion 28 - versionCode 6 - versionName "1.4.1" + versionCode 7 + versionName "1.5.0" } buildTypes { @@ -28,4 +28,5 @@ dependencies { testImplementation 'junit:junit:4.12' implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:design:28.0.0' + implementation 'com.android.support.constraint:constraint-layout:1.1.3' } diff --git a/app/src/main/java/org/secuso/privacyfriendlydicer/MainActivity.java b/app/src/main/java/org/secuso/privacyfriendlydicer/MainActivity.java index c6b1e18..124b1f4 100644 --- a/app/src/main/java/org/secuso/privacyfriendlydicer/MainActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlydicer/MainActivity.java @@ -5,6 +5,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; +import android.graphics.Point; import android.hardware.Sensor; import android.hardware.SensorManager; import android.os.Bundle; @@ -26,20 +27,20 @@ import android.widget.SeekBar; import android.widget.TextView; -public class MainActivity extends AppCompatActivity - implements NavigationView.OnNavigationItemSelectedListener { +public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { + + private static Dicer dicer = new Dicer(); private ImageView[] imageViews; - boolean shakingEnabled; - boolean vibrationEnabled; - SharedPreferences sharedPreferences; + private boolean shakingEnabled; + private boolean vibrationEnabled; + private SharedPreferences sharedPreferences; // for Shaking private SensorManager sensorManager; private Sensor accelerometer; private ShakeListener shakeListener; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -120,6 +121,7 @@ public void onShake(int count) { }); displaySum(new int[]{0}); + initResultDiceViews(); } public void flashResult(ImageView imageView) { @@ -152,7 +154,6 @@ public void initResultDiceViews() { } public void switchDice(ImageView imageView, int result) { - switch (result) { case 1: imageView.setImageResource(R.drawable.d1); @@ -203,27 +204,22 @@ public void evaluate(Vibrator vibrator, int diceNumber, int faceNumber) { applySettings(); - Dicer dicer = new Dicer(); int[] dice = dicer.rollDice(diceNumber, faceNumber); + displaySum(dice); initResultDiceViews(); + showDice(dice); - Display display = getWindowManager().getDefaultDisplay(); + if (vibrationEnabled) { + vibrator.vibrate(50); + } + } + private void showDice(int[] dice) { for (int i = 0; i < dice.length; i++) { switchDice(imageViews[i], dice[i]); - android.view.ViewGroup.LayoutParams layoutParams = imageViews[i].getLayoutParams(); - layoutParams.width = display.getWidth() / 6; - layoutParams.height = display.getWidth() / 6; - - imageViews[i].setLayoutParams(layoutParams); flashResult(imageViews[i]); - if (vibrationEnabled) { - vibrator.vibrate(50); - } - } - } private void displaySum(int[] dice) { diff --git a/app/src/main/res/drawable/ic_launcher_foreground_shadow.xml b/app/src/main/res/drawable/ic_launcher_foreground_shadow.xml new file mode 100644 index 0000000..a44d4d2 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground_shadow.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout-land/content_main.xml b/app/src/main/res/layout-land/content_main.xml new file mode 100644 index 0000000..531ec97 --- /dev/null +++ b/app/src/main/res/layout-land/content_main.xml @@ -0,0 +1,278 @@ + + + + + + + + + + + + + + + +