diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index b0dd519..abe8b81 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -12,7 +12,7 @@ - + diff --git a/app/src/main/java/com/app/simplitend/apputils/AppUtil.java b/app/src/main/java/com/app/simplitend/apputils/AppUtil.java index cefb5cb..f9c31d5 100644 --- a/app/src/main/java/com/app/simplitend/apputils/AppUtil.java +++ b/app/src/main/java/com/app/simplitend/apputils/AppUtil.java @@ -12,12 +12,15 @@ import static com.app.simplitend.patientgeofencing.GeoFenceHelper.GEOFENCE_TAG; import android.Manifest; import android.app.Activity; -import android.app.AlertDialog; +import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.graphics.drawable.InsetDrawable; import android.location.Address; import android.location.Geocoder; import android.net.Uri; @@ -25,6 +28,7 @@ import android.os.Handler; import android.util.Log; import android.view.LayoutInflater; import android.view.View; +import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; import android.widget.Toast; @@ -35,6 +39,7 @@ import androidx.annotation.RawRes; import com.app.simplitend.R; import com.app.simplitend.appblocking.TopAppDetectionService; import com.app.simplitend.articles.ArticleShowerActivity; +import com.app.simplitend.databinding.AlertDialogBinding; import com.app.simplitend.databinding.BottomSheetAlertBinding; import com.app.simplitend.databinding.DecisionBottomsheetBinding; import com.app.simplitend.databinding.DoneBottomsheetBinding; @@ -173,19 +178,73 @@ public abstract class AppUtil { @NonNull String positiveText, @NonNull DialogInterface.OnClickListener positiveClickListener, String negativeText, DialogInterface.OnClickListener negativeClickListener) { - AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context); + AlertDialogBinding binding = AlertDialogBinding.inflate(LayoutInflater.from(context)); + Dialog dialog = new Dialog(context); + dialog.setContentView(binding.getRoot()); - alertBuilder.setTitle(title); - alertBuilder.setMessage(message); - - alertBuilder.setPositiveButton(positiveText, positiveClickListener /* Call back*/); - - if (negativeText != null && negativeClickListener != null) { - // Negative button - alertBuilder.setNegativeButton(negativeText, negativeClickListener); + try { + ColorDrawable back = new ColorDrawable(Color.TRANSPARENT); + InsetDrawable inset = new InsetDrawable(back, 30); + dialog.getWindow().setBackgroundDrawable(inset); + } catch (Exception e) { + // do nothing } - alertBuilder.create().show(); // Showing alert dialog + try { + WindowManager.LayoutParams layoutParams = dialog.getWindow().getAttributes(); + layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; + layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT; + dialog.getWindow().setAttributes(layoutParams); + }catch (Exception e){ + // do nothing + } + + final DialogInterface DIALOG_INTERFACE = new DialogInterface() { + @Override + public void cancel() { + dialog.dismiss(); + } + + @Override + public void dismiss() { + dialog.dismiss(); + } + }; + + binding.title.setText(title); + binding.susbTitle.setText(message); + binding.positiveBtn.setText(positiveText); + binding.positiveBtn.setOnClickListener(v -> { + dialog.dismiss(); + positiveClickListener.onClick(DIALOG_INTERFACE, 0); + }); + + if (negativeText != null){ + binding.negativeBtn.setVisibility(View.VISIBLE); + binding.negativeBtn.setText(negativeText); + binding.negativeBtn.setOnClickListener(v -> { + dialog.dismiss(); + if (negativeClickListener != null){ + negativeClickListener.onClick(DIALOG_INTERFACE, 0); + } + }); + } + + dialog.show(); + +// AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context); +// +// alertBuilder.setTitle(title); +// alertBuilder.setMessage(message); +// +// alertBuilder.setPositiveButton(positiveText, positiveClickListener /* Call back*/); +// +// if (negativeText != null && negativeClickListener != null) { +// // Negative button +// alertBuilder.setNegativeButton(negativeText, negativeClickListener); +// } +// +// alertBuilder.create().show(); // Showing alert dialog } // fetches the country codes from the JSON file in raw directory diff --git a/app/src/main/res/layout/alert_dialog.xml b/app/src/main/res/layout/alert_dialog.xml new file mode 100644 index 0000000..e582c18 --- /dev/null +++ b/app/src/main/res/layout/alert_dialog.xml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0de1a6c..db34f88 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -477,8 +477,8 @@ Change Senior address: Confirm your pin - First name* - Enter your first name + Name* + Enter your name > Frequently used apps]]> Don\'t show this Next medication schedule: diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 37283cf..f75e711 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -23,6 +23,7 @@