IMPORTANT: Before attempting to run this sample, please change the package name to your own
- * package name (not com.android.*) and replace the IDs on res/values/ids.xml by your own IDs (you
- * must create a game in the developer console to get those IDs).
- *
- *
This is a very simple game where the user selects "easy mode" or "hard mode" and then the
- * "gameplay" consists of inputting the desired score (0 to 9999). In easy mode, you get the score
- * you request; in hard mode, you get half.
+ *
+ * IMPORTANT: Before attempting to run this sample, please change
+ * the package name to your own package name (not com.android.*) and
+ * replace the IDs on res/values/ids.xml by your own IDs (you must
+ * create a game in the developer console to get those IDs).
+ *
+ * This is a very simple game where the user selects "easy mode" or
+ * "hard mode" and then the "gameplay" consists of inputting the
+ * desired score (0 to 9999). In easy mode, you get the score you
+ * request; in hard mode, you get half.
*
* @author Bruno Oliveira
*/
-public class MainActivity extends FragmentActivity
- implements MainMenuFragment.Listener,
- GameplayFragment.Callback,
- WinFragment.Listener,
- FriendsFragment.Listener {
+public class MainActivity extends FragmentActivity implements
+ MainMenuFragment.Listener,
+ GameplayFragment.Callback,
+ WinFragment.Listener {
// Fragments
private MainMenuFragment mMainMenuFragment;
private GameplayFragment mGameplayFragment;
private WinFragment mWinFragment;
- public FriendsFragment mFriendsFragment;
// Client used to sign in with Google APIs
private GoogleSignInClient mGoogleSignInClient;
@@ -93,18 +82,12 @@ public class MainActivity extends FragmentActivity
private static final int RC_UNUSED = 5001;
private static final int RC_SIGN_IN = 9001;
- static final int RC_FRIEND_PROFILE = 9002;
- static final int RC_RESOLUTION = 9003;
-
// tag for debug logging
private static final String TAG = "TanC";
// playing on hard mode?
private boolean mHardMode = false;
- // The diplay name of the signed in user.
- private String mDisplayName = "";
-
// achievements and scores we're pending to push to the cloud
// (waiting for the user to sign in, for instance)
private final AccomplishmentsOutbox mOutbox = new AccomplishmentsOutbox();
@@ -123,13 +106,11 @@ public void onCreate(Bundle savedInstanceState) {
mMainMenuFragment = new MainMenuFragment();
mGameplayFragment = new GameplayFragment();
mWinFragment = new WinFragment();
- mFriendsFragment = new FriendsFragment();
// Set the listeners and callbacks of fragment events.
mMainMenuFragment.setListener(this);
mGameplayFragment.setCallback(this);
mWinFragment.setListener(this);
- mFriendsFragment.setListener(this);
// Add initial Main Menu fragment.
// IMPORTANT: if this Activity supported rotation, we'd have to be
@@ -137,8 +118,8 @@ public void onCreate(Bundle savedInstanceState) {
// already be there after rotation and trying to add it again would
// result in overlapping fragments. But since we don't support rotation,
// we don't deal with that for code simplicity.
- getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, mMainMenuFragment)
- .commit();
+ getSupportFragmentManager().beginTransaction().add(R.id.fragment_container,
+ mMainMenuFragment).commit();
checkPlaceholderIds();
}
@@ -181,7 +162,7 @@ private void checkPlaceholderIds() {
problems.append("\nThese problems may prevent the app from working properly.");
problems.append("\n\nSee the TODO window in Android Studio for more information");
(new AlertDialog.Builder(this)).setMessage(problems.toString())
- .setNeutralButton(android.R.string.ok, null).create().show();
+ .setNeutralButton(android.R.string.ok, null).create().show();
}
}
@@ -204,7 +185,10 @@ public void onSuccess(AnnotatedData eventBufferAnnotatedData) {
for (int i = 0; i < count; i++) {
Event event = eventBuffer.get(i);
- Log.i(TAG, "event: " + event.getName() + " -> " + event.getValue());
+ Log.i(TAG, "event: "
+ + event.getName()
+ + " -> "
+ + event.getValue());
}
}
})
@@ -218,10 +202,8 @@ public void onFailure(@NonNull Exception e) {
// Switch UI to the given fragment
private void switchToFragment(Fragment newFrag) {
- getSupportFragmentManager()
- .beginTransaction()
- .replace(R.id.fragment_container, newFrag)
- .commit();
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, newFrag)
+ .commit();
}
private boolean isSignedIn() {
@@ -243,7 +225,7 @@ public void onComplete(@NonNull Task task) {
onDisconnected();
}
}
- });
+ });
}
private void startSignInIntent() {
@@ -277,7 +259,7 @@ public void onComplete(@NonNull Task task) {
onDisconnected();
}
- });
+ });
}
@Override
@@ -295,10 +277,10 @@ public void onSuccess(Intent intent) {
}
})
.addOnFailureListener(new OnFailureListener() {
- @Override
- public void onFailure(@NonNull Exception e) {
- handleException(e, getString(R.string.achievements_exception));
- }
+ @Override
+ public void onFailure(@NonNull Exception e) {
+ handleException(e, getString(R.string.achievements_exception));
+ }
});
}
@@ -447,7 +429,6 @@ private void pushAccomplishments() {
if (mOutbox.mBoredSteps > 0) {
mAchievementsClient.increment(getString(R.string.achievement_really_bored),
mOutbox.mBoredSteps);
-
mAchievementsClient.increment(getString(R.string.achievement_bored),
mOutbox.mBoredSteps);
mOutbox.mBoredSteps = 0;
@@ -464,14 +445,6 @@ private void pushAccomplishments() {
}
}
- public PlayersClient getPlayersClient() {
- return mPlayersClient;
- }
-
- public String getDisplayName() {
- return mDisplayName;
- }
-
/**
* Update leaderboards with the user's score.
*
@@ -494,7 +467,8 @@ public void onWinScreenDismissed() {
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if (requestCode == RC_SIGN_IN) {
- Task task = GoogleSignIn.getSignedInAccountFromIntent(intent);
+ Task task =
+ GoogleSignIn.getSignedInAccountFromIntent(intent);
try {
GoogleSignInAccount account = task.getResult(ApiException.class);
@@ -542,16 +516,16 @@ public void onComplete(@NonNull Task task) {
handleException(e, getString(R.string.players_exception));
displayName = "???";
}
- mDisplayName = displayName;
mMainMenuFragment.setGreeting("Hello, " + displayName);
}
});
+
// if we have accomplishments to push, push them
if (!mOutbox.isEmpty()) {
pushAccomplishments();
- Toast.makeText(this,
- getString(R.string.your_progress_will_be_uploaded), Toast.LENGTH_LONG).show();
+ Toast.makeText(this, getString(R.string.your_progress_will_be_uploaded),
+ Toast.LENGTH_LONG).show();
}
loadAndPrintEvents();
@@ -583,16 +557,6 @@ public void onSignOutButtonClicked() {
signOut();
}
- @Override
- public void onShowFriendsButtonClicked() {
- switchToFragment(mFriendsFragment);
- }
-
- @Override
- public void onBackButtonClicked() {
- switchToFragment(mMainMenuFragment);
- }
-
private class AccomplishmentsOutbox {
boolean mPrimeAchievement = false;
boolean mHumbleAchievement = false;
@@ -603,9 +567,9 @@ private class AccomplishmentsOutbox {
int mHardModeScore = -1;
boolean isEmpty() {
- return !mPrimeAchievement && !mHumbleAchievement && !mLeetAchievement
- && !mArrogantAchievement && mBoredSteps == 0 && mEasyModeScore < 0
- && mHardModeScore < 0;
+ return !mPrimeAchievement && !mHumbleAchievement && !mLeetAchievement &&
+ !mArrogantAchievement && mBoredSteps == 0 && mEasyModeScore < 0 &&
+ mHardModeScore < 0;
}
}
diff --git a/TypeANumber/src/main/java/com/google/example/games/tanc/MainMenuFragment.java b/TypeANumber/src/main/java/com/google/example/games/tanc/MainMenuFragment.java
index ac7b2ba8..9cd7b524 100644
--- a/TypeANumber/src/main/java/com/google/example/games/tanc/MainMenuFragment.java
+++ b/TypeANumber/src/main/java/com/google/example/games/tanc/MainMenuFragment.java
@@ -16,12 +16,12 @@
package com.google.example.games.tanc;
import android.os.Bundle;
+import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;
-import androidx.fragment.app.Fragment;
/**
* Fragment with the main menu for the game. The main menu allows the player
@@ -37,7 +37,6 @@ public class MainMenuFragment extends Fragment implements OnClickListener {
private View mSignOutBarView;
private View mShowAchievementsButton;
private View mShowLeaderboardsButton;
- private View mShowFriendsButton;
interface Listener {
// called when the user presses the `Easy` or `Okay` button; will pass in which via `hardMode`
@@ -54,9 +53,6 @@ interface Listener {
// called when the user presses the `Sign Out` button
void onSignOutButtonClicked();
-
- // called when the user presses the `Friends` button
- void onShowFriendsButtonClicked();
}
private Listener mListener = null;
@@ -75,8 +71,7 @@ public View onCreateView(LayoutInflater inflater,
R.id.show_achievements_button,
R.id.show_leaderboards_button,
R.id.sign_in_button,
- R.id.sign_out_button,
- R.id.show_friends_button
+ R.id.sign_out_button
};
for (int clickableId : clickableIds) {
@@ -86,7 +81,6 @@ public View onCreateView(LayoutInflater inflater,
// cache views
mShowAchievementsButton = view.findViewById(R.id.show_achievements_button);
mShowLeaderboardsButton = view.findViewById(R.id.show_leaderboards_button);
- mShowFriendsButton = view.findViewById(R.id.show_friends_button);
mGreetingTextView = view.findViewById(R.id.text_greeting);
mSignInBarView = view.findViewById(R.id.sign_in_bar);
@@ -110,7 +104,6 @@ private void updateUI() {
mGreetingTextView.setText(mGreeting);
mShowAchievementsButton.setEnabled(!mShowSignInButton);
mShowLeaderboardsButton.setEnabled(!mShowSignInButton);
- mShowFriendsButton.setEnabled(!mShowSignInButton);
mSignInBarView.setVisibility(mShowSignInButton ? View.VISIBLE : View.GONE);
mSignOutBarView.setVisibility(mShowSignInButton ? View.GONE : View.VISIBLE);
}
@@ -130,9 +123,6 @@ public void onClick(View view) {
case R.id.show_leaderboards_button:
mListener.onShowLeaderboardsRequested();
break;
- case R.id.show_friends_button:
- mListener.onShowFriendsButtonClicked();
- break;
case R.id.sign_in_button:
mListener.onSignInButtonClicked();
break;
diff --git a/TypeANumber/src/main/java/com/google/example/games/tanc/WinFragment.java b/TypeANumber/src/main/java/com/google/example/games/tanc/WinFragment.java
index 1d4e03ba..860eadaf 100644
--- a/TypeANumber/src/main/java/com/google/example/games/tanc/WinFragment.java
+++ b/TypeANumber/src/main/java/com/google/example/games/tanc/WinFragment.java
@@ -17,12 +17,12 @@
package com.google.example.games.tanc;
import android.os.Bundle;
+import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;
-import androidx.fragment.app.Fragment;
/**
* Fragment that shows the 'You won' message. Apart from congratulating the user
@@ -123,4 +123,4 @@ public void setShowSignInButton(boolean showSignIn) {
mShowSignIn = showSignIn;
updateUI();
}
-}
\ No newline at end of file
+}
diff --git a/TypeANumber/src/main/res/drawable-hdpi/pgs_signed_in_friend.png b/TypeANumber/src/main/res/drawable-hdpi/pgs_signed_in_friend.png
deleted file mode 100644
index ef8a5084..00000000
Binary files a/TypeANumber/src/main/res/drawable-hdpi/pgs_signed_in_friend.png and /dev/null differ
diff --git a/TypeANumber/src/main/res/drawable-ldpi/pgs_signed_in_friend.png b/TypeANumber/src/main/res/drawable-ldpi/pgs_signed_in_friend.png
deleted file mode 100644
index fd2c6063..00000000
Binary files a/TypeANumber/src/main/res/drawable-ldpi/pgs_signed_in_friend.png and /dev/null differ
diff --git a/TypeANumber/src/main/res/drawable-mdpi/pgs_signed_in_friend.png b/TypeANumber/src/main/res/drawable-mdpi/pgs_signed_in_friend.png
deleted file mode 100644
index 299b359d..00000000
Binary files a/TypeANumber/src/main/res/drawable-mdpi/pgs_signed_in_friend.png and /dev/null differ
diff --git a/TypeANumber/src/main/res/drawable-xhdpi/pgs_signed_in_friend.png b/TypeANumber/src/main/res/drawable-xhdpi/pgs_signed_in_friend.png
deleted file mode 100644
index 7a953a8c..00000000
Binary files a/TypeANumber/src/main/res/drawable-xhdpi/pgs_signed_in_friend.png and /dev/null differ
diff --git a/TypeANumber/src/main/res/layout/fragment_mainmenu.xml b/TypeANumber/src/main/res/layout/fragment_mainmenu.xml
index 1a427642..0bae8ccd 100644
--- a/TypeANumber/src/main/res/layout/fragment_mainmenu.xml
+++ b/TypeANumber/src/main/res/layout/fragment_mainmenu.xml
@@ -86,13 +86,7 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/TypeANumber/src/main/res/layout/friends_screen.xml b/TypeANumber/src/main/res/layout/friends_screen.xml
deleted file mode 100644
index bd707d66..00000000
--- a/TypeANumber/src/main/res/layout/friends_screen.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/TypeANumber/src/main/res/values-v13/styles.xml b/TypeANumber/src/main/res/values-v13/styles.xml
index 03b93037..997965b5 100644
--- a/TypeANumber/src/main/res/values-v13/styles.xml
+++ b/TypeANumber/src/main/res/values-v13/styles.xml
@@ -16,5 +16,5 @@
-->
-
+
diff --git a/TypeANumber/src/main/res/values/strings.xml b/TypeANumber/src/main/res/values/strings.xml
index ffd0a884..00b99429 100644
--- a/TypeANumber/src/main/res/values/strings.xml
+++ b/TypeANumber/src/main/res/values/strings.xml
@@ -51,13 +51,10 @@
See your progress:Show AchievementsShow Leaderboards
- Show FriendsSign in with Google to share your scores and achievements with your friends.You are signed in with Google.Sign outYou win! Your score is:Sign in now to upload this score, save your achievements and share your progress with friends.There was an issue with sign in. Please try again later.
- Friends
- Back
diff --git a/build.gradle b/build.gradle
index 728e805b..d0e9a787 100644
--- a/build.gradle
+++ b/build.gradle
@@ -9,7 +9,7 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.6.2'
+ classpath 'com.android.tools.build:gradle:3.0.1'
}
}
@@ -21,14 +21,14 @@ allprojects {
}
ext {
- android_compile_version = 28
+ android_compile_version = 26
// Google Play Services minimum requirements is 14
android_min_sdk_version = 14
appcompat_library_version = '27.0.2'
support_library_version = '27.0.2'
- gms_library_version = '17.0.0'
+ gms_library_version = '11.6.2'
}
}
diff --git a/gradle.properties b/gradle.properties
deleted file mode 100644
index 5465fec0..00000000
--- a/gradle.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-android.enableJetifier=true
-android.useAndroidX=true
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 8a0ae656..49314a56 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Fri Jul 31 16:24:33 BST 2020
+#Tue Nov 28 14:53:07 PST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip