Skip to content

Commit 218832d

Browse files
committed
Initial demo app
This first commit has feature parity with the iOS version.
1 parent 6ddefc8 commit 218832d

File tree

10 files changed

+146
-34
lines changed

10 files changed

+146
-34
lines changed

app/app.iml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,14 @@
9393
<orderEntry type="sourceFolder" forTests="false" />
9494
<orderEntry type="library" exported="" name="jackson-core-2.2.2" level="project" />
9595
<orderEntry type="library" exported="" name="jackson-databind-2.2.2" level="project" />
96-
<orderEntry type="library" exported="" name="firebase-client-android-2.0.3" level="project" />
9796
<orderEntry type="library" exported="" name="support-v4-22.2.1" level="project" />
98-
<orderEntry type="library" exported="" name="tubesock-0.0.10" level="project" />
97+
<orderEntry type="library" exported="" name="firebase-client-jvm-2.3.1" level="project" />
9998
<orderEntry type="library" exported="" name="recyclerview-v7-22.2.1" level="project" />
99+
<orderEntry type="library" exported="" name="tubesock-0.0.11" level="project" />
100100
<orderEntry type="library" exported="" name="jackson-annotations-2.2.2" level="project" />
101-
<orderEntry type="library" exported="" name="firebase-client-jvm-2.0.3" level="project" />
101+
<orderEntry type="library" exported="" name="firebase-client-android-2.3.1" level="project" />
102102
<orderEntry type="library" exported="" name="support-annotations-22.2.1" level="project" />
103103
<orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
104+
<orderEntry type="module" module-name="library" exported="" />
104105
</component>
105106
</module>

app/build.gradle

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ apply plugin: 'com.android.application'
22

33
android {
44
compileSdkVersion 22
5-
buildToolsVersion "22.0.1"
5+
buildToolsVersion "23.0.0"
66

77
defaultConfig {
8-
applicationId "com.firebase.firebaseui_android"
8+
applicationId "com.firebase.uidemo"
99
minSdkVersion 10
1010
targetSdkVersion 22
1111
versionCode 1
@@ -17,19 +17,19 @@ android {
1717
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
1818
}
1919
}
20+
packagingOptions {
21+
exclude 'META-INF/LICENSE'
22+
exclude 'META-INF/NOTICE'
23+
exclude 'META-INF/NOTICE.txt'
24+
}
25+
2026
}
2127

2228
dependencies {
2329
compile fileTree(dir: 'libs', include: ['*.jar'])
2430
compile 'com.android.support:appcompat-v7:22.2.0'
25-
compile 'com.firebase:firebase-client-android:2.0.3+'
31+
compile 'com.firebase:firebase-client-android:2.3.1'
2632
compile 'com.android.support:recyclerview-v7:22.2.1'
33+
compile project(':library')
2734
}
2835

29-
android {
30-
packagingOptions {
31-
exclude 'META-INF/LICENSE'
32-
exclude 'META-INF/NOTICE'
33-
exclude 'META-INF/NOTICE.txt'
34-
}
35-
}

app/src/androidTest/java/com/firebase/firebaseui_android/ApplicationTest.java renamed to app/src/androidTest/java/com/firebase/uidemo/ApplicationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.firebase.firebaseui_android;
1+
package com.firebase.uidemo;
22

33
import android.app.Application;
44
import android.test.ApplicationTestCase;
@@ -10,4 +10,4 @@ public class ApplicationTest extends ApplicationTestCase<Application> {
1010
public ApplicationTest() {
1111
super(Application.class);
1212
}
13-
}
13+
}

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.firebase.firebaseui_android">
2+
package="com.firebase.uidemo">
33

44
<uses-permission android:name="android.permission.INTERNET" />
55

@@ -8,7 +8,7 @@
88
android:name=".DemoApplication"
99
android:label="@string/app_name"
1010
android:icon="@mipmap/ic_launcher"
11-
android:theme="@style/AppTheme">
11+
android:theme="@style/Theme.AppCompat.Light">
1212

1313
<activity
1414
android:name=".RecyclerViewDemoActivity"

app/src/main/java/com/firebase/firebaseui_android/RecyclerViewDemoActivity.java

Lines changed: 0 additions & 8 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.firebase.firebaseui_android;
1+
package com.firebase.uidemo;
22

33
import com.firebase.client.Firebase;
44

@@ -8,4 +8,4 @@ public void onCreate() {
88
super.onCreate();
99
Firebase.setAndroidContext(this);
1010
}
11-
}
11+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
package com.firebase.uidemo;
2+
3+
import android.app.Activity;
4+
import android.graphics.Color;
5+
import android.os.Bundle;
6+
import android.support.v7.app.AppCompatActivity;
7+
import android.support.v7.widget.LinearLayoutManager;
8+
import android.support.v7.widget.RecyclerView;
9+
import android.util.Log;
10+
import android.view.Gravity;
11+
import android.view.View;
12+
import android.widget.Button;
13+
import android.widget.EditText;
14+
import android.widget.TextView;
15+
16+
import com.firebase.client.Firebase;
17+
import com.firebase.ui.FirebaseRecyclerViewAdapter;
18+
19+
20+
public class RecyclerViewDemoActivity extends AppCompatActivity {
21+
@Override
22+
protected void onCreate(Bundle savedInstanceState) {
23+
super.onCreate(savedInstanceState);
24+
setContentView(R.layout.recycler_view_demo);
25+
26+
final Firebase ref = new Firebase("https://nanochat.firebaseio.com");
27+
28+
final String name = "Android User";
29+
final Button sendButton = (Button) findViewById(R.id.sendButton);
30+
final EditText messageEdit = (EditText) findViewById(R.id.messageEdit);
31+
final RecyclerView messages = (RecyclerView) findViewById(R.id.messagesList);
32+
messages.setHasFixedSize(true);
33+
messages.setLayoutManager(new LinearLayoutManager(this));
34+
35+
sendButton.setOnClickListener(new View.OnClickListener() {
36+
@Override
37+
public void onClick(View v) {
38+
Chat chat = new Chat(name, messageEdit.getText().toString());
39+
ref.push().setValue(chat);
40+
messageEdit.setText("");
41+
}
42+
});
43+
44+
FirebaseRecyclerViewAdapter<Chat, ChatHolder> adapter = new FirebaseRecyclerViewAdapter<Chat, ChatHolder>(Chat.class, android.R.layout.two_line_list_item, ChatHolder.class, ref) {
45+
@Override
46+
public void populateViewHolder(ChatHolder chatView, Chat chat) {
47+
chatView.messageText.setText(chat.getMessage());
48+
chatView.messageText.setPadding(10, 0, 10, 0);
49+
chatView.nameText.setText(chat.getName());
50+
chatView.nameText.setPadding(10, 0, 10, 15);
51+
if (chat.getName().equals(name)) {
52+
chatView.messageText.setGravity(Gravity.END);
53+
chatView.nameText.setGravity(Gravity.END);
54+
chatView.nameText.setTextColor(Color.parseColor("#8BC34A"));
55+
} else {
56+
chatView.nameText.setTextColor(Color.parseColor("#00BCD4"));
57+
}
58+
}
59+
};
60+
61+
messages.setAdapter(adapter);
62+
63+
}
64+
65+
66+
static class Chat {
67+
String name;
68+
String message;
69+
70+
public Chat() {
71+
}
72+
73+
public Chat(String name, String message) {
74+
this.name = name;
75+
this.message = message;
76+
}
77+
78+
public String getName() {
79+
return name;
80+
}
81+
82+
public String getMessage() {
83+
return message;
84+
}
85+
}
86+
87+
static class ChatHolder extends RecyclerView.ViewHolder {
88+
TextView nameText, messageText;
89+
90+
public ChatHolder(View itemView) {
91+
super(itemView);
92+
nameText = (TextView) itemView.findViewById(android.R.id.text2);
93+
messageText = (TextView) itemView.findViewById(android.R.id.text1);
94+
}
95+
}
96+
}
Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,40 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
32
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
43
xmlns:tools="http://schemas.android.com/tools"
54
android:layout_width="match_parent"
65
android:layout_height="match_parent"
76
tools:context=".RecyclerViewDemoActivity">
87

9-
<ListView
10-
android:id="@android:id/list"
11-
android:layout_width="fill_parent"
8+
<android.support.v7.widget.RecyclerView
9+
android:layout_width="wrap_content"
1210
android:layout_height="wrap_content"
11+
android:id="@+id/messagesList"
12+
android:layout_alignParentLeft="true"
13+
android:layout_alignParentStart="true"
1314
android:layout_alignParentTop="true"
14-
android:transcriptMode="alwaysScroll" />
15+
android:layout_above="@+id/linearLayout" />
16+
17+
<LinearLayout
18+
android:orientation="horizontal"
19+
android:layout_width="match_parent"
20+
android:layout_height="wrap_content"
21+
android:layout_alignParentLeft="true"
22+
android:layout_alignParentStart="true"
23+
android:layout_alignParentBottom="true"
24+
android:id="@+id/linearLayout">
25+
26+
<EditText
27+
android:layout_width="wrap_content"
28+
android:layout_height="wrap_content"
29+
android:id="@+id/messageEdit"
30+
android:layout_weight="1" />
31+
32+
<Button
33+
android:layout_width="wrap_content"
34+
android:layout_height="wrap_content"
35+
android:text="Send"
36+
android:id="@+id/sendButton"
37+
android:layout_gravity="bottom|right" />
38+
</LinearLayout>
1539

1640
</RelativeLayout>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<resources>
2-
<string name="app_name">FirebaseUI-Android</string>
2+
<string name="app_name">FirebaseUI Chat</string>
33
</resources>

library/library.iml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
6666
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
6767
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
68-
<excludeFolder url="file://$MODULE_DIR$/build/docs" />
6968
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
7069
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
7170
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />

0 commit comments

Comments
 (0)