mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-03 02:05:36 +00:00
Added identity last connected
This commit is contained in:
parent
0678a8ae0c
commit
e8e4e13878
7 changed files with 1482 additions and 5 deletions
1441
app/schemas/eu.faircode.email.DB/40.json
Normal file
1441
app/schemas/eu.faircode.email.DB/40.json
Normal file
File diff suppressed because it is too large
Load diff
|
@ -29,6 +29,8 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
@ -48,6 +50,8 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
|
|||
private List<TupleIdentityEx> all = new ArrayList<>();
|
||||
private List<TupleIdentityEx> filtered = new ArrayList<>();
|
||||
|
||||
private static final DateFormat df = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
View itemView;
|
||||
View vwColor;
|
||||
|
@ -58,6 +62,7 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
|
|||
TextView tvHost;
|
||||
ImageView ivState;
|
||||
TextView tvAccount;
|
||||
TextView tvLast;
|
||||
TextView tvError;
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
|
@ -72,6 +77,7 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
|
|||
tvHost = itemView.findViewById(R.id.tvHost);
|
||||
ivState = itemView.findViewById(R.id.ivState);
|
||||
tvAccount = itemView.findViewById(R.id.tvAccount);
|
||||
tvLast = itemView.findViewById(R.id.tvLast);
|
||||
tvError = itemView.findViewById(R.id.tvError);
|
||||
}
|
||||
|
||||
|
@ -90,8 +96,6 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
|
|||
tvName.setText(identity.getDisplayName());
|
||||
ivSync.setImageResource(identity.synchronize ? R.drawable.baseline_sync_24 : R.drawable.baseline_sync_disabled_24);
|
||||
tvUser.setText(identity.email);
|
||||
tvHost.setText(String.format("%s:%d", identity.host, identity.port));
|
||||
tvAccount.setText(identity.accountName);
|
||||
|
||||
if ("connected".equals(identity.state))
|
||||
ivState.setImageResource(R.drawable.baseline_cloud_24);
|
||||
|
@ -101,6 +105,11 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
|
|||
ivState.setImageDrawable(null);
|
||||
ivState.setVisibility(identity.synchronize ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
tvHost.setText(String.format("%s:%d", identity.host, identity.port));
|
||||
tvAccount.setText(identity.accountName);
|
||||
tvLast.setText(context.getString(R.string.title_last_connected,
|
||||
identity.last_connected == null ? "-" : df.format(identity.last_connected)));
|
||||
|
||||
tvError.setText(identity.error);
|
||||
tvError.setVisibility(identity.error == null ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
|
|||
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||
|
||||
@Database(
|
||||
version = 39,
|
||||
version = 40,
|
||||
entities = {
|
||||
EntityIdentity.class,
|
||||
EntityAccount.class,
|
||||
|
@ -468,6 +468,13 @@ public abstract class DB extends RoomDatabase {
|
|||
db.execSQL("ALTER TABLE `account` ADD COLUMN `swipe_right` INTEGER");
|
||||
}
|
||||
})
|
||||
.addMigrations(new Migration(39, 40) {
|
||||
@Override
|
||||
public void migrate(SupportSQLiteDatabase db) {
|
||||
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `identity` ADD COLUMN `last_connected` INTEGER");
|
||||
}
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,9 @@ public interface DaoIdentity {
|
|||
@Query("UPDATE identity SET state = :state WHERE id = :id")
|
||||
int setIdentityState(long id, String state);
|
||||
|
||||
@Query("UPDATE identity SET last_connected = :last_connected WHERE id = :id")
|
||||
int setIdentityConnected(long id, long last_connected);
|
||||
|
||||
@Query("UPDATE identity SET password = :password WHERE id = :id")
|
||||
int setIdentityPassword(long id, String password);
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ public class EntityIdentity {
|
|||
public Boolean tbd;
|
||||
public String state;
|
||||
public String error;
|
||||
public Long last_connected;
|
||||
|
||||
public JSONObject toJSON() throws JSONException {
|
||||
JSONObject json = new JSONObject();
|
||||
|
@ -184,7 +185,8 @@ public class EntityIdentity {
|
|||
this.store_sent.equals(other.store_sent) &&
|
||||
(this.tbd == null ? other.tbd == null : this.tbd.equals(other.tbd)) &&
|
||||
(this.state == null ? other.state == null : this.state.equals(other.state)) &&
|
||||
(this.error == null ? other.error == null : this.error.equals(other.error)));
|
||||
(this.error == null ? other.error == null : this.error.equals(other.error)) &&
|
||||
(this.last_connected == null ? other.last_connected == null : this.last_connected.equals(other.last_connected)));
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1937,6 +1937,7 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
EntityOperation.queue(this, db, replied, EntityOperation.ANSWERED, true);
|
||||
}
|
||||
|
||||
db.identity().setIdentityConnected(ident.id, new Date().getTime());
|
||||
db.identity().setIdentityError(ident.id, null);
|
||||
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
|
|
@ -105,6 +105,20 @@
|
|||
app:layout_constraintStart_toEndOf="@id/tvHost"
|
||||
app:layout_constraintTop_toTopOf="@id/ivState" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvLast"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="Last connected time"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/ivState"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvHost" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvError"
|
||||
android:layout_width="0dp"
|
||||
|
@ -117,7 +131,7 @@
|
|||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/vwColor"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvHost" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvLast" />
|
||||
|
||||
<View
|
||||
android:id="@+id/vSeparator"
|
||||
|
|
Loading…
Reference in a new issue