Skip to content

Commit

Permalink
Adaptive Icon added
Browse files Browse the repository at this point in the history
Layout changed to constraint layout and added landscape variant
  • Loading branch information
Kamuno committed Jun 4, 2020
1 parent 22e6675 commit 6a4264c
Show file tree
Hide file tree
Showing 19 changed files with 542 additions and 124 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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'
}
34 changes: 15 additions & 19 deletions app/src/main/java/org/secuso/privacyfriendlydicer/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -120,6 +121,7 @@ public void onShake(int count) {
});

displaySum(new int[]{0});
initResultDiceViews();
}

public void flashResult(ImageView imageView) {
Expand Down Expand Up @@ -152,7 +154,6 @@ public void initResultDiceViews() {
}

public void switchDice(ImageView imageView, int result) {

switch (result) {
case 1:
imageView.setImageResource(R.drawable.d1);
Expand Down Expand Up @@ -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) {
Expand Down
60 changes: 60 additions & 0 deletions app/src/main/res/drawable/ic_launcher_foreground_shadow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="512dp"
android:height="512dp"
android:viewportWidth="512"
android:viewportHeight="512">
<path
android:pathData="M511.35,470.91V258.66l-96.72,-96.72 -161.2,-80.6 -161.2,80.6V350l161.2,161.21H471.05A40.42,40.42 0,0 0,511.35 470.91Z">
<aapt:attr name="android:fillColor">
<gradient
android:startY="157.61"
android:startX="217.08"
android:endY="578.88"
android:endX="460.3"
android:type="linear">
<item android:offset="0" android:color="#FF004492"/>
<item android:offset="0.22" android:color="#F9004593"/>
<item android:offset="0.39" android:color="#E8024894"/>
<item android:offset="0.55" android:color="#C9044E97"/>
<item android:offset="0.7" android:color="#A007569B"/>
<item android:offset="0.84" android:color="#6B0A60A0"/>
<item android:offset="0.97" android:color="#280F6CA6"/>
<item android:offset="1" android:color="#19106FA8"/>
</gradient>
</aapt:attr>
</path>
<path
android:pathData="M253.78,242.75l0,188.07l161.21,-80.6l0,-167.57l0,-20.5l-161.21,80.6z"
android:strokeAlpha="0.6"
android:fillColor="#add7d3"
android:fillAlpha="0.6"/>
<path
android:pathData="M92.58,162.15l0,188.07l161.2,80.6l0,-188.07l-161.2,-80.6z"
android:fillColor="#1f4063"/>
<path
android:pathData="M92.58,162.15l161.2,-80.6l161.21,80.6l-161.21,80.6l-161.2,-80.6z"
android:fillColor="#fff"/>
<path
android:pathData="M200.05,350.22l26.87,13.43l0,26.87l-26.87,-13.43l0,-26.87z"
android:strokeAlpha="0.6"
android:fillColor="#add7d3"
android:fillAlpha="0.6"/>
<path
android:pathData="M119.45,202.45l26.87,13.43l0,26.87l-26.87,-13.43l0,-26.87z"
android:strokeAlpha="0.6"
android:fillColor="#add7d3"
android:fillAlpha="0.6"/>
<path
android:pathData="M388.12,202.45l-26.87,13.43l0,26.87l26.87,-13.43l0,-26.87z"
android:fillColor="#1f4063"/>
<path
android:pathData="M347.82,269.62l-26.87,13.43l0,26.87l26.87,-13.43l0,-26.87z"
android:fillColor="#1f4063"/>
<path
android:pathData="M307.52,350.22l-26.87,13.43l0,26.87l26.87,-13.43l0,-26.87z"
android:fillColor="#1f4063"/>
<path
android:pathData="M253.78,175.59l-26.86,-13.44l26.86,-13.43l26.87,13.43l-26.87,13.44z"
android:fillColor="#1f4063"/>
</vector>
Loading

0 comments on commit 6a4264c

Please sign in to comment.