Skip to content

Commit

Permalink
Merge pull request #17 from kengoon/fix-time-strftime
Browse files Browse the repository at this point in the history
Enhance android check and fix time.strftime("%p") bug
  • Loading branch information
T-Dynamos authored Aug 18, 2024
2 parents 57ec2e4 + 5187dc8 commit 85099ce
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions materialyoucolor/utils/platform_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,16 @@
QuantizeCelebi = None

autoclass = None
_is_android = "ANDROID_ARGUMENT" in os.environ

try:
if _is_android:
from jnius import autoclass
from android import mActivity

Integer = autoclass("java.lang.Integer")
BuildVERSION = autoclass("android.os.Build$VERSION")
context = mActivity.getApplicationContext()
WallpaperManager = autoclass("android.app.WallpaperManager").getInstance(mActivity)
except Exception:
pass

try:
from PIL import Image
Expand Down Expand Up @@ -73,16 +72,6 @@
WALLPAPER_CACHE = {}


def _is_android() -> bool:
try:
from android import mActivity

return True
except Exception as e:
pass
return False


def save_and_resize_bitmap(drawable, path):
CompressFormat = autoclass("android.graphics.Bitmap$CompressFormat")
FileOutputStream = autoclass("java.io.FileOutputStream")
Expand Down Expand Up @@ -217,11 +206,10 @@ def get_dynamic_scheme(
) -> DynamicScheme:
logger = lambda message: message_logger(logger_head + " : " + message)

is_android = _is_android()
selected_scheme = None
selected_color = None

if is_android:
if _is_android:
# For Android 12 and 12+
if BuildVERSION.SDK_INT >= 31:
selected_scheme = _get_android_12_above(
Expand Down Expand Up @@ -297,7 +285,7 @@ def get_dynamic_scheme(
# TODO: Think about getting data from bitmap
pixel_array = [
image_data[_]
for _ in range(0, pixel_len, dynamic_color_quality if not is_android else 1)
for _ in range(0, pixel_len, dynamic_color_quality if not _is_android else 1)
]
logger(
f"Created an array of pixels from a "
Expand Down

0 comments on commit 85099ce

Please sign in to comment.