Skip to content

Commit 4aaa9fc

Browse files
committed
v0.3.2 add RxUser to control User profile setting.
1 parent 1dcfc2f commit 4aaa9fc

File tree

5 files changed

+95
-27
lines changed

5 files changed

+95
-27
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ buildscript {
2323
jcenter()
2424
}
2525
dependencies {
26-
classpath 'com.android.tools.build:gradle:2.3.0'
26+
classpath 'com.android.tools.build:gradle:2.3.1'
2727
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
2828
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
2929
// NOTE: Do not place your application dependencies here; they belong

rxfirebase/build.gradle

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
1+
/*
2+
* Copyright 2017 WBinaryTree
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
apply plugin: 'com.android.library'
218
apply plugin: 'com.github.dcendents.android-maven'
319
apply plugin: 'com.jfrog.bintray'
4-
version = '0.3.1'
20+
version = '0.3.2'
521
android {
622
compileSdkVersion 25
723
buildToolsVersion "25.0.2"
@@ -59,33 +75,15 @@ artifacts {
5975
archives javadocJar
6076
archives sourcesJar
6177
}
62-
group = "com.github.wbinarytree" /*
63-
* Copyright 2017 WBinaryTree
64-
*
65-
* Licensed under the Apache License, Version 2.0 (the "License");
66-
* you may not use this file except in compliance with the License.
67-
* You may obtain a copy of the License at
68-
*
69-
* http://www.apache.org/licenses/LICENSE-2.0
70-
*
71-
* Unless required by applicable law or agreed to in writing, software
72-
* distributed under the License is distributed on an "AS IS" BASIS,
73-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
74-
* See the License for the specific language governing permissions and
75-
* limitations under the License.
76-
*/ // Maven Group ID for the artifact,
78+
group = "com.github.wbinarytree"
7779
install {
7880
repositories.mavenInstaller {
79-
// This generates POM.xml with proper parameters
8081
pom {
8182
project {
8283
version
8384
packaging 'aar'
84-
// Add your description here
8585
name 'RxJava 2.x wrap for Firebase'
86-
//项目的描述 你可以多写一点
8786
url siteUrl
88-
// Set your license
8987
licenses {
9088
license {
9189
name 'The Apache Software License, Version 2.0'
@@ -94,7 +92,7 @@ install {
9492
}
9593
developers {
9694
developer {
97-
id 'wbinarytree' //填写的一些基本信息
95+
id 'wbinarytree'
9896
name 'Yaoda WANG'
9997
10098
}
@@ -116,17 +114,13 @@ bintray {
116114
configurations = ['archives']
117115
pkg {
118116
userOrg = 'phoenixwyd'
119-
//发布到Bintray的哪个仓库
120117
repo = 'maven'
121-
//发布到Bintray上的名字
122118
name = 'RxFirebase'
123-
//项目描述
124119
desc = 'A RxJava 2 wrap for firebase'
125120
websiteUrl = siteUrl
126121
vcsUrl = gitUrl
127122
issueTrackerUrl = issueUrl
128123
licenses = ["Apache-2.0"]
129-
//标签
130124
labels = ['android']
131125
publish = true
132126
publicDownloadNumbers = true

rxfirebase/src/main/java/phoenixlib/io/rxfirebase/auth/AuthStateObservable.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
import com.google.firebase.auth.FirebaseAuth;
2222
import com.google.firebase.auth.FirebaseUser;
23+
import com.google.firebase.auth.UserInfo;
24+
import com.google.firebase.auth.UserProfileChangeRequest;
2325

2426
import java.util.concurrent.atomic.AtomicBoolean;
2527

@@ -32,7 +34,7 @@
3234
* Created by phoenix on 2017/4/15.
3335
*/
3436

35-
class AuthStateObservable extends Observable<FirebaseUser> {
37+
public class AuthStateObservable extends Observable<FirebaseUser> {
3638

3739
private final FirebaseAuth auth;
3840

@@ -49,6 +51,7 @@ protected void subscribeActual(Observer<? super FirebaseUser> observer) {
4951
auth.addAuthStateListener(listener);
5052
}
5153

54+
5255
private static class AuthListener implements Disposable, FirebaseAuth.AuthStateListener {
5356

5457
private final Observer<? super FirebaseUser> observer;

rxfirebase/src/main/java/phoenixlib/io/rxfirebase/auth/RxAuth.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,13 @@ public static Observable<FirebaseUser> authState(FirebaseAuth auth) {
7272
return new AuthStateObservable(auth);
7373
}
7474

75+
public static Observable<AuthResult> createUser(final FirebaseAuth auth, final String email, final String password) {
76+
return new TaskObservable<>(new Callable<Task<AuthResult>>() {
77+
@Override
78+
public Task<AuthResult> call() throws Exception {
79+
return auth.createUserWithEmailAndPassword(email, password);
80+
}
81+
});
82+
}
83+
7584
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright 2017 WBinaryTree
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package phoenixlib.io.rxfirebase.auth;
18+
19+
import com.google.android.gms.tasks.Task;
20+
import com.google.firebase.auth.FirebaseUser;
21+
import com.google.firebase.auth.GetTokenResult;
22+
import com.google.firebase.auth.UserProfileChangeRequest;
23+
24+
import java.util.concurrent.Callable;
25+
26+
import io.reactivex.Completable;
27+
import io.reactivex.Observable;
28+
29+
/**
30+
* Created by phoenix on 2017/4/16.
31+
*/
32+
33+
public class RxUser {
34+
public static Completable updateUsername(final FirebaseUser user, final String username) {
35+
return new TaskObservable<>(new Callable<Task<Void>>() {
36+
@Override
37+
public Task<Void> call() throws Exception {
38+
return user.updateProfile(new UserProfileChangeRequest.Builder().setDisplayName(username)
39+
.build());
40+
}
41+
}).ignoreElements();
42+
}
43+
44+
public static Completable updateProfile(final FirebaseUser user, final UserProfileChangeRequest profile) {
45+
return new TaskObservable<>(new Callable<Task<Void>>() {
46+
@Override
47+
public Task<Void> call() throws Exception {
48+
return user.updateProfile(profile);
49+
}
50+
}).ignoreElements();
51+
}
52+
53+
public static Observable<GetTokenResult> getToken(final FirebaseUser user, final boolean refresh) {
54+
return new TaskObservable<>(new Callable<Task<GetTokenResult>>() {
55+
@Override
56+
public Task<GetTokenResult> call() throws Exception {
57+
return user.getToken(refresh);
58+
}
59+
});
60+
}
61+
62+
}

0 commit comments

Comments
 (0)