Show if folder read only

pull/156/head
M66B 5 years ago
parent 34dd0be865
commit 0d71716720

File diff suppressed because it is too large Load Diff

@ -89,6 +89,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
private View view;
private View vwColor;
private ImageView ivState;
private ImageView ivReadOnly;
private View vwLevel;
private ImageView ivExpander;
private ImageView ivNotify;
@ -122,6 +123,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
view = itemView.findViewById(R.id.clItem);
vwColor = itemView.findViewById(R.id.vwColor);
ivState = itemView.findViewById(R.id.ivState);
ivReadOnly = itemView.findViewById(R.id.ivReadOnly);
vwLevel = itemView.findViewById(R.id.vwLevel);
ivExpander = itemView.findViewById(R.id.ivExpander);
ivNotify = itemView.findViewById(R.id.ivNotify);
@ -222,6 +224,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
folder.synchronize || folder.state != null || folder.sync_state != null
? View.VISIBLE : View.INVISIBLE);
ivReadOnly.setVisibility(folder.read_only ? View.VISIBLE : View.GONE);
ViewGroup.LayoutParams lp = vwLevel.getLayoutParams();
lp.width = (account < 0 || !collapsable ? 1 : level) * dp12;
vwLevel.setLayoutParams(lp);

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

@ -222,6 +222,9 @@ public interface DaoFolder {
@Query("UPDATE folder SET last_sync = :last_sync WHERE id = :id")
int setFolderSync(long id, long last_sync);
@Query("UPDATE folder SET read_only = :read_only WHERE id = :id")
int setFolderReadOnly(long id, boolean read_only);
@Query("UPDATE folder SET `order` = NULL")
int resetFolderOrder();

@ -105,6 +105,8 @@ public class EntityFolder implements Serializable {
public Boolean tbd; // to be deleted
public String state;
public String sync_state;
@NonNull
public Boolean read_only = false;
public String error;
public Long last_sync;

@ -665,10 +665,16 @@ public class ServiceSynchronize extends LifecycleService {
final IMAPFolder ifolder = (IMAPFolder) istore.getFolder(folder.name);
try {
//if ("Postausgang".equals(folder.name))
// throw new ReadOnlyFolderException(ifolder);
ifolder.open(Folder.READ_WRITE);
db.folder().setFolderReadOnly(folder.id, false);
} catch (ReadOnlyFolderException ex) {
Log.w(folder.name + " read only");
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex, true));
try {
ifolder.open(Folder.READ_ONLY);
db.folder().setFolderReadOnly(folder.id, true);
} catch (MessagingException ex1) {
Log.w(ex1);
db.folder().setFolderState(folder.id, null);

@ -30,6 +30,15 @@
app:layout_constraintStart_toEndOf="@id/vwColor"
app:layout_constraintTop_toTopOf="@+id/tvName" />
<ImageView
android:id="@+id/ivReadOnly"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="6dp"
android:src="@drawable/baseline_visibility_24"
app:layout_constraintStart_toEndOf="@id/vwColor"
app:layout_constraintTop_toTopOf="@+id/tvType" />
<View
android:id="@+id/vwLevel"
android:layout_width="0dp"

Loading…
Cancel
Save