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 java.text.DateFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -127,7 +128,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
private TextView tvType;
private TextView tvTotal;
private TextView tvAfter;
private ImageView ivSync;
private ImageButton ibSync;
private TextView tvKeywords;
private TextView tvFlagged;
@ -165,7 +166,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
tvType = itemView.findViewById(R.id.tvType);
tvTotal = itemView.findViewById(R.id.tvTotal);
tvAfter = itemView.findViewById(R.id.tvAfter);
ivSync = itemView.findViewById(R.id.ivSync);
ibSync = itemView.findViewById(R.id.ibSync);
tvKeywords = itemView.findViewById(R.id.tvKeywords);
tvFlagged = itemView.findViewById(R.id.tvFlagged);
@ -185,6 +186,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
tvFlagged.setOnClickListener(this);
if (ibFlagged != null)
ibFlagged.setOnClickListener(this);
if (ibSync != null)
ibSync.setOnClickListener(this);
if (listener == null)
view.setOnLongClickListener(this);
if (btnHelp != null)
@ -198,6 +201,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
tvFlagged.setOnClickListener(null);
if (ibFlagged != null)
ibFlagged.setOnClickListener(null);
if (ibSync != null)
ibSync.setOnClickListener(null);
if (listener == null)
view.setOnLongClickListener(null);
if (btnHelp != null)
@ -321,8 +326,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
if (folder.account == null) {
tvAfter.setText(null);
ivSync.setImageResource(R.drawable.twotone_sync_24);
ivSync.setContentDescription(context.getString(R.string.title_legend_synchronize_on));
ibSync.setImageResource(R.drawable.twotone_sync_24);
ibSync.setContentDescription(context.getString(R.string.title_legend_synchronize_on));
} else {
StringBuilder a = new StringBuilder();
@ -340,22 +345,23 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
tvAfter.setText(a.toString());
if (folder.synchronize) {
ivSync.setImageResource(folder.poll
ibSync.setImageResource(folder.poll
? R.drawable.twotone_hourglass_top_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_on));
} else {
ivSync.setImageResource(R.drawable.twotone_sync_disabled_24);
ivSync.setContentDescription(context.getString(R.string.title_legend_synchronize_off));
ibSync.setImageResource(R.drawable.twotone_sync_disabled_24);
ibSync.setContentDescription(context.getString(R.string.title_legend_synchronize_off));
}
}
ivSync.setImageTintList(ColorStateList.valueOf(
ibSync.setImageTintList(ColorStateList.valueOf(
folder.synchronize && folder.initialize != 0 &&
!EntityFolder.OUTBOX.equals(folder.type) &&
folder.accountProtocol == EntityAccount.TYPE_IMAP
? textColorPrimary : textColorSecondary));
ibSync.setEnabled(folder.last_sync != null);
tvKeywords.setText(BuildConfig.DEBUG ? TextUtils.join(" ", folder.keywords) : null);
tvKeywords.setVisibility(show_flagged ? View.VISIBLE : View.GONE);
@ -394,6 +400,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
onCollapse(folder, pos);
} else if (id == R.id.tvFlagged || id == R.id.ibFlagged) {
onFlagged(folder);
} else if (id == R.id.ibSync) {
onLastSync(folder);
} else {
if (listener == null) {
if (!folder.selectable)
@ -463,6 +471,13 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
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
public boolean onLongClick(View v) {
int pos = getAdapterPosition();

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

Loading…
Cancel
Save