add flutter
This commit is contained in:
Regular → Executable
Regular → Executable
Regular → Executable
+8
-8
@@ -17,12 +17,12 @@ android {
|
||||
keyPassword '123456@ontime'
|
||||
}
|
||||
}
|
||||
compileSdk 33
|
||||
compileSdk 34
|
||||
|
||||
defaultConfig {
|
||||
applicationId "id.ontime.merchant"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 33
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 34
|
||||
versionCode 10
|
||||
versionName '1.1.0'
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
@@ -65,11 +65,11 @@ dependencies {
|
||||
implementation 'com.google.android.libraries.places:places:2.5.0'
|
||||
implementation 'com.google.android.gms:play-services-maps:18.0.2'
|
||||
implementation 'com.google.android.gms:play-services-auth:20.1.0'
|
||||
implementation 'com.google.firebase:firebase-database:20.0.4'
|
||||
implementation 'com.google.firebase:firebase-storage:20.0.1'
|
||||
implementation 'com.google.firebase:firebase-core:20.1.0'
|
||||
implementation 'com.google.firebase:firebase-messaging:20.2.0'
|
||||
implementation 'com.google.firebase:firebase-auth:19.3.1'
|
||||
implementation platform('com.google.firebase:firebase-bom:33.1.0')
|
||||
implementation 'com.google.firebase:firebase-database'
|
||||
implementation 'com.google.firebase:firebase-storage'
|
||||
implementation 'com.google.firebase:firebase-messaging'
|
||||
implementation 'com.google.firebase:firebase-auth'
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
||||
implementation 'com.google.android.material:material:1.5.0'
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
-1
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="id.ontime.merchant"
|
||||
android:installLocation="auto">
|
||||
|
||||
<uses-permission android:name="android.permission.CALL_PHONE" />
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+3
-1
@@ -1417,7 +1417,9 @@ public class ChatActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void sendMessageToDriver(final String regIDTujuan, final Chat chat) {
|
||||
|
||||
if (regIDTujuan == null || regIDTujuan.trim().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final FCMMessage message = new FCMMessage();
|
||||
message.setTo(regIDTujuan);
|
||||
message.setData(chat);
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+30
-7
@@ -31,8 +31,8 @@ import com.google.firebase.auth.FirebaseAuth;
|
||||
import com.google.firebase.auth.FirebaseAuthInvalidCredentialsException;
|
||||
import com.google.firebase.auth.PhoneAuthCredential;
|
||||
import com.google.firebase.auth.PhoneAuthProvider;
|
||||
import com.google.firebase.messaging.FirebaseMessaging;
|
||||
|
||||
import com.google.firebase.iid.FirebaseInstanceId;
|
||||
import id.ontime.merchant.constants.BaseApp;
|
||||
import id.ontime.merchant.R;
|
||||
import id.ontime.merchant.constants.Constants;
|
||||
@@ -478,7 +478,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
private void onSignInClick() {
|
||||
progressshow();
|
||||
LoginRequestJson request = new LoginRequestJson();
|
||||
final LoginRequestJson request = new LoginRequestJson();
|
||||
String emailText = email.getText().toString().trim();
|
||||
String phoneDigits = phoneText.getText().toString().trim();
|
||||
|
||||
@@ -490,13 +490,36 @@ public class LoginActivity extends AppCompatActivity {
|
||||
request.setNotelepon(countryCode.getText().toString().replace("+", "") + phoneDigits);
|
||||
}
|
||||
request.setPassword(password.getText().toString());
|
||||
try {
|
||||
FirebaseInstanceId token = FirebaseInstanceId.getInstance();
|
||||
request.setRegId(token.getToken());
|
||||
} catch (Exception e) {
|
||||
request.setRegId(null);
|
||||
|
||||
// FCM token is mandatory for login: use cached token if available, otherwise fetch a fresh one.
|
||||
io.realm.Realm realm = BaseApp.getInstance(this).getRealmInstance();
|
||||
FirebaseToken storedToken = realm.where(FirebaseToken.class).findFirst();
|
||||
if (storedToken != null && storedToken.getTokenId() != null && !storedToken.getTokenId().isEmpty()) {
|
||||
request.setRegId(storedToken.getTokenId());
|
||||
performLoginRequest(request, emailText);
|
||||
return;
|
||||
}
|
||||
|
||||
FirebaseMessaging.getInstance().getToken()
|
||||
.addOnCompleteListener(task -> {
|
||||
if (task.isSuccessful() && task.getResult() != null && !task.getResult().isEmpty()) {
|
||||
String fcmToken = task.getResult();
|
||||
request.setRegId(fcmToken);
|
||||
// Persist so subsequent logins can reuse without refetch.
|
||||
realm.executeTransaction(r -> {
|
||||
FirebaseToken t = new FirebaseToken(fcmToken);
|
||||
r.delete(FirebaseToken.class);
|
||||
r.copyToRealm(t);
|
||||
});
|
||||
performLoginRequest(request, emailText);
|
||||
} else {
|
||||
progresshide();
|
||||
notif("Firebase token not ready, please check your network and try again.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void performLoginRequest(final LoginRequestJson request, String emailText) {
|
||||
String basicUser = !TextUtils.isEmpty(emailText) ? emailText : request.getNotelepon();
|
||||
MerchantService service = ServiceGenerator.createService(MerchantService.class, basicUser, request.getPassword());
|
||||
service.login(request).enqueue(new Callback<LoginResponseJson>() {
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+7
-2
@@ -70,7 +70,7 @@ import com.google.firebase.auth.FirebaseAuthInvalidCredentialsException;
|
||||
import com.google.firebase.auth.FirebaseUser;
|
||||
import com.google.firebase.auth.PhoneAuthCredential;
|
||||
import com.google.firebase.auth.PhoneAuthProvider;
|
||||
import com.google.firebase.iid.FirebaseInstanceId;
|
||||
import com.google.firebase.messaging.FirebaseMessaging;
|
||||
import id.ontime.merchant.R;
|
||||
import id.ontime.merchant.constants.Constants;
|
||||
import id.ontime.merchant.models.FiturModel;
|
||||
@@ -174,7 +174,12 @@ public class RegisterActivity extends AppCompatActivity {
|
||||
rlnotif2 = findViewById(R.id.rlnotif2);
|
||||
textnotif2 = findViewById(R.id.textnotif2);
|
||||
confirmButton = findViewById(R.id.buttonconfirm);
|
||||
token = FirebaseInstanceId.getInstance().getToken();
|
||||
// FCM v1: async token via FirebaseMessaging.getToken()
|
||||
FirebaseMessaging.getInstance().getToken().addOnCompleteListener(task -> {
|
||||
if (task.isSuccessful() && task.getResult() != null && !task.getResult().isEmpty()) {
|
||||
token = task.getResult();
|
||||
}
|
||||
});
|
||||
numOne = findViewById(R.id.numone);
|
||||
numTwo = findViewById(R.id.numtwo);
|
||||
numThree = findViewById(R.id.numthree);
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+30
-13
@@ -3,7 +3,7 @@ package id.ontime.merchant.constants;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
import com.google.firebase.iid.FirebaseInstanceId;
|
||||
import com.google.firebase.FirebaseApp;
|
||||
import com.google.firebase.messaging.FirebaseMessaging;
|
||||
import id.ontime.merchant.models.FirebaseToken;
|
||||
import id.ontime.merchant.models.User;
|
||||
@@ -15,8 +15,8 @@ import io.realm.RealmConfiguration;
|
||||
|
||||
/**
|
||||
* Created by Ourdevelops Team on 10/13/2019.
|
||||
* FCM v1: async token and topic subscribe (reference: test app).
|
||||
*/
|
||||
|
||||
public class BaseApp extends Application {
|
||||
|
||||
private static final int SCHEMA_VERSION = 0;
|
||||
@@ -34,23 +34,40 @@ public class BaseApp extends Application {
|
||||
super.onCreate();
|
||||
|
||||
Realm.init(this);
|
||||
|
||||
RealmConfiguration config = new RealmConfiguration.Builder()
|
||||
.schemaVersion(SCHEMA_VERSION)
|
||||
.deleteRealmIfMigrationNeeded()
|
||||
.build();
|
||||
|
||||
FirebaseToken token = new FirebaseToken(FirebaseInstanceId.getInstance().getToken());
|
||||
FirebaseMessaging.getInstance().subscribeToTopic("ouride");
|
||||
FirebaseMessaging.getInstance().subscribeToTopic("mitra");
|
||||
Realm.setDefaultConfiguration(config);
|
||||
|
||||
// realmInstance = Realm.getInstance(config);
|
||||
realmInstance = Realm.getDefaultInstance();
|
||||
realmInstance.beginTransaction();
|
||||
realmInstance.delete(FirebaseToken.class);
|
||||
realmInstance.copyToRealm(token);
|
||||
realmInstance.commitTransaction();
|
||||
|
||||
try {
|
||||
FirebaseApp app = FirebaseApp.initializeApp(this);
|
||||
if (app != null) {
|
||||
FirebaseMessaging.getInstance().getToken()
|
||||
.addOnCompleteListener(task -> {
|
||||
if (task.isSuccessful() && task.getResult() != null && !task.getResult().isEmpty()) {
|
||||
String fcmToken = task.getResult();
|
||||
FirebaseToken token = new FirebaseToken(fcmToken);
|
||||
FirebaseMessaging.getInstance().subscribeToTopic("ouride");
|
||||
FirebaseMessaging.getInstance().subscribeToTopic("mitra");
|
||||
try {
|
||||
realmInstance.beginTransaction();
|
||||
realmInstance.delete(FirebaseToken.class);
|
||||
realmInstance.copyToRealm(token);
|
||||
realmInstance.commitTransaction();
|
||||
} catch (Exception e) {
|
||||
if (realmInstance.isInTransaction()) realmInstance.cancelTransaction();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
start();
|
||||
}
|
||||
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user