This commit is contained in:
14Sandee
2024-01-04 20:59:10 +05:30
parent 2e8390fbea
commit 876881dabc
9 changed files with 254 additions and 11 deletions

View File

@@ -1,6 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<targetSelectedWithDropDown>
<Target>
<type value="QUICK_BOOT_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="$USER_HOME$/.android/avd/Pixel_7_Pro_API_33.avd" />
</Key>
</deviceKey>
</Target>
</targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2024-01-04T14:57:20.954289Z" />
<targetsSelectedWithDialog>
<Target>
<type value="QUICK_BOOT_TARGET" />

View File

@@ -8,7 +8,7 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <!-- For app blocking -> open new window over other apps to deny access -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <!-- permissions for app blocking -->
<uses-permission
android:name="android.permission.PACKAGE_USAGE_STATS"
@@ -16,13 +16,12 @@
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission
android:name="android.permission.WRITE_SECURE_SETTINGS"
tools:ignore="ProtectedPermissions" />
<!-- for retrieving all the apps having launcher screen-->
tools:ignore="ProtectedPermissions" /> <!-- for retrieving all the apps having launcher screen -->
<queries>
<intent>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent>
</queries>
@@ -39,11 +38,15 @@
android:theme="@style/Theme.SimpliTend"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".welcome.activities.NewUpdateActivity"
android:exported="false"
android:screenOrientation="portrait"/>
<activity
android:name=".chats.ChatsActivity"
android:exported="false"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:exported="false" />
android:screenOrientation="portrait" />
<activity
android:name=".apputils.BottomNotificationActivity"
android:exported="false"
@@ -233,10 +236,11 @@
android:foregroundServiceType="location" />
<receiver android:name=".patientgeofencing.PatientLocationUpdatesReceiver" />
<receiver android:name=".apputils.BootCompleteReceiver"
<receiver
android:name=".apputils.BootCompleteReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>

View File

@@ -16,6 +16,11 @@ public class BootCompleteReceiver extends BroadcastReceiver {
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
if (!AppUtil.isPatientLoggedIn(context)){
// no senior is logged in
return;
}
AppUtil.updateSeniorOutOfGeofence(context, false);
// starting over the Location updates service again

View File

@@ -0,0 +1,33 @@
package com.app.simplitend.welcome.activities;
import android.os.Bundle;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import com.app.simplitend.BuildConfig;
import com.app.simplitend.databinding.ActivityNewUpdateBinding;
import com.app.simplitend.welcome.welcomepatient.mvvm.models.NewUpdate;
public class NewUpdateActivity extends AppCompatActivity {
public static final String IS_MANDATORY_UPDATE = "is_mandatory_update";
protected ActivityNewUpdateBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityNewUpdateBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
boolean isMandatoryUpdate = getIntent().getBooleanExtra(IS_MANDATORY_UPDATE, false);
if (isMandatoryUpdate){
binding.skipBtn.setVisibility(View.GONE);
}else{
binding.skipBtn.setVisibility(View.VISIBLE);
}
}
}

View File

@@ -1,5 +1,6 @@
package com.app.simplitend.welcome.welcomepatient.fragments.register;
import static com.app.simplitend.welcome.activities.NewUpdateActivity.IS_MANDATORY_UPDATE;
import static com.app.simplitend.welcome.welcomecg.fragments.CgConnectFragment.CAREGIVER_EMAIL;
import static com.app.simplitend.welcome.welcomepatient.fragments.register.ReActivateFragment.CG_STATUS_KEY;
import static com.app.simplitend.welcome.welcomepatient.fragments.register.ReActivateFragment.CG_XID_KEY;
@@ -20,6 +21,7 @@ import androidx.fragment.app.Fragment;
import androidx.navigation.NavOptions;
import androidx.navigation.Navigation;
import com.app.simplitend.BuildConfig;
import com.app.simplitend.R;
import com.app.simplitend.apputils.AppUtil;
import com.app.simplitend.apputils.CaregiverDataCache;
@@ -31,17 +33,21 @@ import com.app.simplitend.databinding.SplashFragmentBinding;
import com.app.simplitend.patient_dashboard.DashBoardActivity;
import com.app.simplitend.patientprofile.PatientProfileAPIService;
import com.app.simplitend.patientprofile.ProfileContracts;
import com.app.simplitend.welcome.activities.NewUpdateActivity;
import com.app.simplitend.welcome.welcomecg.WelcomeApiService;
import com.app.simplitend.welcome.welcomecg.WelcomeContracts;
import com.app.simplitend.welcome.welcomecg.fragments.CgAuthActivity;
import com.app.simplitend.welcome.welcomecg.mvvm.CareGiverData;
import com.app.simplitend.welcome.welcomepatient.mvvm.models.CallResponse;
import com.app.simplitend.welcome.welcomepatient.mvvm.models.NewUpdate;
import com.app.simplitend.welcome.welcomepatient.mvvm.models.PatientData;
import com.onesignal.OneSignal;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.http.GET;
import retrofit2.http.Query;
public class SplashFragment extends Fragment
implements ProfileContracts.ProfileProgressCallback,
@@ -56,7 +62,7 @@ public class SplashFragment extends Fragment
binding = SplashFragmentBinding.inflate(inflater, container, false);
binding.retry.setOnClickListener(v -> {
checkIfAhyUser();
checkNewUpdates();
});
return binding.getRoot();
@@ -65,7 +71,71 @@ public class SplashFragment extends Fragment
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
checkIfAhyUser();
checkNewUpdates();
}
private void checkNewUpdates() {
binding.retry.setVisibility(View.GONE);
binding.loadAnim.setVisibility(View.VISIBLE);
NewUpdatesApiService apiService = RetrofitHelper.getRetrofit().create(NewUpdatesApiService.class);
apiService.checkNewUpdates(2)
.enqueue(new Callback<CallResponse<NewUpdate>>() {
@Override
public void onResponse(Call<CallResponse<NewUpdate>> call, Response<CallResponse<NewUpdate>> response) {
if (response.body() != null) {
if (response.code() != 200 || response.body().error_code != 0){
onFailure(call, new Exception("Response code is " + response.code() + " error code is " + response.body().error_code));
return;
}
if (response.body().result == null){
onFailure(call, new Exception("Received result is null"));
return;
}
if (BuildConfig.VERSION_CODE < response.body().result.new_version){
// current version is less than latest version
// update is required
Intent intent = new Intent(requireActivity(), NewUpdateActivity.class);
if (BuildConfig.VERSION_CODE < response.body().result.force_update_version) {
// current version is less than forced latest version
// update is mandatory
intent.putExtra(IS_MANDATORY_UPDATE, true);
}else{
// current version is greater than or equal to force update version
// thus, this update can be skipped
intent.putExtra(IS_MANDATORY_UPDATE, false);
}
try {
startActivity(intent);
requireActivity().finish();
} catch (Exception e) {
// do nothing
onFailure(call, e);
}
}else{
// current version is equal to latest version
// no update is required
checkIfAhyUser();
}
} else {
onFailure(call, new Exception("Response body is null"));
}
}
@Override
public void onFailure(Call<CallResponse<NewUpdate>> call, Throwable t) {
Toast.makeText(requireContext(), "Couldn't connect.", Toast.LENGTH_SHORT).show();
binding.retry.setVisibility(View.VISIBLE);
binding.loadAnim.setVisibility(View.GONE);
}
});
}
private void checkIfAhyUser() {
@@ -315,4 +385,11 @@ public class SplashFragment extends Fragment
binding.retry.setVisibility(View.VISIBLE);
binding.loadAnim.setVisibility(View.GONE);
}
// new update api
interface NewUpdatesApiService{
@GET("api/auth/get-version-history")
Call<CallResponse<NewUpdate>> checkNewUpdates(@Query("device") int deviceId);
}
}

View File

@@ -0,0 +1,16 @@
package com.app.simplitend.welcome.welcomepatient.mvvm.models;
import java.io.Serializable;
public class NewUpdate implements Serializable {
public int id;
public String version_id;
public String release_date;
public int old_version;
public int new_version;
public int force_update_version;
public int force_update;
public String release_notes;
public String created_at;
public String updated_at;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

View File

@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
>
<ImageView
android:id="@+id/imageView3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:scaleType="fitXY"
android:layout_marginTop="25dp"
app:layout_constraintHeight_percent="0.6"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/img_new_update" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/nunito_bold"
android:text="@string/new_update_available"
android:textColor="@color/black"
android:textSize="@dimen/_18ssp"
android:layout_marginTop="35dp"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView3" />
<TextView
android:id="@+id/sub_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/unlock_enhanced_features_and_improved_performance_with_our_latest_app_update"
android:textColor="@color/black"
android:fontFamily="@font/nunito_regular"
android:textSize="@dimen/_14ssp"
android:textAlignment="center"
android:layout_marginHorizontal="25dp"
android:layout_marginTop="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/title" />
<com.google.android.material.button.MaterialButton
android:id="@+id/materialButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="15dp"
android:layout_marginTop="35dp"
android:fontFamily="@font/nunito_bold"
android:paddingHorizontal="50dp"
android:paddingVertical="10dp"
android:text="@string/update_app"
android:textColor="@color/white"
android:textSize="@dimen/_14ssp"
app:cornerRadius="25dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/sub_title" />
<TextView
android:id="@+id/skip_btn"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/skip_underline"
android:textColor="@color/black"
android:textSize="@dimen/_14ssp"
android:fontFamily="@font/nunito_regular"
android:paddingVertical="5dp"
android:paddingHorizontal="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/materialButton"
app:layout_constraintVertical_bias="0.100" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -487,5 +487,9 @@
<string name="cancel">Cancel</string>
<string name="couldn_t_load_chats">Couldn\'t load chats</string>
<string name="couldn_t_load">Couldn\'t load</string>
<string name="new_update_available">New update available</string>
<string name="unlock_enhanced_features_and_improved_performance_with_our_latest_app_update">Unlock enhanced features and improved performance with our latest app update</string>
<string name="update_app">Update app</string>
<string name="skip_underline"><u>skip</u></string>
</resources>