Skip to content

Commit bb9245d

Browse files
committed
Clean unnecessary code and update README.md
1 parent 5d997d5 commit bb9245d

6 files changed

Lines changed: 74 additions & 104 deletions

File tree

README.md

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,72 @@ Port Firebase Java SDK to Python
1111
## Usage
1212
### Android gradle project
1313
```groovy
14-
implementation 'io.github.simplejnius:sjfirebase:0.3.4'
14+
implementation 'io.github.simplejnius:sjfirebase:1.0.0'
15+
implementation 'com.google.firebase:firebase-auth'
16+
implementation 'com.google.firebase:firebase-database'
17+
implementation 'com.google.firebase:firebase-firestore'
18+
implementation 'com.google.firebase:firebase-storage'
19+
implementation 'com.google.firebase:firebase-analytics'
1520
```
1621
### Buildozer Android project
1722
```properties
18-
android.gradle_dependencies = io.github.simplejnius:sjfirebase:0.3.4
23+
android.gradle_dependencies = io.github.simplejnius:sjfirebase:1.0.0,
24+
com.google.firebase:firebase-auth,com.google.firebase:firebase-database,
25+
com.google.firebase:firebase-firestore,com.google.firebase:firebase-storage,
26+
com.google.firebase:firebase-analytics
1927
```
28+
#### Python(Buildozer) installation
29+
```shell
30+
# pip
31+
pip install sjfirebase
32+
33+
# buildozer.spec
34+
requirements = sjfirebase
35+
```
36+
### Java API
37+
#### SJFirebaseAuthEmail
38+
```java
39+
public class com.simplejnius.sjfirebase.SJFirebaseAuthEmail
40+
```
41+
The entry point of the Firebase Authentication SDK.
42+
First, obtain an instance of this class by calling `get_instance`
43+
(**NOTE** ignore `getInstance` on firebase documentation).
44+
45+
**methods**
46+
- check_user_signed_in
47+
- get_instance
48+
##### Visit [FirebaseAuth Documentation](https://firebase.google.com/docs/reference/android/com/google/firebase/auth/FirebaseAuth) for more API
49+
50+
#### SJFirebaseDatabase
51+
```java
52+
public class com.simplejnius.sjfirebase.SJFirebaseDatabase
53+
```
54+
The entry point for accessing a Firebase Database.
55+
You can get an instance by calling getInstance.
56+
To access a location in the database and read or write data, use `get_ref`
57+
(**NOTE** ignore `getReference` on firebase documentation).
58+
59+
**methods**
60+
- get_db
61+
- get_ref
62+
##### Visit [FirebaseDatabase Documentation](https://firebase.google.com/docs/reference/android/com/google/firebase/database/FirebaseDatabase) for more API
63+
64+
#### SJFirebaseFirestore
65+
```java
66+
public class com.simplejnius.sjfirebase.SJFirebaseFirestore
67+
```
68+
69+
**methods**
70+
- get_db
71+
##### Visit [FirebaseFirestore Documentation](https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FirebaseFirestore) for more API
72+
73+
#### SJFirebaseUser
74+
Represents a user's profile information in your Firebase project's user database.
75+
It also contains helper methods to change or retrieve profile information,
76+
as well as to manage that user's authentication state.
77+
(**NOTE** ignore `getCurrentUser` on firebase documentation and use `get_current_user`).
78+
79+
**methods**
80+
- get_current_user
81+
- profile_change_request_builder
82+
##### Visit [FirebaseUser Documentation](https://firebase.google.com/docs/reference/android/com/google/firebase/auth/FirebaseUser) for more API

buildSrc/src/main/java/Coordinates.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ object AppCoordinates {
88
}
99

1010
object LibraryAndroidCoordinates {
11-
const val LIBRARY_VERSION = "0.3.4"
11+
const val LIBRARY_VERSION = "1.0.0"
1212
const val LIBRARY_VERSION_CODE = 1
1313
}
1414

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ android.useAndroidX=true
1919
android.enableJetifier=true
2020
# Kotlin code style for this project: "official" or "obsolete":
2121
# kotlin.code.style=official
22-
version=0.3.4
22+
version=1.0.0
2323
# kotlin.stdlib.jdk.variants.substitution=false
2424

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.simplejnius.sjfirebase;
22

3-
import com.google.android.gms.tasks.OnCompleteListener;
4-
import com.google.firebase.auth.AuthResult;
53
import com.google.firebase.auth.FirebaseAuth;
64
import com.google.firebase.auth.FirebaseUser;
75

@@ -14,10 +12,6 @@ public static FirebaseAuth get_instance() {
1412
return m_auth;
1513
}
1614

17-
public static String get_uid() {
18-
return m_auth.getUid();
19-
}
20-
2115
public static boolean check_user_signed_in() {
2216
// Check if user is signed in (non-null) and update UI accordingly.
2317
FirebaseUser current_user = m_auth.getCurrentUser();
@@ -27,16 +21,4 @@ public static boolean check_user_signed_in() {
2721
}
2822
return false;
2923
}
30-
31-
public static void create_user_with_email_and_password(
32-
String email, String password, OnCompleteListener<AuthResult> callback) {
33-
m_auth.createUserWithEmailAndPassword(email, password)
34-
.addOnCompleteListener(callback);
35-
}
36-
37-
public static void sign_in_with_email_and_password(
38-
String email, String password, OnCompleteListener<AuthResult> callback) {
39-
m_auth.signInWithEmailAndPassword(email, password)
40-
.addOnCompleteListener(callback);
41-
}
4224
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
package com.simplejnius.sjfirebase;
22

3+
import com.google.firebase.database.DatabaseReference;
34
import com.google.firebase.database.FirebaseDatabase;
45

56
public class SJFirebaseDatabase {
67
public static FirebaseDatabase get_db() {
78
return FirebaseDatabase.getInstance();
89
}
10+
11+
public static DatabaseReference get_ref() {
12+
return get_db().getReference();
13+
}
914
}
Lines changed: 2 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
package com.simplejnius.sjfirebase;
22

3-
import android.net.Uri;
4-
5-
import com.google.android.gms.tasks.OnCompleteListener;
6-
import com.google.firebase.auth.ActionCodeSettings;
7-
import com.google.firebase.auth.AuthCredential;
8-
import com.google.firebase.auth.EmailAuthProvider;
93
import com.google.firebase.auth.FirebaseAuth;
104
import com.google.firebase.auth.FirebaseUser;
115
import com.google.firebase.auth.UserProfileChangeRequest;
@@ -16,81 +10,7 @@ public static FirebaseUser get_current_user() {
1610
return FirebaseAuth.getInstance().getCurrentUser();
1711
}
1812

19-
public static void update_profile(String name, String photo_url, OnCompleteListener<Void> callback) {
20-
// [START update_profile]
21-
UserProfileChangeRequest.Builder profile_updates = new UserProfileChangeRequest.Builder();
22-
UserProfileChangeRequest user_profile_change_request;
23-
24-
if (photo_url == null) {
25-
user_profile_change_request = profile_updates.setDisplayName(name).build();
26-
} else if (name == null) {
27-
user_profile_change_request = profile_updates.setPhotoUri(Uri.parse(photo_url)).build();
28-
} else {
29-
user_profile_change_request = profile_updates.setDisplayName(name)
30-
.setPhotoUri(Uri.parse(photo_url))
31-
.build();
32-
}
33-
34-
get_current_user().updateProfile(user_profile_change_request)
35-
.addOnCompleteListener(callback);
36-
// [END update_profile]
37-
}
38-
39-
public static void update_email(String email, OnCompleteListener<Void> callback) {
40-
get_current_user().updateEmail(email)
41-
.addOnCompleteListener(callback);
42-
}
43-
44-
public static void send_email_verification(OnCompleteListener<Void> callback) {
45-
// [START send_email_verification]
46-
get_current_user().sendEmailVerification()
47-
.addOnCompleteListener(callback);
48-
// [END send_email_verification]
49-
}
50-
51-
public static void send_email_verification_with_continue_url(
52-
String app_package_name, String url, OnCompleteListener<Void> callback) {
53-
// [START send_email_verification_with_continue_url]
54-
ActionCodeSettings actionCodeSettings = ActionCodeSettings.newBuilder()
55-
.setUrl(url)
56-
.setIOSBundleId(app_package_name)
57-
// The default for this is populated with the current android package name.
58-
.setAndroidPackageName(app_package_name, false, null)
59-
.build();
60-
61-
get_current_user().sendEmailVerification(actionCodeSettings)
62-
.addOnCompleteListener(callback);
63-
}
64-
65-
public static void send_password_reset_email(String email, OnCompleteListener<Void> callback) {
66-
// [START send_password_reset]
67-
FirebaseAuth auth = FirebaseAuth.getInstance();
68-
69-
auth.sendPasswordResetEmail(email)
70-
.addOnCompleteListener(callback);
71-
// [END send_password_reset]
72-
}
73-
74-
public static void deleteUser(OnCompleteListener<Void> callback) {
75-
// [START delete_user]
76-
77-
get_current_user().delete()
78-
.addOnCompleteListener(callback);
79-
// [END delete_user]
80-
}
81-
82-
public static void reauthenticate(String email, String password, OnCompleteListener<Void> callback) {
83-
// [START reauthenticate]
84-
85-
// Get auth credentials from the user for re-authentication. The example below shows
86-
// email and password credentials but there are multiple possible providers,
87-
// such as GoogleAuthProvider or FacebookAuthProvider.
88-
AuthCredential credential = EmailAuthProvider
89-
.getCredential(email, password);
90-
91-
// Prompt the user to re-provide their sign-in credentials
92-
get_current_user().reauthenticate(credential)
93-
.addOnCompleteListener(callback);
94-
// [END reauthenticate]
13+
public static UserProfileChangeRequest.Builder profile_change_request_builder() {
14+
return new UserProfileChangeRequest.Builder();
9515
}
9616
}

0 commit comments

Comments
 (0)