Skip to content

Commit

Permalink
fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
zhwanng committed Oct 14, 2024
1 parent ecd8aad commit 10018aa
Show file tree
Hide file tree
Showing 61 changed files with 730 additions and 310 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# License

Copyright (c) 2013-2018 Seafile ltd.
Copyright (c) 2013-2024 Seafile ltd.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
Expand Down
6 changes: 3 additions & 3 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 153
versionName "3.0.3"
versionCode 154
versionName "3.0.4"
multiDexEnabled true

resValue "string", "authorities", defaultConfig.applicationId + '.debug.cameraupload.provider'
Expand Down Expand Up @@ -243,7 +243,7 @@ android {

//
implementation 'com.blankj:utilcode:1.30.7'

//https://github.com/CymChad/BaseRecyclerViewAdapterHelper
implementation "io.github.cymchad:BaseRecyclerViewAdapterHelper4:4.1.2"

Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
android:name=".ui.main.MainActivity"
android:configChanges="uiMode|orientation|screenSize"
android:exported="false"
android:windowSoftInputMode="adjustPan"
android:launchMode="singleTop" />

<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public static void logout(Account account) {
// turn off the gesture lock anyway
GestureLockSharePreferenceHelper.disable();

//TODO ?
Settings.initUserSettings();

NotificationUtils.cancelAll();
Expand Down Expand Up @@ -55,7 +54,6 @@ public static void switchAccount(Account account) {
return;
}


NotificationUtils.cancelAll();

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ public void setAuthToken(android.accounts.Account account, final String authToke
accountManager.setAuthToken(account, authTokenType, authToken);
}


public void setServerInfo(Account account, ServerInfo serverInfo) {
setUserData(account.getAndroidAccount(), Authenticator.KEY_SERVER_URI, serverInfo.getUrl());
setUserData(account.getAndroidAccount(), Authenticator.KEY_SERVER_VERSION, serverInfo.getVersion());
Expand Down
26 changes: 26 additions & 0 deletions app/src/main/java/com/seafile/seadroid2/annotation/Unstable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.seafile.seadroid2.annotation;

import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.CLASS;

import androidx.annotation.RequiresOptIn;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

/**
* In this project, it only means that this feature is not fully validated, please use it with caution.
* <p>
* Referenced in Media3.UnstableApi
*/
@Documented
@Retention(CLASS)
@Target({TYPE, METHOD, CONSTRUCTOR, FIELD})
@androidx.media3.common.util.UnstableApi
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
public @interface Unstable {
}
38 changes: 38 additions & 0 deletions app/src/main/java/com/seafile/seadroid2/compat/ContextCompat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import android.content.IntentFilter
import android.content.res.ColorStateList
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.util.TypedValue
import androidx.annotation.AttrRes
import androidx.annotation.ColorInt
import androidx.annotation.ColorRes
import androidx.annotation.Dimension
import androidx.annotation.DrawableRes
import androidx.annotation.StyleRes
import androidx.annotation.StyleableRes
Expand Down Expand Up @@ -67,3 +69,39 @@ fun Context.registerReceiverCompat(
filter: IntentFilter,
flags: Int
): Intent? = ContextCompat.registerReceiver(this, receiver, filter, flags)


@Dimension
fun Context.dpToDimensionPixelSize(@Dimension(unit = Dimension.DP) dp: Float): Int {
val value = dpToDimension(dp)
val size = (if (value >= 0) value + 0.5f else value - 0.5f).toInt()
return when {
size != 0 -> size
value == 0f -> 0
value > 0 -> 1
else -> -1
}
}


@Dimension
fun Context.dpToDimensionPixelSize(@Dimension(unit = Dimension.DP) dp: Int) = dpToDimensionPixelSize(dp.toFloat())

@Dimension
fun Context.dpToDimension(@Dimension(unit = Dimension.DP) dp: Float): Float =
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.displayMetrics)

@Dimension
fun Context.dpToDimension(@Dimension(unit = Dimension.DP) dp: Int) = dpToDimension(dp.toFloat())

@Dimension
fun Context.dpToDimensionPixelOffset(@Dimension(unit = Dimension.DP) dp: Float): Int =
dpToDimension(dp).toInt()

@Dimension
fun Context.dpToDimensionPixelOffset(@Dimension(unit = Dimension.DP) dp: Int) =
dpToDimensionPixelOffset(dp.toFloat())

@SuppressLint("RestrictedApi")
fun Context.getDrawableByAttr(@AttrRes attr: Int): Drawable =
obtainStyledAttributesCompat(attrs = intArrayOf(attr)).use { it.getDrawable(0) }
46 changes: 46 additions & 0 deletions app/src/main/java/com/seafile/seadroid2/compat/ViewCompat.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.seafile.seadroid2.compat

import android.content.res.ColorStateList
import android.graphics.PorterDuff
import android.graphics.drawable.Drawable
import android.view.View
import androidx.annotation.IdRes
import androidx.core.view.ViewCompat
import com.seafile.seadroid2.framework.util.ForegroundCompat

@Suppress("UNCHECKED_CAST")
fun <T : View> View.requireViewByIdCompat(@IdRes id: Int): T = ViewCompat.requireViewById<T>(this, id)

var View.scrollIndicatorsCompat: Int
get() = ViewCompat.getScrollIndicators(this)
set(value) {
ViewCompat.setScrollIndicators(this, value)
}

fun View.setScrollIndicatorsCompat(indicators: Int, mask: Int) {
ViewCompat.setScrollIndicators(this, indicators, mask)
}

var View.foregroundCompat: Drawable?
get() = ForegroundCompat.getForeground(this)
set(value) {
ForegroundCompat.setForeground(this, value)
}

var View.foregroundGravityCompat: Int
get() = ForegroundCompat.getForegroundGravity(this)
set(value) {
ForegroundCompat.setForegroundGravity(this, value)
}

var View.foregroundTintListCompat: ColorStateList?
get() = ForegroundCompat.getForegroundTintList(this)
set(value) {
ForegroundCompat.setForegroundTintList(this, value)
}

var View.foregroundTintModeCompat: PorterDuff.Mode?
get() = ForegroundCompat.getForegroundTintMode(this)
set(value) {
ForegroundCompat.setForegroundTintMode(this, value)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.seafile.seadroid2.enums;

import android.text.TextUtils;

public enum WebViewPreviewType {
SDOC, URL;

public static boolean contains(String value) {
if (TextUtils.isEmpty(value)){
return false;
}

try {
WebViewPreviewType.valueOf(value);
return true;
} catch (IllegalArgumentException e) {
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,18 @@ public String toString() {
'}';
}

@NonNull
public String getUID() {
if (TextUtils.isEmpty(related_account)) {
throw new IllegalArgumentException("related_account can not be null.");
}
if (null == transfer_action) {
throw new IllegalArgumentException("transfer_action can not be null.");
}
if (TextUtils.isEmpty(full_path)) {
throw new IllegalArgumentException("full_path can not be null.");
}

return EncryptUtils.encryptMD5ToString(related_account + transfer_action + full_path).toLowerCase();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ public class GestureLockSharePreferenceHelper {
public static final long LOCK_EXPIRATION_MSECS = 5 * 60 * 1000;

public static void disable() {
if (Settings.GESTURE_LOCK_SWITCH == null) {
return;
}

//
Settings.GESTURE_LOCK_SWITCH.putValue(false);
Settings.SETTINGS_GESTURE.putValue(false);

//
GestureLockSharePreferenceHelper.updateLockTimeStamp(0L);
Expand All @@ -25,11 +22,8 @@ public static void disable() {
* would not be asked for gesture lock for a short period of time.
*/
public static boolean isLockRequired() {
if (Settings.GESTURE_LOCK_SWITCH == null) {
return false;
}

Boolean isEnable = Settings.GESTURE_LOCK_SWITCH.queryValue();
Boolean isEnable = Settings.SETTINGS_GESTURE.queryValue();
if (!isEnable) {
return false;
}
Expand All @@ -39,11 +33,7 @@ public static boolean isLockRequired() {
return false;
}

if (Settings.GESTURE_LOCK_TIMESTAMP == null) {
return false;
}

long lock_timestamp = Settings.GESTURE_LOCK_TIMESTAMP.queryValue();
long lock_timestamp = Settings.SETTINGS_GESTURE_LOCK_TIMESTAMP.queryValue();
if (lock_timestamp == 0) {
return false;
}
Expand All @@ -62,10 +52,7 @@ public static void updateLockTimeStamp() {
}

public static void updateLockTimeStamp(long time) {
if (Settings.GESTURE_LOCK_TIMESTAMP == null) {
return;
}

Settings.GESTURE_LOCK_TIMESTAMP.putValue(time);
Settings.SETTINGS_GESTURE_LOCK_TIMESTAMP.putValue(time);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void initIgnorePath() {
return;
}

// /storage/emulated/0/Android/media/com.seafile.seadroid2.debug/Seafile
// /storage/emulated/0/Android/media/com.seafile.seadroid2(.debug)/Seafile
String path = StorageManager.getInstance().getMediaDir().getAbsolutePath();
IGNORE_PATHS.add(path);

Expand Down
Loading

0 comments on commit 10018aa

Please sign in to comment.