Skip to content

Commit 795bc83

Browse files
authored
Merge pull request #1081 from haiwen/save_into
Save into - Refactored seafile document provider - Refactored DataManager - updated other feats - fixed some bugs
2 parents 21c4716 + 8fe5e75 commit 795bc83

File tree

201 files changed

+3989
-6836
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+3989
-6836
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ android {
1414
targetSdkVersion rootProject.ext.targetSdkVersion
1515
compileSdk rootProject.ext.compileSdkVersion
1616

17-
versionCode 180
18-
versionName "3.0.13"
17+
versionCode 185
18+
versionName "3.0.14"
1919
multiDexEnabled true
2020

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

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
<uses-sdk tools:overrideLibrary="us.feras.mdv" />
66

7-
87
<uses-permission android:name="android.permission.INTERNET" />
98
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
109
<uses-permission android:name="android.permission.CAMERA" />
@@ -98,7 +97,7 @@
9897
<activity
9998
android:name=".ui.SplashActivity"
10099
android:exported="true"
101-
android:theme="@style/AppTheme.Starting">
100+
android:theme="@style/App.Theme.Splash">
102101
<intent-filter>
103102
<action android:name="android.intent.action.MAIN" />
104103
<category android:name="android.intent.category.LAUNCHER" />
@@ -120,16 +119,6 @@
120119
android:launchMode="singleTop"
121120
android:windowSoftInputMode="adjustPan" />
122121

123-
<activity
124-
android:name=".ui.gesture.UnlockGesturePasswordActivity"
125-
android:launchMode="singleTop"
126-
android:screenOrientation="portrait" />
127-
128-
<activity
129-
android:name=".ui.gesture.CreateGesturePasswordActivity"
130-
android:launchMode="singleTask"
131-
android:screenOrientation="portrait" />
132-
133122
<activity android:name=".ui.markdown.MarkdownActivity" />
134123

135124
<activity
@@ -172,37 +161,15 @@
172161

173162
<activity
174163
android:name=".ui.editor.EditorActivity"
175-
android:screenOrientation="portrait"
176164
android:theme="@style/AppTheme.Editor" />
177165

178-
<provider
179-
android:name=".ui.search.RecentSearchSuggestionsProvider"
180-
android:authorities="${applicationId}.ui.search.RecentSearchSuggestionsProvider" />
181-
182-
<activity
183-
android:name=".ui.search.Search2Activity"
184-
android:configChanges="uiMode"
185-
android:exported="true"
186-
android:launchMode="singleTop"
187-
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer">
188-
<intent-filter>
189-
<action android:name="android.intent.action.SEARCH" />
190-
</intent-filter>
191-
<meta-data
192-
android:name="android.app.searchable"
193-
android:resource="@xml/searchable" />
194-
</activity>
195-
196166
<activity android:name=".ui.folder_backup.FolderBackupSelectedPathActivity" />
197167

198168
<activity
199169
android:name=".ui.media.player.CustomExoVideoPlayerActivity"
200-
android:configChanges="orientation|keyboardHidden|screenSize"
201-
android:screenOrientation="sensor" />
170+
android:configChanges="orientation|keyboardHidden|screenSize" />
202171

203-
<activity
204-
android:name=".ui.webview.SeaWebViewActivity"
205-
android:screenOrientation="portrait" />
172+
<activity android:name=".ui.webview.SeaWebViewActivity" />
206173
<activity android:name=".ui.data_migrate.DataMigrationActivity" />
207174
<activity android:name=".ui.selector.ObjSelectorActivity" />
208175
<activity android:name=".ui.transfer_list.TransferActivity" />
@@ -211,12 +178,8 @@
211178
<activity android:name=".ui.data_migrate.DataMigrationV303Activity" />
212179
<activity android:name=".ui.sdoc.SDocWebViewActivity" />
213180
<activity android:name=".ui.docs_comment.DocsCommentsActivity" />
214-
<activity
215-
android:name=".ui.media.image.CarouselImagePreviewActivity"
216-
android:screenOrientation="portrait" />
217-
<activity
218-
android:name=".ui.media.image.OnlyImagePreviewActivity"
219-
android:screenOrientation="portrait" />
181+
<activity android:name=".ui.media.image.CarouselImagePreviewActivity" />
182+
<activity android:name=".ui.media.image.OnlyImagePreviewActivity" />
220183

221184
<provider
222185
android:name=".provider.SeafileProvider"

app/src/main/java/com/seafile/seadroid2/SeadroidApplication.java

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,31 @@
33

44
import android.app.Application;
55
import android.content.Context;
6+
import android.util.Log;
7+
8+
import androidx.annotation.BoolRes;
9+
import androidx.annotation.IntegerRes;
10+
import androidx.annotation.StringRes;
611

712
import com.jeremyliao.liveeventbus.LiveEventBus;
813
import com.seafile.seadroid2.framework.monitor.ActivityMonitor;
914
import com.seafile.seadroid2.framework.notification.base.NotificationUtils;
1015
import com.seafile.seadroid2.framework.util.CrashHandler;
1116
import com.seafile.seadroid2.framework.util.SLogs;
1217
import com.seafile.seadroid2.preferences.Settings;
18+
import com.seafile.seadroid2.provider.DocumentCache;
1319

1420

1521
public class SeadroidApplication extends Application {
16-
private static Context context;
17-
private static SeadroidApplication instance;
22+
private static Context context = null;
1823

1924
@Override
2025
public void onCreate() {
2126
super.onCreate();
2227

23-
instance = this;
28+
context = this;
29+
30+
Log.e("SeadroidApplication", "onCreate()");
2431

2532
//init slogs
2633
SLogs.init();
@@ -61,8 +68,29 @@ public static Context getAppContext() {
6168
return context;
6269
}
6370

64-
public static SeadroidApplication getInstance() {
65-
return instance;
71+
public static String getAppString(@StringRes int resId) {
72+
return getAppContext().getResources().getString(resId);
73+
}
74+
75+
public static String getAppString(@StringRes int resId, Object... formatArgs) {
76+
return getAppContext().getResources().getString(resId, formatArgs);
77+
}
78+
79+
public static Boolean getAppBoolean(@BoolRes int resId) {
80+
return getAppContext().getResources().getBoolean(resId);
6681
}
6782

68-
}
83+
public static Integer getAppInteger(@IntegerRes int resId) {
84+
return getAppContext().getResources().getInteger(resId);
85+
}
86+
87+
private final DocumentCache mCache = new DocumentCache();
88+
89+
public static DocumentCache getDocumentCache() {
90+
return getApplication().mCache;
91+
}
92+
93+
private static SeadroidApplication getApplication() {
94+
return (SeadroidApplication) getAppContext();
95+
}
96+
}

app/src/main/java/com/seafile/seadroid2/SeafException.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ public class SeafException extends Exception {
1414

1515
public static final SeafException SUCCESS = new SeafException(CODE_SUCCESS, "success");
1616

17-
public static final SeafException OUT_OF_QUOTA = new SeafException(HTTP_ABOVE_QUOTA, SeadroidApplication.getAppContext().getString(R.string.above_quota));
17+
public static final SeafException OUT_OF_QUOTA = new SeafException(HTTP_ABOVE_QUOTA, SeadroidApplication.getAppString(R.string.above_quota));
1818
public static final SeafException REQUEST_EXCEPTION = new SeafException(400, "request failed");
1919
public static final SeafException SERVER_INTERNAL_ERROR = new SeafException(500, "server internal error");
2020

2121
public static final SeafException UNKNOWN_EXCEPTION = new SeafException(1, "unknown error");
22-
public static final SeafException NETWORK_EXCEPTION = new SeafException(2, SeadroidApplication.getAppContext().getString(R.string.network_error));
22+
public static final SeafException NETWORK_EXCEPTION = new SeafException(2, SeadroidApplication.getAppString(R.string.network_error));
2323
public static final SeafException ENCODING_EXCEPTION = new SeafException(3, "encoding error");
2424
public static final SeafException ILL_FORMAT_EXCEPTION = new SeafException(4, "Ill-formatted Response");
2525
public static final SeafException SSL_EXCEPTION = new SeafException(5, "not trusted SSL server");
2626
public static final SeafException USER_CANCELLED_EXCEPTION = new SeafException(6, "operation cancelled by user");
2727

2828

29-
public static final SeafException INVALID_PASSWORD = new SeafException(7, SeadroidApplication.getAppContext().getString(R.string.wrong_password));
29+
public static final SeafException INVALID_PASSWORD = new SeafException(7, SeadroidApplication.getAppString(R.string.wrong_password));
3030
public static final SeafException UNSUPPORTED_ENC_VERSION = new SeafException(8, "unsupported encryption version");
3131
public static final SeafException ENCRYPT_EXCEPTION = new SeafException(10, "encryption key or iv is null");
3232
public static final SeafException DECRYPT_EXCEPTION = new SeafException(11, "decryption key or iv is null");
3333
public static final SeafException REMOTE_WIPED_EXCEPTION = new SeafException(12, "remote Wiped Error");
34-
public static final SeafException TWO_FACTOR_AUTH_TOKEN_MISSING_EXCEPTION = new SeafException(13, SeadroidApplication.getAppContext().getString(R.string.two_factor_auth_token_empty));
35-
public static final SeafException TWO_FACTOR_AUTH_TOKEN_INVALID_EXCEPTION = new SeafException(14, SeadroidApplication.getAppContext().getString(R.string.two_factor_auth_invalid));
34+
public static final SeafException TWO_FACTOR_AUTH_TOKEN_MISSING_EXCEPTION = new SeafException(13, SeadroidApplication.getAppString(R.string.two_factor_auth_token_empty));
35+
public static final SeafException TWO_FACTOR_AUTH_TOKEN_INVALID_EXCEPTION = new SeafException(14, SeadroidApplication.getAppString(R.string.two_factor_auth_invalid));
3636

3737
public static final SeafException NOT_FOUND_EXCEPTION = new SeafException(404, "not found");
3838
public static final SeafException NOT_FOUND_FILE_EXCEPTION = new SeafException(441, "File does not exist");
@@ -43,7 +43,8 @@ public class SeafException extends Exception {
4343
public static final SeafException REQUEST_TRANSFER_URL_EXCEPTION = new SeafException(24, "request transfer url failed");
4444
public static final SeafException IO_EXCEPTION = new SeafException(25, "io exception");
4545
public static final SeafException PERMISSION_EXCEPTION = new SeafException(26, "miss permission");
46-
public static final SeafException NETWORK_UNAVAILABLE = new SeafException(27, SeadroidApplication.getAppContext().getString(R.string.network_unavailable));
46+
public static final SeafException NETWORK_UNAVAILABLE = new SeafException(27, SeadroidApplication.getAppString(R.string.network_unavailable));
47+
public static final SeafException OPERATION_NOT_SUPPORTED_EXCEPTION = new SeafException(27, "Operation not supported");
4748

4849
public SeafException(int code, String msg) {
4950
super(msg);

app/src/main/java/com/seafile/seadroid2/account/AccountUtils.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import com.blankj.utilcode.util.NotificationUtils;
77
import com.seafile.seadroid2.framework.datastore.DataStoreManager;
8-
import com.seafile.seadroid2.framework.datastore.sp_livedata.GestureLockSharePreferenceHelper;
98
import com.seafile.seadroid2.framework.http.HttpIO;
109
import com.seafile.seadroid2.framework.util.SLogs;
1110
import com.seafile.seadroid2.framework.worker.BackgroundJobManagerImpl;
@@ -18,9 +17,6 @@ public class AccountUtils {
1817

1918
public static void logout(Account account) {
2019

21-
// turn off the gesture lock
22-
GestureLockSharePreferenceHelper.disable();
23-
2420
Settings.initUserSettings();
2521

2622
// clear
@@ -52,7 +48,7 @@ public static void logout(Account account) {
5248
cookieManager.removeAllCookies(new ValueCallback<Boolean>() {
5349
@Override
5450
public void onReceiveValue(Boolean value) {
55-
SLogs.d("removeAllCookie? " + value);
51+
SLogs.d("AccountUtils", "removeAllCookie? " + value);
5652
}
5753
});
5854
}
@@ -87,7 +83,7 @@ public static void switchAccount(Account account) {
8783
cookieManager.removeAllCookies(new ValueCallback<Boolean>() {
8884
@Override
8985
public void onReceiveValue(Boolean value) {
90-
SLogs.d("removeAllCookie? " + value);
86+
SLogs.d("AccountUtils", "removeAllCookie? " + value);
9187
}
9288
});
9389
}

app/src/main/java/com/seafile/seadroid2/account/Authenticator.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
public class Authenticator extends AbstractAccountAuthenticator {
2828

29-
private String DEBUG_TAG = "SeafileAuthenticator";
29+
private final String TAG = "SeafileAuthenticator";
3030
private final Context context;
3131

3232
/**
@@ -79,7 +79,7 @@ public class Authenticator extends AbstractAccountAuthenticator {
7979

8080
public Authenticator(Context context) {
8181
super(context);
82-
Log.d(DEBUG_TAG, "SeafileAuthenticator created.");
82+
SLogs.d(TAG, "SeafileAuthenticator created.");
8383
this.context = context;
8484
}
8585

@@ -88,7 +88,7 @@ public Authenticator(Context context) {
8888
*/
8989
@Override
9090
public Bundle editProperties(AccountAuthenticatorResponse r, String s) {
91-
Log.d(DEBUG_TAG, "editProperties");
91+
SLogs.d(TAG, "editProperties");
9292

9393
throw new UnsupportedOperationException();
9494
}
@@ -100,7 +100,7 @@ public Bundle addAccount(AccountAuthenticatorResponse response,
100100
String[] requiredFeatures,
101101
Bundle options) throws NetworkErrorException {
102102

103-
Log.d(DEBUG_TAG, "addAccount of type " + accountType);
103+
SLogs.d(TAG, "addAccount of type " + accountType);
104104

105105
if (authTokenType != null && !authTokenType.equals(Authenticator.AUTHTOKEN_TYPE)) {
106106
Bundle result = new Bundle();
@@ -124,7 +124,7 @@ public Bundle confirmCredentials(
124124
AccountAuthenticatorResponse response,
125125
android.accounts.Account account,
126126
Bundle bundle) throws NetworkErrorException {
127-
Log.d(DEBUG_TAG, "confirmCredentials");
127+
SLogs.d(TAG, "confirmCredentials");
128128

129129

130130
try {
@@ -134,7 +134,7 @@ public Bundle confirmCredentials(
134134

135135
if (res.isSuccessful()) {
136136
AccountInfo accountInfo = res.body();
137-
SLogs.d(accountInfo.toString());
137+
SLogs.d(TAG, accountInfo.toString());
138138
} else {
139139
if (res.code() == HttpURLConnection.HTTP_UNAUTHORIZED) {
140140
// Token is invalid
@@ -143,7 +143,7 @@ public Bundle confirmCredentials(
143143
result.putInt(AccountManager.KEY_ERROR_CODE, AccountManager.ERROR_CODE_INVALID_RESPONSE);
144144
result.putString(AccountManager.KEY_ERROR_MESSAGE, "Authentication error.");
145145
return result;
146-
}else {
146+
} else {
147147
throw new NetworkErrorException();
148148
}
149149
}
@@ -163,7 +163,7 @@ public Bundle getAuthToken(AccountAuthenticatorResponse response,
163163
android.accounts.Account account,
164164
String authTokenType,
165165
Bundle options) throws NetworkErrorException {
166-
Log.d(DEBUG_TAG, "getAuthToken");
166+
SLogs.d(TAG, "getAuthToken");
167167

168168
if (authTokenType != null && !authTokenType.equals(Authenticator.AUTHTOKEN_TYPE)) {
169169
final Bundle result = new Bundle();
@@ -201,7 +201,7 @@ public String getAuthTokenLabel(String authTokenType) {
201201
public Bundle updateCredentials(AccountAuthenticatorResponse response,
202202
android.accounts.Account account,
203203
String authTokenType, Bundle options) throws NetworkErrorException {
204-
Log.d(DEBUG_TAG, "updateCredentials");
204+
SLogs.d(TAG, "updateCredentials");
205205

206206
if (authTokenType != null && !authTokenType.equals(Authenticator.AUTHTOKEN_TYPE)) {
207207
final Bundle result = new Bundle();
@@ -228,7 +228,7 @@ public Bundle updateCredentials(AccountAuthenticatorResponse response,
228228
@Override
229229
public Bundle hasFeatures(AccountAuthenticatorResponse r,
230230
android.accounts.Account account, String[] strings) throws NetworkErrorException {
231-
Log.d(DEBUG_TAG, "hasFeatures");
231+
SLogs.d(TAG, "hasFeatures");
232232

233233
final Bundle result = new Bundle();
234234
result.putBoolean(android.accounts.AccountManager.KEY_BOOLEAN_RESULT, true);

app/src/main/java/com/seafile/seadroid2/config/Constants.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,8 @@ private Constants() {
88
throw new IllegalStateException("Constants class"); //NON-NLS(1)
99
}
1010

11-
12-
public static final int PERIODIC_SCAN_INTERVALS = 1000 * 60 * 5; //5m
1311
public static final String URL_PRIVACY = "https://www.seafile.com/privacy/";
1412

15-
public static class ObjType {
16-
private ObjType() {
17-
throw new IllegalStateException("Don't instantiate this class");
18-
}
19-
20-
public static final String REPO = "repo";
21-
public static final String DIR = "dir";
22-
public static final String FILE = "file";
23-
}
24-
2513
public static class Account {
2614
private Account() {
2715
throw new IllegalStateException("Don't instantiate this class");
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.seafile.seadroid2.config;
2+
3+
public class ObjKey {
4+
//account
5+
public static final String ACCOUNT = "account";
6+
7+
//repo
8+
public static final String REPO = "repo";
9+
public static final String REPO_ID = "repo_id";
10+
public static final String REPO_NAME = "repo_name";
11+
12+
//document
13+
public static final String DIRENT = "dirent";
14+
public static final String FILE = "file";
15+
public static final String DIR = "dir";
16+
}

0 commit comments

Comments
 (0)