mirror of https://github.com/M66B/FairEmail.git
Added 'more options' to junk dialog
This commit is contained in:
parent
a771d742cc
commit
44e4f0d473
|
@ -59,12 +59,15 @@ public class FragmentDialogJunk extends FragmentDialogBase {
|
|||
final ImageButton ibInfoProvider = view.findViewById(R.id.ibInfoProvider);
|
||||
final CheckBox cbBlockSender = view.findViewById(R.id.cbBlockSender);
|
||||
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 CheckBox cbJunkFilter = view.findViewById(R.id.cbJunkFilter);
|
||||
final ImageButton ibInfoFilter = view.findViewById(R.id.ibInfoFilter);
|
||||
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() {
|
||||
@Override
|
||||
|
@ -73,9 +76,6 @@ public class FragmentDialogJunk extends FragmentDialogBase {
|
|||
}
|
||||
});
|
||||
|
||||
cbBlockSender.setEnabled(canBlock && ActivityBilling.isPro(getContext()));
|
||||
cbBlockDomain.setEnabled(false);
|
||||
|
||||
cbBlockSender.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
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() {
|
||||
@Override
|
||||
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);
|
||||
grpMore.setVisibility(inJunk ? View.VISIBLE : View.GONE);
|
||||
|
||||
new SimpleTask<Boolean>() {
|
||||
@Override
|
||||
|
@ -235,17 +259,20 @@ public class FragmentDialogJunk extends FragmentDialogBase {
|
|||
}
|
||||
}.execute(FragmentDialogJunk.this, args, "junk:filter");
|
||||
|
||||
return new AlertDialog.Builder(getContext())
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext())
|
||||
.setView(view)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
getArguments().putBoolean("block_sender", cbBlockSender.isChecked());
|
||||
getArguments().putBoolean("block_domain", cbBlockDomain.isChecked());
|
||||
sendResult(Activity.RESULT_OK);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
.setNegativeButton(android.R.string.cancel, null);
|
||||
|
||||
if (!inJunk)
|
||||
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
getArguments().putBoolean("block_sender", cbBlockSender.isChecked());
|
||||
getArguments().putBoolean("block_domain", cbBlockDomain.isChecked());
|
||||
sendResult(Activity.RESULT_OK);
|
||||
}
|
||||
});
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,6 +78,30 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
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
|
||||
android:id="@+id/btnEditRules"
|
||||
style="?android:attr/buttonStyleSmall"
|
||||
|
@ -86,7 +110,7 @@
|
|||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_edit_rules"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvBlockHint" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvMore" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbJunkFilter"
|
||||
|
@ -131,7 +155,15 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="
|
||||
tvMessage,tvJunkHint,ibInfoProvider,
|
||||
cbJunkFilter,ibInfoFilter" />
|
||||
tvBlockHint,cbBlockSender,cbBlockDomain,
|
||||
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>
|
||||
</eu.faircode.email.ScrollViewEx>
|
Loading…
Reference in New Issue