From b2a5e7e6284ef3817233266a92810dcb86b717e4 Mon Sep 17 00:00:00 2001 From: Toni500git Date: Mon, 16 Dec 2024 19:10:14 +0100 Subject: [PATCH] android app: don't parse at first run + fix -C/--config arg --- .../customfetch_android/widget/customfetch.kt | 21 ++++++++++++------- .../widget/customfetchConfigureActivity.kt | 2 ++ src/main.cpp | 4 ++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/android/app/src/main/java/org/toni/customfetch_android/widget/customfetch.kt b/android/app/src/main/java/org/toni/customfetch_android/widget/customfetch.kt index 8e09079..6c14311 100644 --- a/android/app/src/main/java/org/toni/customfetch_android/widget/customfetch.kt +++ b/android/app/src/main/java/org/toni/customfetch_android/widget/customfetch.kt @@ -31,6 +31,7 @@ class customfetch : AppWidgetProvider() { for (appWidgetId in appWidgetIds) { deleteTitlePref(context, appWidgetId) } + firstRun = true } override fun onAppWidgetOptionsChanged( @@ -88,6 +89,7 @@ class WidgetSizeProvider( } +var firstRun = true internal fun updateAppWidget( context: Context, appWidgetManager: AppWidgetManager, @@ -108,14 +110,17 @@ internal fun updateAppWidget( Log.d("widthTesting", "width = $width") Log.d("wrappingTest", "disableLineWrap = $disableLineWrap") - val parsedContent = customfetchRender.getParsedContent( - context, - appWidgetId, - width, - disableLineWrap, - textPaint - ) - + val parsedContent = if (!firstRun) { + customfetchRender.getParsedContent( + context, + appWidgetId, + width, + disableLineWrap, + textPaint + ) + } else "" + + firstRun = false // Construct the RemoteViews object val views = RemoteViews(context.packageName, R.layout.customfetch) views.setTextViewText(R.id.customfetch_text, parsedContent) diff --git a/android/app/src/main/java/org/toni/customfetch_android/widget/customfetchConfigureActivity.kt b/android/app/src/main/java/org/toni/customfetch_android/widget/customfetchConfigureActivity.kt index e7850e8..6e36231 100644 --- a/android/app/src/main/java/org/toni/customfetch_android/widget/customfetchConfigureActivity.kt +++ b/android/app/src/main/java/org/toni/customfetch_android/widget/customfetchConfigureActivity.kt @@ -160,5 +160,7 @@ internal fun loadTruncateWidthPref(context: Context, appWidgetId: Int): String { internal fun deleteTitlePref(context: Context, appWidgetId: Int) { val prefs = context.getSharedPreferences(PREFS_NAME, 0).edit() prefs.remove(PREF_PREFIX_KEY + appWidgetId) + prefs.remove(PREF_PREFIX_KEY + "bool_" + appWidgetId) + prefs.remove(PREF_PREFIX_KEY + "truncate_" + appWidgetId) prefs.apply() } diff --git a/src/main.cpp b/src/main.cpp index 02ec8e6..4411ebb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -570,9 +570,9 @@ int main(int argc, char *argv[]) #if ANDROID_APP // since ANDROID_APP means that it will run as an android widget, so in GUI, // then let's make it always true - // and also disable wrap lines for cleaner look config.gui = true; - config.wrap_lines = false; + config.wrap_lines = true; + optind = 0; #endif if (config.source_path.empty() || config.source_path == "off")