From c3a177383779a825ac9ce6f0497ff2a2f46b1592 Mon Sep 17 00:00:00 2001 From: Ruben Date: Fri, 19 Aug 2016 19:56:58 +0100 Subject: [PATCH] More prominent final score --- .../rubenvandeven/emotionhero/GamingActivity.java | 2 +- .../rubenvandeven/emotionhero/ScenarioView.java | 15 ++++++++++++++- app/src/main/res/layout/activity_gaming.xml | 7 ++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/rubenvandeven/emotionhero/GamingActivity.java b/app/src/main/java/com/rubenvandeven/emotionhero/GamingActivity.java index 44a14bb..8cca7c3 100644 --- a/app/src/main/java/com/rubenvandeven/emotionhero/GamingActivity.java +++ b/app/src/main/java/com/rubenvandeven/emotionhero/GamingActivity.java @@ -206,7 +206,7 @@ public class GamingActivity extends AppCompatActivity implements Detector.ImageL // if(!currentScenario.isWithinTime(timestamp)) if(currentScenario.isFinished()) { - setText(String.format("LEVEL ENDED\nScore: %.2f", currentScenario.getTotalScore())); + setText("LEVEL ENDED"); stopDetector(); restartButton.setVisibility(View.VISIBLE); return; diff --git a/app/src/main/java/com/rubenvandeven/emotionhero/ScenarioView.java b/app/src/main/java/com/rubenvandeven/emotionhero/ScenarioView.java index e0d9ff6..a5f95ce 100644 --- a/app/src/main/java/com/rubenvandeven/emotionhero/ScenarioView.java +++ b/app/src/main/java/com/rubenvandeven/emotionhero/ScenarioView.java @@ -40,6 +40,7 @@ public class ScenarioView extends SurfaceView implements SurfaceHolder.Callback private Paint attrScorePaint = new Paint(); private Paint linePaint = new Paint(); private Paint scorePaint = new Paint(); + private Paint scoreFinishedPaint = new Paint(); // see: http://blog.danielnadeau.io/2012/01/android-canvas-beginners-tutorial.html class PanelThread extends Thread { @@ -90,6 +91,11 @@ public class ScenarioView extends SurfaceView implements SurfaceHolder.Callback scorePaint.setTextSize(50); scorePaint.setTypeface(Typeface.DEFAULT_BOLD); + scoreFinishedPaint.setColor(Color.YELLOW); + scoreFinishedPaint.setTextSize(100); + scoreFinishedPaint.setTypeface(Typeface.DEFAULT_BOLD); + + //setup paints for drawing mainPaint.setColor(Color.GRAY); @@ -206,7 +212,14 @@ public class ScenarioView extends SurfaceView implements SurfaceHolder.Callback // canvas.drawText(target_text, cx, y_pos + diff_y , emoPaint); } - canvas.drawText("Total: " + Float.toString(_scenario.getTotalScore()), 50, 50, scorePaint); + // draw the score middle bottom; + Paint usedScorePaint = _scenario.isFinished() ? scoreFinishedPaint : scorePaint; + String scoreText = String.format("Total: %1$.0f", _scenario.getTotalScore()); + Rect scoreTextBounds = new Rect(); + usedScorePaint.getTextBounds(scoreText, 0, scoreText.length(), scoreTextBounds); + + canvas.drawText(scoreText, (width - scoreTextBounds.width()) / 2, height - 10, usedScorePaint); + } diff --git a/app/src/main/res/layout/activity_gaming.xml b/app/src/main/res/layout/activity_gaming.xml index 4c97447..a96c9b6 100644 --- a/app/src/main/res/layout/activity_gaming.xml +++ b/app/src/main/res/layout/activity_gaming.xml @@ -26,7 +26,12 @@ android:text="@string/dummy_content" android:textColor="#ffffff" android:textSize="50sp" - android:textStyle="bold" /> + android:textStyle="bold" + android:paddingBottom="100dp" + android:shadowColor="@android:color/black" + android:shadowDx="0" + android:shadowDy="0" + android:shadowRadius="20" />