Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 17 additions & 23 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "android.example.com.squawker"
minSdkVersion 16
targetSdkVersion 25
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand All @@ -21,26 +21,20 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
implementation fileTree(dir: 'libs', include: ['*.jar'])

// RecyclerView
compile 'com.android.support:recyclerview-v7:25.1.0'
implementation 'androidx.appcompat:appcompat:1.1.0'

// Schematic dependencies for ContentProvider
apt 'net.simonvt.schematic:schematic-compiler:0.6.3'
compile 'net.simonvt.schematic:schematic:0.6.3'
testImplementation 'junit:junit:4.13.2'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
annotationProcessor 'net.simonvt.schematic:schematic-compiler:0.6.3'
implementation 'net.simonvt.schematic:schematic:0.6.3'
implementation "androidx.preference:preference:1.1.1"
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

// Preferences Dependencies
compile 'com.android.support:preference-v7:25.1.0'
implementation platform('com.google.firebase:firebase-bom:29.0.3')
implementation 'com.google.firebase:firebase-analytics'

// Firebase dependency
compile 'com.google.firebase:firebase-messaging:10.0.1'
implementation 'com.google.firebase:firebase-messaging:23.0.0'
}
// Apply the Google Services plugin. Make sure to add the google-services.json file in the app
// folder. You download it from the Firebase console
apply plugin: 'com.google.gms.google-services'
14 changes: 14 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
android:authorities="android.example.com.squawker.provider.provider"
android:exported="false" />

<service
android:name=".fcm.SquawkFirebaseInstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>

<activity
android:name=".following.FollowingPreferenceActivity"
android:parentActivityName=".MainActivity">
Expand All @@ -33,6 +40,13 @@
android:value=".MainActivity" />
</activity>

<meta-data
android:name="firebase_messaging_auto_init_enabled"
android:value="false" />
<meta-data
android:name="firebase_analytics_collection_enabled"
android:value="false" />

</application>

</manifest>
41 changes: 28 additions & 13 deletions app/src/main/java/android/example/com/squawker/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,20 @@
import android.example.com.squawker.provider.SquawkContract;
import android.example.com.squawker.provider.SquawkProvider;
import android.os.Bundle;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.PreferenceManager;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.loader.app.LoaderManager;
import androidx.loader.content.CursorLoader;
import androidx.loader.content.Loader;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;
import com.google.firebase.messaging.FirebaseMessaging;

public class MainActivity extends AppCompatActivity implements
LoaderManager.LoaderCallbacks<Cursor> {
Expand Down Expand Up @@ -84,11 +86,24 @@ protected void onCreate(Bundle savedInstanceState) {
mRecyclerView.setAdapter(mAdapter);

// Start the loader
getSupportLoaderManager().initLoader(LOADER_ID_MESSAGES, null, this);

// TODO (1) Get the test data here from the extras bundle that came with this intent.
// To confirm that the data was passed in, make sure to show the data in a log statement.

LoaderManager.getInstance(this).initLoader(LOADER_ID_MESSAGES, null, this);

FirebaseMessaging.getInstance().getToken()
.addOnCompleteListener(task -> {
if (!task.isSuccessful()) {
Log.w(MainActivity.LOG_TAG, "Fetching FCM registration token failed", task.getException());
return;
}

// Get new FCM registration token
String token = task.getResult();

// Log and toast
String msg = getString(R.string.message_token_format, token);
Log.d(MainActivity.LOG_TAG, msg);
Toast.makeText(MainActivity.this, msg, Toast.LENGTH_SHORT).show();
});
FirebaseMessaging.getInstance().setAutoInitEnabled(true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import android.database.Cursor;
import android.example.com.squawker.provider.SquawkContract;
import android.support.v7.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -105,6 +105,8 @@ public void onBindViewHolder(SquawkViewHolder holder, int position) {
case SquawkContract.NIKITA_KEY:
holder.authorImageView.setImageResource(R.drawable.nikita);
break;
case SquawkContract.SAGAR_KEY:
holder.authorImageView.setImageResource(R.drawable.test);
default:
holder.authorImageView.setImageResource(R.drawable.test);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package android.example.com.squawker.fcm;

import android.util.Log;

import com.google.firebase.messaging.FirebaseMessagingService;

public class SquawkFirebaseInstanceIdService extends FirebaseMessagingService{

private static String LOG_TAG = SquawkFirebaseInstanceIdService.class.getSimpleName();
@Override
public void onNewToken(String token) {
Log.d(LOG_TAG, "Refreshed token: " + token);

// If you want to send messages to this application instance or
// manage this apps subscriptions on the server side, send the
// FCM registration token to your app server.
sendRegistrationToServer(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.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

import android.example.com.squawker.R;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.NavUtils;
import android.view.MenuItem;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

import android.example.com.squawker.R;
import android.os.Bundle;
import android.support.v7.preference.PreferenceFragmentCompat;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.SwitchPreferenceCompat;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class SquawkContract {
public static final String JLIN_KEY = "key_jlin";
public static final String LYLA_KEY = "key_lyla";
public static final String NIKITA_KEY = "key_nikita";
public static final String SAGAR_KEY = "key_sagar";
public static final String TEST_ACCOUNT_KEY = "key_test";


Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
android:layout_height="match_parent"
tools:context="android.example.com.squawker.MainActivity">

<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/squawks_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
<string name="follow_key_switch_jlin">key_jlin</string>
<string name="follow_key_switch_lyla">key_lyla</string>
<string name="follow_key_switch_nikita">key_nikita</string>
<string name="follow_key_switch_sagar">key_sagar</string>

<string name="follow_title_switch_asser">Asser</string>
<string name="follow_title_switch_cezanne">Cezanne</string>
<string name="follow_title_switch_jlin">Jessica</string>
<string name="follow_title_switch_lyla">Lyla</string>
<string name="follow_title_switch_nikita">Nikita</string>
<string name="follow_title_switch_sagar">Sagar</string>

<string name="follow_summary_not_following">Not Following</string>
<string name="follow_summary_following">Following</string>
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/res/xml/following_squawker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@
android:summaryOn="@string/follow_summary_following"
android:title="@string/follow_title_switch_nikita" />


<SwitchPreferenceCompat
android:defaultValue="@bool/follow_default_message_subscription"
android:key="@string/follow_key_switch_sagar"
android:summaryOff="@string/follow_summary_not_following"
android:summaryOn="@string/follow_summary_following"
android:title="@string/follow_title_switch_sagar" />


</PreferenceScreen>
10 changes: 6 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

buildscript {
repositories {
jcenter()
google()
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2'
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.google.gms:google-services:4.3.10'

// Google Services plugin
classpath 'com.google.gms:google-services:3.0.0'
Expand All @@ -18,7 +19,8 @@ buildscript {

allprojects {
repositories {
jcenter()
google()
mavenCentral()
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m

android.useAndroidX=true
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip