From efaad0a4ddfdcb4f377b1047ab13879ad7bef8fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Wed, 13 Nov 2019 22:37:30 +0100 Subject: [PATCH] [APIv1] Remove remaining APIv1 components. [*] --- .../szczodrzynski/edziennik/MainActivity.kt | 18 +--- .../api/interfaces/AttachmentGetCallback.java | 11 --- .../api/interfaces/EdziennikInterface.java | 92 ------------------- .../data/api/interfaces/ErrorCallback.java | 11 --- .../data/api/interfaces/LoginCallback.java | 5 - .../api/interfaces/MessageGetCallback.java | 11 --- .../api/interfaces/MessageListCallback.java | 9 -- .../data/api/interfaces/ProgressCallback.java | 8 -- .../interfaces/RecipientListGetCallback.java | 9 -- .../data/api/interfaces/SyncCallback.java | 19 ---- .../ui/modules/error/ErrorSnackbar.kt | 4 - .../modules/settings/SettingsNewFragment.java | 2 - 12 files changed, 1 insertion(+), 198 deletions(-) delete mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/AttachmentGetCallback.java delete mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/EdziennikInterface.java delete mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/ErrorCallback.java delete mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/LoginCallback.java delete mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/MessageGetCallback.java delete mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/MessageListCallback.java delete mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/ProgressCallback.java delete mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/RecipientListGetCallback.java delete mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/SyncCallback.java diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt b/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt index da39314c..413e7cfb 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt @@ -38,7 +38,6 @@ import pl.droidsonroids.gif.GifDrawable import pl.szczodrzynski.edziennik.App.APP_URL import pl.szczodrzynski.edziennik.api.v2.events.* import pl.szczodrzynski.edziennik.api.v2.events.task.EdziennikTask -import pl.szczodrzynski.edziennik.data.api.interfaces.EdziennikInterface.* import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata.* import pl.szczodrzynski.edziennik.databinding.ActivitySzkolnyBinding import pl.szczodrzynski.edziennik.network.ServerRequest @@ -616,22 +615,7 @@ class MainActivity : AppCompatActivity() { .setCancelable(false) .show() } - private fun fragmentToFeature(currentFragment: Int): Int { - return when (currentFragment) { - DRAWER_ITEM_TIMETABLE -> FEATURE_TIMETABLE - DRAWER_ITEM_AGENDA -> FEATURE_AGENDA - DRAWER_ITEM_GRADES -> FEATURE_GRADES - DRAWER_ITEM_HOMEWORK -> FEATURE_HOMEWORK - DRAWER_ITEM_BEHAVIOUR -> FEATURE_NOTICES - DRAWER_ITEM_ATTENDANCE -> FEATURE_ATTENDANCE - DRAWER_ITEM_MESSAGES -> when (MessagesFragment.pageSelection) { - 1 -> FEATURE_MESSAGES_OUTBOX - else -> FEATURE_MESSAGES_INBOX - } - DRAWER_ITEM_ANNOUNCEMENTS -> FEATURE_ANNOUNCEMENTS - else -> FEATURE_ALL - } - } + private fun fragmentToSyncName(currentFragment: Int): Int { return when (currentFragment) { DRAWER_ITEM_TIMETABLE -> R.string.sync_feature_timetable diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/AttachmentGetCallback.java b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/AttachmentGetCallback.java deleted file mode 100644 index 0bd76455..00000000 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/AttachmentGetCallback.java +++ /dev/null @@ -1,11 +0,0 @@ -package pl.szczodrzynski.edziennik.data.api.interfaces; - -import im.wangchao.mhttp.Request; - -/** - * Callback containing a {@link Request.Builder} which has correct headers and body to download a corresponding message attachment when ran. - * {@code onSuccess} has to be ran on the UI thread. - */ -public interface AttachmentGetCallback { - void onSuccess(Request.Builder builder); -} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/EdziennikInterface.java b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/EdziennikInterface.java deleted file mode 100644 index 962b1bef..00000000 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/EdziennikInterface.java +++ /dev/null @@ -1,92 +0,0 @@ -package pl.szczodrzynski.edziennik.data.api.interfaces; - -import android.content.Context; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import java.util.Map; - -import pl.szczodrzynski.edziennik.data.db.modules.login.LoginStore; -import pl.szczodrzynski.edziennik.data.db.modules.messages.MessageFull; -import pl.szczodrzynski.edziennik.data.db.modules.profiles.Profile; -import pl.szczodrzynski.edziennik.data.db.modules.profiles.ProfileFull; -import pl.szczodrzynski.edziennik.data.db.modules.teachers.Teacher; -import pl.szczodrzynski.edziennik.ui.modules.messages.MessagesComposeInfo; -import pl.szczodrzynski.edziennik.utils.models.Endpoint; - -public interface EdziennikInterface { - - /** - * Sync all Edziennik data. - * Ran always on worker thread. - * - * @param activityContext a {@link Context}, used for resource extractions, passed back to {@link SyncCallback} - * @param callback ran on worker thread. - * @param profileId - * @param profile - * @param loginStore - */ - void sync(@NonNull Context activityContext, @NonNull SyncCallback callback, int profileId, @Nullable Profile profile, @NonNull LoginStore loginStore); - void syncMessages(@NonNull Context activityContext, @NonNull SyncCallback errorCallback, @NonNull ProfileFull profile); - void syncFeature(@NonNull Context activityContext, @NonNull SyncCallback callback, @NonNull ProfileFull profile, int ... featureList); - - int FEATURE_ALL = 0; - int FEATURE_TIMETABLE = 1; - int FEATURE_AGENDA = 2; - int FEATURE_GRADES = 3; - int FEATURE_HOMEWORK = 4; - int FEATURE_NOTICES = 5; - int FEATURE_ATTENDANCE = 6; - int FEATURE_MESSAGES_INBOX = 7; - int FEATURE_MESSAGES_OUTBOX = 8; - int FEATURE_ANNOUNCEMENTS = 9; - - /** - * Download a single message or get its recipient list if it's already downloaded. - * - * May be executed on any thread. - * - * @param activityContext - * @param errorCallback used for error reporting. Ran on a background thread. - * @param profile - * @param message a message of which body and recipient list should be downloaded. - * @param messageCallback always executed on UI thread. - */ - void getMessage(@NonNull Context activityContext, @NonNull SyncCallback errorCallback, @NonNull ProfileFull profile, @NonNull MessageFull message, @NonNull MessageGetCallback messageCallback); - void getAttachment(@NonNull Context activityContext, @NonNull SyncCallback errorCallback, @NonNull ProfileFull profile, @NonNull MessageFull message, long attachmentId, @NonNull AttachmentGetCallback attachmentCallback); - //void getMessageList(@NonNull Context activityContext, @NonNull SyncCallback errorCallback, @NonNull ProfileFull profile, int type, @NonNull MessageListCallback messageCallback); - /** - * Download a list of available message recipients. - * - * Updates a database-saved {@code teacherList} with {@code loginId}s. - * - * A {@link Teacher} is considered as a recipient when its {@code loginId} is not null. - * - * May be executed on any thread. - * - * @param activityContext - * @param errorCallback used for error reporting. Ran on a background thread. - * @param profile - * @param recipientListGetCallback always executed on UI thread. - */ - void getRecipientList(@NonNull Context activityContext, @NonNull SyncCallback errorCallback, @NonNull ProfileFull profile, @NonNull RecipientListGetCallback recipientListGetCallback); - MessagesComposeInfo getComposeInfo(@NonNull ProfileFull profile); - - - /** - * - * @param profile a {@link Profile} containing already changed endpoints - * @return a map of configurable {@link Endpoint}s along with their names, {@code null} when unsupported - */ - Map getConfigurableEndpoints(Profile profile); - - /** - * Check if the specified endpoint is enabled for the current profile. - * - * @param profile a {@link Profile} containing already changed endpoints - * @param defaultActive if the endpoint is enabled by default. - * @param name the endpoint's name - * @return {@code true} if the endpoint is enabled, {@code false} when it's not. Return {@code defaultActive} if unsupported. - */ - boolean isEndpointEnabled(Profile profile, boolean defaultActive, String name); -} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/ErrorCallback.java b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/ErrorCallback.java deleted file mode 100644 index cc8f2375..00000000 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/ErrorCallback.java +++ /dev/null @@ -1,11 +0,0 @@ -package pl.szczodrzynski.edziennik.data.api.interfaces; - -import android.content.Context; - -import androidx.annotation.NonNull; - -import pl.szczodrzynski.edziennik.data.api.AppError; - -public interface ErrorCallback { - void onError(Context activityContext, @NonNull AppError error); -} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/LoginCallback.java b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/LoginCallback.java deleted file mode 100644 index cae0c65e..00000000 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/LoginCallback.java +++ /dev/null @@ -1,5 +0,0 @@ -package pl.szczodrzynski.edziennik.data.api.interfaces; - -public interface LoginCallback { - void onSuccess(); -} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/MessageGetCallback.java b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/MessageGetCallback.java deleted file mode 100644 index 7fd973c8..00000000 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/MessageGetCallback.java +++ /dev/null @@ -1,11 +0,0 @@ -package pl.szczodrzynski.edziennik.data.api.interfaces; - -import pl.szczodrzynski.edziennik.data.db.modules.messages.MessageFull; - -/** - * Callback containing a {@link MessageFull} which already has its {@code body} and {@code recipients}. - * {@code onSuccess} is always ran on the UI thread. - */ -public interface MessageGetCallback { - void onSuccess(MessageFull message); -} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/MessageListCallback.java b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/MessageListCallback.java deleted file mode 100644 index 71561ffd..00000000 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/MessageListCallback.java +++ /dev/null @@ -1,9 +0,0 @@ -package pl.szczodrzynski.edziennik.data.api.interfaces; - -import java.util.List; - -import pl.szczodrzynski.edziennik.data.db.modules.messages.MessageFull; - -public interface MessageListCallback { - void onSuccess(List messageList); -} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/ProgressCallback.java b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/ProgressCallback.java deleted file mode 100644 index 32948eb9..00000000 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/ProgressCallback.java +++ /dev/null @@ -1,8 +0,0 @@ -package pl.szczodrzynski.edziennik.data.api.interfaces; - -import androidx.annotation.StringRes; - -public interface ProgressCallback extends ErrorCallback { - void onProgress(int progressStep); - void onActionStarted(@StringRes int stringResId); -} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/RecipientListGetCallback.java b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/RecipientListGetCallback.java deleted file mode 100644 index fc249432..00000000 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/RecipientListGetCallback.java +++ /dev/null @@ -1,9 +0,0 @@ -package pl.szczodrzynski.edziennik.data.api.interfaces; - -import java.util.List; - -import pl.szczodrzynski.edziennik.data.db.modules.teachers.Teacher; - -public interface RecipientListGetCallback { - void onSuccess(List teacherList); -} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/SyncCallback.java b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/SyncCallback.java deleted file mode 100644 index dfaf243b..00000000 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/interfaces/SyncCallback.java +++ /dev/null @@ -1,19 +0,0 @@ -package pl.szczodrzynski.edziennik.data.api.interfaces; - -import android.content.Context; - -import java.util.List; - -import pl.szczodrzynski.edziennik.data.db.modules.login.LoginStore; -import pl.szczodrzynski.edziennik.data.db.modules.profiles.Profile; -import pl.szczodrzynski.edziennik.data.db.modules.profiles.ProfileFull; - -/** - * A callback used for error reporting, progress information. - * All the methods are always ran on a worker thread. - */ -public interface SyncCallback extends ProgressCallback { - void onLoginFirst(List profileList, LoginStore loginStore); - void onSuccess(Context activityContext, ProfileFull profileFull); - -} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/error/ErrorSnackbar.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/error/ErrorSnackbar.kt index 17b69c8b..c4e32ae2 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/error/ErrorSnackbar.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/error/ErrorSnackbar.kt @@ -11,7 +11,6 @@ import androidx.core.graphics.ColorUtils import com.google.android.material.snackbar.Snackbar import pl.szczodrzynski.edziennik.R import pl.szczodrzynski.edziennik.api.v2.models.ApiError -import pl.szczodrzynski.edziennik.data.api.AppError import pl.szczodrzynski.navlib.getColorFromAttr class ErrorSnackbar(val activity: AppCompatActivity) { @@ -37,9 +36,6 @@ class ErrorSnackbar(val activity: AppCompatActivity) { showAbove?.let { snackbar?.anchorView = it } } - fun addError(appError: AppError) { - - } fun addError(apiError: ApiError): ErrorSnackbar { errors += apiError snackbar?.setText(apiError.getStringReason(activity)) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/settings/SettingsNewFragment.java b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/settings/SettingsNewFragment.java index ee9e307d..05bff7c4 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/settings/SettingsNewFragment.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/settings/SettingsNewFragment.java @@ -1292,8 +1292,6 @@ public class SettingsNewFragment extends MaterialAboutFragment { if (app.profile == null) return new MaterialAboutList.Builder().build(); - //configurableEndpoints = Edziennik.getApi(app, app.profile.loginStoreType).getConfigurableEndpoints(app.profile); - MaterialAboutList materialAboutList = new MaterialAboutList(); materialAboutList.addCard(getCardWithItems(null, getProfileCard(false))); materialAboutList.addCard(getCardWithItems(getString(R.string.settings_theme_title_text), getThemeCard(false)));