Skip to content

Commit

Permalink
new repo/dirent dialog feat
Browse files Browse the repository at this point in the history
  • Loading branch information
zhwanng committed Nov 20, 2024
1 parent a27aa19 commit 828af6a
Show file tree
Hide file tree
Showing 124 changed files with 2,227 additions and 1,280 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
targetSdkVersion rootProject.ext.targetSdkVersion
compileSdk rootProject.ext.compileSdkVersion

versionCode 156
versionName "3.0.5"
versionCode 157
versionName "3.0.6"
multiDexEnabled true

resValue "string", "authorities", defaultConfig.applicationId + '.debug.cameraupload.provider'
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class AbsLayoutItemType {
public static final int DIRENT_GRID = 12;
public static final int DIRENT_GALLERY = 13;

public static final int SEARCH = 50;

public static final int ACTIVITY = 20;

public static final int GROUP_ITEM = 30;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void pop() {
navStack.pop();
}

public void navToPath(RepoModel repoModel, String full_path) {
public void switchToPath(RepoModel repoModel, String full_path) {
navStack.clear();

navStack.push(repoModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public enum RepoSelectType {
NOT_SELECTABLE(-1),
ONLY_ACCOUNT(0),
ONLY_REPO(1),
DIRENT(2);
FOLDER(2);

RepoSelectType(int i) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
package com.seafile.seadroid2.framework.data.db;

import androidx.annotation.NonNull;
import androidx.room.Dao;
import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;

import com.seafile.seadroid2.SeadroidApplication;
import com.seafile.seadroid2.framework.data.db.dao.CertCacheDAO;
import com.seafile.seadroid2.framework.data.db.dao.DirentDAO;
import com.seafile.seadroid2.framework.data.db.dao.EncKeyCacheDAO;
import com.seafile.seadroid2.framework.data.db.dao.FileTransferDAO;
import com.seafile.seadroid2.framework.data.db.dao.FolderBackupMonitorDAO;
import com.seafile.seadroid2.framework.data.db.dao.PermissionDAO;
import com.seafile.seadroid2.framework.data.db.dao.RepoDAO;
import com.seafile.seadroid2.framework.data.db.dao.StarredDirentDAO;
import com.seafile.seadroid2.framework.data.db.entities.CertEntity;
import com.seafile.seadroid2.framework.data.db.entities.DirentModel;
import com.seafile.seadroid2.framework.data.db.entities.EncKeyCacheEntity;
import com.seafile.seadroid2.framework.data.db.entities.FolderBackupMonitorEntity;
import com.seafile.seadroid2.framework.data.db.entities.PermissionEntity;
import com.seafile.seadroid2.framework.data.db.entities.RepoModel;
import com.seafile.seadroid2.framework.data.db.entities.FileTransferEntity;
import com.seafile.seadroid2.framework.data.db.entities.StarredModel;
import com.seafile.seadroid2.framework.util.SLogs;

@Database(entities = {
RepoModel.class,
DirentModel.class,
FolderBackupMonitorEntity.class,
EncKeyCacheEntity.class,
CertEntity.class,
FileTransferEntity.class,
StarredModel.class
}, version = 2, exportSchema = false)
StarredModel.class,
PermissionEntity.class,
}, version = 3, exportSchema = false)
public abstract class AppDatabase extends RoomDatabase {
private static final String DATABASE_NAME = "seafile_room.db";
private static volatile AppDatabase _instance;

public static AppDatabase getInstance() {
if (_instance == null) {
synchronized (AppDatabase.class) {
if (_instance == null) {
_instance = Room
.databaseBuilder(SeadroidApplication.getAppContext(), AppDatabase.class, DATABASE_NAME)
.addMigrations(MIGRATION_1_2)
.addMigrations(MIGRATION_2_3)
.build();
}
}
Expand All @@ -63,6 +63,33 @@ public void migrate(@NonNull SupportSQLiteDatabase database) {
};


static final Migration MIGRATION_2_3 = new Migration(2, 3) {

@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("DROP TABLE IF EXISTS cert_cache");

database.execSQL("DROP TABLE IF EXISTS permissions");
database.execSQL("CREATE TABLE permissions (" +
"id INTEGER NOT NULL DEFAULT 0, " +
"repo_id TEXT NOT NULL DEFAULT '', " +
"description TEXT, " +
"name TEXT DEFAULT '', " +
"'create' INTEGER NOT NULL DEFAULT 0, " +
"upload INTEGER NOT NULL DEFAULT 0, " +
"download INTEGER NOT NULL DEFAULT 0, " +
"preview INTEGER NOT NULL DEFAULT 0, " +
"copy INTEGER NOT NULL DEFAULT 0, " +
"'delete' INTEGER NOT NULL DEFAULT 0, " +
"modify INTEGER NOT NULL DEFAULT 0, " +
"download_external_link INTEGER NOT NULL DEFAULT 0, " +
"'v' INTEGER NOT NULL DEFAULT 1, " +
"data_status INTEGER NOT NULL DEFAULT 0, " +
"PRIMARY KEY(repo_id, id))");
}
};


public abstract RepoDAO repoDao();

public abstract DirentDAO direntDao();
Expand All @@ -71,11 +98,9 @@ public void migrate(@NonNull SupportSQLiteDatabase database) {

public abstract EncKeyCacheDAO encKeyCacheDAO();

@Deprecated
public abstract CertCacheDAO certDAO();

public abstract FolderBackupMonitorDAO folderBackupMonitorDAO();

public abstract FileTransferDAO fileTransferDAO();

public abstract PermissionDAO permissionDAO();
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public interface DirentDAO {
@Query("select * from dirents where uid in ( :uids )")
List<DirentModel> getListByIdsSync(List<String> uids);

@Query("select * from dirents where uid in ( :uids )")
Single<List<DirentModel>> getListByIdsAsync(List<String> uids);

@Insert(onConflict = OnConflictStrategy.REPLACE)
void insert(DirentModel model);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.seafile.seadroid2.framework.data.db.dao;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import com.seafile.seadroid2.framework.data.db.entities.FileTransferEntity;
import com.seafile.seadroid2.framework.data.db.entities.PermissionEntity;
import com.seafile.seadroid2.framework.data.db.entities.PermissionEntity;

import java.util.List;

import io.reactivex.Completable;
import io.reactivex.Single;

@Dao
public interface PermissionDAO {

@Query("select * from permissions where repo_id = :repoId and id = :id limit 1")
List<PermissionEntity> getByIdSync(String repoId, int id);

@Query("select * from permissions where repo_id = :repoId and id = :id limit 1")
Single<List<PermissionEntity>> getByIdAsync(String repoId, int id);

@Query("select * from permissions where repo_id = :repoId")
Single<List<PermissionEntity>> getByRepoIdAsync(String repoId);


@Query("DELETE FROM permissions")
void deleteAll();

@Insert(onConflict = OnConflictStrategy.REPLACE)
void insert(PermissionEntity PermissionEntity);

@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertAllSync(List<PermissionEntity> list);

@Insert(onConflict = OnConflictStrategy.REPLACE)
Completable insertAllAsync(List<PermissionEntity> list);


}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;
Expand All @@ -19,6 +20,8 @@
import com.seafile.seadroid2.framework.util.Times;
import com.seafile.seadroid2.framework.util.Utils;

import org.apache.commons.lang3.StringUtils;

@Entity(tableName = "dirents")
public class DirentModel extends BaseModel implements Parcelable {

Expand Down Expand Up @@ -102,7 +105,9 @@ public String getSubtitle() {

public int getIcon() {
if (isDir()) {
if (!hasWritePermission()) {
if (isCustomPermission()) {
return R.drawable.baseline_folder_24;
} else if (!hasWritePermission()) {
return R.drawable.baseline_folder_read_only_24;
} else {
return R.drawable.baseline_folder_24;
Expand All @@ -111,6 +116,9 @@ public int getIcon() {
return Icons.getFileIcon(name);
}

/**
* You'll also need to check if it's a custom permission
*/
public boolean hasWritePermission() {
if (TextUtils.isEmpty(permission)) {
return false;
Expand All @@ -127,6 +135,9 @@ public boolean hasWritePermission() {
return permission.contains("w");
}

/**
* You'll also need to check if it's a custom permission
*/
public boolean hasDownloadPermission() {
if (TextUtils.isEmpty(permission)) {
return false;
Expand All @@ -143,6 +154,15 @@ public boolean hasDownloadPermission() {
return true;
}

public boolean isCustomPermission() {
return !TextUtils.isEmpty(permission) && permission.startsWith("custom-");
}

public int getCustomPermissionNum() {
String[] ss = StringUtils.split(permission, "-");
return Integer.parseInt(ss[1]);
}

public static DirentModel convertStarredModelToThis(StarredModel starredModel) {
if (starredModel == null) {
return null;
Expand Down
Loading

0 comments on commit 828af6a

Please sign in to comment.