1 package org
.libreoffice
;
3 import android
.app
.AlertDialog
;
4 import android
.app
.Dialog
;
5 import android
.content
.DialogInterface
;
6 import android
.os
.Bundle
;
7 import androidx
.annotation
.NonNull
;
8 import androidx
.annotation
.Nullable
;
9 import androidx
.fragment
.app
.DialogFragment
;
10 import android
.view
.LayoutInflater
;
11 import android
.view
.View
;
12 import android
.view
.ViewGroup
;
13 import android
.widget
.EditText
;
15 public class PasswordDialogFragment
extends DialogFragment
{
17 private LibreOfficeMainActivity mContext
;
21 public Dialog
onCreateDialog(Bundle savedInstanceState
) {
22 AlertDialog
.Builder builder
= new AlertDialog
.Builder(getActivity());
23 LayoutInflater inflater
= getActivity().getLayoutInflater();
25 final View dialogView
= inflater
.inflate(R
.layout
.password_dialog
, null);
27 builder
.setView(dialogView
)
28 .setPositiveButton(R
.string
.action_pwd_dialog_OK
, new DialogInterface
.OnClickListener() {
30 public void onClick(DialogInterface dialog
, int which
) {
31 String pwd
= ((EditText
)dialogView
.findViewById(R
.id
.password
)).getText().toString();
32 mContext
.savePassword(pwd
);
35 .setNegativeButton(R
.string
.action_pwd_dialog_cancel
, new DialogInterface
.OnClickListener() {
37 public void onClick(DialogInterface dialog
, int which
) {
38 mContext
.savePassword(null);
40 }).setTitle(R
.string
.action_pwd_dialog_title
);
42 return builder
.create();
47 public View
onCreateView(LayoutInflater inflater
, @Nullable ViewGroup container
, @Nullable Bundle savedInstanceState
) {
48 getDialog().setCanceledOnTouchOutside(false);
50 return super.onCreateView(inflater
, container
, savedInstanceState
);
53 public void setLOMainActivity(LibreOfficeMainActivity context
) {