+ * Modify this method to associate the user's FCM InstanceID token with any server-side account
+ * maintained by your application.
+ *
+ * @param token The new token.
+ */
+ private void sendRegistrationToServer(String token) {
+ // This method is blank, but if you were to build a server that stores users token
+ // information, this is where you'd send the token to the server.
+ }
+
+ @Override
+ public void onMessageReceived(RemoteMessage remoteMessage) {
+ super.onMessageReceived(remoteMessage);
+ Toast.makeText(this, "Received", Toast.LENGTH_SHORT).show();
+ }
+}
diff --git a/Advanced NanoDegree/Squawker/app/src/main/java/android/example/com/squawker/fcm/SquawkFirebaseMessageService.java b/Advanced NanoDegree/Squawker/app/src/main/java/android/example/com/squawker/fcm/SquawkFirebaseMessageService.java
new file mode 100644
index 0000000..7a0b9f9
--- /dev/null
+++ b/Advanced NanoDegree/Squawker/app/src/main/java/android/example/com/squawker/fcm/SquawkFirebaseMessageService.java
@@ -0,0 +1,172 @@
+/*
+* Copyright (C) 2017 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package android.example.com.squawker.fcm;
+
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.Intent;
+import android.example.com.squawker.MainActivity;
+import android.example.com.squawker.R;
+import android.example.com.squawker.provider.SquawkContract;
+import android.example.com.squawker.provider.SquawkProvider;
+import android.media.RingtoneManager;
+import android.net.Uri;
+import android.os.AsyncTask;
+import androidx.core.app.NotificationCompat;
+
+import android.os.Build;
+import android.util.Log;
+import android.widget.Toast;
+
+import com.google.firebase.messaging.FirebaseMessagingService;
+import com.google.firebase.messaging.RemoteMessage;
+
+import java.util.Map;
+
+/**
+ * Listens for squawk FCM messages both in the background and the foreground and responds
+ * appropriately
+ * depending on type of message
+ */
+public class SquawkFirebaseMessageService extends FirebaseMessagingService {
+
+ private static final String JSON_KEY_AUTHOR = SquawkContract.COLUMN_AUTHOR;
+ private static final String JSON_KEY_AUTHOR_KEY = SquawkContract.COLUMN_AUTHOR_KEY;
+ private static final String JSON_KEY_MESSAGE = SquawkContract.COLUMN_MESSAGE;
+ private static final String JSON_KEY_DATE = SquawkContract.COLUMN_DATE;
+
+ private static final int NOTIFICATION_MAX_CHARACTERS = 30;
+ private static String LOG_TAG = SquawkFirebaseMessageService.class.getSimpleName();
+ public static final String NOTIFICATION_CHANNEL_ID = "android.example.com.squawker.fcm";
+
+ /**
+ * Called when message is received.
+ *
+ * @param remoteMessage Object representing the message received from Firebase Cloud Messaging
+ */
+ @Override
+ public void onMessageReceived(RemoteMessage remoteMessage) {
+ // There are two types of messages data messages and notification messages. Data messages
+ // are handled
+ // here in onMessageReceived whether the app is in the foreground or background. Data
+ // messages are the type
+ // traditionally used with FCM. Notification messages are only received here in
+ // onMessageReceived when the app
+ // is in the foreground. When the app is in the background an automatically generated
+ // notification is displayed.
+ // When the user taps on the notification they are returned to the app. Messages
+ // containing both notification
+ // and data payloads are treated as notification messages. The Firebase console always
+ // sends notification
+ // messages. For more see: https://firebase.google.com/docs/cloud-messaging/concept-options\
+
+ // The Squawk server always sends just *data* messages, meaning that onMessageReceived when
+ // the app is both in the foreground AND the background
+
+ Log.d(LOG_TAG, "From: " + remoteMessage.getFrom());
+
+ Toast.makeText(this, "Notification", Toast.LENGTH_SHORT).show();
+
+ // Check if message contains a data payload.
+ Map
+ * Consider using CountingIdlingResource from espresso-contrib package if you use this class from
+ * multiple threads or need to keep a count of pending operations.
+ */
+
+public class SimpleIdlingResource implements IdlingResource {
+
+ @Nullable private volatile ResourceCallback mCallback;
+
+ // Idleness is controlled with this boolean.
+ private AtomicBoolean mIsIdleNow = new AtomicBoolean(true);
+
+ @Override
+ public String getName() {
+ return this.getClass().getName();
+ }
+
+ @Override
+ public boolean isIdleNow() {
+ return mIsIdleNow.get();
+ }
+
+ @Override
+ public void registerIdleTransitionCallback(ResourceCallback callback) {
+ mCallback = callback;
+ }
+
+ /**
+ * Sets the new idle state, if isIdleNow is true, it pings the {@link ResourceCallback}.
+ * @param isIdleNow false if there are pending operations, true if idle.
+ */
+ public void setIdleState(boolean isIdleNow) {
+ mIsIdleNow.set(isIdleNow);
+ if (isIdleNow && mCallback != null) {
+ mCallback.onTransitionToIdle();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Advanced NanoDegree/TeaTime/app/src/main/java/com/example/android/teatime/ImageDownloader.java b/Advanced NanoDegree/TeaTime/app/src/main/java/com/example/android/teatime/ImageDownloader.java
new file mode 100644
index 0000000..8d89fa4
--- /dev/null
+++ b/Advanced NanoDegree/TeaTime/app/src/main/java/com/example/android/teatime/ImageDownloader.java
@@ -0,0 +1,108 @@
+/*
+* Copyright (C) 2017 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.example.android.teatime;
+
+import android.content.Context;
+import android.os.Handler;
+import android.support.annotation.Nullable;
+import android.support.test.espresso.IdlingResource;
+import android.widget.Toast;
+
+import com.example.android.teatime.IdlingResource.SimpleIdlingResource;
+import com.example.android.teatime.model.Tea;
+
+import java.util.ArrayList;
+
+/**
+ * Takes a String and returns it after a while via a callback.
+ *
+ * This executes a long-running operation on a different thread that results in problems with
+ * Espresso if an {@link IdlingResource} is not implemented and registered.
+ */
+class ImageDownloader {
+
+ private static final int DELAY_MILLIS = 3000;
+
+ // Create an ArrayList of mTeas
+ final static ArrayList
+
+
+
+
-
-
-
-