Added do not show again option for changelog

This commit is contained in:
M66B
2024-05-29 10:08:30 +02:00
parent 4b9de6f263
commit cc1c62ba8c
4 changed files with 51 additions and 11 deletions

View File

@@ -21,11 +21,16 @@ package eu.faircode.email;
import android.app.Dialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.Spanned;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageButton;
import android.widget.TextView;
@@ -33,6 +38,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.Group;
import androidx.core.text.method.LinkMovementMethodCompat;
import androidx.preference.PreferenceManager;
import java.io.InputStream;
@@ -43,14 +49,27 @@ public class FragmentDialogMarkdown extends FragmentDialogBase {
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
final View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_markdown, null);
final Context context = getContext();
String option = getArguments().getString("option");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
final View dview = LayoutInflater.from(context).inflate(R.layout.dialog_markdown, null);
final TextView tvMarkdown = dview.findViewById(R.id.tvMarkdown);
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
final ImageButton ibCancel = dview.findViewById(R.id.ibCancel);
final ContentLoadingProgressBar pbWait = dview.findViewById(R.id.pbWait);
final Group grpReady = dview.findViewById(R.id.grpReady);
tvMarkdown.setText(null);
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean checked) {
prefs.edit().putBoolean(option, !checked).apply();
}
});
ibCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -58,23 +77,22 @@ public class FragmentDialogMarkdown extends FragmentDialogBase {
}
});
Dialog dialog = new Dialog(getContext());
Dialog dialog = new Dialog(context);
//dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(dview);
dialog.getWindow().setLayout(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT);
new SimpleTask<Spanned>() {
@Override
protected void onPreExecute(Bundle args) {
grpReady.setVisibility(View.GONE);
cbNotAgain.setVisibility(View.GONE);
pbWait.setVisibility(View.VISIBLE);
}
@Override
protected void onPostExecute(Bundle args) {
grpReady.setVisibility(View.VISIBLE);
cbNotAgain.setVisibility(TextUtils.isEmpty(option) ? View.GONE : View.VISIBLE);
pbWait.setVisibility(View.GONE);
}
@@ -121,4 +139,10 @@ public class FragmentDialogMarkdown extends FragmentDialogBase {
return dialog;
}
}
@Override
public void onStart() {
super.onStart();
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
}
}