wangzhibo
2026-08-30 af6b816e29ebe329c59cfdd368bf41d2a4940946
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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());
    }
}