mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-30 13:47:05 +02:00
Refactoring
This commit is contained in:
@@ -28,8 +28,10 @@ import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ApplicationExitInfo;
|
||||
import android.app.KeyguardManager;
|
||||
import android.app.UiModeManager;
|
||||
import android.app.usage.UsageEvents;
|
||||
import android.app.usage.UsageStatsManager;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ComponentName;
|
||||
@@ -655,6 +657,78 @@ public class Helper {
|
||||
}
|
||||
}
|
||||
|
||||
static String getEventType(int type) {
|
||||
switch (type) {
|
||||
case UsageEvents.Event.ACTIVITY_PAUSED:
|
||||
return "Activity/paused";
|
||||
case UsageEvents.Event.ACTIVITY_RESUMED:
|
||||
return "Activity/resumed";
|
||||
case UsageEvents.Event.ACTIVITY_STOPPED:
|
||||
return "Activity/stopped";
|
||||
case UsageEvents.Event.CONFIGURATION_CHANGE:
|
||||
return "Configuration/change";
|
||||
case UsageEvents.Event.DEVICE_SHUTDOWN:
|
||||
return "Device/shutdown";
|
||||
case UsageEvents.Event.DEVICE_STARTUP:
|
||||
return "Device/startup";
|
||||
case UsageEvents.Event.FOREGROUND_SERVICE_START:
|
||||
return "Foreground/start";
|
||||
case UsageEvents.Event.FOREGROUND_SERVICE_STOP:
|
||||
return "Foreground/stop";
|
||||
case UsageEvents.Event.KEYGUARD_HIDDEN:
|
||||
return "Keyguard/hidden";
|
||||
case UsageEvents.Event.KEYGUARD_SHOWN:
|
||||
return "Keyguard/shown";
|
||||
case UsageEvents.Event.SCREEN_INTERACTIVE:
|
||||
return "Screen/interactive";
|
||||
case UsageEvents.Event.SCREEN_NON_INTERACTIVE:
|
||||
return "Screen/non-interactive";
|
||||
case UsageEvents.Event.SHORTCUT_INVOCATION:
|
||||
return "Shortcut/invocation";
|
||||
case UsageEvents.Event.STANDBY_BUCKET_CHANGED:
|
||||
return "Bucket/changed";
|
||||
case UsageEvents.Event.USER_INTERACTION:
|
||||
return "User/interaction";
|
||||
default:
|
||||
return Integer.toString(type);
|
||||
}
|
||||
}
|
||||
|
||||
static String getExitReason(int reason) {
|
||||
switch (reason) {
|
||||
case ApplicationExitInfo.REASON_UNKNOWN:
|
||||
return "Unknown";
|
||||
case ApplicationExitInfo.REASON_EXIT_SELF:
|
||||
return "ExitSelf";
|
||||
case ApplicationExitInfo.REASON_SIGNALED:
|
||||
return "Signaled";
|
||||
case ApplicationExitInfo.REASON_LOW_MEMORY:
|
||||
return "LowMemory";
|
||||
case ApplicationExitInfo.REASON_CRASH:
|
||||
return "Crash";
|
||||
case ApplicationExitInfo.REASON_CRASH_NATIVE:
|
||||
return "CrashNative";
|
||||
case ApplicationExitInfo.REASON_ANR:
|
||||
return "ANR";
|
||||
case ApplicationExitInfo.REASON_INITIALIZATION_FAILURE:
|
||||
return "InitializationFailure";
|
||||
case ApplicationExitInfo.REASON_PERMISSION_CHANGE:
|
||||
return "PermissionChange";
|
||||
case ApplicationExitInfo.REASON_EXCESSIVE_RESOURCE_USAGE:
|
||||
return "ExcessiveResourceUsage";
|
||||
case ApplicationExitInfo.REASON_USER_REQUESTED:
|
||||
return "UserRequested";
|
||||
case ApplicationExitInfo.REASON_USER_STOPPED:
|
||||
return "UserStopped";
|
||||
case ApplicationExitInfo.REASON_DEPENDENCY_DIED:
|
||||
return "DependencyDied";
|
||||
case ApplicationExitInfo.REASON_OTHER:
|
||||
return "Other";
|
||||
default:
|
||||
return Integer.toString(reason);
|
||||
}
|
||||
}
|
||||
|
||||
static <T extends Object> T getSystemService(Context context, Class<T> type) {
|
||||
return ContextCompat.getSystemService(context.getApplicationContext(), type);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user