Show folder sync time on tapping sync symbol

pull/200/head
M66B 3 years ago
parent c05731ab5c
commit dc8c63670c

@ -67,6 +67,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import java.text.DateFormat;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
@ -127,7 +128,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
private TextView tvType; private TextView tvType;
private TextView tvTotal; private TextView tvTotal;
private TextView tvAfter; private TextView tvAfter;
private ImageView ivSync; private ImageButton ibSync;
private TextView tvKeywords; private TextView tvKeywords;
private TextView tvFlagged; private TextView tvFlagged;
@ -165,7 +166,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
tvType = itemView.findViewById(R.id.tvType); tvType = itemView.findViewById(R.id.tvType);
tvTotal = itemView.findViewById(R.id.tvTotal); tvTotal = itemView.findViewById(R.id.tvTotal);
tvAfter = itemView.findViewById(R.id.tvAfter); tvAfter = itemView.findViewById(R.id.tvAfter);
ivSync = itemView.findViewById(R.id.ivSync); ibSync = itemView.findViewById(R.id.ibSync);
tvKeywords = itemView.findViewById(R.id.tvKeywords); tvKeywords = itemView.findViewById(R.id.tvKeywords);
tvFlagged = itemView.findViewById(R.id.tvFlagged); tvFlagged = itemView.findViewById(R.id.tvFlagged);
@ -185,6 +186,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
tvFlagged.setOnClickListener(this); tvFlagged.setOnClickListener(this);
if (ibFlagged != null) if (ibFlagged != null)
ibFlagged.setOnClickListener(this); ibFlagged.setOnClickListener(this);
if (ibSync != null)
ibSync.setOnClickListener(this);
if (listener == null) if (listener == null)
view.setOnLongClickListener(this); view.setOnLongClickListener(this);
if (btnHelp != null) if (btnHelp != null)
@ -198,6 +201,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
tvFlagged.setOnClickListener(null); tvFlagged.setOnClickListener(null);
if (ibFlagged != null) if (ibFlagged != null)
ibFlagged.setOnClickListener(null); ibFlagged.setOnClickListener(null);
if (ibSync != null)
ibSync.setOnClickListener(null);
if (listener == null) if (listener == null)
view.setOnLongClickListener(null); view.setOnLongClickListener(null);
if (btnHelp != null) if (btnHelp != null)
@ -321,8 +326,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
if (folder.account == null) { if (folder.account == null) {
tvAfter.setText(null); tvAfter.setText(null);
ivSync.setImageResource(R.drawable.twotone_sync_24); ibSync.setImageResource(R.drawable.twotone_sync_24);
ivSync.setContentDescription(context.getString(R.string.title_legend_synchronize_on)); ibSync.setContentDescription(context.getString(R.string.title_legend_synchronize_on));
} else { } else {
StringBuilder a = new StringBuilder(); StringBuilder a = new StringBuilder();
@ -340,22 +345,23 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
tvAfter.setText(a.toString()); tvAfter.setText(a.toString());
if (folder.synchronize) { if (folder.synchronize) {
ivSync.setImageResource(folder.poll ibSync.setImageResource(folder.poll
? R.drawable.twotone_hourglass_top_24 ? R.drawable.twotone_hourglass_top_24
: R.drawable.twotone_sync_24); : R.drawable.twotone_sync_24);
ivSync.setContentDescription(context.getString(folder.poll ibSync.setContentDescription(context.getString(folder.poll
? R.string.title_legend_synchronize_poll ? R.string.title_legend_synchronize_poll
: R.string.title_legend_synchronize_on)); : R.string.title_legend_synchronize_on));
} else { } else {
ivSync.setImageResource(R.drawable.twotone_sync_disabled_24); ibSync.setImageResource(R.drawable.twotone_sync_disabled_24);
ivSync.setContentDescription(context.getString(R.string.title_legend_synchronize_off)); ibSync.setContentDescription(context.getString(R.string.title_legend_synchronize_off));
} }
} }
ivSync.setImageTintList(ColorStateList.valueOf( ibSync.setImageTintList(ColorStateList.valueOf(
folder.synchronize && folder.initialize != 0 && folder.synchronize && folder.initialize != 0 &&
!EntityFolder.OUTBOX.equals(folder.type) && !EntityFolder.OUTBOX.equals(folder.type) &&
folder.accountProtocol == EntityAccount.TYPE_IMAP folder.accountProtocol == EntityAccount.TYPE_IMAP
? textColorPrimary : textColorSecondary)); ? textColorPrimary : textColorSecondary));
ibSync.setEnabled(folder.last_sync != null);
tvKeywords.setText(BuildConfig.DEBUG ? TextUtils.join(" ", folder.keywords) : null); tvKeywords.setText(BuildConfig.DEBUG ? TextUtils.join(" ", folder.keywords) : null);
tvKeywords.setVisibility(show_flagged ? View.VISIBLE : View.GONE); tvKeywords.setVisibility(show_flagged ? View.VISIBLE : View.GONE);
@ -394,6 +400,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
onCollapse(folder, pos); onCollapse(folder, pos);
} else if (id == R.id.tvFlagged || id == R.id.ibFlagged) { } else if (id == R.id.tvFlagged || id == R.id.ibFlagged) {
onFlagged(folder); onFlagged(folder);
} else if (id == R.id.ibSync) {
onLastSync(folder);
} else { } else {
if (listener == null) { if (listener == null) {
if (!folder.selectable) if (!folder.selectable)
@ -463,6 +471,13 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
folder.account, folder.id, false, criteria); folder.account, folder.id, false, criteria);
} }
private void onLastSync(TupleFolderEx folder) {
if (folder.last_sync == null)
return;
DateFormat DTF = Helper.getDateTimeInstance(context, SimpleDateFormat.LONG, SimpleDateFormat.LONG);
ToastEx.makeText(context, DTF.format(folder.last_sync), Toast.LENGTH_LONG).show();
}
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
int pos = getAdapterPosition(); int pos = getAdapterPosition();

@ -197,14 +197,15 @@
android:text="30" android:text="30"
android:textAppearance="@android:style/TextAppearance.Small" android:textAppearance="@android:style/TextAppearance.Small"
app:layout_constraintBottom_toBottomOf="@id/tvType" app:layout_constraintBottom_toBottomOf="@id/tvType"
app:layout_constraintEnd_toStartOf="@+id/ivSync" app:layout_constraintEnd_toStartOf="@+id/ibSync"
app:layout_constraintTop_toTopOf="@+id/tvType" /> app:layout_constraintTop_toTopOf="@+id/tvType" />
<ImageView <ImageButton
android:id="@+id/ivSync" android:id="@+id/ibSync"
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:layout_marginEnd="6dp" android:layout_marginEnd="6dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
app:layout_constraintBottom_toBottomOf="@id/tvType" app:layout_constraintBottom_toBottomOf="@id/tvType"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/tvType" app:layout_constraintTop_toTopOf="@+id/tvType"
@ -287,7 +288,7 @@
android:id="@+id/grpExtended" android:id="@+id/grpExtended"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
app:constraint_referenced_ids="ivType,tvType,tvTotal,tvAfter,ivSync" /> app:constraint_referenced_ids="ivType,tvType,tvTotal,tvAfter,ibSync" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ViewCardOptional> </eu.faircode.email.ViewCardOptional>
</FrameLayout> </FrameLayout>

Loading…
Cancel
Save