add flutter

This commit is contained in:
Ariska
2026-03-11 15:29:37 +07:00
parent c253e1a370
commit 619d758027
9490 changed files with 135801 additions and 1353 deletions
Regular → Executable
View File
View File
+8 -8
View File
@@ -8,12 +8,12 @@ android {
// Use default debug keystore on this machine
}
}
compileSdk 33
compileSdk 34
defaultConfig {
applicationId "id.ontime.driver"
minSdkVersion 21
targetSdkVersion 33
minSdkVersion 23
targetSdkVersion 34
versionCode 10
versionName '1.1.0'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -55,11 +55,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.3'
implementation 'com.google.firebase:firebase-storage:20.0.0'
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'
View File
View File
View File
Vendored Regular → Executable
View File
View File
View File
View File
+26
View File
@@ -0,0 +1,26 @@
Alias name: ontimekeystore
Creation date: Oct 26, 2022
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Ontime Apps
Issuer: CN=Ontime Apps
Serial number: 39fdbb23
Valid from: Wed Oct 26 11:27:28 WIB 2022 until: Thu Oct 13 11:27:28 WIB 2072
Certificate fingerprints:
SHA1: DC:13:DA:DC:9F:5F:A8:AD:3A:6C:F7:1C:5C:94:55:BB:AD:2E:F6:10
SHA256: 73:17:40:D3:E1:63:4A:2E:AB:C1:BA:0A:65:BD:A4:77:A2:FB:CC:F5:46:C1:87:3D:AE:6D:87:4B:94:5C:2B:66
Signature algorithm name: SHA256withRSA
Subject Public Key Algorithm: 2048-bit RSA key
Version: 3
Extensions:
#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 04 8E EC F7 50 72 86 16 C2 AF 1C 2B A9 B4 63 47 ....Pr.....+..cG
0010: 71 55 24 44 qU$D
]
]
-1
View File
@@ -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.driver"
android:installLocation="auto">
<uses-permission android:name="android.permission.CALL_PHONE" />
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

@@ -1359,7 +1359,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);
@@ -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.driver.constants.BaseApp;
import id.ontime.driver.R;
import id.ontime.driver.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 != null ? email.getText().toString().trim() : "";
String phoneDigits = phoneText.getText().toString().trim();
@@ -490,13 +490,47 @@ 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);
// Enforce FCM token: login ONLY proceeds when we have a non-empty Firebase token.
// 1) Try to use token that was already stored in Realm (BaseApp / MessagingService.onNewToken).
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());
doLoginRequest(request, emailText);
return;
}
// 2) If not yet stored, request a fresh token from FirebaseMessaging.
try {
FirebaseMessaging.getInstance().getToken()
.addOnCompleteListener(task -> {
if (task.isSuccessful() && task.getResult() != null && !task.getResult().isEmpty()) {
String fcmToken = task.getResult();
request.setRegId(fcmToken);
// Persist so future logins can use the cached value.
realm.executeTransaction(r -> {
FirebaseToken t = new FirebaseToken(fcmToken);
r.delete(FirebaseToken.class);
r.copyToRealm(t);
});
doLoginRequest(request, emailText);
} else {
// Token is required: stop login and show message.
progresshide();
notif("Firebase token not ready, please check your network and try again.");
}
});
} catch (IllegalStateException e) {
// Firebase not initialized: block login instead of proceeding without token.
progresshide();
notif("Firebase is not initialized, cannot login. Please restart the app.");
}
}
private void doLoginRequest(LoginRequestJson request, String emailText) {
String basicUser = !TextUtils.isEmpty(emailText) ? emailText : request.getNotelepon();
DriverService service = ServiceGenerator.createService(DriverService.class, basicUser, request.getPassword());
service.login(request).enqueue(new Callback<LoginResponseJson>() {
@@ -372,6 +372,7 @@ public class MainActivity extends AppCompatActivity {
public void onLocationChanged(Location location) {
if (location != null) {
User loginUser = BaseApp.getInstance(this).getLoginUser();
if (loginUser == null) return;
DriverService service = ServiceGenerator.createService(DriverService.class, loginUser.getEmail(), loginUser.getPassword());
UpdateLocationRequestJson param = new UpdateLocationRequestJson();
@@ -379,6 +380,12 @@ public class MainActivity extends AppCompatActivity {
param.setLatitude(String.valueOf(location.getLatitude()));
param.setLongitude(String.valueOf(location.getLongitude()));
param.setBearing(String.valueOf(location.getBearing()));
// Include FCM token so backend always has latest reg_id for push notifications
io.realm.Realm realm = BaseApp.getInstance(this).getRealmInstance();
id.ontime.driver.models.FirebaseToken ft = realm.where(id.ontime.driver.models.FirebaseToken.class).findFirst();
if (ft != null && ft.getTokenId() != null && !ft.getTokenId().isEmpty()) {
param.setRegId(ft.getTokenId());
}
service.updatelocation(param).enqueue(new Callback<ResponseJson>() {
@Override
@@ -54,7 +54,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.driver.R;
import id.ontime.driver.constants.Constants;
import id.ontime.driver.json.JobResponseJson;
@@ -164,7 +164,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);
+27 -14
View File
@@ -16,8 +16,8 @@ import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.firebase.FirebaseApp;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.messaging.FirebaseMessaging;
import android.util.Log;
import id.ontime.driver.json.UpdateLocationRequestJson;
import id.ontime.driver.utils.MyLocationService;
import id.ontime.driver.utils.api.ServiceGenerator;
@@ -71,22 +71,29 @@ public class BaseApp extends Application {
// realmInstance = Realm.getInstance(config);
realmInstance = Realm.getDefaultInstance();
// Best-effort Firebase initialization and token registration for driver.
// If Firebase is not configured, ignore failures so the app can still run.
// FCM v1: async token fetch and topic subscribe (reference: test app).
try {
FirebaseApp app = FirebaseApp.initializeApp(this);
if (app != null) {
String fcmToken = FirebaseInstanceId.getInstance().getToken();
if (fcmToken != null) {
FirebaseToken token = new FirebaseToken(fcmToken);
FirebaseMessaging.getInstance().subscribeToTopic("ouride");
FirebaseMessaging.getInstance().subscribeToTopic("driver");
realmInstance.beginTransaction();
realmInstance.delete(FirebaseToken.class);
realmInstance.copyToRealm(token);
realmInstance.commitTransaction();
}
FirebaseMessaging.getInstance().getToken()
.addOnCompleteListener(task -> {
if (task.isSuccessful() && task.getResult() != null && !task.getResult().isEmpty()) {
String fcmToken = task.getResult();
Log.d("FCM_TOKEN", "BaseApp init token=" + fcmToken);
FirebaseToken token = new FirebaseToken(fcmToken);
FirebaseMessaging.getInstance().subscribeToTopic("ouride");
FirebaseMessaging.getInstance().subscribeToTopic("driver");
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();
@@ -160,6 +167,7 @@ public class BaseApp extends Application {
public void onLocationChanged(Location location) {
if (location != null) {
User loginUser = getLoginUser();
if (loginUser == null) return;
DriverService service = ServiceGenerator.createService(DriverService.class, loginUser.getEmail(), loginUser.getPassword());
UpdateLocationRequestJson param = new UpdateLocationRequestJson();
@@ -167,6 +175,11 @@ public class BaseApp extends Application {
param.setLatitude(String.valueOf(location.getLatitude()));
param.setLongitude(String.valueOf(location.getLongitude()));
param.setBearing(String.valueOf(location.getBearing()));
// Include FCM token so backend always has latest reg_id for push notifications
FirebaseToken ft = realmInstance.where(FirebaseToken.class).findFirst();
if (ft != null && ft.getTokenId() != null && !ft.getTokenId().isEmpty()) {
param.setRegId(ft.getTokenId());
}
service.updatelocation(param).enqueue(new Callback<ResponseJson>() {
@Override
@@ -6,6 +6,7 @@ import java.util.Locale;
public class Constants {
/** Test backend API base URL (api/, notification/send_generic, etc.). */
private static final String BASE_URL = "https://apitest.semestaterpadu.my.id/";
public static final String URL = "https://panic.on-time.id/"; //panicButton
public static final String CONNECTION = BASE_URL + "api/";

Some files were not shown because too many files have changed in this diff Show More