diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9a49e5b..7e5196f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -24,6 +24,7 @@ @@ -35,6 +36,8 @@ @@ -49,6 +52,8 @@ - + 0) { - TextView achievementText = new TextView(this); - achievementText.setText(String.format("+%1$d achievements", playerAchievementCount)); - achievementText.setTextColor(getResources().getColor(R.color.textSecondary)); - RelativeLayout.LayoutParams achievementTextParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - achievementTextParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE); - achievementTextParams.addRule(RelativeLayout.BELOW, scoreText.getId()); - achievementText.setLayoutParams(achievementTextParams); - lvlLayout.addView(achievementText); - } + lvlLayout.addView(scoreText); - if(hasAccess) { - lvlLayout.setOnClickListener(new View.OnClickListener() { + View.OnClickListener toHighScoreClick = new View.OnClickListener() { @Override public void onClick(View v) { Intent intent; - // TODO: is this behaviour confusing? - if(highscoreGame != null) { - // Clicking score -> highscores - intent = new Intent(ProgressActivity.this, HighscoreActivity.class); - intent.putExtra(HighscoreActivity.INTENT_EXTRA_LVL_ID, scenario.id); - } else { - // "PLAY NOW!" - showLoadingDialog(); - intent = new Intent(ProgressActivity.this, GamingActivity.class); - intent.putExtra(GamingActivity.INTENT_EXTRA_SCENARIO, scenario.id); - } + // Clicking score -> highscores + intent = new Intent(ProgressActivity.this, HighscoreActivity.class); + intent.putExtra(HighscoreActivity.INTENT_EXTRA_LVL_ID, scenario.id); + startActivity(intent); + } + }; + + scoreText.setOnClickListener(toHighScoreClick); + + // +3 achievements + if(playerAchievementCount > 0) { + TextView achievementText = new TextView(this); + achievementText.setText(String.format("+%1$d achievements", playerAchievementCount)); + achievementText.setTextColor(getResources().getColor(R.color.textSecondary)); + RelativeLayout.LayoutParams achievementTextParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + achievementTextParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); + achievementTextParams.addRule(RelativeLayout.BELOW, scoreText.getId()); + achievementText.setLayoutParams(achievementTextParams); + achievementText.setOnClickListener(toHighScoreClick); + + lvlLayout.addView(achievementText); + } + } + + if(hasAccess) { + playText.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent; + // "PLAY NOW!" + showLoadingDialog(); + intent = new Intent(ProgressActivity.this, GamingActivity.class); + intent.putExtra(GamingActivity.INTENT_EXTRA_SCENARIO, scenario.id); startActivity(intent); } }); } - levelsLayout.addView(lvlLayout); si++; diff --git a/app/src/main/res/layout/fragment_highscore.xml b/app/src/main/res/layout/fragment_highscore.xml index 0212dc1..33c406b 100644 --- a/app/src/main/res/layout/fragment_highscore.xml +++ b/app/src/main/res/layout/fragment_highscore.xml @@ -55,7 +55,7 @@