Added button to go from account to inbox

This commit is contained in:
M66B 2020-06-08 07:37:05 +02:00
parent 52fd46202b
commit 1ea79307af
2 changed files with 58 additions and 6 deletions

View File

@ -39,6 +39,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
@ -85,6 +86,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
private ImageView ivNotify;
private TextView tvName;
private ImageView ivSync;
private ImageButton ibInbox;
private TextView tvUser;
private ImageView ivState;
private TextView tvHost;
@ -105,6 +107,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
view = itemView.findViewById(R.id.clItem);
vwColor = itemView.findViewById(R.id.vwColor);
ivSync = itemView.findViewById(R.id.ivSync);
ibInbox = itemView.findViewById(R.id.ibInbox);
ivOAuth = itemView.findViewById(R.id.ivOAuth);
ivPrimary = itemView.findViewById(R.id.ivPrimary);
ivNotify = itemView.findViewById(R.id.ivNotify);
@ -125,12 +128,14 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
private void wire() {
view.setOnClickListener(this);
view.setOnLongClickListener(this);
ibInbox.setOnClickListener(this);
btnHelp.setOnClickListener(this);
}
private void unwire() {
view.setOnClickListener(null);
view.setOnLongClickListener(null);
ibInbox.setOnClickListener(null);
btnHelp.setOnClickListener(null);
}
@ -199,6 +204,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
tvError.setVisibility(account.error == null ? View.GONE : View.VISIBLE);
btnHelp.setVisibility(account.error == null ? View.GONE : View.VISIBLE);
ibInbox.setVisibility(settings ? View.GONE : View.VISIBLE);
grpSettings.setVisibility(settings ? View.VISIBLE : View.GONE);
}
@ -215,11 +221,45 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
if (account.tbd != null)
return;
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(settings ? ActivitySetup.ACTION_EDIT_ACCOUNT : ActivityView.ACTION_VIEW_FOLDERS)
.putExtra("id", account.id)
.putExtra("protocol", account.protocol));
if (view.getId() == R.id.ibInbox) {
Bundle args = new Bundle();
args.putLong("id", account.id);
new SimpleTask<EntityFolder>() {
@Override
protected EntityFolder onExecute(Context context, Bundle args) {
long id = args.getLong("id");
DB db = DB.getInstance(context);
return db.folder().getFolderByType(id, EntityFolder.INBOX);
}
@Override
protected void onExecuted(Bundle args, EntityFolder inbox) {
if (inbox == null)
return;
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGES)
.putExtra("account", inbox.account)
.putExtra("folder", inbox.id)
.putExtra("type", inbox.type));
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
}
}.execute(context, owner, args, "account:inbox");
} else {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(settings ? ActivitySetup.ACTION_EDIT_ACCOUNT : ActivityView.ACTION_VIEW_FOLDERS)
.putExtra("id", account.id)
.putExtra("protocol", account.protocol));
}
}
}

View File

@ -100,10 +100,22 @@
android:layout_marginEnd="6dp"
android:contentDescription="@string/title_legend_synchronize_on"
app:layout_constraintBottom_toBottomOf="@+id/tvName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@+id/ibInbox"
app:layout_constraintTop_toTopOf="@+id/tvName"
app:srcCompat="@drawable/baseline_sync_24" />
<ImageButton
android:id="@+id/ibInbox"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginEnd="6dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_folder_inbox"
app:layout_constraintBottom_toBottomOf="@+id/tvName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/tvName"
app:srcCompat="@drawable/baseline_inbox_24" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvUser"
android:layout_width="0dp"