Skip to content

Commit

Permalink
android app: don't parse at first run + fix -C/--config arg
Browse files Browse the repository at this point in the history
  • Loading branch information
Toni500github committed Dec 16, 2024
1 parent 1eefe4d commit b2a5e7e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class customfetch : AppWidgetProvider() {
for (appWidgetId in appWidgetIds) {
deleteTitlePref(context, appWidgetId)
}
firstRun = true
}

override fun onAppWidgetOptionsChanged(
Expand Down Expand Up @@ -88,6 +89,7 @@ class WidgetSizeProvider(

}

var firstRun = true
internal fun updateAppWidget(
context: Context,
appWidgetManager: AppWidgetManager,
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit b2a5e7e

Please sign in to comment.