From 21d7cf5d6ac2eb8dbaba542e1cfa639e8fb5bc9e Mon Sep 17 00:00:00 2001 From: Aria Moradi Date: Fri, 30 Jul 2021 00:46:06 +0430 Subject: [PATCH] prepare for PreferenceScreen support, remove some old depricated android libs --- .../support/v4/content/ContextCompat.java | 291 ------------------ .../support/v4/os/EnvironmentCompat.java | 53 ---- .../v7/preference/PreferenceDataStore.java | 193 ------------ .../v7/preference/PreferenceScreen.java | 4 - .../androidx/preference/PreferenceScreen.java | 4 + .../tachiyomi/source/ConfigurableSource.kt | 12 +- 6 files changed, 14 insertions(+), 543 deletions(-) delete mode 100644 AndroidCompat/src/main/java/android/support/v4/content/ContextCompat.java delete mode 100644 AndroidCompat/src/main/java/android/support/v4/os/EnvironmentCompat.java delete mode 100644 AndroidCompat/src/main/java/android/support/v7/preference/PreferenceDataStore.java delete mode 100644 AndroidCompat/src/main/java/android/support/v7/preference/PreferenceScreen.java create mode 100644 AndroidCompat/src/main/java/androidx/preference/PreferenceScreen.java diff --git a/AndroidCompat/src/main/java/android/support/v4/content/ContextCompat.java b/AndroidCompat/src/main/java/android/support/v4/content/ContextCompat.java deleted file mode 100644 index 508253ec..00000000 --- a/AndroidCompat/src/main/java/android/support/v4/content/ContextCompat.java +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.support.v4.content; - -import android.content.Context; -import android.content.Intent; -import android.graphics.drawable.Drawable; -import android.os.Bundle; -import android.os.StatFs; -import android.support.v4.os.EnvironmentCompat; - -import java.io.File; - -/** - * Helper for accessing features in {@link android.content.Context} - * introduced after API level 4 in a backwards compatible fashion. - */ -public class ContextCompat { - /** - * Start a set of activities as a synthesized task stack, if able. - * - *

In API level 11 (Android 3.0/Honeycomb) the recommended conventions for - * app navigation using the back key changed. The back key's behavior is local - * to the current task and does not capture navigation across different tasks. - * Navigating across tasks and easily reaching the previous task is accomplished - * through the "recents" UI, accessible through the software-provided Recents key - * on the navigation or system bar. On devices with the older hardware button configuration - * the recents UI can be accessed with a long press on the Home key.

- * - *

When crossing from one task stack to another post-Android 3.0, - * the application should synthesize a back stack/history for the new task so that - * the user may navigate out of the new task and back to the Launcher by repeated - * presses of the back key. Back key presses should not navigate across task stacks.

- * - *

startActivities provides a mechanism for constructing a synthetic task stack of - * multiple activities. If the underlying API is not available on the system this method - * will return false.

- * - * @param context Start activities using this activity as the starting context - * @param intents Array of intents defining the activities that will be started. The element - * length-1 will correspond to the top activity on the resulting task stack. - * @return true if the underlying API was available and the call was successful, false otherwise - */ - public static boolean startActivities(Context context, Intent[] intents) { - return startActivities(context, intents, null); - } - - /** - * Start a set of activities as a synthesized task stack, if able. - * - *

In API level 11 (Android 3.0/Honeycomb) the recommended conventions for - * app navigation using the back key changed. The back key's behavior is local - * to the current task and does not capture navigation across different tasks. - * Navigating across tasks and easily reaching the previous task is accomplished - * through the "recents" UI, accessible through the software-provided Recents key - * on the navigation or system bar. On devices with the older hardware button configuration - * the recents UI can be accessed with a long press on the Home key.

- * - *

When crossing from one task stack to another post-Android 3.0, - * the application should synthesize a back stack/history for the new task so that - * the user may navigate out of the new task and back to the Launcher by repeated - * presses of the back key. Back key presses should not navigate across task stacks.

- * - *

startActivities provides a mechanism for constructing a synthetic task stack of - * multiple activities. If the underlying API is not available on the system this method - * will return false.

- * - * @param context Start activities using this activity as the starting context - * @param intents Array of intents defining the activities that will be started. The element - * length-1 will correspond to the top activity on the resulting task stack. - * @param options Additional options for how the Activity should be started. - * See {@link android.content.Context#startActivity(Intent, Bundle) - * @return true if the underlying API was available and the call was successful, false otherwise - */ - public static boolean startActivities(Context context, Intent[] intents, - Bundle options) { - context.startActivities(intents, options); - return true; - } - - /** - * Returns absolute paths to application-specific directories on all - * external storage devices where the application's OBB files (if there are - * any) can be found. Note if the application does not have any OBB files, - * these directories may not exist. - *

- * This is like {@link Context#getFilesDir()} in that these files will be - * deleted when the application is uninstalled, however there are some - * important differences: - *

- *

- * External storage devices returned here are considered a permanent part of - * the device, including both emulated external storage and physical media - * slots, such as SD cards in a battery compartment. The returned paths do - * not include transient devices, such as USB flash drives. - *

- * An application may store data on any or all of the returned devices. For - * example, an app may choose to store large files on the device with the - * most available space, as measured by {@link StatFs}. - *

- * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions - * are required to write to the returned paths; they're always accessible to - * the calling app. Before then, - * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} is required to - * write. Write access outside of these paths on secondary external storage - * devices is not available. To request external storage access in a - * backwards compatible way, consider using {@code android:maxSdkVersion} - * like this: - * - *

<uses-permission
-     *     android:name="android.permission.WRITE_EXTERNAL_STORAGE"
-     *     android:maxSdkVersion="18" />
- *

- * The first path returned is the same as {@link Context#getObbDir()}. - * Returned paths may be {@code null} if a storage device is unavailable. - * - * @see Context#getObbDir() - * @see EnvironmentCompat#getStorageState(File) - */ - public static File[] getObbDirs(Context context) { - return context.getObbDirs(); - } - - /** - * Returns absolute paths to application-specific directories on all - * external storage devices where the application can place persistent files - * it owns. These files are internal to the application, and not typically - * visible to the user as media. - *

- * This is like {@link Context#getFilesDir()} in that these files will be - * deleted when the application is uninstalled, however there are some - * important differences: - *

- *

- * External storage devices returned here are considered a permanent part of - * the device, including both emulated external storage and physical media - * slots, such as SD cards in a battery compartment. The returned paths do - * not include transient devices, such as USB flash drives. - *

- * An application may store data on any or all of the returned devices. For - * example, an app may choose to store large files on the device with the - * most available space, as measured by {@link StatFs}. - *

- * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions - * are required to write to the returned paths; they're always accessible to - * the calling app. Before then, - * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} is required to - * write. Write access outside of these paths on secondary external storage - * devices is not available. To request external storage access in a - * backwards compatible way, consider using {@code android:maxSdkVersion} - * like this: - * - *

<uses-permission
-     *     android:name="android.permission.WRITE_EXTERNAL_STORAGE"
-     *     android:maxSdkVersion="18" />
- *

- * The first path returned is the same as - * {@link Context#getExternalFilesDir(String)}. Returned paths may be - * {@code null} if a storage device is unavailable. - * - * @see Context#getExternalFilesDir(String) - * @see EnvironmentCompat#getStorageState(File) - */ - public static File[] getExternalFilesDirs(Context context, String type) { - return context.getExternalFilesDirs(type); - } - - /** - * Returns absolute paths to application-specific directories on all - * external storage devices where the application can place cache files it - * owns. These files are internal to the application, and not typically - * visible to the user as media. - *

- * This is like {@link Context#getCacheDir()} in that these files will be - * deleted when the application is uninstalled, however there are some - * important differences: - *

- *

- * External storage devices returned here are considered a permanent part of - * the device, including both emulated external storage and physical media - * slots, such as SD cards in a battery compartment. The returned paths do - * not include transient devices, such as USB flash drives. - *

- * An application may store data on any or all of the returned devices. For - * example, an app may choose to store large files on the device with the - * most available space, as measured by {@link StatFs}. - *

- * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions - * are required to write to the returned paths; they're always accessible to - * the calling app. Before then, - * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} is required to - * write. Write access outside of these paths on secondary external storage - * devices is not available. To request external storage access in a - * backwards compatible way, consider using {@code android:maxSdkVersion} - * like this: - * - *

<uses-permission
-     *     android:name="android.permission.WRITE_EXTERNAL_STORAGE"
-     *     android:maxSdkVersion="18" />
- *

- * The first path returned is the same as - * {@link Context#getExternalCacheDir()}. Returned paths may be {@code null} - * if a storage device is unavailable. - * - * @see Context#getExternalCacheDir() - * @see EnvironmentCompat#getStorageState(File) - */ - public static File[] getExternalCacheDirs(Context context) { - return context.getExternalCacheDirs(); - } - - /** - * Return a drawable object associated with a particular resource ID. - *

- * Starting in {@link android.os.Build.VERSION_CODES#LOLLIPOP}, the returned - * drawable will be styled for the specified Context's theme. - * - * @param id The desired resource identifier, as generated by the aapt tool. - * This integer encodes the package, type, and resource entry. - * The value 0 is an invalid identifier. - * @return Drawable An object that can be used to draw this resource. - */ - public static final Drawable getDrawable(Context context, int id) { - return context.getDrawable(id); - } - - /** - * Returns the absolute path to the directory on the filesystem similar to - * {@link Context#getFilesDir()}. The difference is that files placed under this - * directory will be excluded from automatic backup to remote storage on - * devices running {@link android.os.Build.VERSION_CODES#LOLLIPOP} or later. See - * {@link android.app.backup.BackupAgent BackupAgent} for a full discussion - * of the automatic backup mechanism in Android. - * - *

No permissions are required to read or write to the returned path, since this - * path is internal storage. - * - * @return The path of the directory holding application files that will not be - * automatically backed up to remote storage. - * - * @see android.content.Context.getFilesDir - */ - public final File getNoBackupFilesDir(Context context) { - return context.getNoBackupFilesDir(); - } - - /** - * Returns the absolute path to the application specific cache directory on - * the filesystem designed for storing cached code. On devices running - * {@link android.os.Build.VERSION_CODES#LOLLIPOP} or later, the system will delete - * any files stored in this location both when your specific application is - * upgraded, and when the entire platform is upgraded. - *

- * This location is optimal for storing compiled or optimized code generated - * by your application at runtime. - *

- * Apps require no extra permissions to read or write to the returned path, - * since this path lives in their private storage. - * - * @return The path of the directory holding application code cache files. - */ - public final File getCodeCacheDir(Context context) { - return context.getCodeCacheDir(); - } -} \ No newline at end of file diff --git a/AndroidCompat/src/main/java/android/support/v4/os/EnvironmentCompat.java b/AndroidCompat/src/main/java/android/support/v4/os/EnvironmentCompat.java deleted file mode 100644 index e98982fc..00000000 --- a/AndroidCompat/src/main/java/android/support/v4/os/EnvironmentCompat.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.support.v4.os; - -import android.os.Environment; - -import java.io.File; - -/** - * Helper for accessing features in {@link Environment} introduced after API - * level 4 in a backwards compatible fashion. - */ -public class EnvironmentCompat { - /** - * Unknown storage state, such as when a path isn't backed by known storage - * media. - * - * @see #getStorageState(File) - */ - public static final String MEDIA_UNKNOWN = "unknown"; - - /** - * Returns the current state of the storage device that provides the given - * path. - * - * @return one of {@link #MEDIA_UNKNOWN}, {@link Environment#MEDIA_REMOVED}, - * {@link Environment#MEDIA_UNMOUNTED}, - * {@link Environment#MEDIA_CHECKING}, - * {@link Environment#MEDIA_NOFS}, - * {@link Environment#MEDIA_MOUNTED}, - * {@link Environment#MEDIA_MOUNTED_READ_ONLY}, - * {@link Environment#MEDIA_SHARED}, - * {@link Environment#MEDIA_BAD_REMOVAL}, or - * {@link Environment#MEDIA_UNMOUNTABLE}. - */ - public static String getStorageState(File path) { - return Environment.getStorageState(path); - } -} \ No newline at end of file diff --git a/AndroidCompat/src/main/java/android/support/v7/preference/PreferenceDataStore.java b/AndroidCompat/src/main/java/android/support/v7/preference/PreferenceDataStore.java deleted file mode 100644 index ab7ec0c8..00000000 --- a/AndroidCompat/src/main/java/android/support/v7/preference/PreferenceDataStore.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.support.v7.preference; - -import android.support.annotation.Nullable; - -import java.util.Set; - -/** - * A data store interface to be implemented and provided to the Preferences framework. This can be - * used to replace the default {@link android.content.SharedPreferences}, if needed. - * - *

In most cases you want to use {@link android.content.SharedPreferences} as it is automatically - * backed up and migrated to new devices. However, providing custom data store to preferences can be - * useful if your app stores its preferences in a local db, cloud or they are device specific like - * "Developer settings". It might be also useful when you want to use the preferences UI but - * the data are not supposed to be stored at all because they are valid per session only. - * - *

Once a put method is called it is full responsibility of the data store implementation to - * safely store the given values. Time expensive operations need to be done in the background to - * prevent from blocking the UI. You also need to have a plan on how to serialize the data in case - * the activity holding this object gets destroyed. - * - *

By default, all "put" methods throw {@link UnsupportedOperationException}. - */ -public abstract class PreferenceDataStore { - - /** - * Sets a {@link String} value to the data store. - * - *

Once the value is set the data store is responsible for holding it. - * - * @param key the name of the preference to modify - * @param value the new value for the preference - * @see #getString(String, String) - */ - public void putString(String key, @Nullable String value) { - throw new UnsupportedOperationException("Not implemented on this data store"); - } - - /** - * Sets a set of Strings to the data store. - * - *

Once the value is set the data store is responsible for holding it. - * - * @param key the name of the preference to modify - * @param values the set of new values for the preference - * @see #getStringSet(String, Set) - */ - public void putStringSet(String key, @Nullable Set values) { - throw new UnsupportedOperationException("Not implemented on this data store"); - } - - /** - * Sets an {@link Integer} value to the data store. - * - *

Once the value is set the data store is responsible for holding it. - * - * @param key the name of the preference to modify - * @param value the new value for the preference - * @see #getInt(String, int) - */ - public void putInt(String key, int value) { - throw new UnsupportedOperationException("Not implemented on this data store"); - } - - /** - * Sets a {@link Long} value to the data store. - * - *

Once the value is set the data store is responsible for holding it. - * - * @param key the name of the preference to modify - * @param value the new value for the preference - * @see #getLong(String, long) - */ - public void putLong(String key, long value) { - throw new UnsupportedOperationException("Not implemented on this data store"); - } - - /** - * Sets a {@link Float} value to the data store. - * - *

Once the value is set the data store is responsible for holding it. - * - * @param key the name of the preference to modify - * @param value the new value for the preference - * @see #getFloat(String, float) - */ - public void putFloat(String key, float value) { - throw new UnsupportedOperationException("Not implemented on this data store"); - } - - /** - * Sets a {@link Boolean} value to the data store. - * - *

Once the value is set the data store is responsible for holding it. - * - * @param key the name of the preference to modify - * @param value the new value for the preference - * @see #getBoolean(String, boolean) - */ - public void putBoolean(String key, boolean value) { - throw new UnsupportedOperationException("Not implemented on this data store"); - } - - /** - * Retrieves a {@link String} value from the data store. - * - * @param key the name of the preference to retrieve - * @param defValue value to return if this preference does not exist in the storage - * @return the value from the data store or the default return value - * @see #putString(String, String) - */ - @Nullable - public String getString(String key, @Nullable String defValue) { - return defValue; - } - - /** - * Retrieves a set of Strings from the data store. - * - * @param key the name of the preference to retrieve - * @param defValues values to return if this preference does not exist in the storage - * @return the values from the data store or the default return values - * @see #putStringSet(String, Set) - */ - @Nullable - public Set getStringSet(String key, @Nullable Set defValues) { - return defValues; - } - - /** - * Retrieves an {@link Integer} value from the data store. - * - * @param key the name of the preference to retrieve - * @param defValue value to return if this preference does not exist in the storage - * @return the value from the data store or the default return value - * @see #putInt(String, int) - */ - public int getInt(String key, int defValue) { - return defValue; - } - - /** - * Retrieves a {@link Long} value from the data store. - * - * @param key the name of the preference to retrieve - * @param defValue value to return if this preference does not exist in the storage - * @return the value from the data store or the default return value - * @see #putLong(String, long) - */ - public long getLong(String key, long defValue) { - return defValue; - } - - /** - * Retrieves a {@link Float} value from the data store. - * - * @param key the name of the preference to retrieve - * @param defValue value to return if this preference does not exist in the storage - * @return the value from the data store or the default return value - * @see #putFloat(String, float) - */ - public float getFloat(String key, float defValue) { - return defValue; - } - - /** - * Retrieves a {@link Boolean} value from the data store. - * - * @param key the name of the preference to retrieve - * @param defValue value to return if this preference does not exist in the storage - * @return the value from the data store or the default return value - * @see #getBoolean(String, boolean) - */ - public boolean getBoolean(String key, boolean defValue) { - return defValue; - } -} diff --git a/AndroidCompat/src/main/java/android/support/v7/preference/PreferenceScreen.java b/AndroidCompat/src/main/java/android/support/v7/preference/PreferenceScreen.java deleted file mode 100644 index cff9a9f0..00000000 --- a/AndroidCompat/src/main/java/android/support/v7/preference/PreferenceScreen.java +++ /dev/null @@ -1,4 +0,0 @@ -package android.support.v7.preference; - -public class PreferenceScreen { -} diff --git a/AndroidCompat/src/main/java/androidx/preference/PreferenceScreen.java b/AndroidCompat/src/main/java/androidx/preference/PreferenceScreen.java new file mode 100644 index 00000000..cf1832e0 --- /dev/null +++ b/AndroidCompat/src/main/java/androidx/preference/PreferenceScreen.java @@ -0,0 +1,4 @@ +package androidx.preference; + +public class PreferenceScreen { +} diff --git a/server/src/main/kotlin/eu/kanade/tachiyomi/source/ConfigurableSource.kt b/server/src/main/kotlin/eu/kanade/tachiyomi/source/ConfigurableSource.kt index a1a2f3a7..0dd9bb4e 100644 --- a/server/src/main/kotlin/eu/kanade/tachiyomi/source/ConfigurableSource.kt +++ b/server/src/main/kotlin/eu/kanade/tachiyomi/source/ConfigurableSource.kt @@ -1,8 +1,16 @@ package eu.kanade.tachiyomi.source -// import androidx.preference.PreferenceScreen +/* + * Copyright (C) Contributors to the Suwayomi project + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + + +import androidx.preference.PreferenceScreen interface ConfigurableSource : Source { -// fun setupPreferenceScreen(screen: PreferenceScreen) + fun setupPreferenceScreen(screen: PreferenceScreen) }