package com.jsbogang.womp.workbench;
|
|
import android.content.Context;
|
import android.os.Handler;
|
import android.os.Looper;
|
import android.widget.Toast;
|
|
/**
|
* 健康/GPS 是否上报:默认仅上班打卡后;可改为全天。
|
*/
|
public final class UploadPolicy {
|
private static final String KEY = "reportAllDay";
|
|
private UploadPolicy() {}
|
|
public static boolean reportAllDay(Context context) {
|
return WompSession.prefs(context).getBoolean(KEY, WompConfig.REPORT_ALL_DAY);
|
}
|
|
public static void setReportAllDay(Context context, boolean allDay) {
|
WompSession.prefs(context).edit().putBoolean(KEY, allDay).apply();
|
}
|
|
public static boolean shouldUpload(Context context) {
|
if (!WompSession.isLoggedIn(context)) {
|
return false;
|
}
|
if (reportAllDay(context)) {
|
return true;
|
}
|
return WompSession.isCheckedIn(context);
|
}
|
|
public static void debugToast(Context context, String msg) {
|
if (!WompConfig.DEBUG_UPLOAD_TOAST || context == null || msg == null) {
|
return;
|
}
|
Context app = context.getApplicationContext();
|
new Handler(Looper.getMainLooper()).post(() ->
|
Toast.makeText(app, msg, Toast.LENGTH_SHORT).show());
|
}
|
}
|