Added 'more options' to junk dialog

pull/199/head
M66B 4 years ago
parent a771d742cc
commit 44e4f0d473

@ -59,12 +59,15 @@ public class FragmentDialogJunk extends FragmentDialogBase {
final ImageButton ibInfoProvider = view.findViewById(R.id.ibInfoProvider); final ImageButton ibInfoProvider = view.findViewById(R.id.ibInfoProvider);
final CheckBox cbBlockSender = view.findViewById(R.id.cbBlockSender); final CheckBox cbBlockSender = view.findViewById(R.id.cbBlockSender);
final CheckBox cbBlockDomain = view.findViewById(R.id.cbBlockDomain); final CheckBox cbBlockDomain = view.findViewById(R.id.cbBlockDomain);
final ImageButton ibMore = view.findViewById(R.id.ibMore);
final TextView tvMore = view.findViewById(R.id.tvMore);
final Button btnEditRules = view.findViewById(R.id.btnEditRules); final Button btnEditRules = view.findViewById(R.id.btnEditRules);
final CheckBox cbJunkFilter = view.findViewById(R.id.cbJunkFilter); final CheckBox cbJunkFilter = view.findViewById(R.id.cbJunkFilter);
final ImageButton ibInfoFilter = view.findViewById(R.id.ibInfoFilter); final ImageButton ibInfoFilter = view.findViewById(R.id.ibInfoFilter);
final Group grpInJunk = view.findViewById(R.id.grpInJunk); final Group grpInJunk = view.findViewById(R.id.grpInJunk);
final Group grpMore = view.findViewById(R.id.grpMore);
tvMessage.setText(getString(R.string.title_ask_spam_who, from)); // Wire controls
ibInfoProvider.setOnClickListener(new View.OnClickListener() { ibInfoProvider.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -73,9 +76,6 @@ public class FragmentDialogJunk extends FragmentDialogBase {
} }
}); });
cbBlockSender.setEnabled(canBlock && ActivityBilling.isPro(getContext()));
cbBlockDomain.setEnabled(false);
cbBlockSender.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { cbBlockSender.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@ -83,6 +83,22 @@ public class FragmentDialogJunk extends FragmentDialogBase {
} }
}); });
View.OnClickListener onMore = new View.OnClickListener() {
@Override
public void onClick(View v) {
if (grpMore.getVisibility() == View.VISIBLE) {
ibMore.setImageLevel(1);
grpMore.setVisibility(View.GONE);
} else {
ibMore.setImageLevel(0);
grpMore.setVisibility(View.VISIBLE);
}
}
};
ibMore.setOnClickListener(onMore);
tvMore.setOnClickListener(onMore);
btnEditRules.setOnClickListener(new View.OnClickListener() { btnEditRules.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -192,7 +208,15 @@ public class FragmentDialogJunk extends FragmentDialogBase {
} }
}); });
// Initialize
tvMessage.setText(inJunk
? getString(R.string.title_folder_junk)
: getString(R.string.title_ask_spam_who, from));
cbBlockSender.setEnabled(canBlock && ActivityBilling.isPro(getContext()));
cbBlockDomain.setEnabled(false);
ibMore.setImageLevel(1);
grpInJunk.setVisibility(inJunk ? View.GONE : View.VISIBLE); grpInJunk.setVisibility(inJunk ? View.GONE : View.VISIBLE);
grpMore.setVisibility(inJunk ? View.VISIBLE : View.GONE);
new SimpleTask<Boolean>() { new SimpleTask<Boolean>() {
@Override @Override
@ -235,17 +259,20 @@ public class FragmentDialogJunk extends FragmentDialogBase {
} }
}.execute(FragmentDialogJunk.this, args, "junk:filter"); }.execute(FragmentDialogJunk.this, args, "junk:filter");
return new AlertDialog.Builder(getContext()) AlertDialog.Builder builder = new AlertDialog.Builder(getContext())
.setView(view) .setView(view)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { .setNegativeButton(android.R.string.cancel, null);
@Override
public void onClick(DialogInterface dialog, int which) { if (!inJunk)
getArguments().putBoolean("block_sender", cbBlockSender.isChecked()); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
getArguments().putBoolean("block_domain", cbBlockDomain.isChecked()); @Override
sendResult(Activity.RESULT_OK); public void onClick(DialogInterface dialog, int which) {
} getArguments().putBoolean("block_sender", cbBlockSender.isChecked());
}) getArguments().putBoolean("block_domain", cbBlockDomain.isChecked());
.setNegativeButton(android.R.string.cancel, null) sendResult(Activity.RESULT_OK);
.create(); }
});
return builder.create();
} }
} }

@ -78,6 +78,30 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cbBlockDomain" /> app:layout_constraintTop_toBottomOf="@+id/cbBlockDomain" />
<ImageButton
android:id="@+id/ibMore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:padding="3dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBlockHint"
app:srcCompat="@drawable/expander" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvMore"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center_vertical"
android:paddingStart="6dp"
android:text="@string/title_search_more"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintBottom_toBottomOf="@+id/ibMore"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/ibMore"
app:layout_constraintTop_toTopOf="@+id/ibMore" />
<Button <Button
android:id="@+id/btnEditRules" android:id="@+id/btnEditRules"
style="?android:attr/buttonStyleSmall" style="?android:attr/buttonStyleSmall"
@ -86,7 +110,7 @@
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_edit_rules" android:text="@string/title_edit_rules"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBlockHint" /> app:layout_constraintTop_toBottomOf="@id/tvMore" />
<CheckBox <CheckBox
android:id="@+id/cbJunkFilter" android:id="@+id/cbJunkFilter"
@ -131,7 +155,15 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
app:constraint_referenced_ids=" app:constraint_referenced_ids="
tvMessage,tvJunkHint,ibInfoProvider, tvBlockHint,cbBlockSender,cbBlockDomain,
cbJunkFilter,ibInfoFilter" /> ibMore,tvMore" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpMore"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="
btnEditRules,
cbJunkFilter,tvJunkFilterHint,ibInfoFilter" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ScrollViewEx> </eu.faircode.email.ScrollViewEx>
Loading…
Cancel
Save