Change askForComprehensive dialog to use customlayout

This commit is contained in:
jacques 2023-07-14 12:29:52 +02:00
parent bffa1bc091
commit 3b84d41a44

View file

@ -1,7 +1,9 @@
package net.foucry.pilldroid; package net.foucry.pilldroid;
import android.app.Dialog;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -12,11 +14,11 @@ import android.view.WindowInsets;
import android.view.WindowInsetsController; import android.view.WindowInsetsController;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.PagerAdapter;
@ -134,14 +136,29 @@ public class WelcomeActivity extends AppCompatActivity {
} }
private void askForComprehensive() { private void askForComprehensive() {
AlertDialog.Builder dlg = new AlertDialog.Builder(this); final Dialog dlg = new Dialog(this);
dlg.setTitle(getString(R.string.app_name)); dlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
dlg.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
dlg.setMessage(R.string.understood); dlg.setContentView(R.layout.custodialoglayout);
dlg.setPositiveButton(R.string.Yes, (dialog, which) -> { dlg.setCancelable(false);
// Nothing to do just dismiss dialog TextView msg = dlg.findViewById(R.id.msg);
}); String msgString;
ImageView icon = dlg.findViewById(R.id.image);
Button btn = (Button)dlg.findViewById(R.id.txtClose);
dlg.show(); dlg.show();
msgString = getString(R.string.understood);
msg.setText(msgString);
icon.setImageResource(R.drawable.pilldroid_icon);
btn.setText(R.string.Yes);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
dlg.dismiss();
finish();
}
});
} }
private void addBottomDots(int currentPage) { private void addBottomDots(int currentPage) {