support features

This commit is contained in:
14Sandee
2023-12-20 19:29:57 +05:30
parent c549022c17
commit 1e85864467
25 changed files with 542 additions and 121 deletions

View File

@@ -1,6 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="RZCW41EJRPN" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2023-12-20T13:31:33.742284Z" />
<targetsSelectedWithDialog>
<Target>
<type value="QUICK_BOOT_TARGET" />

View File

@@ -44,6 +44,7 @@ import com.bumptech.glide.Glide;
import com.google.android.gms.location.GeofencingClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.onesignal.OneSignal;
import org.json.JSONArray;
import org.json.JSONObject;
@@ -381,7 +382,8 @@ public abstract class AppUtil {
public static final String WHITE_LISTED_CONTACTS = "white_listed_contacts";
public static final String NO_OF_NOTIFICATIONS = "no_of_notifications_cg";
public static final String NO_OF_NOTIFICATIONS = "no_of_notifications";
public static final String NO_OF_CHAT_NOTIFICATIONS = "no_of_chat_notifications";
public static void savePatientData(String token, int patient_uid, Context context, boolean isLoggedIn) {
SharedPreferences sp = context.getSharedPreferences(PATIENT_DETAILS, Context.MODE_PRIVATE);
@@ -414,6 +416,8 @@ public abstract class AppUtil {
public static void patientSignOut(Context context) {
clearAllNotifications(context);
clearAllChatNotificationsCount(context);
OneSignal.getNotifications().clearAllNotifications();
AppUtil.savePatientData(null, -1, context, false);
@@ -513,6 +517,8 @@ public abstract class AppUtil {
CaregiverDataCache.setCareGiverData(null);
clearAllNotifications(context);
clearAllChatNotificationsCount(context);
OneSignal.getNotifications().clearAllNotifications();
// setting up notification prefs default to yes
setCgNotificationPref(context, MEDICATIONS_NOTIFICATIONS, true);
@@ -546,6 +552,29 @@ public abstract class AppUtil {
return sp.getInt(NO_OF_NOTIFICATIONS, 0);
}
public static void incrementNoOfChatNotification(Context context){
SharedPreferences sp = context.getSharedPreferences(CAREGIVER_DETAILS, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.putInt(NO_OF_CHAT_NOTIFICATIONS, sp.getInt(NO_OF_CHAT_NOTIFICATIONS, 0) + 1);
editor.apply();
}
public static void clearAllChatNotificationsCount(Context context){
SharedPreferences sp = context.getSharedPreferences(CAREGIVER_DETAILS, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.putInt(NO_OF_CHAT_NOTIFICATIONS, 0);
editor.apply();
}
public static int getNoOfChatNotificationsCount(Context context){
SharedPreferences sp = context.getSharedPreferences(CAREGIVER_DETAILS, Context.MODE_PRIVATE);
return sp.getInt(NO_OF_CHAT_NOTIFICATIONS, 0);
}
// caregiver notification preference
public static final String MEDICATIONS_NOTIFICATIONS = "medications_notifications";
public static final String MEDICATION_REFILL_NOTIFICATIONS = "MEDICATION_REFILL_notifications";

View File

@@ -28,11 +28,11 @@ import com.app.simplitend.R;
import com.app.simplitend.caregiverdashboard.mvvm.CaregiverMainViewModel;
import com.app.simplitend.chats.ChatsActivity;
import com.app.simplitend.databinding.BottomSheetAlertBinding;
import com.app.simplitend.patient_dashboard.PatientMainViewModel;
import com.app.simplitend.patientprofile.medreminder.mvvm.models.ReminderResult;
import com.app.simplitend.patientprofile.setuproutine.mvvm.RoutineDetails;
import com.bumptech.glide.Glide;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.onesignal.OneSignal;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -45,24 +45,59 @@ public class BottomNotificationActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bottom_notification);
if (AppUtil.getCgToken(this) == null){
// no caregiver is logged in
finish();
return;
}
// to solve Android Oreo problem where we cannot set activity's orientation to portrait in the manifest
// if (android.os.Build.VERSION.SDK_INT != Build.VERSION_CODES.O) {
// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
// }
if (AppUtil.getCgToken(this) != null){
// handle caregiver bottom sheets
handleCaregiverBottomSheets();
}else{
handleSeniorBottomSheets();
}
View view = findViewById(R.id.bsa_tint);
if (view != null){
view.setOnClickListener(v -> {
finish();
});
}
}
private void handleSeniorBottomSheets() {
Intent intent = getIntent();
String content_type = intent.getStringExtra(CONTENT_TYPE_KEY);
int id = intent.getIntExtra(NOTIFICATION_CONTENT_ID_KEY, -1);
if (id != -1){
if (Constants.ACTIVITY_TIME.equals(content_type) && PatientMainViewModel.activityList != null) {
for (RoutineDetails routine : PatientMainViewModel.activityList) {
if (id == routine.id) {
intent.putExtra(Constants.ACTIVITY_EXTRA_KEY, routine);
break;
}
}
} else if (Constants.MEDICINE_TIME.equals(content_type) && PatientMainViewModel.remindersList != null) {
for (ReminderResult reminder : PatientMainViewModel.remindersList) {
if (id == reminder.id) {
intent.putExtra(Constants.REMINDER_EXTRA_KEY, reminder);
break;
}
}
}
}
try {
showSeniorBottomAlert(this, content_type, intent);
} catch (Exception e) {
// do nothing
}
}
private void handleCaregiverBottomSheets() {
Intent intent = getIntent();
String content_type = intent.getStringExtra(CONTENT_TYPE_KEY);
@@ -73,12 +108,14 @@ public class BottomNotificationActivity extends AppCompatActivity {
for (RoutineDetails routine : CaregiverMainViewModel.activityList) {
if (id == routine.id) {
intent.putExtra(Constants.ACTIVITY_EXTRA_KEY, routine);
break;
}
}
} else if (Constants.MEDICINE_TIME.equals(content_type) && CaregiverMainViewModel.remindersList != null) {
for (ReminderResult reminder : CaregiverMainViewModel.remindersList) {
if (id == reminder.id) {
intent.putExtra(Constants.REMINDER_EXTRA_KEY, reminder);
break;
}
}
} else if (Constants.MEDICATION_REFILL.equals(content_type) && CaregiverMainViewModel.remindersList != null) {
@@ -90,6 +127,7 @@ public class BottomNotificationActivity extends AppCompatActivity {
}
}
// caregiver logged in
CaregiverDataCache.getCaregiverData(this, careGiverData -> {
String patient_name = null;
if (careGiverData != null && careGiverData.patientDetails != null) {
@@ -99,7 +137,7 @@ public class BottomNotificationActivity extends AppCompatActivity {
}
try {
showBottomAlert(this,
showCgBottomAlert(this,
patient_name,
content_type,
intent);
@@ -109,7 +147,7 @@ public class BottomNotificationActivity extends AppCompatActivity {
}, false);
}
public void showBottomAlert(Context context,
public void showCgBottomAlert(Context context,
String patient_name,
@Nullable String content_type, Intent intent) throws Exception {
@@ -148,7 +186,7 @@ public class BottomNotificationActivity extends AppCompatActivity {
senior_distance = "Unable to locate";
}
setupBottomSheet(binding,
setUpCgBottomSheet(binding,
R.drawable.img_out_of_geo,
title, "Current location",
senior_distance, "Call senior",
@@ -202,7 +240,7 @@ public class BottomNotificationActivity extends AppCompatActivity {
// do nothing
}
setupBottomSheet(binding,
setUpCgBottomSheet(binding,
R.drawable.img_activity_time,
title, body,
routine_description, "Text senior", view -> {
@@ -243,7 +281,7 @@ public class BottomNotificationActivity extends AppCompatActivity {
// do nothing
}
setupBottomSheet(binding,
setUpCgBottomSheet(binding,
R.drawable.img_medication_time,
title, body,
description, "Text senior", view -> {
@@ -275,7 +313,7 @@ public class BottomNotificationActivity extends AppCompatActivity {
doh_distance = "Unable to locate";
}
setupBottomSheet(binding,
setUpCgBottomSheet(binding,
R.drawable.img_directioin_requested,
title, body,
doh_distance, "Call senior",
@@ -303,7 +341,7 @@ public class BottomNotificationActivity extends AppCompatActivity {
title = patient_name + " called the emergency number";
body = "Please contact " + patient_name;
setupBottomSheet(binding,
setUpCgBottomSheet(binding,
R.drawable.img_sos_requested,
title, body,
null, "Call senior",
@@ -345,7 +383,7 @@ public class BottomNotificationActivity extends AppCompatActivity {
// do nothing
}
setupBottomSheet(binding,
setUpCgBottomSheet(binding,
R.drawable.img_med_refill,
title, body,
refill_description, "Text senior", view -> {
@@ -367,7 +405,7 @@ public class BottomNotificationActivity extends AppCompatActivity {
// already returning
}
private void setupBottomSheet(BottomSheetAlertBinding binding,
private void setUpCgBottomSheet(BottomSheetAlertBinding binding,
int img_res,
String title, String description_title,
String description, String btn_text,
@@ -382,4 +420,135 @@ public class BottomNotificationActivity extends AppCompatActivity {
binding.btn.setText(btn_text);
binding.btn.setOnClickListener(btn_clickListener);
}
public void showSeniorBottomAlert(Context context, @Nullable String content_type, Intent intent) throws Exception {
if (content_type == null) return;
BottomSheetDialog bsd = new BottomSheetDialog(context, R.style.BottomSheetDialog);
BottomSheetAlertBinding binding = BottomSheetAlertBinding.inflate(LayoutInflater.from(context));
bsd.setContentView(binding.getRoot());
bsd.setOnDismissListener(dialogInterface -> {
BottomNotificationActivity.this.finish();
});
binding.close.setOnClickListener(v -> bsd.dismiss());
String title = intent.getStringExtra(NotificationService.NOTIFICATION_TITLE_KEY);
String body = intent.getStringExtra(NotificationService.NOTIFICATION_BODY_KEY);
switch (content_type) {
case Constants.ACTIVITY_TIME:
if (!getCgNotificationPref(context, ACTIVITY_NOTIFICATIONS)) {
// notifications are off by user
return;
}
String routine_description = null;
try {
RoutineDetails routine = (RoutineDetails) intent.getSerializableExtra(ACTIVITY_EXTRA_KEY);
if (routine != null) {
title = "Reminder";
String start_time, end_time;
try {
SimpleDateFormat input_sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
SimpleDateFormat output_sdf = new SimpleDateFormat("hh:mm a", Locale.getDefault());
Date start_date = input_sdf.parse(routine.routine_start_time);
Date end_date = input_sdf.parse(routine.routine_end_time);
start_time = output_sdf.format(Objects.requireNonNull(start_date));
end_time = output_sdf.format(Objects.requireNonNull(end_date));
} catch (Exception e) {
start_time = routine.routine_start_time;
end_time = routine.routine_end_time;
}
body = routine.routine_title;
routine_description = start_time + " - " + end_time;
}
} catch (Exception e) {
// do nothing
}
setUpSeniorBottomSheet(binding,
R.drawable.img_activity_time,
title, body,
routine_description, "Close", view -> {
bsd.dismiss();
finish();
});
bsd.show();
break;
case Constants.MEDICINE_TIME:
if (!getCgNotificationPref(context, MEDICATIONS_NOTIFICATIONS)) {
// notifications are off by user
return;
}
String description = null;
try {
ReminderResult reminder = (ReminderResult) intent.getSerializableExtra(REMINDER_EXTRA_KEY);
if (reminder != null) {
String med_time = AppUtil.formatDate("HH:mm:ss", "hh:mm a", reminder.medicine_time);
if (med_time == null){
med_time = reminder.medicine_time;
}
title = med_time + " Medication reminder:";
body = reminder.medicine_name + "\n" + reminder.medication_quantity;
try {
body += " " + reminder.medication_type.get(0).title;
} catch (Exception e) {
// do nothing
body += " unit";
}
if (reminder.medication_instruction == null)
reminder.medication_instruction = "None";
description = "Instructions: " + reminder.medication_instruction;
}
} catch (Exception e) {
// do nothing
}
setUpSeniorBottomSheet(binding,
R.drawable.img_medication_time,
title, body,
description, "Close", view -> {
bsd.dismiss();
finish();
});
bsd.show();
break;
}
}
private void setUpSeniorBottomSheet(BottomSheetAlertBinding binding,
int img_res,
String title, String description_title,
String description, String btn_text,
View.OnClickListener btn_clickListener) {
// binding.image.setImageResource(img_res);
Glide.with(binding.image)
.load(img_res)
.into(binding.image);
binding.title.setText(title);
binding.descriptionTitle.setText(description_title);
binding.description.setText(description);
binding.close.setVisibility(View.GONE);
binding.btn.setText(btn_text);
binding.btn.setOnClickListener(btn_clickListener);
}
}

View File

@@ -2,6 +2,8 @@ package com.app.simplitend.apputils;
import static android.content.Context.NOTIFICATION_SERVICE;
import static com.app.simplitend.apputils.AppUtil.NOTIFICATION_ACTION;
import static com.app.simplitend.apputils.Constants.ACTIVITY_TIME;
import static com.app.simplitend.apputils.Constants.MEDICINE_TIME;
import static com.app.simplitend.patientgeofencing.GeoFenceHelper.GEOFENCE_ID;
import static com.app.simplitend.patientgeofencing.GeoFenceHelper.GEOFENCE_TAG;
@@ -50,9 +52,6 @@ public class NotificationService implements INotificationServiceExtension {
public void onNotificationReceived(@NonNull INotificationReceivedEvent iNotificationReceivedEvent) {
// Log.d("aditya testing", "onNotificationReceived: " + iNotificationReceivedEvent.getNotification());
// increment notifications count
AppUtil.incrementNoOfNotification(iNotificationReceivedEvent.getContext());
// showing maximum 7 notifications due to the limitations enforced by manufacturers
// Thus, removing the oldest notification to show this new notification
NotificationManager notificationManager = (NotificationManager) iNotificationReceivedEvent.getContext().getSystemService(NOTIFICATION_SERVICE);
@@ -98,9 +97,15 @@ public class NotificationService implements INotificationServiceExtension {
}
if (Constants.CHATS_NOTIFICATIONS.equals(content_type)){
// keeping count of chat notifications
AppUtil.incrementNoOfChatNotification(iNotificationReceivedEvent.getContext());
// chat notifications doesn't need to be handled for bottom sheet
// or broadcasts
return;
}else{
// increment notifications count
AppUtil.incrementNoOfNotification(iNotificationReceivedEvent.getContext());
}
Intent intent = new Intent(iNotificationReceivedEvent.getContext(), BottomNotificationActivity.class);
@@ -112,15 +117,23 @@ public class NotificationService implements INotificationServiceExtension {
intent.putExtra(NOTIFICATION_CONTENT_ID_KEY, id);
intent.putExtra(NOTIFICATION_SENIOR_ADDRESS_KEY, senior_current_address);
// showing bottom sheet
try {
if (AppUtil.getCgToken(iNotificationReceivedEvent.getContext()) != null){
// only if caregiver is logged in
// when caregiver is logged in
iNotificationReceivedEvent.getContext().startActivity(intent);
}else{
// when patient is logged in
if (MEDICINE_TIME.equals(content_type) || ACTIVITY_TIME.equals(content_type)){
// Only for meds and activity reminders
iNotificationReceivedEvent.getContext().startActivity(intent);
}
}
} catch (Exception e) {
// do nothing
}
// sending local broadcast
Intent broadcastIntent = new Intent(NOTIFICATION_ACTION);
broadcastIntent.putExtra(CONTENT_TYPE_KEY, content_type);
broadcastIntent.putExtra(NOTIFICATION_BODY_KEY, iNotificationReceivedEvent.getNotification().getBody());

View File

@@ -7,12 +7,14 @@ import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import com.app.simplitend.R;
import com.app.simplitend.apputils.AppUtil;
import com.app.simplitend.apputils.CaregiverDataCache;
import com.app.simplitend.apputils.RetrofitHelper;
import com.app.simplitend.articles.ArticlesActivity;
@@ -29,12 +31,15 @@ import com.app.simplitend.databinding.CaregiverDashboardMenuBinding;
import com.app.simplitend.faqs.FAQ_Activity;
import com.app.simplitend.welcome.welcomecg.mvvm.CareGiverData;
import com.bumptech.glide.Glide;
import com.onesignal.OneSignal;
import com.onesignal.notifications.INotificationLifecycleListener;
import com.onesignal.notifications.INotificationWillDisplayEvent;
import com.yarolegovich.slidingrootnav.SlidingRootNavBuilder;
import com.yarolegovich.slidingrootnav.callback.DragStateListener;
public class CaregiverDashActivity extends AppCompatActivity implements
DragStateListener,
HomeBottomNav.OnBottomNavItemSelectListener {
HomeBottomNav.OnBottomNavItemSelectListener, INotificationLifecycleListener {
// view binding
protected CaregiverDashboardActivityBinding binding;
@@ -57,6 +62,8 @@ public class CaregiverDashActivity extends AppCompatActivity implements
watchSubscription();
}, true);
OneSignal.getNotifications().addForegroundLifecycleListener(this);
}
@Override
@@ -75,6 +82,8 @@ public class CaregiverDashActivity extends AppCompatActivity implements
setLayoutDetails();
}, true);
binding.bottomNav.updateChatNotificationCount(AppUtil.getNoOfChatNotificationsCount(this));
}
@Override
@@ -96,6 +105,7 @@ public class CaregiverDashActivity extends AppCompatActivity implements
protected void onDestroy() {
super.onDestroy();
SocketHelper.getInstance().closeConnection();
OneSignal.getNotifications().removeForegroundLifecycleListener(this);
}
private void initViews() {
@@ -267,6 +277,8 @@ public class CaregiverDashActivity extends AppCompatActivity implements
binding.toolbar.setTitle("Welcome " + first_name);
// updating chats count
binding.bottomNav.updateChatNotificationCount(AppUtil.getNoOfChatNotificationsCount(this));
} else if (selectedItem == MenuItem.MY_PATIENT) {
replaceFragment(MyPatientFragment.getInstance(), "my_patient");
@@ -277,6 +289,9 @@ public class CaregiverDashActivity extends AppCompatActivity implements
binding.toolbar.setTitle(null);
binding.toolbar.setNavigationIcon(AppCompatResources.getDrawable(this, R.drawable.ic_menu));
binding.toolbar.setNavigationIconTint(getResources().getColor(R.color.white));
// updating chats count
binding.bottomNav.updateChatNotificationCount(AppUtil.getNoOfChatNotificationsCount(this));
} else if (selectedItem == MenuItem.CHATS) {
if (careGiverData.link_id == null){
CaregiverDataCache.setCareGiverData(null); // to fetch new data with link id
@@ -316,4 +331,11 @@ public class CaregiverDashActivity extends AppCompatActivity implements
binding.bottomNav.setVisibility(View.GONE);
}
}
@Override
public void onWillDisplay(@NonNull INotificationWillDisplayEvent iNotificationWillDisplayEvent) {
runOnUiThread(() -> {
binding.bottomNav.updateChatNotificationCount(AppUtil.getNoOfChatNotificationsCount(this));
});
}
}

View File

@@ -16,7 +16,6 @@ import androidx.lifecycle.ViewModelProvider;
import com.app.simplitend.R;
import com.app.simplitend.apputils.AppUtil;
import com.app.simplitend.apputils.Constants;
import com.app.simplitend.chats.mvvm.Author;
import com.app.simplitend.chats.mvvm.ChatViewModel;
import com.app.simplitend.chats.mvvm.Message;
@@ -24,13 +23,12 @@ import com.app.simplitend.chats.mvvm.Receiver;
import com.app.simplitend.chats.mvvm.RemoteMessage;
import com.app.simplitend.databinding.ChatFragmentBinding;
import com.bumptech.glide.Glide;
import com.onesignal.OneSignal;
import com.onesignal.notifications.INotificationLifecycleListener;
import com.onesignal.notifications.INotificationWillDisplayEvent;
import com.stfalcon.chatkit.messages.MessagesListAdapter;
import com.stfalcon.chatkit.utils.DateFormatter;
import org.json.JSONObject;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
@@ -98,10 +96,10 @@ public class ChatFragment extends Fragment implements SocketHelper.Callback<Mess
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
binding = ChatFragmentBinding.inflate(inflater, container, false);
// OneSignal.getNotifications().addForegroundLifecycleListener(this);
chatViewModel = new ViewModelProvider(requireActivity()).get(ChatViewModel.class);
OneSignal.getNotifications().addForegroundLifecycleListener(this);
initViews();
clickEvents();
@@ -145,6 +143,16 @@ public class ChatFragment extends Fragment implements SocketHelper.Callback<Mess
return binding.getRoot();
}
@Override
public void onResume() {
super.onResume();
try {
AppUtil.clearAllChatNotificationsCount(requireContext());
} catch (Exception e) {
// do nothing
}
}
private void getChats() {
if (channel_id == null){
binding.noChats.setVisibility(View.VISIBLE);
@@ -172,7 +180,7 @@ public class ChatFragment extends Fragment implements SocketHelper.Callback<Mess
SocketHelper.getInstance().stopMessages(channel_id);
}
// OneSignal.getNotifications().removeForegroundLifecycleListener(this);
OneSignal.getNotifications().removeForegroundLifecycleListener(this);
}
private void clickEvents() {
@@ -372,14 +380,9 @@ public class ChatFragment extends Fragment implements SocketHelper.Callback<Mess
@Override
public void onWillDisplay(@NonNull INotificationWillDisplayEvent iNotificationWillDisplayEvent) {
JSONObject extras = iNotificationWillDisplayEvent.getNotification().getAdditionalData();
try {
if (extras == null) return;
if (Constants.CHATS_NOTIFICATIONS.equals(extras.getString("content_type"))){
iNotificationWillDisplayEvent.preventDefault();
}
}catch (Exception e){
AppUtil.clearAllChatNotificationsCount(requireContext());
} catch (Exception e) {
// do nothing
}
}

View File

@@ -2,13 +2,21 @@ package com.app.simplitend.chats;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import com.app.simplitend.R;
import com.app.simplitend.apputils.AppUtil;
import com.app.simplitend.apputils.CaregiverDataCache;
import com.app.simplitend.apputils.Constants;
import com.app.simplitend.apputils.RetrofitHelper;
import com.onesignal.OneSignal;
import com.onesignal.notifications.INotificationLifecycleListener;
import com.onesignal.notifications.INotificationWillDisplayEvent;
public class ChatsActivity extends AppCompatActivity {
import org.json.JSONObject;
public class ChatsActivity extends AppCompatActivity implements INotificationLifecycleListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -48,5 +56,37 @@ public class ChatsActivity extends AppCompatActivity {
}
}), true);
OneSignal.getNotifications().addForegroundLifecycleListener(this);
}
@Override
protected void onResume() {
super.onResume();
AppUtil.clearAllChatNotificationsCount(this);
}
@Override
protected void onDestroy() {
super.onDestroy();
OneSignal.getNotifications().removeForegroundLifecycleListener(this);
}
@Override
public void onWillDisplay(@NonNull INotificationWillDisplayEvent iNotificationWillDisplayEvent) {
// JSONObject extras = iNotificationWillDisplayEvent.getNotification().getAdditionalData();
//
// try {
// if (extras == null) return;
// if (Constants.CHATS_NOTIFICATIONS.equals(extras.getString("content_type"))){
// iNotificationWillDisplayEvent.preventDefault();
// }
// }catch (Exception e){
// // do nothing
// }
runOnUiThread(() -> {
AppUtil.clearAllChatNotificationsCount(this);
});
}
}

View File

@@ -21,7 +21,7 @@ public class HomeBottomNav extends FrameLayout {
private FloatingActionButton dashBtnBig, patientBig, chatsBig;
private LinearLayout dashSmall, patientSmall, chatsSmall;
private TextView chatWithTxt, myPatientTxt;
private TextView chatWithTxt, myPatientTxt, bottomNavigationCountTxt;
// fields
private MenuItem selected_item = MenuItem.DASHBOARD;
@@ -59,6 +59,8 @@ public class HomeBottomNav extends FrameLayout {
chatWithTxt = view.findViewById(R.id.chat_with);
myPatientTxt = view.findViewById(R.id.my_patient);
bottomNavigationCountTxt = view.findViewById(R.id.bottom_notification_count);
clickEvents();
}
@@ -89,6 +91,15 @@ public class HomeBottomNav extends FrameLayout {
this.itemSelectListener = itemSelectListener;
}
public void updateChatNotificationCount(int count){
if (count == 0) {
bottomNavigationCountTxt.setVisibility(GONE);
}else{
bottomNavigationCountTxt.setVisibility(VISIBLE);
bottomNavigationCountTxt.setText(count + "");
}
}
public void setMyPatient(String myPatient){
if (myPatient != null && myPatientTxt != null){
myPatientTxt.setText(myPatient);

View File

@@ -84,6 +84,8 @@ public class DashBoardActivity extends AppCompatActivity implements CgHomeContra
}
}
}).launch(Manifest.permission.READ_CONTACTS);
}
@Override

View File

@@ -58,8 +58,8 @@ public class PatientMainViewModel extends ViewModel {
public String ongoingActivityText, upcomingActivityText;
public String upcomingReminderText, dailyReminderText;
public List<ReminderResult> remindersList;
public List<RoutineDetails> activityList;
public static List<ReminderResult> remindersList;
public static List<RoutineDetails> activityList;
public PatientMainViewModel() {
cgHomeRepository = CgHomeRepository.getHomeRepository();

View File

@@ -184,7 +184,7 @@ public class PatientDashboardFragment extends Fragment implements ProfileContrac
try {
AppUtil.setWhiteListedContacts(requireContext(), contactList);
} catch (Exception e) {
throw new RuntimeException(e);
// do nothing
}
}
}), false);
@@ -242,6 +242,15 @@ public class PatientDashboardFragment extends Fragment implements ProfileContrac
}else {
binding.notificationCount.setVisibility(View.GONE);
}
// chats notifications count
int chatNotificationCount = AppUtil.getNoOfChatNotificationsCount(requireContext());
if (chatNotificationCount > 0){
binding.chatNotificationCount.setText(String.valueOf(chatNotificationCount));
binding.chatNotificationCount.setVisibility(View.VISIBLE);
}else {
binding.chatNotificationCount.setVisibility(View.GONE);
}
}
@Override
@@ -494,7 +503,7 @@ public class PatientDashboardFragment extends Fragment implements ProfileContrac
@Override
public void onRemindersListFetched(List<ReminderResult> reminderResult) {
viewModel.remindersList = reminderResult;
PatientMainViewModel.remindersList = reminderResult;
viewModel.getNearestReminder(reminderResult, this);
}
@@ -567,7 +576,7 @@ public class PatientDashboardFragment extends Fragment implements ProfileContrac
@Override
public void onRoutinesFetched(List<RoutineDetails> routineList) {
viewModel.activityList = routineList;
PatientMainViewModel.activityList = routineList;
viewModel.getNearestActivity(routineList, this);
}

View File

@@ -16,8 +16,10 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import com.app.simplitend.R;
import com.app.simplitend.apputils.AppUtil;
import com.app.simplitend.apputils.PatientDataCache;
import com.app.simplitend.caregiverdashboard.mvvm.CaregiverMainViewModel;
import com.app.simplitend.databinding.RemindersFragmentBinding;
import com.app.simplitend.patient_dashboard.PatientMainViewModel;
import com.app.simplitend.patientprofile.ProfileContracts;
import com.app.simplitend.patientprofile.medreminder.mvvm.ReminderAdapter;
import com.app.simplitend.patientprofile.medreminder.mvvm.ReminderViewModel;
@@ -333,6 +335,7 @@ public class ReminderFragment extends Fragment implements RecyclerTouchListener.
if (reminderViewModel.selected_dow == 0){
// only updating global list of reminders with current day's reminder list
CaregiverMainViewModel.remindersList = reminderResultList;
PatientMainViewModel.remindersList = reminderResultList;
}
binding.remindersRv.setVisibility(View.VISIBLE);

View File

@@ -20,6 +20,7 @@ import com.app.simplitend.R;
import com.app.simplitend.apputils.AppUtil;
import com.app.simplitend.caregiverdashboard.mvvm.CaregiverMainViewModel;
import com.app.simplitend.databinding.RoutineFragmentBinding;
import com.app.simplitend.patient_dashboard.PatientMainViewModel;
import com.app.simplitend.patientprofile.ProfileContracts;
import com.app.simplitend.patientprofile.medreminder.WeekDayViewHolder;
import com.app.simplitend.patientprofile.setuproutine.mvvm.RoutineAdapter;
@@ -346,6 +347,7 @@ public class RoutineFragment extends Fragment implements RoutineAdapter.ClickLis
// updating global list of activities for today's day
if (routineViewModel.selected_dow == 0) {
CaregiverMainViewModel.activityList = routineList;
PatientMainViewModel.activityList = routineList;
}
binding.routineRv.setVisibility(View.VISIBLE);

View File

@@ -73,8 +73,8 @@ public class CgOnBoardFragment extends Fragment {
// initiating view pager
CgOnBoardAdapter adapter = new CgOnBoardAdapter(requireActivity());
binding.viewPager.setAdapter(adapter);
binding.indicators.setViewPager(binding.viewPager);
binding.viewPager.setSaveEnabled(false);
binding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
@Override

View File

@@ -215,8 +215,8 @@ public class SignInFragment extends Fragment implements WelcomeContracts.Registe
} else if (patientResult.isCareGiverLink == 1){
gotoProfileProgress();
}else{
// no patient data or no caregiver contact yet added thus sending to contact list
gotoContactList();
// no patient data or no caregiver contact yet added thus sending to thank you page for adding caregiver details
gotoThankYouPage();
}
}
@@ -242,13 +242,13 @@ public class SignInFragment extends Fragment implements WelcomeContracts.Registe
.navigate(R.id.action_signInFragment_to_profileProgressFragment, null, navOptions);
}
private void gotoContactList(){
private void gotoThankYouPage(){
NavOptions navOptions = new NavOptions.Builder()
.setPopUpTo(R.id.welcomeFragment, true)
.build();
Navigation.findNavController(binding.getRoot())
.navigate(R.id.action_signInFragment_to_createContactFragment, null, navOptions);
.navigate(R.id.action_signInFragment_to_thankYouFragment, null, navOptions);
}
}

View File

@@ -54,5 +54,6 @@ public class SignInSignUpFragment extends Fragment {
onBoardPagerAdapter = new OnBoardPagerAdapter(getChildFragmentManager(), getLifecycle());
binding.viewPager.setAdapter(onBoardPagerAdapter);
binding.circleIndicator.setViewPager(binding.viewPager);
binding.viewPager.setSaveEnabled(false);
}
}

View File

@@ -154,7 +154,11 @@ public class ContactListFragment extends Fragment {
new Thread(() -> {
if (searchInput.isEmpty()) {
submitContactList(contactList);
try {
requireActivity().runOnUiThread(() -> submitContactList(contactList));
} catch (Exception e) {
// do nothing
}
return;
}

View File

@@ -382,9 +382,13 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
this.mustBeeCaregiver = true;
binding.caregiverCheck.setChecked(true);
// setting up title
// setting up title for caregiver details to be fetched
setLayoutDetails(getString(R.string.create_caregiver_contact), getString(R.string.add_photo), getString(R.string.save));
addContactView("", true);
if (contactData == null){
// user is here to add caregiver details manually
// thus, adding an empty field for input
addContactView("", true);
}
}
// checking if there is any SOS contact already in list

View File

@@ -299,13 +299,13 @@ public class SplashFragment extends Fragment
gotoPatientProfileProgress();
}else{
// user has not added caregiver contact.
// thus, sending it to contact list to add caregiver contact.
// thus, sending it to thank you screen to add caregiver contact.
NavOptions navOptions = new NavOptions.Builder()
.setPopUpTo(R.id.splashFragment, true)
.build();
Navigation.findNavController(binding.getRoot())
.navigate(R.id.action_splashFragment_to_createContactFragment, null, navOptions);
.navigate(R.id.action_splashFragment_to_thankYouFragment, null, navOptions);
}
}

View File

@@ -1,5 +1,7 @@
package com.app.simplitend.welcome.welcomepatient.fragments.register;
import static com.app.simplitend.welcome.welcomepatient.fragments.contacts.CreateContactFragment.TO_EDIT_KEY;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@@ -10,16 +12,17 @@ import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.navigation.Navigation;
import com.app.simplitend.R;
import com.app.simplitend.apputils.AppUtil;
import com.app.simplitend.databinding.ThankYouFragmentBinding;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.load.resource.gif.GifDrawable;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
import com.app.simplitend.R;
import com.app.simplitend.databinding.ThankYouFragmentBinding;
public class ThankYouFragment extends Fragment {
public class ThankYouFragment extends Fragment {
// view binding
protected ThankYouFragmentBinding binding;
@@ -61,9 +64,22 @@ public class ThankYouFragment extends Fragment {
}
private void clickEvents() {
binding.proceed.setOnClickListener(v ->
Navigation.findNavController(v).navigate(R.id.action_thankYouFragment_to_createContactFragment)
);
binding.proceed.setOnClickListener(v ->{
AppUtil.showAlert(requireContext(),
"Add caregiver contact",
"Add from phonebook contacts or manually?",
"Contacts",
((dialogInterface, i) -> {
Navigation.findNavController(binding.getRoot())
.navigate(R.id.action_thankYouFragment_to_contactListFragment);
}),
"Manually",
((dialogInterface, i) -> {
Navigation.findNavController(binding.getRoot())
.navigate(R.id.action_thankYouFragment_to_createContactFragment);
})
);
});
}
}

View File

@@ -93,57 +93,60 @@
</com.google.android.material.card.MaterialCardView>
<LinearLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:weightSum="2"
android:orientation="horizontal">
android:weightSum="2">
<Button
android:id="@+id/btn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:text="Call senior"
android:fontFamily="@font/nunito_regular"
android:textColor="@color/white"
android:textAllCaps="false"
android:textSize="@dimen/_16ssp"
app:cornerRadius="5dp"
android:paddingVertical="10dp"
android:maxLines="1"
android:ellipsize="end"
/>
android:fontFamily="@font/nunito_regular"
android:maxLines="1"
android:paddingVertical="10dp"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="@dimen/_16ssp"
app:cornerRadius="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/close"
app:layout_constraintStart_toStartOf="parent"
tools:text="Text senior" />
<Button
android:id="@+id/close"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/close_"
android:fontFamily="@font/nunito_regular"
android:textColor="@color/black"
android:textAllCaps="false"
android:textSize="@dimen/_16ssp"
app:cornerRadius="5dp"
android:paddingVertical="10dp"
android:text="@string/close_"
android:textAllCaps="false"
android:textColor="@color/black"
android:textSize="@dimen/_16ssp"
app:backgroundTint="@color/white"
android:layout_marginStart="15dp"
app:cornerRadius="5dp"
android:layout_marginStart="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/btn"
app:strokeColor="@color/color_accent"
app:strokeWidth="1dp"
app:strokeWidth="1dp" />
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

View File

@@ -65,7 +65,7 @@
android:background="@drawable/round_corners"
android:backgroundTint="@android:color/holo_red_light"
android:visibility="visible"
android:visibility="gone"
tools:text="9"
android:fontFamily="@font/nunito_regular"

View File

@@ -124,44 +124,86 @@
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:id="@+id/chats_small"
<RelativeLayout
android:id="@+id/notifications"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:visibility="visible">
android:layout_marginHorizontal="15dp"
>
<ImageView
android:layout_width="@dimen/_25sdp"
android:layout_height="@dimen/_25sdp"
android:contentDescription="@string/chat"
android:src="@drawable/ic_chats_outline"
app:tint="@color/black"
/>
<TextView
android:id="@+id/chat_with"
<LinearLayout
android:id="@+id/chats_small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:visibility="visible">
android:layout_marginTop="5sp"
android:fontFamily="@font/nunito_regular"
android:text="@string/chat"
tools:text="Chat with Suresh"
android:textColor="@color/black"
<RelativeLayout
android:layout_width="@dimen/_35sdp"
android:layout_height="@dimen/_25sdp"
>
android:maxLines="1"
android:ellipsize="end"
<ImageView
android:layout_width="@dimen/_25sdp"
android:layout_height="@dimen/_25sdp"
android:textSize="@dimen/_11ssp"
android:contentDescription="@string/chat"
android:src="@drawable/ic_chats_outline"
/>
app:tint="@color/black"
android:layout_centerInParent="true"
</LinearLayout>
/>
<TextView
android:id="@+id/bottom_notification_count"
android:layout_width="@dimen/_15sdp"
android:layout_height="@dimen/_15sdp"
android:background="@drawable/round_corners"
android:backgroundTint="@android:color/holo_red_light"
android:visibility="gone"
android:layout_alignParentEnd="true"
tools:text="9"
android:fontFamily="@font/nunito_regular"
android:textColor="@color/white"
android:textSize="11sp"
android:gravity="center"
android:layout_marginStart="7dp"
android:maxLength="2"
android:singleLine="true"
/>
</RelativeLayout>
<TextView
android:id="@+id/chat_with"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5sp"
android:fontFamily="@font/nunito_regular"
android:text="@string/chat"
tools:text="Chat with Suresh"
android:textColor="@color/black"
android:maxLines="1"
android:ellipsize="end"
android:textSize="@dimen/_11ssp"
/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>

View File

@@ -357,12 +357,44 @@
android:layout_marginVertical="15dp"
android:gravity="center">
<ImageView
android:layout_width="@dimen/_60sdp"
android:layout_height="@dimen/_60sdp"
android:contentDescription="@string/chats"
<RelativeLayout
android:layout_width="@dimen/_70sdp"
android:layout_height="wrap_content"
>
app:srcCompat="@drawable/img_chats"/>
<ImageView
android:layout_width="@dimen/_60sdp"
android:layout_height="@dimen/_60sdp"
android:contentDescription="@string/chats"
android:layout_centerInParent="true"
app:srcCompat="@drawable/img_chats"/>
<TextView
android:id="@+id/chat_notification_count"
android:layout_width="@dimen/_15sdp"
android:layout_height="@dimen/_15sdp"
android:background="@drawable/round_corners"
android:backgroundTint="@android:color/holo_red_light"
android:visibility="gone"
android:layout_alignParentEnd="true"
tools:text="9"
android:fontFamily="@font/nunito_regular"
android:textColor="@color/white"
android:textSize="11sp"
android:gravity="center"
android:layout_marginStart="7dp"
android:maxLength="2"
android:singleLine="true"
/>
</RelativeLayout>
<TextView
android:id="@+id/chat_with"

View File

@@ -48,8 +48,8 @@
android:id="@+id/action_signInFragment_to_reActivateFragment"
app:destination="@id/reActivateFragment" />
<action
android:id="@+id/action_signInFragment_to_createContactFragment"
app:destination="@id/createContactFragment" />
android:id="@+id/action_signInFragment_to_thankYouFragment"
app:destination="@id/thankYouFragment" />
</fragment>
<fragment
android:id="@+id/forgotPinFragment"
@@ -102,9 +102,13 @@
android:id="@+id/thankYouFragment"
android:name="com.app.simplitend.welcome.welcomepatient.fragments.register.ThankYouFragment"
android:label="ThankYouFragment" >
<action
android:id="@+id/action_thankYouFragment_to_createContactFragment"
app:destination="@id/createContactFragment" />
<action
android:id="@+id/action_thankYouFragment_to_contactListFragment"
app:destination="@id/contactListFragment" />
</fragment>
<fragment
android:id="@+id/contactListFragment"
@@ -214,8 +218,8 @@
android:id="@+id/action_splashFragment_to_reActivateFragment"
app:destination="@id/reActivateFragment" />
<action
android:id="@+id/action_splashFragment_to_createContactFragment"
app:destination="@id/createContactFragment" />
android:id="@+id/action_splashFragment_to_thankYouFragment"
app:destination="@id/thankYouFragment" />
</fragment>
<fragment
android:id="@+id/medicalInfoFragment"