Added account warning

pull/153/head
M66B 6 years ago
parent 05f4c7497e
commit 3acb07b916

File diff suppressed because it is too large Load Diff

@ -70,6 +70,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
private ImageView ivState;
private TextView tvHost;
private TextView tvLast;
private TextView tvWarning;
private TextView tvError;
private Group grpSettings;
@ -86,6 +87,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
ivState = itemView.findViewById(R.id.ivState);
tvHost = itemView.findViewById(R.id.tvHost);
tvLast = itemView.findViewById(R.id.tvLast);
tvWarning = itemView.findViewById(R.id.tvWarning);
tvError = itemView.findViewById(R.id.tvError);
grpSettings = itemView.findViewById(R.id.grpSettings);
}
@ -135,6 +137,9 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
tvLast.setText(context.getString(R.string.title_last_connected,
account.last_connected == null ? "-" : df.format(account.last_connected)));
tvWarning.setText(account.warning);
tvWarning.setVisibility(account.warning == null || !settings ? View.GONE : View.VISIBLE);
tvError.setText(account.error);
tvError.setVisibility(account.error == null ? View.GONE : View.VISIBLE);

@ -50,7 +50,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 61,
version = 62,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -669,6 +669,13 @@ public abstract class DB extends RoomDatabase {
db.execSQL("ALTER TABLE `folder` ADD COLUMN `collapsed` INTEGER NOT NULL DEFAULT 0");
}
})
.addMigrations(new Migration(61, 62) {
@Override
public void migrate(SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `account` ADD COLUMN `warning` TEXT");
}
})
.build();
}

@ -108,6 +108,9 @@ public interface DaoAccount {
@Query("UPDATE account SET password = :password WHERE id = :id")
int setAccountPassword(long id, String password);
@Query("UPDATE account SET warning = :warning WHERE id = :id")
int setAccountWarning(long id, String warning);
@Query("UPDATE account SET error = :error WHERE id = :id")
int setAccountError(long id, String error);

@ -90,6 +90,7 @@ public class EntityAccount implements Serializable {
public Long created;
public Boolean tbd;
public String state;
public String warning;
public String error;
public Long last_connected;
@ -211,6 +212,7 @@ public class EntityAccount implements Serializable {
Objects.equals(this.created, other.created) &&
Objects.equals(this.tbd, other.tbd) &&
Objects.equals(this.state, other.state) &&
Objects.equals(this.warning, other.warning) &&
Objects.equals(this.error, other.error) &&
Objects.equals(this.last_connected, other.last_connected));
} else

@ -970,7 +970,7 @@ public class ServiceSynchronize extends LifecycleService {
account.last_connected = new Date().getTime();
EntityLog.log(this, account.name + " set last_connected=" + new Date(account.last_connected));
db.account().setAccountConnected(account.id, account.last_connected);
db.account().setAccountError(account.id, capIdle ? null : getString(R.string.title_no_idle));
db.account().setAccountWarning(account.id, capIdle ? null : getString(R.string.title_no_idle));
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.cancel("receive", account.id.intValue());

@ -126,6 +126,20 @@
app:layout_constraintStart_toEndOf="@+id/ivState"
app:layout_constraintTop_toBottomOf="@id/tvHost" />
<TextView
android:id="@+id/tvWarning"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginEnd="6dp"
android:text="warning"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?attr/colorWarning"
android:textIsSelectable="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/vwColor"
app:layout_constraintTop_toBottomOf="@id/tvLast" />
<TextView
android:id="@+id/tvError"
android:layout_width="0dp"
@ -138,7 +152,7 @@
android:textIsSelectable="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/vwColor"
app:layout_constraintTop_toBottomOf="@id/tvLast" />
app:layout_constraintTop_toBottomOf="@id/tvWarning" />
<View
android:id="@+id/marginBottom"

Loading…
Cancel
Save