forked from github/szkolny
[APIv1] Remove remaining APIv1 components. [*]
This commit is contained in:
parent
71015c0137
commit
efaad0a4dd
@ -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
|
||||
|
@ -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);
|
||||
}
|
@ -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<String, Endpoint> 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);
|
||||
}
|
@ -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);
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package pl.szczodrzynski.edziennik.data.api.interfaces;
|
||||
|
||||
public interface LoginCallback {
|
||||
void onSuccess();
|
||||
}
|
@ -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);
|
||||
}
|
@ -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<MessageFull> messageList);
|
||||
}
|
@ -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);
|
||||
}
|
@ -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<Teacher> teacherList);
|
||||
}
|
@ -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<Profile> profileList, LoginStore loginStore);
|
||||
void onSuccess(Context activityContext, ProfileFull profileFull);
|
||||
|
||||
}
|
@ -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))
|
||||
|
@ -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)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user