From 958780b57eeeeb38d5432472257f4bdded6cb956 Mon Sep 17 00:00:00 2001 From: Ruben Date: Thu, 22 Sep 2016 00:24:03 +0100 Subject: [PATCH] Ad wrinkle achievement and layout fixes --- .idea/misc.xml | 2 +- app/build.gradle | 4 +- app/src/main/AndroidManifest.xml | 2 +- .../emotionhero/AchievementCollection.java | 41 +++++++---- .../emotionhero/EndingActivity.java | 2 +- .../emotionhero/HighscoreActivity.java | 68 ++++++++++++++++--- .../ReviewAchievementsActivity.java | 2 +- .../emotionhero/ReviewActivity.java | 15 +++- .../rubenvandeven/emotionhero/Scenario.java | 31 +++++---- app/src/main/res/layout/activity_ending.xml | 6 +- .../main/res/layout/activity_highscore.xml | 3 +- app/src/main/res/layout/activity_review.xml | 14 ++-- .../layout/activity_review_achievements.xml | 1 - .../main/res/layout/fragment_highscore.xml | 13 ++-- app/src/main/res/values/strings.xml | 4 +- app/src/main/res/values/styles.xml | 14 ++++ 16 files changed, 159 insertions(+), 63 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index bd04605..1b77328 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -37,7 +37,7 @@ - + diff --git a/app/build.gradle b/app/build.gradle index 26242b9..db3e5b0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId 'com.rubenvandeven.emotion_hero' minSdkVersion 16 targetSdkVersion 24 - versionCode 6 - versionName '0.5' + versionCode 7 + versionName '0.9' testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" renderscriptTargetApi 16 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 15b9c63..461073b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -54,7 +54,7 @@ + android:theme="@style/AchievementTheme"> diff --git a/app/src/main/java/com/rubenvandeven/emotionhero/AchievementCollection.java b/app/src/main/java/com/rubenvandeven/emotionhero/AchievementCollection.java index b576ace..a367b29 100644 --- a/app/src/main/java/com/rubenvandeven/emotionhero/AchievementCollection.java +++ b/app/src/main/java/com/rubenvandeven/emotionhero/AchievementCollection.java @@ -331,13 +331,14 @@ public class AchievementCollection { public void setDescription(Player player, Game game, LinearLayout descriptionLayout) { Context c = descriptionLayout.getContext(); AppCompatTextView textView = new AppCompatTextView(c); - textView.setText("..."); + textView.setText("\"Emotion work is understood as the art of trying to change in degree or quality an emotion or feeling. "+ + "It may be defined as the management of one's own feelings or as work done in a conscious effort to maintain the well being of a relationship;\" (Wikipedia)"); descriptionLayout.addView(textView); } }) ); add(new Achievement( - "Emotion work: evocation", + "Emotional labour: evocation", null, new Achievement.AchievementListener() { @Override @@ -364,18 +365,30 @@ public class AchievementCollection { public void setDescription(Player player, Game game, LinearLayout descriptionLayout) { Context c = descriptionLayout.getContext(); AppCompatTextView textView = new AppCompatTextView(c); - textView.setText("..."); + textView.setText("\"Emotional labor is the process of managing feelings and expressions in order to fulfill emotional requirements as part of the job role.[1][2] More specifically, workers are expected to regulate their emotions during interactions with customers, co-workers and superiors. This includes analysis and decision making in terms of the expression of emotion, whether actually felt or not, as well as its opposite: the suppression of emotions that are felt but not expressed.\" (Wikipedia)"); descriptionLayout.addView(textView); } }) ); add(new Achievement( - "The game's on you", // ??(mixed feelings/complex emotions) + "Wrinkle alarm",//"The game's on you", // ??(mixed feelings/complex emotions) null, new Achievement.AchievementListener() { @Override public boolean hasGotAchievement(Player player, Game game) { - // ???? + // lots of joy + float requiredJoy = 0; + float hasJoy = 0; + for(Hit hit: game.hits.values()) { + if(hit.target.emotion == Emotion.JOY) { + requiredJoy += hit.target.value; + } + hasJoy += hit.emotions.get(Emotion.JOY); + } + + if(hasJoy >= requiredJoy * 2) { + return true; + } return false; } @@ -383,7 +396,7 @@ public class AchievementCollection { public void setDescription(Player player, Game game, LinearLayout descriptionLayout) { Context c = descriptionLayout.getContext(); AppCompatTextView textView = new AppCompatTextView(c); - textView.setText("..."); + textView.setText("Besides tracking only points in the face, the intensity of wrinkles next to the eyes provides a clue as to how much someone is smiling."); descriptionLayout.addView(textView); } }) @@ -424,7 +437,7 @@ public class AchievementCollection { boolean missedATarget = false; // Add Kuleshov's target... person managers to do it for(int target_id: game.scenario.kuleshovTargetIds) { - if(game.hits.get(target_id).bonus < 5) { // needs at least a little bonus on all + if(game.hits.get(target_id).bonus < 1) { // needs at least a little bonus on all missedATarget = true; } } @@ -473,12 +486,16 @@ public class AchievementCollection { public boolean hasGotAchievement(Player player, Game game) { // on average an overexecaration?? int niceOnes = 0; + int applicableHits = 0; for(Hit hit: game.hits.values()) { - if(hit.score >= 80) { - niceOnes ++; + if(hit.target.value > 75) { + applicableHits++; + if(hit.score >= 80) { + niceOnes ++; + } } } - if(niceOnes >= game.hits.size() * 0.8) { + if(niceOnes >= applicableHits * 0.8) { return true; } return false; @@ -488,8 +505,8 @@ public class AchievementCollection { public void setDescription(Player player, Game game, LinearLayout descriptionLayout) { Context c = descriptionLayout.getContext(); AppCompatTextView textView = new AppCompatTextView(c); - textView.setText("You are remarkably good at posing, just like this guy:"); - // TODO: ad MS image + textView.setText("You are remarkably good at posing for the requested emotion!"); + // TODO: ad MS image "just like this guy" descriptionLayout.addView(textView); } }) diff --git a/app/src/main/java/com/rubenvandeven/emotionhero/EndingActivity.java b/app/src/main/java/com/rubenvandeven/emotionhero/EndingActivity.java index 5c8e150..99b5fa6 100644 --- a/app/src/main/java/com/rubenvandeven/emotionhero/EndingActivity.java +++ b/app/src/main/java/com/rubenvandeven/emotionhero/EndingActivity.java @@ -79,7 +79,7 @@ public class EndingActivity extends AppCompatActivity { if(rank == 1) { textSuccess.setVisibility(View.VISIBLE); - logoEmotionHero.setVisibility(View.VISIBLE); +// logoEmotionHero.setVisibility(View.VISIBLE); } else { textFailure.setVisibility(View.VISIBLE); } diff --git a/app/src/main/java/com/rubenvandeven/emotionhero/HighscoreActivity.java b/app/src/main/java/com/rubenvandeven/emotionhero/HighscoreActivity.java index f896c00..5820a01 100644 --- a/app/src/main/java/com/rubenvandeven/emotionhero/HighscoreActivity.java +++ b/app/src/main/java/com/rubenvandeven/emotionhero/HighscoreActivity.java @@ -2,6 +2,7 @@ package com.rubenvandeven.emotionhero; import android.app.ProgressDialog; import android.content.Intent; +import android.graphics.Color; import android.graphics.Typeface; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; @@ -15,7 +16,9 @@ import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.os.Bundle; +import android.text.Layout; import android.util.Log; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; @@ -32,6 +35,8 @@ import org.ocpsoft.prettytime.PrettyTime; import java.util.UUID; +import static android.view.View.TEXT_ALIGNMENT_TEXT_END; + public class HighscoreActivity extends AppCompatActivity { @@ -201,7 +206,10 @@ public class HighscoreActivity extends AppCompatActivity { TextView levelName = (TextView) rootView.findViewById(R.id.levelName); - levelName.setText("\""+scenario.toString()+"\""); + levelName.setText(scenario.toString()); + Typeface font = Typeface.createFromAsset(getContext().getAssets(), "unifont-9.0.02.ttf"); + levelName.setTypeface(font); + startLvlButton.setTypeface(font); LinearLayout topscoreList = (LinearLayout) rootView.findViewById(R.id.topscoreList); @@ -223,11 +231,26 @@ public class HighscoreActivity extends AppCompatActivity { for(Game game: games) { final long itemGameId = game.id; i++; - String highscoreText = String.format("%1$d. %2$.4f", i, game.score+game.bonus); //make line by line elements + String highscoreScoreText = String.format("%1$.2f", game.score+game.bonus); //make line by line elements + String highscorePositionText = String.format("%1$d.", i); //make line by line elements + LinearLayout scoreLayout = new LinearLayout(getContext()); + scoreLayout.setOrientation(LinearLayout.HORIZONTAL); + TextView scoreItem = new TextView(getContext()); - scoreItem.setText(highscoreText); - scoreItem.setTextColor(ContextCompat.getColor(getContext(), R.color.highscore)); - scoreItem.setOnClickListener(new View.OnClickListener() { + TextView scorePos = new TextView(getContext()); + + scoreItem.setGravity(Gravity.RIGHT); + scoreItem.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); + scoreItem.setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL)); + + scoreItem.setText(highscoreScoreText ); + scorePos.setText(highscorePositionText); + +// scoreItem.setTextColor(ContextCompat.getColor(getContext(), R.color.highscore)); + scoreItem.setTextColor(ContextCompat.getColor(getContext(), R.color.textPrimary)); + scorePos.setTextColor(ContextCompat.getColor(getContext(), R.color.textHighlight)); + + scoreLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getContext(), ReviewActivity.class); @@ -239,17 +262,39 @@ public class HighscoreActivity extends AppCompatActivity { float multiplier = i <= 5 ? 1 + (5-i)/5f : 1f; scoreItem.setTextSize(getResources().getDimension(R.dimen.highscore_textsize) * multiplier); - scoreItem.setTypeface(Typeface.DEFAULT_BOLD); - topscoreList.addView(scoreItem); + scorePos.setTextSize(getResources().getDimension(R.dimen.highscore_textsize) * multiplier); + + scoreLayout.addView(scorePos); + scoreLayout.addView(scoreItem); + + topscoreList.addView(scoreLayout); + + + + LinearLayout detailLayout = new LinearLayout(getContext()); + detailLayout.setOrientation(LinearLayout.HORIZONTAL); + LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); + llp.setMargins(0, -20, 0, 0); // llp.setMargins(left, top, right, bottom); + detailLayout.setLayoutParams(llp); TextView dateItem = new TextView(getContext()); dateItem.setText(prettyTime.format(game.time)); dateItem.setTextColor(ContextCompat.getColor(getContext(), R.color.textSecondary)); - LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); - llp.setMargins(0, -20, 0, 0); // llp.setMargins(left, top, right, bottom); - dateItem.setLayoutParams(llp); dateItem.setTypeface(Typeface.DEFAULT); - topscoreList.addView(dateItem); + + TextView achievementText = new TextView(getContext()); + achievementText.setText(String.format("+%1$d achievements", game.achievements.size())); + achievementText.setTextColor(getResources().getColor(R.color.textPrimary)); + achievementText.setGravity(Gravity.RIGHT); + achievementText.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); + + + detailLayout.addView(dateItem); + detailLayout.addView(achievementText); + + topscoreList.addView(detailLayout); + + if(currentGame != null && currentGame.id == game.id) { foundScore = true; @@ -273,6 +318,7 @@ public class HighscoreActivity extends AppCompatActivity { if(player.getPlayerInfo().hasAccessToLevel(lvl_id)) { + if(currentGame != null) { // if we come from the level itself.. show retry! startLvlButton.setText("Retry"); } diff --git a/app/src/main/java/com/rubenvandeven/emotionhero/ReviewAchievementsActivity.java b/app/src/main/java/com/rubenvandeven/emotionhero/ReviewAchievementsActivity.java index b10978d..9b6546f 100644 --- a/app/src/main/java/com/rubenvandeven/emotionhero/ReviewAchievementsActivity.java +++ b/app/src/main/java/com/rubenvandeven/emotionhero/ReviewAchievementsActivity.java @@ -81,7 +81,7 @@ public class ReviewAchievementsActivity extends AppCompatActivity { titleText.setText(achievement.title); // titleText.setText("mwa"); - titleText.setTextColor(getResources().getColor(R.color.textHighlight)); + titleText.setTextColor(getResources().getColor(R.color.colorPrimary)); titleText.setTextSize(getResources().getDimensionPixelSize(R.dimen.highscore_textsize)); titleText.setLayoutParams(params); diff --git a/app/src/main/java/com/rubenvandeven/emotionhero/ReviewActivity.java b/app/src/main/java/com/rubenvandeven/emotionhero/ReviewActivity.java index e8617e6..f2add68 100644 --- a/app/src/main/java/com/rubenvandeven/emotionhero/ReviewActivity.java +++ b/app/src/main/java/com/rubenvandeven/emotionhero/ReviewActivity.java @@ -172,21 +172,30 @@ public class ReviewActivity extends AppCompatActivity { nextLvlText.setVisibility(View.GONE); nextLvlLayout.setVisibility(View.GONE); + TextView improveTitle= (TextView) findViewById(R.id.improveTitle); + TextView retryTitle = (TextView) findViewById(R.id.retryTitle ); + TextView nextLvlTitle = (TextView) findViewById(R.id.nextLvlTitle); + checkAchievements(); Typeface font = Typeface.createFromAsset(getAssets(), "unifont-9.0.02.ttf"); lvlNameText.setTypeface(font); overallScorePercText.setTypeface(font); achievementArrow.setTypeface(font); - achievementText.setTypeface(font); +// achievementText.setTypeface(font); retryArrow.setTypeface(font); // improveArrow.setTypeface(font); nextLvlArrow.setTypeface(font); + achievementTitle.setTypeface(font); + improveTitle.setTypeface(font); + retryTitle.setTypeface(font); + nextLvlTitle.setTypeface(font); - lvlNameText.setText("\""+game.scenario.toString()+"\""); + + lvlNameText.setText(game.scenario.toString()); PrettyTime p = new PrettyTime(); dateText.setText(p.format(game.time)); - scoreText.setText(String.format("%1$.4f", game.score+game.bonus)); + scoreText.setText(String.format("%1$.2f", game.score+game.bonus)); // overallScorePercText.setText(String.format("%1$.0f%%", 30f)); loadRemoteInfo.run(); diff --git a/app/src/main/java/com/rubenvandeven/emotionhero/Scenario.java b/app/src/main/java/com/rubenvandeven/emotionhero/Scenario.java index bf03ece..052af94 100644 --- a/app/src/main/java/com/rubenvandeven/emotionhero/Scenario.java +++ b/app/src/main/java/com/rubenvandeven/emotionhero/Scenario.java @@ -684,10 +684,10 @@ public class Scenario { setMinimumScoreFromPercentage(40); minimumAchievements = 2; - achievements.add(achievementCollection.get(8)); - achievements.add(achievementCollection.get(9)); - achievements.add(achievementCollection.get(10)); achievements.add(achievementCollection.get(11)); + achievements.add(achievementCollection.get(12)); + achievements.add(achievementCollection.get(13)); + achievements.add(achievementCollection.get(14)); break; case LVL_ACTNORMAL: @@ -733,20 +733,21 @@ public class Scenario { setTarget(Emotion.CONTEMPT, 10, a); setTarget(Emotion.SURPRISE, 10, a); - setTarget(Emotion.DISGUST, 5, a++); - setTarget(Emotion.CONTEMPT, 5, a); - setTarget(Emotion.SURPRISE, 5, a); + setTarget(Emotion.DISGUST, 10, a++); + setTarget(Emotion.CONTEMPT, 10, a); + setTarget(Emotion.SURPRISE, 10, a); // Kuleshov's target: kuleshovTargetIds = new int[3]; - kuleshovTargetIds[0] = setTarget(Emotion.DISGUST, 1, a++); - kuleshovTargetIds[1] = setTarget(Emotion.CONTEMPT, 1, a); - kuleshovTargetIds[2] = setTarget(Emotion.SURPRISE, 1, a); + // use 3% instead of 0.2% as it otherwise becomes invisible! + kuleshovTargetIds[0] = setTarget(Emotion.DISGUST, 3, a++); + kuleshovTargetIds[1] = setTarget(Emotion.CONTEMPT, 3, a); + kuleshovTargetIds[2] = setTarget(Emotion.SURPRISE, 3, a); // END OF KULESHOV - setTarget(Emotion.DISGUST, 1, a++); - setTarget(Emotion.CONTEMPT, 1, a); - setTarget(Emotion.SURPRISE, 1, a); + setTarget(Emotion.DISGUST, 3, a++); + setTarget(Emotion.CONTEMPT, 3, a); + setTarget(Emotion.SURPRISE, 3, a); setTarget(Emotion.ANGER, 1, a++); @@ -759,9 +760,9 @@ public class Scenario { setMinimumScoreFromPercentage(40); minimumAchievements = 2; - achievements.add(achievementCollection.get(12)); - achievements.add(achievementCollection.get(13)); - achievements.add(achievementCollection.get(14)); + achievements.add(achievementCollection.get(15)); + achievements.add(achievementCollection.get(16)); + achievements.add(achievementCollection.get(17)); break; } diff --git a/app/src/main/res/layout/activity_ending.xml b/app/src/main/res/layout/activity_ending.xml index e23f155..ffacf24 100644 --- a/app/src/main/res/layout/activity_ending.xml +++ b/app/src/main/res/layout/activity_ending.xml @@ -56,8 +56,9 @@ android:textSize="30sp" android:textColor="@color/textPrimary" /> + + + app:popupTheme="@style/AppTheme.PopupOverlay" + app:titleTextColor="@color/textHighlight"> diff --git a/app/src/main/res/layout/activity_review.xml b/app/src/main/res/layout/activity_review.xml index 351da35..c4f5edd 100644 --- a/app/src/main/res/layout/activity_review.xml +++ b/app/src/main/res/layout/activity_review.xml @@ -89,13 +89,12 @@ android:layout_alignLeft="@+id/dateText" android:layout_alignStart="@+id/dateText" android:layout_marginTop="40dp" - android:layout_toStartOf="@+id/scoreText" - android:layout_width="wrap_content" + android:layout_width="100dp" android:layout_alignBottom="@+id/scoreText" android:layout_marginLeft="0dp" android:layout_marginBottom="-10dp" - android:layout_alignRight="@+id/dateText" - android:layout_alignEnd="@+id/dateText" /> + android:adjustViewBounds="false" + android:cropToPadding="true" /> @@ -170,7 +170,7 @@ android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:id="@+id/achievementArrow" - android:textColor="@color/textPrimary" + android:textColor="@color/textSecondary" android:textSize="36sp" android:layout_centerInParent="true" /> diff --git a/app/src/main/res/layout/activity_review_achievements.xml b/app/src/main/res/layout/activity_review_achievements.xml index 41212a2..ea457a6 100644 --- a/app/src/main/res/layout/activity_review_achievements.xml +++ b/app/src/main/res/layout/activity_review_achievements.xml @@ -20,7 +20,6 @@ android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" - android:background="?attr/colorPrimary" app:layout_scrollFlags="scroll|enterAlways" app:popupTheme="@style/AppTheme.PopupOverlay" app:titleTextColor="@color/textHighlight"> diff --git a/app/src/main/res/layout/fragment_highscore.xml b/app/src/main/res/layout/fragment_highscore.xml index 21c50b1..0212dc1 100644 --- a/app/src/main/res/layout/fragment_highscore.xml +++ b/app/src/main/res/layout/fragment_highscore.xml @@ -33,9 +33,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/levelName" - android:textSize="15sp" - android:textColor="@color/highscore" - android:textStyle="normal|bold" /> + android:textSize="24sp" + android:textColor="@color/textPrimary" + android:textStyle="normal" + android:fontFamily="monospace" + tools:text=""Please don't cry"" /> @@ -55,7 +57,10 @@ android:layout_height="wrap_content" android:text="Start" android:id="@+id/startLvlButton" - android:layout_weight="1"/> + android:layout_weight="1" + android:fontFamily="monospace" + android:textSize="24sp" + android:textColor="@color/textHighlight" />