.
This commit is contained in:
@@ -41,6 +41,11 @@ dependencies {
|
||||
// This is due to new api's in java which are not available in android's lower version
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
|
||||
|
||||
// socket IO for chat
|
||||
implementation ('io.socket:socket.io-client:1.0.0') {
|
||||
exclude group: 'org.json', module: 'json'
|
||||
}
|
||||
|
||||
implementation 'com.google.firebase:firebase-crashlytics:18.3.2'
|
||||
implementation 'com.google.firebase:firebase-analytics:21.2.0'
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:usesCleartextTraffic="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.app.simplitend.caregiverdashboard.activities;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -7,7 +8,12 @@ import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.app.simplitend.apputils.AppUtil;
|
||||
import com.app.simplitend.caregiverdashboard.mvvm.CaregiverMainViewModel;
|
||||
import com.app.simplitend.caregiverdashboard.mvvm.CgHomeContracts;
|
||||
import com.app.simplitend.caregiverdashboard.mvvm.models.GeoFenceDetails;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.app.simplitend.R;
|
||||
import com.app.simplitend.apputils.CaregiverDataCache;
|
||||
@@ -16,20 +22,28 @@ import com.app.simplitend.databinding.ActivityCgProfileProgressBinding;
|
||||
import com.app.simplitend.welcome.welcomecg.mvvm.CareGiverData;
|
||||
|
||||
import static com.app.simplitend.caregiverdashboard.activities.PatientProfileShowerActivity.*;
|
||||
import static com.app.simplitend.cg_geofencing.CgGeoFencingActivity.GEOFENCE_DETAILS_KEY;
|
||||
|
||||
public class CgProfileProgressActivity extends AppCompatActivity {
|
||||
public class CgProfileProgressActivity extends AppCompatActivity implements CgHomeContracts.GetGeoFenceCallback {
|
||||
|
||||
// view binding
|
||||
protected ActivityCgProfileProgressBinding binding;
|
||||
|
||||
private CareGiverData careGiverData;
|
||||
|
||||
private CaregiverMainViewModel viewModel;
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivityCgProfileProgressBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
viewModel = new ViewModelProvider(this).get(CaregiverMainViewModel.class);
|
||||
progressDialog = new ProgressDialog(this);
|
||||
|
||||
startAnimation();
|
||||
|
||||
new Handler().postDelayed(() -> {
|
||||
@@ -68,8 +82,15 @@ public class CgProfileProgressActivity extends AppCompatActivity {
|
||||
});
|
||||
|
||||
binding.geoFencing.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(this, CgGeoFencingActivity.class);
|
||||
startActivity(intent);
|
||||
progressDialog.setTitle("please wait...");
|
||||
progressDialog.setMessage("while we load GeoFence.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
viewModel.getGeoFenceDetails("",
|
||||
careGiverData.caregiver_xid + "",
|
||||
"Bearer " + AppUtil.getCgToken(this),
|
||||
this);
|
||||
});
|
||||
|
||||
binding.medicReminder.setOnClickListener(v -> {
|
||||
@@ -104,4 +125,26 @@ public class CgProfileProgressActivity extends AppCompatActivity {
|
||||
intent.putExtra(WHICH_FRAGMENT, which_f);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGeofenceDetailsFetched(GeoFenceDetails geoFenceDetails) {
|
||||
progressDialog.dismiss();
|
||||
try {
|
||||
Intent intent = new Intent(this, CgGeoFencingActivity.class);
|
||||
intent.putExtra(GEOFENCE_DETAILS_KEY, geoFenceDetails);
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGeofenceDetailsFetchFailed(Throwable throwable, String message) {
|
||||
progressDialog.dismiss();
|
||||
try {
|
||||
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class PatientMainViewModel extends ViewModel {
|
||||
if (ContextCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_BACKGROUND_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
Log.d(GEOFENCE_TAG, "setGeofence: REQUESTING BACKGROUND LOCATION PERMISSION" );
|
||||
AppUtil.showSOSDecision(activity,
|
||||
"Testing content\nWe understand your privacy.\nTo enable Geofencing we need to access your location while the app is closed.\nKindly click on the Settings button below and select \"Allow all the time\"",
|
||||
"To enable caregivers to receive notifications even when the app is closed, go to the settings menu and select allow all the time",
|
||||
"Settings", "No thanks", view -> {
|
||||
// No thanks click
|
||||
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.ACCESS_BACKGROUND_LOCATION}, LOCATION_REQUEST_CODE);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.app.simplitend.patient_dashboard.chats;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -10,20 +11,24 @@ import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.app.simplitend.R;
|
||||
import com.app.simplitend.databinding.ChatFragmentBinding;
|
||||
import com.app.simplitend.patient_dashboard.chats.mvvm.Author;
|
||||
import com.app.simplitend.patient_dashboard.chats.mvvm.Message;
|
||||
import com.app.simplitend.patient_dashboard.chats.mvvm.Receiver;
|
||||
import com.app.simplitend.databinding.ChatFragmentBinding;
|
||||
import com.stfalcon.chatkit.messages.MessagesListAdapter;
|
||||
|
||||
public class ChatFragment extends Fragment {
|
||||
import io.socket.emitter.Emitter;
|
||||
|
||||
public class ChatFragment extends Fragment implements Emitter.Listener {
|
||||
|
||||
private static final String TAG = "SOCKET_CHAT_TAG";
|
||||
|
||||
// view binding
|
||||
protected ChatFragmentBinding binding;
|
||||
|
||||
public static final String CHAT_ITEM_KEY = "chat_item_key";
|
||||
|
||||
private MessagesListAdapter<Message> messageAdapter;
|
||||
protected MessagesListAdapter<Message> messageAdapter;
|
||||
|
||||
public ChatFragment() {
|
||||
// required
|
||||
@@ -34,7 +39,27 @@ public class ChatFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = ChatFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
socketConnection();
|
||||
SocketHelper socketHelper = SocketHelper.getInstance();
|
||||
socketHelper.establishConnection();
|
||||
|
||||
socketHelper.joinChatRoom("BILAL", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.d(TAG, "ROOM JOINED AS BILAL");
|
||||
}
|
||||
});
|
||||
|
||||
socketHelper.getMessage(new SocketHelper.Callback<Object>() {
|
||||
@Override
|
||||
public void onSuccess(Object result) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
initViews();
|
||||
|
||||
@@ -43,8 +68,16 @@ public class ChatFragment extends Fragment {
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
private void socketConnection() {
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
SocketHelper.getInstance().closeConnection();
|
||||
SocketHelper.getInstance().leaveChatRoom("BILAL", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.d(TAG, "LEAVED ROOM AS ADITYA");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
@@ -55,17 +88,14 @@ public class ChatFragment extends Fragment {
|
||||
});
|
||||
|
||||
binding.sendBtn.setOnClickListener(v -> {
|
||||
if (!binding.messageEt.getText().toString().trim().isEmpty()){
|
||||
messageAdapter.addToStart(new Message(new Author(), binding.messageEt.getText().toString().trim()), true);
|
||||
binding.messageEt.setText(null);
|
||||
}
|
||||
SocketHelper.getInstance().sendMessage("Hi there", "Bilal");
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
|
||||
binding.chatTitle.setText("Aditya");
|
||||
binding.chatTitle.setText("BILAL");
|
||||
|
||||
MessagesListAdapter.HoldersConfig holdersConfig = new MessagesListAdapter.HoldersConfig();
|
||||
holdersConfig.setOutcomingLayout(R.layout.sender_msg_viewholder);
|
||||
@@ -85,4 +115,9 @@ public class ChatFragment extends Fragment {
|
||||
messageAdapter.addToStart(new Message(new Author(), "Good morning"), true);
|
||||
messageAdapter.addToStart(new Message(new Receiver(), "Good morning mate!"), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(Object... args) {
|
||||
Log.d(TAG, "call: " + args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.app.simplitend.patient_dashboard.chats;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONArray;
|
||||
|
||||
import io.socket.client.IO;
|
||||
import io.socket.client.Socket;
|
||||
import io.socket.emitter.Emitter;
|
||||
|
||||
public class SocketHelper {
|
||||
|
||||
private static final String TAG = "SOCKET_CHAT_TAG";
|
||||
|
||||
private static final String kHost = "http://77.68.102.23:3002/";
|
||||
private static final String kConnectUser = "connectUser";
|
||||
private static final String kUserList = "userList";
|
||||
private static final String kExitUser = "exitUser";
|
||||
|
||||
private static SocketHelper instance;
|
||||
private Socket mSocket;
|
||||
|
||||
private SocketHelper() {
|
||||
try {
|
||||
IO.Options options = new IO.Options();
|
||||
options.forceNew = true;
|
||||
options.reconnection = true;
|
||||
mSocket = IO.socket(kHost, options);
|
||||
|
||||
mSocket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||
@Override
|
||||
public void call(Object... args) {
|
||||
Log.d(TAG, "Socket connected ");
|
||||
}
|
||||
});
|
||||
|
||||
mSocket.on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
|
||||
@Override
|
||||
public void call(Object... args) {
|
||||
Log.d(TAG, "Socket disconnected ");
|
||||
}
|
||||
});
|
||||
|
||||
mSocket.on(Socket.EVENT_CONNECT_ERROR, new Emitter.Listener() {
|
||||
@Override
|
||||
public void call(Object... args) {
|
||||
Exception e = (Exception) args[0];
|
||||
Log.e(TAG, "call: ", e);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "SocketHelper: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized SocketHelper getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new SocketHelper();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void establishConnection() {
|
||||
if (!mSocket.connected()) {
|
||||
mSocket.connect();
|
||||
}
|
||||
}
|
||||
|
||||
public void closeConnection() {
|
||||
if (mSocket.connected()) {
|
||||
mSocket.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
public void joinChatRoom(String nickname, final Runnable completion) {
|
||||
mSocket.emit(kConnectUser, nickname);
|
||||
completion.run();
|
||||
}
|
||||
|
||||
public void leaveChatRoom(String nickname, final Runnable completion) {
|
||||
mSocket.emit(kExitUser, nickname);
|
||||
completion.run();
|
||||
}
|
||||
|
||||
public void getMessage(final Callback<Object> callback) {
|
||||
mSocket.on("newChatMessage", new Emitter.Listener() {
|
||||
@Override
|
||||
public void call(Object... args) {
|
||||
if (args.length >= 3) {
|
||||
String nickName = (String) args[0];
|
||||
String message = (String) args[1];
|
||||
String date = (String) args[2];
|
||||
|
||||
Log.d(TAG, " Message received " + message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void sendMessage(String message, String nickname) {
|
||||
mSocket.emit("chatMessage", nickname, message);
|
||||
}
|
||||
|
||||
public interface Callback<T> {
|
||||
void onSuccess(T result);
|
||||
void onError(Exception e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,9 +217,8 @@ public class CgRegisterFragment extends Fragment implements WelcomeContracts.Reg
|
||||
});
|
||||
|
||||
binding.tncBtn.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(getString(R.string.terms_n_conditions_link)));
|
||||
startActivity(intent);
|
||||
AppUtil.openLink(requireActivity(), getString(R.string.terms_n_conditions_link),
|
||||
getString(R.string.terms_conditions_));
|
||||
});
|
||||
|
||||
binding.pwdInfo.setOnClickListener(v -> {
|
||||
|
||||
@@ -155,16 +155,19 @@ public class AddContactFragment extends Fragment implements WelcomeContracts.Con
|
||||
@Override
|
||||
public void onContactClick(ContactData contactData, int position) {
|
||||
|
||||
if (contacts_count == 9 && !is_doctor_set){
|
||||
// last contact to be added
|
||||
// and doctor not yet set
|
||||
Toast.makeText(requireContext(), "Contact is reserved for doctor, Please add medical information.", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (contactData.id == -1){
|
||||
// a new contact should be added
|
||||
|
||||
if (contacts_count == 9 && !is_doctor_set){
|
||||
// last contact to be added
|
||||
// and doctor not yet set
|
||||
AppUtil.showAlert(requireContext(),
|
||||
"This contact is reserved",
|
||||
"Contact is reserved for your primary doctor, Please add medical information.",
|
||||
getString(R.string.ok), ((dialogInterface, i) -> {}), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
AppUtil.showAlert(requireContext(),
|
||||
"Select contact",
|
||||
"Add from contacts or manually?",
|
||||
|
||||
@@ -27,12 +27,6 @@ import androidx.fragment.app.FragmentManager;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.github.dhaval2404.imagepicker.ImagePicker;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.google.i18n.phonenumbers.PhoneNumberUtil;
|
||||
import com.google.i18n.phonenumbers.Phonenumber;
|
||||
import com.skydoves.powerspinner.PowerSpinnerView;
|
||||
import com.app.simplitend.R;
|
||||
import com.app.simplitend.apputils.AppUtil;
|
||||
import com.app.simplitend.databinding.CreateContactViewHolderBinding;
|
||||
@@ -42,6 +36,12 @@ import com.app.simplitend.welcome.welcomepatient.fragments.contacts.mvvm.Contact
|
||||
import com.app.simplitend.welcome.welcomepatient.fragments.contacts.mvvm.models.ContactData;
|
||||
import com.app.simplitend.welcome.welcomepatient.fragments.contacts.mvvm.models.ContactListResponse;
|
||||
import com.app.simplitend.welcome.welcomepatient.mvvm.WelcomeContracts;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.github.dhaval2404.imagepicker.ImagePicker;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.google.i18n.phonenumbers.PhoneNumberUtil;
|
||||
import com.google.i18n.phonenumbers.Phonenumber;
|
||||
import com.skydoves.powerspinner.PowerSpinnerView;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -199,7 +199,11 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
String[] phone_numbers = getAllPhoneNumbers();
|
||||
|
||||
if (!phone_numbers[3].equals("0")) {
|
||||
Toast.makeText(requireContext(), "Please select a default contact.", Toast.LENGTH_SHORT).show();
|
||||
AppUtil.showAlert(requireContext(),
|
||||
"Select a default number",
|
||||
"Your contact has multiple phone numbers. Please set one as the default. All numbers will be saved in the contact, and you will still be able to access them.",
|
||||
getString(R.string.ok),
|
||||
(dialogInterface, i) -> {}, null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -228,9 +228,8 @@ public class RegisterFragment extends Fragment implements WelcomeContracts.Verif
|
||||
});
|
||||
|
||||
binding.tncBtn.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(getString(R.string.terms_n_conditions_link)));
|
||||
startActivity(intent);
|
||||
AppUtil.openLink(requireActivity(), getString(R.string.terms_n_conditions_link),
|
||||
getString(R.string.terms_conditions_));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -495,6 +495,7 @@
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
|
||||
Reference in New Issue
Block a user