package com.farmerbb.taskbar.util;
// Utility class meant for compatibility between the Android-x86 version of Taskbar (compiled with SDK 27)
-// and the Play Store version of Taskbar (compiled with SDK 28).
+// and the Play Store version of Taskbar (compiled with SDK 29).
// TODO Do not make changes to this file without making corresponding changes to the Android-x86 version.
import android.os.Build;
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1
- && Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
+ && U.getCurrentApiVersion() <= 28.0f) {
builder.setTitle(R.string.freeform_dialog_title)
.setMessage(R.string.freeform_dialog_message_alt)
.setPositiveButton(R.string.action_continue, (dialogInterface, i) -> freeformSetupComplete());
} else {
- String settingName = Build.VERSION.SDK_INT > Build.VERSION_CODES.P
+ String settingName = U.getCurrentApiVersion() > 28.0f
? getString(R.string.enable_freeform_windows)
: getString(R.string.force_activities_resizable);
private Drawable getBatteryDrawable() {
BatteryManager bm = (BatteryManager) context.getSystemService(Context.BATTERY_SERVICE);
int batLevel = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
- boolean isCharging = bm.isCharging();
if(batLevel == Integer.MIN_VALUE)
return null;
+ IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
+ Intent batteryStatus = context.registerReceiver(null, ifilter);
+
+ int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
+ boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||
+ status == BatteryManager.BATTERY_STATUS_FULL;
+
String batDrawable;
- if(batLevel <= 10 && !isCharging)
+ if(batLevel < 10 && !isCharging)
batDrawable = "alert";
- else if(batLevel <= 20)
+ else if(batLevel < 25)
batDrawable = "20";
- else if(batLevel <= 30)
+ else if(batLevel < 40)
batDrawable = "30";
- else if(batLevel <= 50)
+ else if(batLevel < 55)
batDrawable = "50";
- else if(batLevel <= 60)
+ else if(batLevel < 70)
batDrawable = "60";
- else if(batLevel <= 80)
+ else if(batLevel < 85)
batDrawable = "80";
- else if(batLevel <= 90)
+ else if(batLevel < 95)
batDrawable = "90";
else
batDrawable = "full";
}
}
- private static float getCurrentApiVersion() {
+ public static float getCurrentApiVersion() {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
return Float.valueOf(Build.VERSION.SDK_INT + "." + Build.VERSION.PREVIEW_SDK_INT);
else
android:layout_width="84dp"
android:layout_height="match_parent"
android:gravity="center"
- android:textSize="16dp"
+ android:textSize="15.499dp"
android:visibility="gone"
tools:text="1:41 AM\n03/27/18"
tools:visibility="visible"