Added button to go from account to inbox

pull/180/head
M66B 5 years ago
parent 52fd46202b
commit 1ea79307af

@ -39,6 +39,7 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -85,6 +86,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
private ImageView ivNotify; private ImageView ivNotify;
private TextView tvName; private TextView tvName;
private ImageView ivSync; private ImageView ivSync;
private ImageButton ibInbox;
private TextView tvUser; private TextView tvUser;
private ImageView ivState; private ImageView ivState;
private TextView tvHost; private TextView tvHost;
@ -105,6 +107,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
view = itemView.findViewById(R.id.clItem); view = itemView.findViewById(R.id.clItem);
vwColor = itemView.findViewById(R.id.vwColor); vwColor = itemView.findViewById(R.id.vwColor);
ivSync = itemView.findViewById(R.id.ivSync); ivSync = itemView.findViewById(R.id.ivSync);
ibInbox = itemView.findViewById(R.id.ibInbox);
ivOAuth = itemView.findViewById(R.id.ivOAuth); ivOAuth = itemView.findViewById(R.id.ivOAuth);
ivPrimary = itemView.findViewById(R.id.ivPrimary); ivPrimary = itemView.findViewById(R.id.ivPrimary);
ivNotify = itemView.findViewById(R.id.ivNotify); ivNotify = itemView.findViewById(R.id.ivNotify);
@ -125,12 +128,14 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
private void wire() { private void wire() {
view.setOnClickListener(this); view.setOnClickListener(this);
view.setOnLongClickListener(this); view.setOnLongClickListener(this);
ibInbox.setOnClickListener(this);
btnHelp.setOnClickListener(this); btnHelp.setOnClickListener(this);
} }
private void unwire() { private void unwire() {
view.setOnClickListener(null); view.setOnClickListener(null);
view.setOnLongClickListener(null); view.setOnLongClickListener(null);
ibInbox.setOnClickListener(null);
btnHelp.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); tvError.setVisibility(account.error == null ? View.GONE : View.VISIBLE);
btnHelp.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); grpSettings.setVisibility(settings ? View.VISIBLE : View.GONE);
} }
@ -215,6 +221,39 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
if (account.tbd != null) if (account.tbd != null)
return; return;
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); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast( lbm.sendBroadcast(
new Intent(settings ? ActivitySetup.ACTION_EDIT_ACCOUNT : ActivityView.ACTION_VIEW_FOLDERS) new Intent(settings ? ActivitySetup.ACTION_EDIT_ACCOUNT : ActivityView.ACTION_VIEW_FOLDERS)
@ -222,6 +261,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
.putExtra("protocol", account.protocol)); .putExtra("protocol", account.protocol));
} }
} }
}
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {

@ -100,10 +100,22 @@
android:layout_marginEnd="6dp" android:layout_marginEnd="6dp"
android:contentDescription="@string/title_legend_synchronize_on" android:contentDescription="@string/title_legend_synchronize_on"
app:layout_constraintBottom_toBottomOf="@+id/tvName" app:layout_constraintBottom_toBottomOf="@+id/tvName"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toStartOf="@+id/ibInbox"
app:layout_constraintTop_toTopOf="@+id/tvName" app:layout_constraintTop_toTopOf="@+id/tvName"
app:srcCompat="@drawable/baseline_sync_24" /> 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 <eu.faircode.email.FixedTextView
android:id="@+id/tvUser" android:id="@+id/tvUser"
android:layout_width="0dp" android:layout_width="0dp"

Loading…
Cancel
Save