Browse Source

Add edit button to folder items

main
M66B 6 years ago
parent
commit
850397c4fa
4 changed files with 26 additions and 31 deletions
  1. +15
    -22
      app/src/main/java/eu/faircode/email/AdapterFolder.java
  2. +0
    -5
      app/src/main/java/eu/faircode/email/FragmentFolders.java
  3. +11
    -2
      app/src/main/res/layout/item_folder.xml
  4. +0
    -2
      app/src/main/res/values/strings.xml

+ 15
- 22
app/src/main/java/eu/faircode/email/AdapterFolder.java View File

@ -26,6 +26,7 @@ import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; 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> all = new ArrayList<>();
private List<TupleFolderEx> filtered = 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; View itemView;
TextView tvName; TextView tvName;
TextView tvMessages; TextView tvMessages;
TextView tvType; TextView tvType;
TextView tvAfter; TextView tvAfter;
ImageView ivSync; ImageView ivSync;
ImageButton ibEdit;
TextView tvError; TextView tvError;
ViewHolder(View itemView) { ViewHolder(View itemView) {
@ -67,18 +68,18 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
tvType = itemView.findViewById(R.id.tvType); tvType = itemView.findViewById(R.id.tvType);
tvAfter = itemView.findViewById(R.id.tvAfter); tvAfter = itemView.findViewById(R.id.tvAfter);
ivSync = itemView.findViewById(R.id.ivSync); ivSync = itemView.findViewById(R.id.ivSync);
ibEdit = itemView.findViewById(R.id.ibEdit);
tvError = itemView.findViewById(R.id.tvError); tvError = itemView.findViewById(R.id.tvError);
} }
private void wire(boolean properties) { private void wire(boolean properties) {
itemView.setOnClickListener(this); itemView.setOnClickListener(this);
if (properties) if (properties)
itemView.setOnLongClickListener(this);
ibEdit.setOnClickListener(this);
} }
private void unwire() { private void unwire() {
itemView.setOnClickListener(null); itemView.setOnClickListener(null);
itemView.setOnLongClickListener(null);
} }
private void bindTo(TupleFolderEx folder) { private void bindTo(TupleFolderEx folder) {
@ -112,30 +113,22 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
int pos = getAdapterPosition(); int pos = getAdapterPosition();
if (pos == RecyclerView.NO_POSITION) if (pos == RecyclerView.NO_POSITION)
return; 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); 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); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast( 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;
} }
} }


+ 0
- 5
app/src/main/java/eu/faircode/email/FragmentFolders.java View File

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

+ 11
- 2
app/src/main/res/layout/item_folder.xml View File

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


+ 0
- 2
app/src/main/res/values/strings.xml View File

@ -145,8 +145,6 @@
<string name="title_draft_saved">Draft saved</string> <string name="title_draft_saved">Draft saved</string>
<string name="title_queued">Sending message</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">Debug info</string>
<string name="title_debug_info_remark">Please describe the problem and indicate the time of the problem:</string> <string name="title_debug_info_remark">Please describe the problem and indicate the time of the problem:</string>
</resources> </resources>

Loading…
Cancel
Save