Added pull down to refresh

Single folders only for now
pull/146/head
M66B 6 years ago
parent 3dd522f6b8
commit d3032555ee

@ -45,7 +45,6 @@ Anything on this list is in random order and *might* be added in the near future
* Snooze timer: snoozed emails are not supported by [IMAP](https://en.wikipedia.org/wiki/Internet_Message_Access_Protocol).
* Badge count: there is no standard Android API for this and third party solutions might stop working anytime.
* Shortcut frequently contacted: Android [doesn't support this anymore](https://developer.android.com/guide/topics/providers/contacts-provider#ObsoleteData).
* Pull down to refresh: new messages are received in real-time, so manual refreshing is not needed, see also [this FAQ](#user-content-faq2).
* Switch language: although it is possible to change the language of an app, Android is not designed for this. Better fix the translation in your language if needed, see [this FAQ](#user-content-faq26) about how to.
* Select identities to show in unified inbox: this would add complexity for something which would hardly be used.
* Better design: please let me know what you have in mind [in this forum](https://forum.xda-developers.com/android/apps-games/source-email-t3824168).

@ -135,7 +135,9 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
else
ivState.setImageResource(android.R.drawable.stat_sys_warning);
} else {
if ("syncing".equals(folder.sync_state))
if ("requested".equals(folder.sync_state))
ivState.setImageResource(R.drawable.baseline_hourglass_empty_24);
else if ("syncing".equals(folder.sync_state))
ivState.setImageResource(R.drawable.baseline_compare_arrows_24);
else if ("downloading".equals(folder.sync_state))
ivState.setImageResource(R.drawable.baseline_cloud_download_24);

@ -92,8 +92,10 @@ public class EntityOperation {
}
static void sync(DB db, long folder) {
if (db.operation().getOperationCount(folder, EntityOperation.SYNC) == 0)
if (db.operation().getOperationCount(folder, EntityOperation.SYNC) == 0) {
queue(db, folder, null, EntityOperation.SYNC, new JSONArray());
db.folder().setFolderSyncState(folder, "requested");
}
}
private static void queue(DB db, long folder, Long message, String name, JSONArray jargs) {

@ -24,6 +24,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.os.Bundle;
@ -31,6 +32,7 @@ import android.os.Handler;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@ -70,9 +72,11 @@ import androidx.recyclerview.selection.StorageStrategy;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
public class FragmentMessages extends FragmentEx {
private ViewGroup view;
private SwipeRefreshLayout swipeRefresh;
private View popupAnchor;
private TextView tvSupport;
private ImageButton ibHintSupport;
@ -168,6 +172,7 @@ public class FragmentMessages extends FragmentEx {
setHasOptionsMenu(true);
// Get controls
swipeRefresh = view.findViewById(R.id.swipeRefresh);
popupAnchor = view.findViewById(R.id.popupAnchor);
tvSupport = view.findViewById(R.id.tvSupport);
ibHintSupport = view.findViewById(R.id.ibHintSupport);
@ -189,6 +194,37 @@ public class FragmentMessages extends FragmentEx {
// Wire controls
TypedValue tv = new TypedValue();
getContext().getTheme().resolveAttribute(R.attr.colorAccent, tv, true);
swipeRefresh.setColorSchemeColors(tv.data, tv.data, tv.data);
swipeRefresh.setProgressBackgroundColorSchemeColor(Color.WHITE);
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
Bundle args = new Bundle();
args.putLong("id", folder);
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
long id = args.getLong("id");
DB db = DB.getInstance(context);
try {
db.beginTransaction();
EntityOperation.sync(db, id);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
return null;
}
}.load(FragmentMessages.this, args);
}
});
tvSupport.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -977,6 +1013,7 @@ public class FragmentMessages extends FragmentEx {
((ActivityBase) getActivity()).addBackPressedListener(onBackPressedListener);
// Initialize
swipeRefresh.setEnabled(viewType == AdapterMessage.ViewType.FOLDER);
tvNoEmail.setVisibility(View.GONE);
bottom_navigation.setVisibility(View.GONE);
grpReady.setVisibility(View.GONE);
@ -1072,6 +1109,8 @@ public class FragmentMessages extends FragmentEx {
outbox = EntityFolder.OUTBOX.equals(folder.type);
getActivity().invalidateOptionsMenu();
}
swipeRefresh.setRefreshing(folder != null && folder.sync_state != null);
}
});
break;

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M6,2v6h0.01L6,8.01 10,12l-4,4 0.01,0.01L6,16.01L6,22h12v-5.99h-0.01L18,16l-4,-4 4,-3.99 -0.01,-0.01L18,8L18,2L6,2zM16,16.5L16,20L8,20v-3.5l4,-4 4,4zM12,11.5l-4,-4L8,4h8v3.5l-4,4z"/>
</vector>

@ -6,6 +6,11 @@
android:layout_height="match_parent"
tools:context=".ActivityView">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -208,6 +213,8 @@
app:constraint_referenced_ids="rvFolder" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabMore"
android:layout_width="wrap_content"

Loading…
Cancel
Save