1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-27 02:07:12 +00:00

Add edit button to folder items

This commit is contained in:
M66B 2018-08-11 18:04:50 +00:00
parent cdecb5e205
commit 850397c4fa
4 changed files with 27 additions and 32 deletions

View file

@ -26,6 +26,7 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
@ -48,14 +49,14 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
private List<TupleFolderEx> all = new ArrayList<>();
private List<TupleFolderEx> filtered = new ArrayList<>();
public class ViewHolder extends RecyclerView.ViewHolder
implements View.OnClickListener, View.OnLongClickListener {
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
View itemView;
TextView tvName;
TextView tvMessages;
TextView tvType;
TextView tvAfter;
ImageView ivSync;
ImageButton ibEdit;
TextView tvError;
ViewHolder(View itemView) {
@ -67,18 +68,18 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
tvType = itemView.findViewById(R.id.tvType);
tvAfter = itemView.findViewById(R.id.tvAfter);
ivSync = itemView.findViewById(R.id.ivSync);
ibEdit = itemView.findViewById(R.id.ibEdit);
tvError = itemView.findViewById(R.id.tvError);
}
private void wire(boolean properties) {
itemView.setOnClickListener(this);
if (properties)
itemView.setOnLongClickListener(this);
ibEdit.setOnClickListener(this);
}
private void unwire() {
itemView.setOnClickListener(null);
itemView.setOnLongClickListener(null);
}
private void bindTo(TupleFolderEx folder) {
@ -112,30 +113,22 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
int pos = getAdapterPosition();
if (pos == RecyclerView.NO_POSITION)
return;
TupleFolderEx folder = filtered.get(pos);
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGES)
.putExtra("folder", folder.id));
}
@Override
public boolean onLongClick(View view) {
int pos = getAdapterPosition();
if (pos == RecyclerView.NO_POSITION)
return false;
TupleFolderEx folder = filtered.get(pos);
if (!EntityFolder.OUTBOX.equals(folder.type)) {
if (view.getId() == R.id.ibEdit) {
if (!EntityFolder.OUTBOX.equals(folder.type)) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_EDIT_FOLDER)
.putExtra("id", folder.id));
}
} else {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_EDIT_FOLDER)
.putExtra("id", folder.id));
return true;
new Intent(ActivityView.ACTION_VIEW_MESSAGES)
.putExtra("folder", folder.id));
}
return false;
}
}

View file

@ -24,7 +24,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
@ -107,9 +106,5 @@ public class FragmentFolders extends FragmentEx {
grpReady.setVisibility(View.VISIBLE);
}
});
// Show hint
// TODO: find better solution
Toast.makeText(getContext(), R.string.title_item_edit_hint, Toast.LENGTH_SHORT).show();
}
}

View file

@ -37,7 +37,7 @@
android:layout_height="24dp"
android:layout_marginEnd="6dp"
android:src="@drawable/baseline_mail_outline_24"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@+id/ibEdit"
app:layout_constraintTop_toTopOf="parent" />
<TextView
@ -68,9 +68,18 @@
android:layout_height="24dp"
android:layout_marginEnd="6dp"
android:src="@drawable/baseline_sync_24"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@+id/ibEdit"
app:layout_constraintTop_toBottomOf="@id/ivMessages" />
<ImageButton
android:id="@+id/ibEdit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="6dp"
android:src="@drawable/baseline_edit_24"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvError"
android:layout_width="0dp"

View file

@ -145,8 +145,6 @@
<string name="title_draft_saved">Draft saved</string>
<string name="title_queued">Sending message</string>
<string name="title_item_edit_hint">Long press item to edit properties</string>
<string name="title_debug_info">Debug info</string>
<string name="title_debug_info_remark">Please describe the problem and indicate the time of the problem:</string>
</resources>