Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
tag: v3.0.2-pre first commit
  • Loading branch information
zhwanng committed Jul 24, 2024
1 parent c25f164 commit 2f191c0
Show file tree
Hide file tree
Showing 89 changed files with 1,624 additions and 1,128 deletions.
22 changes: 15 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
targetSdkVersion rootProject.ext.targetSdkVersion
compileSdk rootProject.ext.compileSdkVersion

versionCode 150
versionName "3.0.1-beta"
versionCode 152
versionName "3.0.2-pre"
multiDexEnabled true

resValue "string", "authorities", defaultConfig.applicationId + '.debug.cameraupload.provider'
Expand Down Expand Up @@ -185,14 +185,18 @@ android {
implementation 'com.blankj:utilcode:1.30.7'
//https://github.com/CymChad/BaseRecyclerViewAdapterHelper
implementation "io.github.cymchad:BaseRecyclerViewAdapterHelper4:4.1.2"
//https://github.com/panpf/stickyitemdecoration
implementation "io.github.panpf.stickyitemdecoration:stickyitemdecoration:1.0.2"
//https://github.com/timusus/RecyclerView-FastScroll
implementation "com.simplecityapps:recyclerview-fastscroll:2.0.1"

// Firebase
implementation platform('com.google.firebase:firebase-bom:32.8.1')
implementation platform('com.google.firebase:firebase-bom:33.1.1')
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-analytics'

//media3
final def media3_version = '1.2.1'
final def media3_version = '1.3.1'
implementation "androidx.media3:media3-exoplayer:$media3_version"
implementation "androidx.media3:media3-ui:$media3_version"

Expand All @@ -206,7 +210,8 @@ android {
// implementation "androidx.datastore:datastore-preferences-rxjava2:1.0.0"
implementation "androidx.core:core-splashscreen:1.0.1"

implementation "com.google.android.material:material:1.11.0"
//https://github.com/material-components/material-components-android
implementation "com.google.android.material:material:1.12.0"

def lifecycle_version = "2.7.0"
implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
Expand Down Expand Up @@ -237,11 +242,11 @@ android {
annotationProcessor "androidx.room:room-compiler:$room_version"

//https://github.com/google/guava
implementation "com.google.guava:guava:32.1.2-android"
implementation "com.google.guava:guava:33.0.0-android"
//gson
implementation 'com.google.code.gson:gson:2.10.1'
//https://github.com/apache/commons-io
implementation 'commons-io:commons-io:2.13.0'
implementation 'commons-io:commons-io:2.16.1'
//https://github.com/apache/commons-lang
implementation 'com.github.apache:commons-lang:rel~commons-lang-3.12.0'

Expand All @@ -252,6 +257,9 @@ android {
//https://github.com/elvishew/xLog
implementation 'com.elvishew:xlog:1.10.1'

//https://github.com/zhanghai/AndroidFastScroll
implementation 'me.zhanghai.android.fastscroll:library:1.3.0'

// //https://github.com/wasabeef/recyclerview-animators
// implementation 'jp.wasabeef:recyclerview-animators:4.0.2'

Expand Down
7 changes: 0 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@

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

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

<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
Expand Down Expand Up @@ -94,10 +91,6 @@
<!-- tools:node="remove" />-->
<!-- </provider>-->

<meta-data
android:name=".util.GlideCache"
android:value="AppGlideModule" />

<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
android:foregroundServiceType="dataSync"
Expand Down
52 changes: 38 additions & 14 deletions app/src/main/java/com/seafile/seadroid2/account/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
import com.seafile.seadroid2.framework.util.URLs;
import com.seafile.seadroid2.framework.util.Utils;

import org.apache.commons.lang3.StringUtils;

import java.util.Locale;

public class Account extends BaseModel implements Parcelable, Comparable<Account> {
// The full URL of the server, like 'http://gonggeng.org/seahub/' or 'http://gonggeng.org/'
public String server;
Expand Down Expand Up @@ -48,8 +52,14 @@ public void setTotalSpace(long total) {
this.total = total;
}

public boolean isQuotaNoLimit() {
return total < 0;
/**
* in fact, the value should be less than 0.
* however, in some cases, it may be 0, and should also return unlimited.
* even if the non-limit is returned, App does not need to verify "Out of quota" status.
* and the "Out of quota" error will be returned in the file upload result.
*/
public boolean isQuotaUnlimited() {
return total <= 0;
}

public void setLoginTimestamp(long timestamp) {
Expand Down Expand Up @@ -114,12 +124,6 @@ public String getServerDomainName() {
return dn;
}

/**
* https://dev.xxx.com/dev/ => https://dev.xxx.com
*/
public String getProtocolHost() {
return URLs.getProtocolHost(server);
}

public String getEmail() {
return email;
Expand All @@ -133,10 +137,21 @@ public String getName() {
return name;
}


public String getServer() {
return server;
}

/**
* https://dev.xxx.com/dev/ => https://dev.xxx.com
*/
public String getProtocolHost() {
return URLs.getProtocolHost(server);
}

/**
* https://dev.xxx.com/dev/ => dev.xxx.com/dev
*/
public String getServerNoProtocol() {
String result = server.substring(server.indexOf("://") + 3);
if (result.endsWith("/"))
Expand All @@ -149,7 +164,7 @@ public String getToken() {
}

public boolean isHttps() {
return server.startsWith("https");
return server.toLowerCase(Locale.getDefault()).startsWith("https");
}

public boolean isShib() {
Expand All @@ -165,6 +180,9 @@ public void setSessionKey(String sessionKey) {
}


/**
* NOTICE: Do not modify the splicing format of this string
*/
public String getSignature() {
return String.format("%s (%s)", getServerNoProtocol(), email);
}
Expand All @@ -189,16 +207,22 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;
if (obj == null || (obj.getClass() != this.getClass()))
}

if (obj == null || (obj.getClass() != this.getClass())) {
return false;
}

Account a = (Account) obj;
if (a.server == null || a.email == null || a.token == null)
Account newAccount = (Account) obj;
if (newAccount.server == null || newAccount.email == null) {
return false;
}

return a.server.equals(this.server) && a.email.equals(this.email);
return Objects.equal(newAccount.server, this.server)
&& Objects.equal(newAccount.email, this.email)
&& Objects.equal(newAccount.token, this.token);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import android.text.TextUtils;
import android.util.Log;

import com.seafile.seadroid2.framework.http.IO;
import com.seafile.seadroid2.framework.http.HttpIO;
import com.seafile.seadroid2.framework.util.SLogs;
import com.seafile.seadroid2.ui.account.AccountService;
import com.seafile.seadroid2.ui.account.SeafileAuthenticatorActivity;
Expand Down Expand Up @@ -129,7 +129,7 @@ public Bundle confirmCredentials(

try {
Account a = SupportAccountManager.getInstance().getSeafileAccount(account);
Call<AccountInfo> call = IO.getInstanceByAccount(a).execute(AccountService.class).getAccountInfoCall();
Call<AccountInfo> call = HttpIO.getInstanceByAccount(a).execute(AccountService.class).getAccountInfoCall();
Response<AccountInfo> res = call.execute();

if (res.isSuccessful()) {
Expand Down
48 changes: 19 additions & 29 deletions app/src/main/java/com/seafile/seadroid2/config/GlideLoadConfig.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
package com.seafile.seadroid2.config;

import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.load.model.LazyHeaders;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.signature.ObjectKey;
import com.seafile.seadroid2.R;
import com.seafile.seadroid2.account.Account;
import com.seafile.seadroid2.account.SupportAccountManager;
import com.seafile.seadroid2.ui.WidgetUtils;

public class GlideLoadConfig {

public static GlideUrl getGlideUrl(String url) {

Account account = SupportAccountManager.getInstance().getCurrentAccount();
if (account == null) {
return new GlideUrl(url, new LazyHeaders.Builder().build());
}

String token = account.token;

return new GlideUrl(url, new LazyHeaders.Builder()
.addHeader("Authorization", "Token " + token)
.build());
}

public static GlideUrl getGlideUrl(String url, String token) {
return new GlideUrl(url, new LazyHeaders.Builder()
.addHeader("Authorization", "Token " + token)
.build());
}
// public static GlideUrl getGlideUrl(String url) {
//
// Account account = SupportAccountManager.getInstance().getCurrentAccount();
// if (account == null) {
// return new GlideUrl(url, new LazyHeaders.Builder().build());
// }
//
// String token = account.token;
//
// return new GlideUrl(url, new LazyHeaders.Builder()
// .addHeader("Authorization", "Token " + token)
// .build());
// }
//
// public static GlideUrl getGlideUrl(String url, String token) {
// return new GlideUrl(url, new LazyHeaders.Builder()
// .addHeader("Authorization", "Token " + token)
// .build());
// }

public static RequestOptions getAvatarOptions() {
return new RequestOptions()
Expand All @@ -51,10 +47,4 @@ public static RequestOptions getOptions(String key) {
.signature(new ObjectKey(key))
.override(WidgetUtils.getThumbnailWidth(), WidgetUtils.getThumbnailWidth());
}

public static RequestOptions getDefaultAvatarOptions() {
return new RequestOptions()
.placeholder(R.drawable.default_avatar)
.override(WidgetUtils.getThumbnailWidth(), WidgetUtils.getThumbnailWidth());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;

import com.seafile.seadroid2.framework.data.db.entities.CertEntity;

Expand All @@ -21,6 +22,12 @@ public interface CertCacheDAO {
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertAll(List<CertEntity> entities);

@Query("DELETE FROM cert_cache where url = :u")
void deleteByUrl(String u);

@Query("select * from cert_cache where url = :u limit 1")
List<CertEntity> getListByUrl(String u);

// @Query("select * from repo_config_cache where repo_id = :repoId limit 1")
// Single<List<RepoConfigCacheEntity>> getByRepoId(String repoId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,12 @@ public interface FileTransferDAO {
int countPendingDownloadListSync(String related_account);


@Query("select * from file_transfer_list where related_account = :related_account and transfer_action = 'UPLOAD' and data_source in ('FOLDER_BACKUP','FILE_BACKUP','ALBUM_BACKUP') and data_status = 0 order by created_at desc")
Single<List<FileTransferEntity>> getUploadListAsync(String related_account);

@Query("select * from file_transfer_list where related_account = :related_account and transfer_action = 'UPLOAD' and data_source in ('FOLDER_BACKUP','FILE_BACKUP','ALBUM_BACKUP') and data_status = 0 order by created_at desc limit :limit offset :offset")
@Query("select * from file_transfer_list where related_account = :related_account and transfer_action = 'UPLOAD' and data_source in ('FOLDER_BACKUP','FILE_BACKUP','ALBUM_BACKUP') and data_status = 0 order by modified_at desc limit :limit offset :offset")
List<FileTransferEntity> getPageUploadListSync(String related_account, int limit, int offset);


@Query("select * from file_transfer_list where related_account = :related_account and transfer_action = 'DOWNLOAD' and data_status = 0 order by created_at desc")
Single<List<FileTransferEntity>> getDownloadListAsync(String related_account);

@Query("select * from file_transfer_list where related_account = :related_account and transfer_action = 'DOWNLOAD' and data_status = 0 order by created_at desc limit :limit offset :offset")
@Query("select * from file_transfer_list where related_account = :related_account and transfer_action = 'DOWNLOAD' and data_status = 0 order by modified_at desc limit :limit offset :offset")
List<FileTransferEntity> getPageDownloadListSync(String related_account, int limit, int offset);


@Query("select * from file_transfer_list where related_account = :related_account and transfer_action = 'DOWNLOAD' and data_status = 0 order by created_at desc")
List<FileTransferEntity> getDownloadListSync(String related_account);

@Query("select * from file_transfer_list where related_account = :related_account and transfer_action = :transferAction and target_path = :target_path and data_status = 0 order by created_at desc limit 1")
List<FileTransferEntity> getByTargetPathSync(String related_account, TransferAction transferAction, String target_path);

Expand Down
Loading

0 comments on commit 2f191c0

Please sign in to comment.