Skip to content
Merged
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
12 changes: 12 additions & 0 deletions database/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'org.jetbrains.kotlin.android.extensions'

check.dependsOn 'assembleDebugAndroidTest'

android {
Expand Down Expand Up @@ -26,7 +30,15 @@ configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:27.1.1'
}

androidExtensions {
experimental = true
}

dependencies {
implementation project(":internal:lintchecks")
implementation project(":internal:chooser")
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.61"

implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
Expand Down
4 changes: 2 additions & 2 deletions database/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
-keepattributes EnclosingMethod
-keepattributes InnerClasses

-keep class com.google.firebase.quickstart.database.viewholder.** {
-keep class com.google.firebase.quickstart.database.java.viewholder.** {
*;
}

-keepclassmembers class com.google.firebase.quickstart.database.models.** {
-keepclassmembers class com.google.firebase.quickstart.database.java.models.** {
*;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;

import com.google.firebase.quickstart.database.java.SignInActivity;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -46,50 +48,50 @@ public void newPostTest() {

// Select email field
ViewInteraction appCompatEditText = onView(
allOf(withId(R.id.field_email),
withParent(withId(R.id.layout_email_password)),
allOf(withId(R.id.fieldEmail),
withParent(withId(R.id.layoutEmailPassword)),
isDisplayed()));
appCompatEditText.perform(click());

// Enter email address
ViewInteraction appCompatEditText2 = onView(
allOf(withId(R.id.field_email),
withParent(withId(R.id.layout_email_password)),
allOf(withId(R.id.fieldEmail),
withParent(withId(R.id.layoutEmailPassword)),
isDisplayed()));
appCompatEditText2.perform(replaceText(email));

// Enter password
ViewInteraction appCompatEditText3 = onView(
allOf(withId(R.id.field_password),
withParent(withId(R.id.layout_email_password)),
allOf(withId(R.id.fieldPassword),
withParent(withId(R.id.layoutEmailPassword)),
isDisplayed()));
appCompatEditText3.perform(replaceText(password));

// Click sign up
ViewInteraction appCompatButton = onView(
allOf(withId(R.id.button_sign_up), withText(R.string.sign_up),
withParent(withId(R.id.layout_buttons)),
allOf(withId(R.id.buttonSignUp), withText(R.string.sign_up),
withParent(withId(R.id.layoutButtons)),
isDisplayed()));
appCompatButton.perform(click());

// Click new post button
ViewInteraction floatingActionButton = onView(
allOf(withId(R.id.fab_new_post), isDisplayed()));
allOf(withId(R.id.fabNewPost), isDisplayed()));
floatingActionButton.perform(click());

// Enter post title
ViewInteraction appCompatEditText4 = onView(
allOf(withId(R.id.field_title), isDisplayed()));
allOf(withId(R.id.fieldTitle), isDisplayed()));
appCompatEditText4.perform(replaceText(postTitle));

// Enter post content
ViewInteraction appCompatEditText5 = onView(
allOf(withId(R.id.field_body), isDisplayed()));
allOf(withId(R.id.fieldBody), isDisplayed()));
appCompatEditText5.perform(replaceText(postContent));

// Click submit button
ViewInteraction floatingActionButton2 = onView(
allOf(withId(R.id.fab_submit_post), isDisplayed()));
allOf(withId(R.id.fabSubmitPost), isDisplayed()));
floatingActionButton2.perform(click());

// Navigate to "My Posts"
Expand All @@ -99,18 +101,18 @@ public void newPostTest() {

// Check that the title is correct
ViewInteraction textView = onView(
allOf(withId(R.id.post_title), withText(postTitle), isDisplayed()));
allOf(withId(R.id.postTitle), withText(postTitle), isDisplayed()));
textView.check(matches(withText(postTitle)));

// Check that the content is correct
ViewInteraction textView2 = onView(
allOf(withId(R.id.post_body), withText(postContent), isDisplayed()));
allOf(withId(R.id.postBody), withText(postContent), isDisplayed()));
textView2.check(matches(withText(postContent)));

// Check that it has zero stars
ViewInteraction textView3 = onView(
allOf(withId(R.id.post_num_stars), withText("0"),
withParent(withId(R.id.star_layout)),
allOf(withId(R.id.postNumStars), withText("0"),
withParent(withId(R.id.starLayout)),
isDisplayed()));
textView3.check(matches(withText("0")));

Expand Down
28 changes: 21 additions & 7 deletions database/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,33 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme" />
<activity android:name=".NewPostActivity" />
<activity android:name=".SignInActivity">

<activity android:name=".EntryChoiceActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".PostDetailActivity"></activity>

<activity
android:name=".java.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme" />

<activity
android:name=".kotlin.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme" />

<activity android:name=".java.SignInActivity" />
<activity android:name=".kotlin.SignInActivity" />

<activity android:name=".java.NewPostActivity" />
<activity android:name=".kotlin.NewPostActivity" />

<activity android:name=".java.PostDetailActivity" />
<activity android:name=".kotlin.PostDetailActivity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.google.firebase.quickstart.database

import android.content.Intent
import com.firebase.example.internal.BaseEntryChoiceActivity
import com.firebase.example.internal.Choice

class EntryChoiceActivity : BaseEntryChoiceActivity() {

override fun getChoices(): List<Choice> {
return listOf(
Choice(
"Java",
"Run the Firebase Realtime Database quickstart written in Java.",
Intent(this, com.google.firebase.quickstart.database.java.MainActivity::class.java)),
Choice(
"Kotlin",
"Run the Firebase Realtime Database quickstart written in Kotlin.",
Intent(this, com.google.firebase.quickstart.database.kotlin.MainActivity::class.java))
)
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.google.firebase.quickstart.database;
package com.google.firebase.quickstart.database.java;

import android.app.ProgressDialog;
import android.support.v7.app.AppCompatActivity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.google.firebase.quickstart.database;
package com.google.firebase.quickstart.database.java;

import android.content.Intent;
import android.os.Bundle;
Expand All @@ -27,9 +27,10 @@
import android.view.View;

import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.quickstart.database.fragment.MyPostsFragment;
import com.google.firebase.quickstart.database.fragment.MyTopPostsFragment;
import com.google.firebase.quickstart.database.fragment.RecentPostsFragment;
import com.google.firebase.quickstart.database.R;
import com.google.firebase.quickstart.database.java.fragment.MyPostsFragment;
import com.google.firebase.quickstart.database.java.fragment.MyTopPostsFragment;
import com.google.firebase.quickstart.database.java.fragment.RecentPostsFragment;

public class MainActivity extends BaseActivity {

Expand Down Expand Up @@ -75,7 +76,7 @@ public CharSequence getPageTitle(int position) {
tabLayout.setupWithViewPager(mViewPager);

// Button launches NewPostActivity
findViewById(R.id.fab_new_post).setOnClickListener(new View.OnClickListener() {
findViewById(R.id.fabNewPost).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, NewPostActivity.class));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.google.firebase.quickstart.database;
package com.google.firebase.quickstart.database.java;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
Expand All @@ -13,8 +13,9 @@
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.google.firebase.quickstart.database.models.Post;
import com.google.firebase.quickstart.database.models.User;
import com.google.firebase.quickstart.database.R;
import com.google.firebase.quickstart.database.java.models.Post;
import com.google.firebase.quickstart.database.java.models.User;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -41,9 +42,9 @@ protected void onCreate(Bundle savedInstanceState) {
mDatabase = FirebaseDatabase.getInstance().getReference();
// [END initialize_database_ref]

mTitleField = findViewById(R.id.field_title);
mBodyField = findViewById(R.id.field_body);
mSubmitButton = findViewById(R.id.fab_submit_post);
mTitleField = findViewById(R.id.fieldTitle);
mBodyField = findViewById(R.id.fieldBody);
mSubmitButton = findViewById(R.id.fabSubmitPost);

mSubmitButton.setOnClickListener(new View.OnClickListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.google.firebase.quickstart.database;
package com.google.firebase.quickstart.database.java;

import android.content.Context;
import android.os.Bundle;
Expand All @@ -19,9 +19,10 @@
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.google.firebase.quickstart.database.models.User;
import com.google.firebase.quickstart.database.models.Comment;
import com.google.firebase.quickstart.database.models.Post;
import com.google.firebase.quickstart.database.R;
import com.google.firebase.quickstart.database.java.models.User;
import com.google.firebase.quickstart.database.java.models.Comment;
import com.google.firebase.quickstart.database.java.models.Post;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -63,12 +64,12 @@ protected void onCreate(Bundle savedInstanceState) {
.child("post-comments").child(mPostKey);

// Initialize Views
mAuthorView = findViewById(R.id.post_author);
mTitleView = findViewById(R.id.post_title);
mBodyView = findViewById(R.id.post_body);
mCommentField = findViewById(R.id.field_comment_text);
mCommentButton = findViewById(R.id.button_post_comment);
mCommentsRecycler = findViewById(R.id.recycler_comments);
mAuthorView = findViewById(R.id.postAuthor);
mTitleView = findViewById(R.id.postTitle);
mBodyView = findViewById(R.id.postBody);
mCommentField = findViewById(R.id.fieldCommentText);
mCommentButton = findViewById(R.id.buttonPostComment);
mCommentsRecycler = findViewById(R.id.recyclerPostComments);

mCommentButton.setOnClickListener(this);
mCommentsRecycler.setLayoutManager(new LinearLayoutManager(this));
Expand Down Expand Up @@ -130,7 +131,7 @@ public void onStop() {
@Override
public void onClick(View v) {
int i = v.getId();
if (i == R.id.button_post_comment) {
if (i == R.id.buttonPostComment) {
postComment();
}
}
Expand Down Expand Up @@ -171,8 +172,8 @@ private static class CommentViewHolder extends RecyclerView.ViewHolder {
public CommentViewHolder(View itemView) {
super(itemView);

authorView = itemView.findViewById(R.id.comment_author);
bodyView = itemView.findViewById(R.id.comment_body);
authorView = itemView.findViewById(R.id.commentAuthor);
bodyView = itemView.findViewById(R.id.commentBody);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.google.firebase.quickstart.database;
package com.google.firebase.quickstart.database.java;

import android.content.Intent;
import android.os.Bundle;
Expand All @@ -17,7 +17,8 @@
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.quickstart.database.models.User;
import com.google.firebase.quickstart.database.R;
import com.google.firebase.quickstart.database.java.models.User;

public class SignInActivity extends BaseActivity implements View.OnClickListener {

Expand All @@ -40,10 +41,10 @@ protected void onCreate(Bundle savedInstanceState) {
mAuth = FirebaseAuth.getInstance();

// Views
mEmailField = findViewById(R.id.field_email);
mPasswordField = findViewById(R.id.field_password);
mSignInButton = findViewById(R.id.button_sign_in);
mSignUpButton = findViewById(R.id.button_sign_up);
mEmailField = findViewById(R.id.fieldEmail);
mPasswordField = findViewById(R.id.fieldPassword);
mSignInButton = findViewById(R.id.buttonSignIn);
mSignUpButton = findViewById(R.id.buttonSignUp);

// Click listeners
mSignInButton.setOnClickListener(this);
Expand Down Expand Up @@ -163,9 +164,9 @@ private void writeNewUser(String userId, String name, String email) {
@Override
public void onClick(View v) {
int i = v.getId();
if (i == R.id.button_sign_in) {
if (i == R.id.buttonSignIn) {
signIn();
} else if (i == R.id.button_sign_up) {
} else if (i == R.id.buttonSignUp) {
signUp();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.google.firebase.quickstart.database.fragment;
package com.google.firebase.quickstart.database.java.fragment;

import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.Query;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.google.firebase.quickstart.database.fragment;
package com.google.firebase.quickstart.database.java.fragment;

import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.Query;
Expand Down
Loading