Skip to content

Commit 62f8860

Browse files
committed
Change default duration from SHORT to LONG
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
1 parent 97762ff commit 62f8860

3 files changed

Lines changed: 14 additions & 24 deletions

File tree

app/src/main/java/at/bitfire/icsdroid/model/AddSubscriptionModel.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import android.content.Intent
55
import android.net.Uri
66
import android.provider.OpenableColumns
77
import android.util.Log
8-
import android.widget.Toast
98
import androidx.compose.runtime.getValue
109
import androidx.compose.runtime.mutableStateOf
1110
import androidx.compose.runtime.setValue
@@ -154,17 +153,13 @@ class AddSubscriptionModel @AssistedInject constructor(
154153
}
155154
toastAsync(
156155
context,
157-
messageResId = R.string.add_calendar_created,
158-
cancelToast = null,
159-
duration = Toast.LENGTH_LONG
156+
messageResId = R.string.add_calendar_created
160157
)
161158
} catch (e: Exception) {
162159
Log.e(Constants.TAG, "Couldn't create calendar", e)
163160
toastAsync(
164161
context,
165-
message = { e.localizedMessage ?: e.message },
166-
cancelToast = null,
167-
duration = Toast.LENGTH_LONG
162+
message = { e.localizedMessage ?: e.message }
168163
)
169164
} finally {
170165
uiState = uiState.copy(isCreating = false)

app/src/main/java/at/bitfire/icsdroid/model/SubscriptionsModel.kt

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ class SubscriptionsModel @Inject constructor(
184184
viewModelScope.launch(Dispatchers.IO) {
185185
val toast = toastAsync(
186186
context,
187-
messageResId = R.string.backup_exporting,
188-
duration = Toast.LENGTH_LONG
187+
messageResId = R.string.backup_exporting
189188
)
190189

191190
val subscriptions = subscriptions.value
@@ -206,14 +205,14 @@ class SubscriptionsModel @Inject constructor(
206205
toastAsync(
207206
context,
208207
messageResId = R.string.backup_exported,
209-
cancelToast = toast
208+
cancelToast = toast,
209+
duration = Toast.LENGTH_SHORT
210210
)
211211
} catch (e: IOException) {
212212
Log.e(TAG, "Could not write export file.", e)
213213
toastAsync(
214214
context,
215-
messageResId = R.string.backup_export_error_io,
216-
duration = Toast.LENGTH_LONG
215+
messageResId = R.string.backup_export_error_io
217216
)
218217
}
219218
}
@@ -223,8 +222,7 @@ class SubscriptionsModel @Inject constructor(
223222
viewModelScope.launch(Dispatchers.IO) {
224223
val toast = toastAsync(
225224
context,
226-
messageResId = R.string.backup_importing,
227-
duration = Toast.LENGTH_LONG
225+
messageResId = R.string.backup_importing
228226
)
229227

230228
try {
@@ -237,8 +235,7 @@ class SubscriptionsModel @Inject constructor(
237235
toastAsync(
238236
context,
239237
messageResId = R.string.backup_import_error_io,
240-
cancelToast = toast,
241-
duration = Toast.LENGTH_LONG
238+
cancelToast = toast
242239
)
243240
return@launch
244241
}
@@ -274,31 +271,29 @@ class SubscriptionsModel @Inject constructor(
274271
message = {
275272
resources.getQuantityString(R.plurals.backup_imported, newSubscriptions.size, newSubscriptions.size)
276273
},
277-
cancelToast = toast
274+
cancelToast = toast,
275+
duration = Toast.LENGTH_SHORT
278276
)
279277
} catch (e: JSONException) {
280278
Log.e(TAG, "Could not load JSON: $e")
281279
toastAsync(
282280
context,
283281
messageResId = R.string.backup_import_error_json,
284-
cancelToast = toast,
285-
duration = Toast.LENGTH_LONG
282+
cancelToast = toast
286283
)
287284
} catch (e: SecurityException) {
288285
Log.e(TAG, "Could not load JSON: $e")
289286
toastAsync(
290287
context,
291288
messageResId = R.string.backup_import_error_security,
292-
cancelToast = toast,
293-
duration = Toast.LENGTH_LONG
289+
cancelToast = toast
294290
)
295291
} catch (e: IOException) {
296292
Log.e(TAG, "Could not load JSON: $e")
297293
toastAsync(
298294
context,
299295
messageResId = R.string.backup_import_error_io,
300-
cancelToast = toast,
301-
duration = Toast.LENGTH_LONG
296+
cancelToast = toast
302297
)
303298
}
304299
}

app/src/main/java/at/bitfire/icsdroid/model/ViewModelUtils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ suspend fun toastAsync(
1111
message: Context.() -> String? = { null },
1212
@StringRes messageResId: Int? = null,
1313
cancelToast: Toast? = null,
14-
duration: Int = Toast.LENGTH_SHORT
14+
duration: Int = Toast.LENGTH_LONG
1515
): Toast? = withContext(Dispatchers.Main) {
1616
cancelToast?.cancel()
1717

0 commit comments

Comments
 (0)