Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasKaminsky committed May 23, 2024
2 parents 51b11fc + d770603 commit be7e3a5
Show file tree
Hide file tree
Showing 30 changed files with 141 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class DashboardWidgetConfigurationActivity :
@Inject
lateinit var widgetUpdater: DashboardWidgetUpdater

var appWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID
private var appWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID

public override fun onCreate(bundle: Bundle?) {
super.onCreate(bundle)
Expand Down Expand Up @@ -117,7 +117,7 @@ class DashboardWidgetConfigurationActivity :

// Find the widget id from the intent.
appWidgetId = intent?.extras?.getInt(
AppWidgetManager.EXTRA_APPWIDGET_ID,
EXTRA_APPWIDGET_ID,
AppWidgetManager.INVALID_APPWIDGET_ID
) ?: AppWidgetManager.INVALID_APPWIDGET_ID

Expand Down Expand Up @@ -153,11 +153,9 @@ class DashboardWidgetConfigurationActivity :
visibility = View.VISIBLE
}
binding.emptyView.emptyListViewText.apply {
setText(
String.format(
getString(R.string.widgets_not_available),
getString(R.string.app_name)
)
text = String.format(
getString(R.string.widgets_not_available),
getString(R.string.app_name)
)
visibility = View.VISIBLE
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ class DashboardWidgetProvider : AppWidgetProvider() {
AndroidInjection.inject(this, context)

if (intent?.action == OPEN_INTENT) {
val clickIntent = Intent(Intent.ACTION_VIEW, intent.data)
clickIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context?.startActivity(clickIntent)
context?.let {
val clickIntent = Intent(Intent.ACTION_VIEW, intent.data).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}
context.startActivity(clickIntent)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,20 @@ class StackRemoteViewsFactory(
override fun onDataSetChanged() {
CoroutineScope(Dispatchers.IO).launch {
try {
if (widgetConfiguration.user.isPresent) {
val client = clientFactory.createNextcloudClient(widgetConfiguration.user.get())
val result = DashboardGetWidgetItemsRemoteOperation(widgetConfiguration.widgetId, LIMIT_SIZE)
.execute(client)
widgetItems = if (result.isSuccess) {
result.resultData[widgetConfiguration.widgetId] ?: emptyList()
} else {
emptyList()
}
hasLoadMore = widgetConfiguration.moreButton != null && widgetItems.size == LIMIT_SIZE
} else {
if (!widgetConfiguration.user.isPresent) {
Log_OC.w(TAG, "User not present for widget update")
return@launch
}

val client = clientFactory.createNextcloudClient(widgetConfiguration.user.get())
val result = DashboardGetWidgetItemsRemoteOperation(widgetConfiguration.widgetId, LIMIT_SIZE)
.execute(client)
widgetItems = if (result.isSuccess) {
result.resultData[widgetConfiguration.widgetId] ?: emptyList()
} else {
emptyList()
}
hasLoadMore = widgetConfiguration.moreButton != null && widgetItems.size == LIMIT_SIZE
} catch (e: ClientFactory.CreationException) {
Log_OC.e(TAG, "Error updating widget", e)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import android.content.Context
import android.content.Intent
import android.graphics.Bitmap
import android.net.Uri
import android.os.Build
import android.view.View
import android.widget.RemoteViews
import com.bumptech.glide.Glide
Expand Down Expand Up @@ -63,64 +64,96 @@ class DashboardWidgetUpdater @Inject constructor(
loadIcon(appWidgetId, iconUrl, this)
}

appWidgetManager.updateAppWidget(appWidgetId, views)
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.list)
appWidgetManager.run {
updateAppWidget(appWidgetId, views)
notifyAppWidgetViewDataChanged(appWidgetId, R.id.list)
}
}

private fun setPendingReload(remoteViews: RemoteViews, appWidgetId: Int) {
val intentUpdate = Intent(context, DashboardWidgetProvider::class.java)
intentUpdate.action = AppWidgetManager.ACTION_APPWIDGET_UPDATE

val idArray = intArrayOf(appWidgetId)
intentUpdate.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, idArray)

remoteViews.setOnClickPendingIntent(
R.id.reload,
PendingIntent.getBroadcast(
context,
appWidgetId,
intentUpdate,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)
)
val pendingIntent = getReloadPendingIntent(appWidgetId)
remoteViews.setOnClickPendingIntent(R.id.reload, pendingIntent)
}

private fun setPendingClick(remoteViews: RemoteViews) {
val flags = PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
val intent = Intent().apply {
setPackage(context.packageName)
}

val clickIntent = PendingIntent.getActivity(
val pendingIntent = PendingIntent.getActivity(
context,
0,
Intent(),
flags
intent,
pendingIntentFlags
)

remoteViews.setPendingIntentTemplate(R.id.list, clickIntent)
remoteViews.setPendingIntentTemplate(R.id.list, pendingIntent)
}

private fun setAddButton(addButton: DashboardButton?, appWidgetId: Int, remoteViews: RemoteViews) {
// create add button
if (addButton == null) {
remoteViews.setViewVisibility(R.id.create, View.GONE)
} else {
remoteViews.setViewVisibility(R.id.create, View.VISIBLE)
remoteViews.setContentDescription(R.id.create, addButton.text)

val clickIntent = Intent(context, DashboardWidgetProvider::class.java)
clickIntent.action = DashboardWidgetProvider.OPEN_INTENT
clickIntent.data = Uri.parse(addButton.link)

remoteViews.setOnClickPendingIntent(
R.id.create,
PendingIntent.getBroadcast(
context,
appWidgetId,
clickIntent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
remoteViews.run {
if (addButton == null) {
setViewVisibility(R.id.create, View.GONE)
} else {
setViewVisibility(R.id.create, View.VISIBLE)
setContentDescription(R.id.create, addButton.text)

val pendingIntent = getAddPendingIntent(appWidgetId, addButton)

setOnClickPendingIntent(
R.id.create,
pendingIntent
)
)
}
}
}

// region PendingIntents
private fun getReloadPendingIntent(appWidgetId: Int): PendingIntent {
val intent = Intent(context, DashboardWidgetProvider::class.java).apply {
setPackage(context.packageName)
action = AppWidgetManager.ACTION_APPWIDGET_UPDATE

val idArray = intArrayOf(appWidgetId)
putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, idArray)
}

return PendingIntent.getBroadcast(
context,
appWidgetId,
intent,
pendingIntentFlags
)
}

private fun getAddPendingIntent(appWidgetId: Int, addButton: DashboardButton): PendingIntent {
val intent = Intent(context, DashboardWidgetProvider::class.java).apply {
setPackage(context.packageName)
action = DashboardWidgetProvider.OPEN_INTENT
data = Uri.parse(addButton.link)
}

return PendingIntent.getBroadcast(
context,
appWidgetId,
intent,
pendingIntentFlags
)
}

@Suppress("MagicNumber")
private val pendingIntentFlags: Int = when {
Build.VERSION.SDK_INT >= 34 -> {
PendingIntent.FLAG_UPDATE_CURRENT or
PendingIntent.FLAG_MUTABLE or
PendingIntent.FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT
}

else -> {
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
}
}
// endregion

private fun loadIcon(appWidgetId: Int, iconUrl: String, remoteViews: RemoteViews) {
val iconTarget = object : AppWidgetTarget(context, remoteViews, R.id.icon, appWidgetId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public static void clearTempEncryptedFolder(String accountName) {
File tempEncryptedFolder = new File(FileStorageUtils.getTemporalEncryptedFolderPath(accountName));

if (!tempEncryptedFolder.exists()) {
Log_OC.d(TAG,"tempEncryptedFolder not exists");
Log_OC.d(TAG,"tempEncryptedFolder does not exist");
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ private RemoteOperationResult encryptedUpload(OwnCloudClient client, OCFile pare
updateMetadataForE2E(object, e2eData, clientData, e2eFiles, arbitraryDataProvider, encryptionUtilsV2, metadataExists);
}
} catch (FileNotFoundException e) {
Log_OC.d(TAG, mFile.getStoragePath() + " not exists anymore");
Log_OC.d(TAG, mFile.getStoragePath() + " does not exist anymore");
result = new RemoteOperationResult(ResultCode.LOCAL_FILE_NOT_FOUND);
} catch (OverlappingFileLockException e) {
Log_OC.d(TAG, "Overlapping file lock exception");
Expand Down Expand Up @@ -917,7 +917,7 @@ private RemoteOperationResult checkConditions(File originalFile) {

// check if the file continues existing before schedule the operation
if (!originalFile.exists()) {
Log_OC.d(TAG, mOriginalStoragePath + " not exists anymore");
Log_OC.d(TAG, mOriginalStoragePath + " does not exist anymore");
remoteOperationResult = new RemoteOperationResult(ResultCode.LOCAL_FILE_NOT_FOUND);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public static String getInstantUploadFilePath(File file,

String relativeSubfolderPath = "";
if (parentFile == null) {
Log_OC.e("AutoUpload", "Parent folder does not exists!");
Log_OC.e("AutoUpload", "Parent folder does not exist!");
} else {
relativeSubfolderPath = parentFile.getAbsolutePath();
}
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,6 @@
<string name="upload_action_cancelled_resume">إستئناف المرفوعات الملغاة</string>
<string name="upload_action_failed_clear">مسح الملفات التي فشل رفعها</string>
<string name="upload_action_failed_retry">أعِد محاولات الرفع الفاشلة</string>
<string name="upload_action_file_not_exist_message">بعض الملفات غير موجودة و لا يمكن استئناف هذه الملفات</string>
<string name="upload_action_global_upload_pause">جمِّد كل عمليات الرفع</string>
<string name="upload_action_global_upload_resume">إستَأنِف عمليات الرفع</string>
<string name="upload_cannot_create_file">لا يمكن إنشاء ملف محلي</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-b+en+001/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,6 @@
<string name="upload_action_cancelled_resume">Resume cancelled uploads</string>
<string name="upload_action_failed_clear">Clear failed uploads</string>
<string name="upload_action_failed_retry">Retry failed uploads</string>
<string name="upload_action_file_not_exist_message">Some files not exists those files cannot be resumed</string>
<string name="upload_action_global_upload_pause">Pause all uploads</string>
<string name="upload_action_global_upload_resume">Resume all uploads</string>
<string name="upload_cannot_create_file">Cannot create local file</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,6 @@
<string name="upload_action_cancelled_resume">Abgebrochene Uploads fortsetzen</string>
<string name="upload_action_failed_clear">Fehlgeschlagene Uploads entfernen</string>
<string name="upload_action_failed_retry">Fehlgeschlagene Uploads neu starten</string>
<string name="upload_action_file_not_exist_message">Einige Dateien existieren nicht, Fortsetzung für diese Dateien ist nicht möglich</string>
<string name="upload_action_global_upload_pause">Alle Uploads pausieren</string>
<string name="upload_action_global_upload_resume">Alle Uploads fortsetzen</string>
<string name="upload_cannot_create_file">Datei kann lokal nicht erstellt werden</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-es-rMX/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,6 @@
<string name="upload_action_cancelled_resume">Reanudar cargas canceladas</string>
<string name="upload_action_failed_clear">Borrar cargas fallidas</string>
<string name="upload_action_failed_retry">Reintentar cargas fallidas</string>
<string name="upload_action_file_not_exist_message">Algunos archivos no existen, estos archivos no se pueden resumir</string>
<string name="upload_action_global_upload_pause">Pausar todas las cargas</string>
<string name="upload_action_global_upload_resume">Reanudar todas las cargas</string>
<string name="upload_cannot_create_file">No se puede crear el archivo local</string>
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@
<string name="folder_picker_choose_caption_text">Elegir carpeta de destino</string>
<string name="folder_picker_copy_button_text">Copia</string>
<string name="folder_picker_move_button_text">Mover</string>
<string name="forbidden_permissions">No tienes permiso %s</string>
<string name="forbidden_permissions">No tiene permiso %s</string>
<string name="forbidden_permissions_copy">copiar este archivo</string>
<string name="forbidden_permissions_create">para crear este archivo</string>
<string name="forbidden_permissions_delete">para eliminar este archivo</string>
Expand Down Expand Up @@ -896,7 +896,6 @@
<string name="upload_action_cancelled_resume">Reanudar cargas canceladas</string>
<string name="upload_action_failed_clear">Borrar subidas fallidas</string>
<string name="upload_action_failed_retry">Reintentar cargas fallidas</string>
<string name="upload_action_file_not_exist_message">Algunos archivos no existen, estos archivos no pueden ser resumidos</string>
<string name="upload_action_global_upload_pause">Pausar todas las cargas</string>
<string name="upload_action_global_upload_resume">Reanudar todas las cargas</string>
<string name="upload_cannot_create_file">No se puede crear el archivo local</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-eu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,6 @@
<string name="upload_action_cancelled_resume">Berrekin bertan behera utzitako igoerei</string>
<string name="upload_action_failed_clear">Garbitu huts egin duten igoerak</string>
<string name="upload_action_failed_retry">Erroredun igoerak berriz saiatu</string>
<string name="upload_action_file_not_exist_message">Fitxategi batzuk ez daude eta fitxategi horiei ezin zaie berrekin</string>
<string name="upload_action_global_upload_pause">Pausatu igoera guztiak</string>
<string name="upload_action_global_upload_resume">Berrekin igoera guztiei</string>
<string name="upload_cannot_create_file">Ezin da sortu fitxategi lokala</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,6 @@
<string name="upload_action_cancelled_resume">ازسرگیری آپلودهای لغو شده</string>
<string name="upload_action_failed_clear">پاک کردن آپلودهای ناموفق</string>
<string name="upload_action_failed_retry">تلاش مجدد آپلودهای ناموفق</string>
<string name="upload_action_file_not_exist_message">برخی فایل‌ها وجود ندارند درنتیجه نمی‌توان آن فایل‌ها را ازسرگیری کرد</string>
<string name="upload_action_global_upload_pause">توقف موقت همه آپلودها</string>
<string name="upload_action_global_upload_resume">ازسرگیری همه آپلودها</string>
<string name="upload_cannot_create_file">پرونده محلی ایجاد نمی شود</string>
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
<string name="add_to_cloud">Ajouter à %1$s</string>
<string name="advanced_settings">Paramètres avancés</string>
<string name="allow_resharing">Autoriser le repartage</string>
<string name="app_config_base_url_title">URL de base</string>
<string name="app_config_proxy_host_title">Nom de l\'hôte du proxy</string>
<string name="app_config_proxy_port_title">Port Proxy</string>
<string name="app_widget_description">Affiche un widget du tableau de bord</string>
<string name="appbar_search_in">Recherche dans %s</string>
Expand Down Expand Up @@ -89,6 +91,8 @@
<string name="auth_unknown_host_title">Impossible de trouver l\'hôte</string>
<string name="auth_unsupported_multiaccount">%1$s ne prend pas en charge les comptes multiples</string>
<string name="auth_wrong_connection_title">Impossible d\'établir la connexion</string>
<string name="authenticator_activity_cancel_login">Annuler la connexion</string>
<string name="authenticator_activity_please_complete_login_process">Veuillez finaliser la connexion dans votre navigateur</string>
<string name="auto_upload_file_behaviour_kept_in_folder">conservé dans le dossier original (puisqu\'il est en lecture seule)</string>
<string name="auto_upload_on_wifi">Téléverser par Wi-Fi uniquement</string>
<string name="auto_upload_path">/TéléversementAuto</string>
Expand Down Expand Up @@ -173,6 +177,7 @@
<string name="confirmation_remove_folder_alert">Voulez-vous vraiment supprimer %1$s et ses contenus ?</string>
<string name="confirmation_remove_folders_alert">Souhaitez-vous vraiment supprimer les éléments sélectionnés ainsi que leurs contenus ?</string>
<string name="confirmation_remove_local">Local seulement</string>
<string name="conflict_dialog_error">Erreur lors de la création de la boîte de dialogue de conflit !</string>
<string name="conflict_file_headline">Fichier %1$s en conflit</string>
<string name="conflict_local_file">fichier local</string>
<string name="conflict_message_description">Si vous sélectionnez les deux versions, le fichier local aura un numéro ajouté à son nom.</string>
Expand Down Expand Up @@ -657,6 +662,7 @@
<string name="preview_image_description">Prévisualisation de l’image</string>
<string name="preview_image_error_no_local_file">Il n\'y a aucun fichier local à prévisualiser</string>
<string name="preview_image_error_unknown_format">L\'image ne peut pas être affichée</string>
<string name="preview_media_unhandled_http_code_message">Ce fichier est actuellement vérouillé par un autre utilisateur ou processus et ne peut donc pas être supprimé. Veuillez réessayer plus tard.</string>
<string name="preview_sorry">Désolé</string>
<string name="privacy">Vie privée</string>
<string name="public_share_name">Nouveau nom</string>
Expand Down Expand Up @@ -888,7 +894,6 @@
<string name="upload_action_cancelled_resume">Poursuivre les téléversements annulés</string>
<string name="upload_action_failed_clear">Effacer les téléversements échoués</string>
<string name="upload_action_failed_retry">Réessayer les téléversements qui ont échoué</string>
<string name="upload_action_file_not_exist_message">Certains fichiers n’existent pas et ne peuvent pas être relancés.</string>
<string name="upload_action_global_upload_pause">Suspendre tous les téléversements</string>
<string name="upload_action_global_upload_resume">Poursuivre tous les téléversements</string>
<string name="upload_cannot_create_file">Impossible de créer le fichier local</string>
Expand Down
Loading

0 comments on commit be7e3a5

Please sign in to comment.