Skip to content

Commit 01eed0f

Browse files
committed
MainActivity building
1 parent 242bab2 commit 01eed0f

File tree

4 files changed

+44
-91
lines changed

4 files changed

+44
-91
lines changed

.gitignore

+33-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
1-
.gradle
2-
/local.properties
3-
/.idea/workspace.xml
4-
/.idea/libraries
5-
.DS_Store
6-
/build
7-
/captures
8-
sh.exe.stackdump
9-
Blacksmith/Blacksmith.iml
10-
BaseGameUtils/BaseGameUtils.iml
11-
.idea/misc.xml
12-
Blacksmith.iml
13-
Blacksmith/Blacksmith-Blacksmith.iml
14-
.idea/modules.xml
1+
# Gradle files
2+
.gradle/
3+
build/
4+
5+
# Local configuration file (sdk path, etc)
6+
local.properties
7+
8+
# Log/OS Files
9+
*.log
10+
11+
# Android Studio generated files and folders
12+
captures/
13+
.externalNativeBuild/
14+
.cxx/
15+
*.apk
16+
output.json
17+
18+
# IntelliJ
19+
*.iml
20+
.idea/
21+
misc.xml
22+
deploymentTargetDropDown.xml
23+
render.experimental.xml
24+
25+
# Keystore files
26+
*.jks
27+
*.keystore
28+
29+
# Google Services (e.g. APIs or Firebase)
30+
google-services.json
31+
32+
# Android Profiling
33+
*.hprof

Blacksmith/build.gradle

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ android {
2222
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.pro'
2323
}
2424
}
25+
buildFeatures {
26+
buildConfig true
27+
}
2528
}
2629

2730
repositories {
@@ -39,6 +42,8 @@ dependencies {
3942
implementation "com.android.support:percent:$supportLibraryVersion"
4043
implementation "com.google.android.gms:play-services-ads:$playLibraryVersion"
4144
implementation "com.google.android.gms:play-services-gcm:$playLibraryVersion"
45+
implementation "com.google.android.gms:play-services-games:$playLibraryVersion"
46+
implementation "com.google.android.gms:play-services-drive:$playLibraryVersion"
4247
implementation 'com.github.satyan:sugar:1.5'
4348
implementation 'com.google.code.gson:gson:2.7'
4449
implementation 'com.anjlab.android.iab.v3:library:1.0.31'

Blacksmith/src/main/java/uk/co/jakelee/blacksmith/helper/GooglePlayHelper.java

-42
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,6 @@ public static void ActivityResult(Activity activity, int requestCode, int result
8585
}
8686
}
8787

88-
public static String CompleteQuest(Quest quest) {
89-
Games.Quests.claim(mGoogleApiClient, quest.getQuestId(),
90-
quest.getCurrentMilestone().getMilestoneId());
91-
Context context = mGoogleApiClient.getContext();
92-
93-
String questName = quest.getName();
94-
String questDifficulty = new String(quest.getCurrentMilestone().getCompletionRewardData(), Charset.forName("UTF-8"));
95-
String questReward = QuestHelper.getQuestReward(context, questDifficulty);
96-
97-
Player_Info.increaseByOne(Player_Info.Statistic.QuestsCompleted);
98-
return String.format(context.getString(R.string.questComplete),
99-
questName,
100-
questDifficulty,
101-
questReward);
102-
}
103-
10488
public static void UpdateEvent(String eventId, int quantity) {
10589
if (!IsConnected() || quantity <= 0) {
10690
return;
@@ -502,30 +486,4 @@ private static String[] splitBackupData(String backupData) {
502486
return splitData;
503487
}
504488

505-
public void onResult(com.google.android.gms.common.api.Result result) {
506-
Quests.LoadQuestsResult r = (Quests.LoadQuestsResult) result;
507-
QuestBuffer qb = r.getQuests();
508-
509-
int current = 0;
510-
int max = 1;
511-
String event = "";
512-
if (qb.getCount() > 0) {
513-
Quest q = qb.get(0);
514-
current = (int) q.getCurrentMilestone().getCurrentProgress();
515-
max = (int) q.getCurrentMilestone().getTargetProgress();
516-
event = q.getCurrentMilestone().getEventId();
517-
}
518-
519-
DisplayHelper.updateQuest(current, max, event);
520-
qb.close();
521-
}
522-
523-
public void UpdateQuest() {
524-
if (!IsConnected()) {
525-
return;
526-
}
527-
528-
PendingResult<Quests.LoadQuestsResult> quests = Games.Quests.load(mGoogleApiClient, new int[]{Quest.STATE_ACCEPTED}, Quests.SORT_ORDER_ENDING_SOON_FIRST, false);
529-
quests.setResultCallback(this);
530-
}
531489
}

Blacksmith/src/main/java/uk/co/jakelee/blacksmith/main/MainActivity.java

+6-35
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.content.SharedPreferences;
77
import android.os.Bundle;
88
import android.os.Handler;
9+
import android.support.annotation.Nullable;
910
import android.support.v7.app.AppCompatActivity;
1011
import android.util.Log;
1112
import android.view.Gravity;
@@ -21,8 +22,6 @@
2122
import com.google.android.gms.common.api.GoogleApiClient;
2223
import com.google.android.gms.drive.Drive;
2324
import com.google.android.gms.games.Games;
24-
import com.google.android.gms.games.quest.Quest;
25-
import com.google.android.gms.games.quest.QuestUpdateListener;
2625
import com.orm.query.Condition;
2726
import com.orm.query.Select;
2827
import com.tapjoy.TJPlacement;
@@ -66,10 +65,8 @@
6665

6766
public class MainActivity extends AppCompatActivity implements
6867
GoogleApiClient.ConnectionCallbacks,
69-
GoogleApiClient.OnConnectionFailedListener,
70-
QuestUpdateListener{
68+
GoogleApiClient.OnConnectionFailedListener {
7169
private static final Handler handler = new Handler();
72-
public static RelativeLayout questContainer;
7370
public static VariableHelper vh;
7471
public static boolean needToRedrawVisitors = false;
7572
public static boolean needToRedrawSlots = false;
@@ -79,7 +76,6 @@ public class MainActivity extends AppCompatActivity implements
7976
private int newVisitors;
8077
private Intent musicService;
8178
private boolean musicServiceIsStarted = false;
82-
private GooglePlayHelper gph;
8379
public static TJPlacement adPlacement;
8480

8581
@Override
@@ -91,7 +87,6 @@ protected void onCreate(Bundle savedInstanceState) {
9187

9288
dh = DisplayHelper.getInstance(getApplicationContext());
9389
vh = new VariableHelper();
94-
gph = new GooglePlayHelper();
9590
musicService = new Intent(this, MusicService.class);
9691
prefs = getSharedPreferences("uk.co.jakelee.blacksmith", MODE_PRIVATE);
9792
LanguageHelper.updateLanguage(getApplicationContext());
@@ -101,8 +96,6 @@ protected void onCreate(Bundle savedInstanceState) {
10196
TutorialHelper.currentStage = prefs.getInt("tutorialStage", 0);
10297
}
10398

104-
assignUIElements();
105-
10699
try {
107100
GooglePlayHelper.mGoogleApiClient = new GoogleApiClient.Builder(this)
108101
.addConnectionCallbacks(this)
@@ -138,8 +131,11 @@ protected void onCreate(Bundle savedInstanceState) {
138131
AlertDialogHelper.displayUpdateMessage(this, this);
139132
}
140133
}
134+
}
135+
136+
@Override
137+
public void onConnected(@Nullable Bundle bundle) {
141138

142-
gph.UpdateQuest();
143139
}
144140

145141
private void ratingPrompt() {
@@ -153,18 +149,13 @@ private void ratingPrompt() {
153149
AppRate.showRateDialogIfMeetsConditions(this);
154150
}
155151

156-
private void assignUIElements() {
157-
questContainer = (RelativeLayout) findViewById(R.id.questContainer);
158-
}
159-
160152
public void startFirstTutorial() {
161153
// Stage 1
162154
findViewById(mainScroller).scrollTo(0, 0);
163155

164156
TutorialHelper th = new TutorialHelper(this, Constants.STAGE_1_MAIN);
165157
th.addTutorialNoOverlay(findViewById(R.id.visitors_container), R.string.tutorialIntro, R.string.tutorialIntroText, false);
166158
th.addTutorial(findViewById(R.id.coinCount), R.string.tutorialCoins, R.string.tutorialCoinsText, false);
167-
th.addTutorial(findViewById(R.id.questContainer), R.string.tutorialQuest, R.string.tutorialQuestText, false);
168159
th.addTutorial(findViewById(R.id.currentLevel), R.string.tutorialLevel, R.string.tutorialLevelText, false);
169160
th.addTutorialRectangle(findViewById(R.id.visitors_container), R.string.tutorialVisitor, R.string.tutorialVisitorText, true);
170161
th.start();
@@ -437,7 +428,6 @@ public void run() {
437428
ToastHelper.showToast(null, ToastHelper.LONG, String.format(getString(R.string.visitorsArriving), newVisitors), true);
438429
}
439430
DisplayHelper.updateBonusChest((ImageView) activity.findViewById(R.id.bonus_chest));
440-
gph.UpdateQuest();
441431
handler.postDelayed(this, DateHelper.MILLISECONDS_IN_SECOND * 10);
442432
}
443433
};
@@ -579,14 +569,6 @@ public void openBuyCoins(View view) {
579569
startActivity(new Intent(this, BuyCoinsActivity.class).addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT));
580570
}
581571

582-
public void openQuests(View view) {
583-
if (GooglePlayHelper.mGoogleApiClient.isConnected()) {
584-
startActivity(new Intent(this, QuestActivity.class).addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT));
585-
} else {
586-
ToastHelper.showErrorToast(null, ToastHelper.LONG, getString(R.string.questsNoConnection), false);
587-
}
588-
}
589-
590572
public void openMessages(View view) {
591573
Intent intent = new Intent(this, MessagesActivity.class);
592574
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -622,13 +604,6 @@ public void clickBookcase(View view) {
622604
prefs.edit().putInt("nextTip", ++thisTip).apply();
623605
}
624606

625-
@Override
626-
public void onConnected(Bundle connectionHint) {
627-
if (GooglePlayHelper.IsConnected()) {
628-
Games.Quests.registerQuestUpdateListener(GooglePlayHelper.mGoogleApiClient, this);
629-
}
630-
}
631-
632607
@Override
633608
public void onConnectionFailed(ConnectionResult connectionResult) {
634609
GooglePlayHelper.ConnectionFailed(this, connectionResult);
@@ -639,10 +614,6 @@ public void onConnectionSuspended(int i) {
639614
GooglePlayHelper.mGoogleApiClient.connect();
640615
}
641616

642-
public void onQuestCompleted(Quest quest) {
643-
ToastHelper.showPositiveToast(null, ToastHelper.LONG, GooglePlayHelper.CompleteQuest(quest), true);
644-
}
645-
646617
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
647618
GooglePlayHelper.ActivityResult(this, requestCode, resultCode);
648619
}

0 commit comments

Comments
 (0)