Added more options to theme dialog

This commit is contained in:
M66B 2021-10-23 09:27:02 +02:00
parent cfd6eadf90
commit 8816da11d8
3 changed files with 36 additions and 2 deletions

View File

@ -3,11 +3,13 @@ package eu.faircode.email;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.RadioGroup;
import android.widget.TextView;
@ -27,6 +29,7 @@ public class FragmentDialogTheme extends FragmentDialogBase {
private SwitchCompat swBlack;
private SwitchCompat swHtmlLight;
private SwitchCompat swComposerLight;
private Button btnMore;
private TextView tvMore;
private void eval() {
@ -56,6 +59,9 @@ public class FragmentDialogTheme extends FragmentDialogBase {
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
Bundle args = getArguments();
boolean settings = (args != null && args.getBoolean("settings"));
final Context context = getContext();
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String theme = prefs.getString("theme", "blue_orange_system");
@ -70,6 +76,7 @@ public class FragmentDialogTheme extends FragmentDialogBase {
swBlack = dview.findViewById(R.id.swBlack);
swHtmlLight = dview.findViewById(R.id.swHtmlLight);
swComposerLight = dview.findViewById(R.id.swComposerLight);
btnMore = dview.findViewById(R.id.btnMore);
tvMore = dview.findViewById(R.id.tvMore);
rgTheme.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@ -191,6 +198,17 @@ public class FragmentDialogTheme extends FragmentDialogBase {
}
});
btnMore.setVisibility(settings ? View.GONE : View.VISIBLE);
btnMore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
v.getContext().startActivity(new Intent(v.getContext(), ActivitySetup.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
.putExtra("tab", "display"));
}
});
return new AlertDialog.Builder(getContext())
.setView(dview)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

View File

@ -293,7 +293,11 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
btnTheme.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new FragmentDialogTheme().show(getParentFragmentManager(), "setup:theme");
Bundle args = new Bundle();
args.putBoolean("settings", true);
FragmentDialogTheme dialog = new FragmentDialogTheme();
dialog.setArguments(args);
dialog.show(getParentFragmentManager(), "setup:theme");
}
});

View File

@ -175,6 +175,18 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swHtmlLight" />
<Button
android:id="@+id/btnMore"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:drawableEnd="@drawable/twotone_more_horiz_24"
android:drawablePadding="6dp"
android:text="@string/title_advanced_more"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swComposerLight" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvMore"
android:layout_width="wrap_content"
@ -184,6 +196,6 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorLink"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swComposerLight" />
app:layout_constraintTop_toBottomOf="@id/btnMore" />
</androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ScrollViewEx>