Skip to content

Commit

Permalink
Feat 2.3.6 (#988)
Browse files Browse the repository at this point in the history
* custom video player UI

* fix bugs

1. [fix] #985
2.[modify] WRITE_EXTERNAL_STORAGE Modified to MANAGE_EXTERNAL_STORAGE in BrowserActivity
3. fix other bugs

* remove useless xml label

* fix a bug

Clicking on an Item of type "/" in an ActivityFragment will toast an internal server error.

* code improvement

1、Fix the bug: when you open the APP, you can't delete the data on the "Starred Files" page when you directly long-press and delete it.
2. Add star feature to the list of libraries.
3. Add star feature to folder list.
4、Folders and libraries on the starred page can be clicked to enter details.
5. Remove the client password feature on the settings page.
6. Modify the API and logic for deleting files/folders.
7. Modify the entity fields of library page, starred page and activity page.
8. Update NavContext class
9. Add storage permission check when entering the home page: different system versions request different storage permissions.

* feat-2.3.6

- Refactoring the SettingsFragment page
- Folder Backup: Add Skip Hidden Files Feature
- Add preview for sdoc format files
- Cleaning up useless code
- Add some util classes

* improve code
  • Loading branch information
zhwanng authored Dec 13, 2023
1 parent 1eefe8d commit 4f4d7f0
Show file tree
Hide file tree
Showing 117 changed files with 4,432 additions and 2,789 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ lint.xml
# Gradle files
.gradle/
**/build/
gradle.properties

# Local configuration file (sdk path, etc)
local.properties
Expand Down
8 changes: 6 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId 'com.seafile.seadroid2'
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 138
versionName "2.3.5"
versionCode 139
versionName "2.3.6"
multiDexEnabled true
resValue "string", "authorities", applicationId + '.cameraupload.provider'
resValue "string", "account_type", "com.seafile.seadroid2.account.api2"
Expand Down Expand Up @@ -126,6 +126,10 @@ android {
implementation "com.google.android.material:material:$x_version"
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation "androidx.preference:preference:1.2.1"

//live event bus
// implementation 'io.github.jeremyliao:live-event-bus-x:1.8.0'

//https://github.com/ongakuer/CircleIndicator
implementation 'me.relex:circleindicator:2.1.6'
Expand Down
46 changes: 29 additions & 17 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,22 @@
<!--<uses-permission android:name="android.permission.WRITE_CONTACTS"/>-->

<!--android 9.0 FOREGROUND_SERVICE -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.READ_SYNC_STATS" />

<!-- <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />-->


<!-- Runtime permissions introduced in Android 13 (API level 33) -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />

<application
android:name="com.seafile.seadroid2.SeadroidApplication"
Expand Down Expand Up @@ -126,33 +137,34 @@

<activity android:name="com.seafile.seadroid2.ui.activity.TransferActivity" />

<activity
android:name="com.seafile.seadroid2.ui.activity.search.SearchActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
</activity>

<activity android:name="com.seafile.seadroid2.cameraupload.CameraUploadConfigActivity" />
<activity android:name=".folderbackup.FolderBackupConfigActivity" />
<!--<activity android:name="com.seafile.seadroid2.cameraupload.ContactsUploadConfigActivity"-->
<!--android:label="@string/app_name">-->
<!--</activity>-->

<activity android:name=".ui.activity.GalleryActivity" />
<activity
android:name=".play.PlayActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="sensor"
android:theme="@style/Theme.Fullscreen" />
<activity
android:name=".editor.EditorActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.Editor" />
<activity android:name=".ui.activity.search.Search2Activity" />

<activity
android:name=".ui.activity.search.Search2Activity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
</activity>

<activity android:name=".folderbackup.FolderBackupSelectedPathActivity" />
<activity android:name=".play.exoplayer.ExoVideoPlayerActivity" />

<activity
android:name=".play.exoplayer.CustomExoVideoPlayerActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="sensor"
android:theme="@style/Theme.Fullscreen" />
<activity android:name=".ui.activity.webview.SeaWebViewActivity" />

<provider
android:name="com.seafile.seadroid2.provider.SeafileProvider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
import com.joanzapata.iconify.Iconify;
import com.joanzapata.iconify.fonts.MaterialCommunityModule;
import com.seafile.seadroid2.gesturelock.AppLockManager;
import com.seafile.seadroid2.monitor.ActivityMonitor;
import com.seafile.seadroid2.ui.CustomNotificationBuilder;
import com.seafile.seadroid2.util.CrashHandler;
import com.seafile.seadroid2.util.DeviceIdManager;
import com.seafile.seadroid2.util.SeafileLog;
import com.seafile.seadroid2.util.Utils;

public class SeadroidApplication extends Application {
Expand All @@ -33,10 +32,12 @@ public void onCreate() {
AppLockManager.getInstance().enableDefaultAppLockIfAvailable(this);

initNotificationChannel();

CrashHandler crashHandler = CrashHandler.getInstance();
crashHandler.init(this);
Utils.logPhoneModelInfo();

//This feature can be extended
registerActivityLifecycleCallbacks(new ActivityMonitor());
}

@Override
Expand Down
105 changes: 53 additions & 52 deletions app/src/main/java/com/seafile/seadroid2/SeafConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;
import android.os.FileUtils;
import android.provider.Settings.Secure;
import android.text.TextUtils;
import android.util.Log;
Expand All @@ -13,6 +14,7 @@
import com.github.kevinsawicki.http.HttpRequest.HttpRequestException;
import com.google.common.collect.Maps;
import com.seafile.seadroid2.account.Account;
import com.seafile.seadroid2.config.ApiUrls;
import com.seafile.seadroid2.data.Block;
import com.seafile.seadroid2.data.BlockInfoBean;
import com.seafile.seadroid2.data.DataManager;
Expand Down Expand Up @@ -282,7 +284,7 @@ public boolean doLogin(String passwd, String authToken, boolean rememberDevice)
public String getRepos() throws SeafException {
HttpRequest req = null;
try {
req = prepareApiGetRequest("api2/repos/");
req = prepareApiGetRequest("api/v2.1/repos/");
checkRequestResponseStatus(req, HttpURLConnection.HTTP_OK);

String result = new String(req.bytes(), "UTF-8");
Expand Down Expand Up @@ -346,8 +348,7 @@ public String getHistoryChanges(String repoID, String commitId) throws SeafExcep

public String getStarredFiles() throws SeafException {
try {
// HttpRequest req = prepareApiGetRequest("api2/starredfiles/");
HttpRequest req = prepareApiGetRequest("api/v2.1/starred-items/");
HttpRequest req = prepareApiGetRequest(ApiUrls.STAR_ITEMS);
checkRequestResponseStatus(req, HttpURLConnection.HTTP_OK);

return new String(req.bytes(), "UTF-8");
Expand Down Expand Up @@ -416,43 +417,20 @@ private static String encodeUriComponent(String src) throws UnsupportedEncodingE
* @return A non-null Pair of (dirID, content). If the local cache is up to date, the "content" is null.
* @throws SeafException
*/
public Pair<String, String> getDirents(String repoID, String path, String cachedDirID)
throws SeafException {
public String getDirents(String repoID, String path) throws SeafException {
try {
String apiPath = String.format("api2/repos/%s/dir/", repoID);
String apiPath = String.format(ApiUrls.REPOS_DIR, repoID);
Map<String, Object> params = Maps.newHashMap();
params.put("p", encodeUriComponent(path));
if (cachedDirID != null) {
params.put("oid", cachedDirID);
}

HttpRequest req = prepareApiGetRequest(apiPath, params);
checkRequestResponseStatus(req, HttpURLConnection.HTTP_OK);

String dirID = req.header("oid");
String content;
if (dirID == null) {
byte[] rawBytes = req.bytes();
if (rawBytes == null) {
throw SeafException.unknownException;
}

if (dirID.equals(cachedDirID)) {
// local cache is valid
// Log.d(DEBUG_TAG, String.format("dir %s is cached", path));
content = null;
} else {
/*Log.d(DEBUG_TAG,
String.format("dir %s will be downloaded from server, latest %s, local cache %s",
path, dirID, cachedDirID != null ? cachedDirID : "null"));*/
byte[] rawBytes = req.bytes();
if (rawBytes == null) {
throw SeafException.unknownException;
}
content = new String(rawBytes, "UTF-8");
}

return new Pair<String, String>(dirID, content);

} catch (SeafException e) {
throw e;
return new String(rawBytes, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw SeafException.encodingException;
} catch (HttpRequestException e) {
Expand Down Expand Up @@ -634,7 +612,6 @@ private File getFileFromLink(String dlink, String path, String localPath, String
return null;
}
return file;

} catch (SeafException e) {
throw e;
} catch (UnsupportedEncodingException e) {
Expand Down Expand Up @@ -715,11 +692,7 @@ public String getReUsedFileLink(String repoID, String path) throws SeafException
* @param monitor
* @return A two tuple of (fileID, file). If the local cached version is up to date, the returned file is null.
*/
public Pair<String, File> getFile(String repoID,
String path,
String localPath,
String cachedFileID,
ProgressMonitor monitor) throws SeafException {
public Pair<String, File> getFile(String repoID, String path, String localPath, String cachedFileID, ProgressMonitor monitor) throws SeafException {
Pair<String, String> ret = getDownloadLink(repoID, path, false);
String dlink = ret.first;
String fileID = ret.second;
Expand Down Expand Up @@ -1306,6 +1279,7 @@ public void completeRemoteWipe(String token) throws SeafException {

public void star(String repoID, String path) throws SeafException {
try {
//api/v2.1/starred-items/
HttpRequest req = prepareApiPostRequest("api2/starredfiles/", true, null);

req.form("repo_id", repoID);
Expand All @@ -1320,6 +1294,22 @@ public void star(String repoID, String path) throws SeafException {
}
}

public void starItems(String repoID, String path) throws SeafException {
try {
//api/v2.1/starred-items/
HttpRequest req = prepareApiPostRequest(ApiUrls.STAR_ITEMS, true, null);

req.form("repo_id", repoID);
req.form("path", path);

checkRequestResponseStatus(req, HttpURLConnection.HTTP_OK);
} catch (SeafException e) {
throw e;
} catch (HttpRequestException e) {
throw getSeafExceptionFromHttpRequestException(e);
}
}

public void unstar(String repoID, String path) throws SeafException {
try {
Map<String, Object> params = Maps.newHashMap();
Expand All @@ -1336,8 +1326,23 @@ public void unstar(String repoID, String path) throws SeafException {
}
}

public Pair<String, String> rename(String repoID, String path,
String newName, boolean isdir) throws SeafException {
public void unstarItems(String repoID, String path) throws SeafException {
try {
Map<String, Object> params = Maps.newHashMap();
params.put("repo_id", repoID);
params.put("path", path);
HttpRequest req = prepareApiDeleteRequest(ApiUrls.STAR_ITEMS, params);

checkRequestResponseStatus(req, HttpURLConnection.HTTP_OK);

} catch (SeafException e) {
throw e;
} catch (HttpRequestException e) {
throw getSeafExceptionFromHttpRequestException(e);
}
}

public Pair<String, String> rename(String repoID, String path, String newName, boolean isdir) throws SeafException {
try {
Map<String, Object> params = Maps.newHashMap();
params.put("p", encodeUriComponent(path).replaceAll("\\+", "%20"));
Expand Down Expand Up @@ -1370,34 +1375,30 @@ public Pair<String, String> rename(String repoID, String path,
}
}

public Pair<String, String> delete(String repoID, String path,
boolean isdir) throws SeafException {
public boolean delete(String repoID, String path, boolean isdir) throws SeafException {
try {
Map<String, Object> params = Maps.newHashMap();
params.put("p", encodeUriComponent(path).replaceAll("\\+", "%20"));
params.put("reloaddir", "true");
String suffix = isdir ? "/dir/" : "/file/";
HttpRequest req = prepareApiDeleteRequest("api2/repos/" + repoID + suffix, params);
HttpRequest req = prepareApiDeleteRequest(ApiUrls.DELETE_FILE_OR_DIR + repoID + suffix, params);

checkRequestResponseStatus(req, HttpURLConnection.HTTP_OK);

String newDirID = req.header("oid");
if (newDirID == null) {
return null;
}

String content = new String(req.bytes(), "UTF-8");
if (content.length() == 0) {
return null;
return false;
}

return new Pair<String, String>(newDirID, content);
JSONObject jsonObject = new JSONObject(content);
return jsonObject.optBoolean("success");
} catch (SeafException e) {
throw e;
} catch (UnsupportedEncodingException e) {
throw SeafException.encodingException;
} catch (HttpRequestException e) {
throw getSeafExceptionFromHttpRequestException(e);
} catch (JSONException e) {
throw SeafException.illFormatException;
}
}

Expand Down Expand Up @@ -1525,7 +1526,7 @@ private void checkRequestResponseStatus(HttpRequest req, int expectedStatusCode)
String result = new String(req.bytes(), "UTF-8");
if (result != null && Utils.parseJsonObject(result) != null) {
JSONObject json = Utils.parseJsonObject(result);
if (json.has("detail")){
if (json.has("detail")) {
throw new SeafException(req.code(), json.optString("detail"));
}
throw new SeafException(req.code(), json.optString("error_msg"));
Expand Down
Loading

0 comments on commit 4f4d7f0

Please sign in to comment.