move the wallpaper handling in a background thread

This commit is contained in:
tibbi 2016-10-08 19:39:50 +02:00
parent d907e3cef5
commit c64a158a49
9 changed files with 25 additions and 22 deletions

View file

@ -206,7 +206,7 @@ public class ViewPagerActivity extends SimpleActivity
} }
} else if (requestCode == SET_WALLPAPER) { } else if (requestCode == SET_WALLPAPER) {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
Utils.showToast(getApplicationContext(), R.string.wallpaper_changed_successfully); Utils.showToast(getApplicationContext(), R.string.wallpaper_set_successfully);
} }
} }
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);

View file

@ -63,6 +63,8 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete
override fun onCropImageComplete(view: CropImageView?, result: CropImageView.CropResult) { override fun onCropImageComplete(view: CropImageView?, result: CropImageView.CropResult) {
if (result.error == null) { if (result.error == null) {
toast(R.string.setting_wallpaper)
Thread({
val bitmap = result.bitmap val bitmap = result.bitmap
val wantedHeight = wallpaperManager.desiredMinimumHeight val wantedHeight = wallpaperManager.desiredMinimumHeight
val ratio = wantedHeight / bitmap.height.toFloat() val ratio = wantedHeight / bitmap.height.toFloat()
@ -70,6 +72,7 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete
wallpaperManager.setBitmap(Bitmap.createScaledBitmap(bitmap, wantedWidth, wantedHeight, false)) wallpaperManager.setBitmap(Bitmap.createScaledBitmap(bitmap, wantedWidth, wantedHeight, false))
setResult(Activity.RESULT_OK) setResult(Activity.RESULT_OK)
finish() finish()
}).start()
} else { } else {
toast("${getString(R.string.image_editing_failed)}: ${result.error.message}") toast("${getString(R.string.image_editing_failed)}: ${result.error.message}")
} }

View file

@ -19,7 +19,6 @@
<string name="renaming_folder">Benenne Ordner um</string> <string name="renaming_folder">Benenne Ordner um</string>
<string name="extension">Dateiendung</string> <string name="extension">Dateiendung</string>
<string name="file_deleted">Datei gelöscht</string> <string name="file_deleted">Datei gelöscht</string>
<string name="setting_wallpaper">Setze Hintergrundbild</string>
<string name="open_camera">Kamera öffnen</string> <string name="open_camera">Kamera öffnen</string>
<string name="unknown_error">Ein unbekannter Fehler ist aufgetreten</string> <string name="unknown_error">Ein unbekannter Fehler ist aufgetreten</string>
<string name="sort_by">Sortieren nach</string> <string name="sort_by">Sortieren nach</string>
@ -58,7 +57,8 @@
<string name="set_as_wallpaper_failed">Setzen des Hintergrundbildes fehlgeschlagen</string> <string name="set_as_wallpaper_failed">Setzen des Hintergrundbildes fehlgeschlagen</string>
<string name="set_as_wallpaper_with">Set as wallpaper with:</string> <string name="set_as_wallpaper_with">Set as wallpaper with:</string>
<string name="no_wallpaper_setter_found">No app capable of it has been found</string> <string name="no_wallpaper_setter_found">No app capable of it has been found</string>
<string name="wallpaper_changed_successfully">Wallpaper changed successfully</string> <string name="setting_wallpaper">Setze Hintergrundbild&#8230;</string>
<string name="wallpaper_set_successfully">Wallpaper set successfully</string>
<!-- About --> <!-- About -->
<string name="about">Über</string> <string name="about">Über</string>

View file

@ -19,7 +19,6 @@
<string name="renaming_folder">Renombrando carpeta</string> <string name="renaming_folder">Renombrando carpeta</string>
<string name="extension">Extensión</string> <string name="extension">Extensión</string>
<string name="file_deleted">Archivo eliminado</string> <string name="file_deleted">Archivo eliminado</string>
<string name="setting_wallpaper">Estableciendo fondo de pantalla</string>
<string name="open_camera">Abrir cámara</string> <string name="open_camera">Abrir cámara</string>
<string name="unknown_error">Ocurrió un error desconocido</string> <string name="unknown_error">Ocurrió un error desconocido</string>
<string name="sort_by">Ordenar por</string> <string name="sort_by">Ordenar por</string>
@ -58,7 +57,8 @@
<string name="set_as_wallpaper_failed">Error al establecer fondo de pantalla</string> <string name="set_as_wallpaper_failed">Error al establecer fondo de pantalla</string>
<string name="set_as_wallpaper_with">Set as wallpaper with:</string> <string name="set_as_wallpaper_with">Set as wallpaper with:</string>
<string name="no_wallpaper_setter_found">No app capable of it has been found</string> <string name="no_wallpaper_setter_found">No app capable of it has been found</string>
<string name="wallpaper_changed_successfully">Wallpaper changed successfully</string> <string name="setting_wallpaper">Estableciendo fondo de pantalla&#8230;</string>
<string name="wallpaper_set_successfully">Wallpaper set successfully</string>
<!-- About --> <!-- About -->
<string name="about">Acerca de</string> <string name="about">Acerca de</string>

View file

@ -19,7 +19,6 @@
<string name="renaming_folder">Rinominazione cartella</string> <string name="renaming_folder">Rinominazione cartella</string>
<string name="extension">Estensione</string> <string name="extension">Estensione</string>
<string name="file_deleted">File eliminato</string> <string name="file_deleted">File eliminato</string>
<string name="setting_wallpaper">Impostazione sfondo</string>
<string name="open_camera">Apri fotocamera</string> <string name="open_camera">Apri fotocamera</string>
<string name="unknown_error">Riscontrato un errore sconosciuto</string> <string name="unknown_error">Riscontrato un errore sconosciuto</string>
<string name="sort_by">Sort by</string> <string name="sort_by">Sort by</string>
@ -58,7 +57,8 @@
<string name="set_as_wallpaper_failed">Setting as Wallpaper failed</string> <string name="set_as_wallpaper_failed">Setting as Wallpaper failed</string>
<string name="set_as_wallpaper_with">Set as wallpaper with:</string> <string name="set_as_wallpaper_with">Set as wallpaper with:</string>
<string name="no_wallpaper_setter_found">No app capable of it has been found</string> <string name="no_wallpaper_setter_found">No app capable of it has been found</string>
<string name="wallpaper_changed_successfully">Wallpaper changed successfully</string> <string name="setting_wallpaper">Impostazione sfondo&#8230;</string>
<string name="wallpaper_set_successfully">Wallpaper set successfully</string>
<!-- About --> <!-- About -->
<string name="about">Informazioni</string> <string name="about">Informazioni</string>

View file

@ -19,7 +19,6 @@
<string name="renaming_folder">フォルダーの名前を変更中</string> <string name="renaming_folder">フォルダーの名前を変更中</string>
<string name="extension">拡張</string> <string name="extension">拡張</string>
<string name="file_deleted">ファイルを削除しました</string> <string name="file_deleted">ファイルを削除しました</string>
<string name="setting_wallpaper">壁紙の設定</string>
<string name="open_camera">カメラを開く</string> <string name="open_camera">カメラを開く</string>
<string name="unknown_error">不明なエラーが発生しました</string> <string name="unknown_error">不明なエラーが発生しました</string>
<string name="sort_by">Sort by</string> <string name="sort_by">Sort by</string>
@ -58,7 +57,8 @@
<string name="set_as_wallpaper_failed">Setting as Wallpaper failed</string> <string name="set_as_wallpaper_failed">Setting as Wallpaper failed</string>
<string name="set_as_wallpaper_with">Set as wallpaper with:</string> <string name="set_as_wallpaper_with">Set as wallpaper with:</string>
<string name="no_wallpaper_setter_found">No app capable of it has been found</string> <string name="no_wallpaper_setter_found">No app capable of it has been found</string>
<string name="wallpaper_changed_successfully">Wallpaper changed successfully</string> <string name="setting_wallpaper">壁紙の設定&#8230;</string>
<string name="wallpaper_set_successfully">Wallpaper set successfully</string>
<!-- About --> <!-- About -->
<string name="about">アプリについて</string> <string name="about">アプリについて</string>

View file

@ -19,7 +19,6 @@
<string name="renaming_folder">A renomear pasta</string> <string name="renaming_folder">A renomear pasta</string>
<string name="extension">Extensão</string> <string name="extension">Extensão</string>
<string name="file_deleted">Ficheiro eliminado</string> <string name="file_deleted">Ficheiro eliminado</string>
<string name="setting_wallpaper">A definir como fundo de ecrã</string>
<string name="open_camera">Abrir câmara</string> <string name="open_camera">Abrir câmara</string>
<string name="unknown_error">Ocorreu um erro desconhecido</string> <string name="unknown_error">Ocorreu um erro desconhecido</string>
<string name="sort_by">Ordenar por</string> <string name="sort_by">Ordenar por</string>
@ -58,7 +57,8 @@
<string name="set_as_wallpaper_failed">Falha ao definir como fundo de ecrã</string> <string name="set_as_wallpaper_failed">Falha ao definir como fundo de ecrã</string>
<string name="set_as_wallpaper_with">Set as wallpaper with:</string> <string name="set_as_wallpaper_with">Set as wallpaper with:</string>
<string name="no_wallpaper_setter_found">No app capable of it has been found</string> <string name="no_wallpaper_setter_found">No app capable of it has been found</string>
<string name="wallpaper_changed_successfully">Wallpaper changed successfully</string> <string name="setting_wallpaper">A definir como fundo de ecrã&#8230;</string>
<string name="wallpaper_set_successfully">Wallpaper set successfully</string>
<!-- About --> <!-- About -->
<string name="about">Sobre</string> <string name="about">Sobre</string>

View file

@ -19,7 +19,6 @@
<string name="renaming_folder">Döper om mappen</string> <string name="renaming_folder">Döper om mappen</string>
<string name="extension">Filändelse</string> <string name="extension">Filändelse</string>
<string name="file_deleted">Fil borttagen</string> <string name="file_deleted">Fil borttagen</string>
<string name="setting_wallpaper">Inställningar för bakgrundsbild</string>
<string name="open_camera">Starta kameran</string> <string name="open_camera">Starta kameran</string>
<string name="unknown_error">Ett okänt fel har uppstått</string> <string name="unknown_error">Ett okänt fel har uppstått</string>
<string name="sort_by">Sort by</string> <string name="sort_by">Sort by</string>
@ -58,7 +57,8 @@
<string name="set_as_wallpaper_failed">Setting as Wallpaper failed</string> <string name="set_as_wallpaper_failed">Setting as Wallpaper failed</string>
<string name="set_as_wallpaper_with">Set as wallpaper with:</string> <string name="set_as_wallpaper_with">Set as wallpaper with:</string>
<string name="no_wallpaper_setter_found">No app capable of it has been found</string> <string name="no_wallpaper_setter_found">No app capable of it has been found</string>
<string name="wallpaper_changed_successfully">Wallpaper changed successfully</string> <string name="setting_wallpaper">Inställningar för bakgrundsbild&#8230;</string>
<string name="wallpaper_set_successfully">Wallpaper set successfully</string>
<!-- About --> <!-- About -->
<string name="about">Om</string> <string name="about">Om</string>

View file

@ -19,7 +19,6 @@
<string name="renaming_folder">Renaming folder</string> <string name="renaming_folder">Renaming folder</string>
<string name="extension">Extension</string> <string name="extension">Extension</string>
<string name="file_deleted">File deleted</string> <string name="file_deleted">File deleted</string>
<string name="setting_wallpaper">Setting wallpaper</string>
<string name="open_camera">Open camera</string> <string name="open_camera">Open camera</string>
<string name="unknown_error">An unknown error occurred</string> <string name="unknown_error">An unknown error occurred</string>
<string name="sort_by">Sort by</string> <string name="sort_by">Sort by</string>
@ -58,7 +57,8 @@
<string name="set_as_wallpaper_failed">Setting as Wallpaper failed</string> <string name="set_as_wallpaper_failed">Setting as Wallpaper failed</string>
<string name="set_as_wallpaper_with">Set as wallpaper with:</string> <string name="set_as_wallpaper_with">Set as wallpaper with:</string>
<string name="no_wallpaper_setter_found">No app capable of it has been found</string> <string name="no_wallpaper_setter_found">No app capable of it has been found</string>
<string name="wallpaper_changed_successfully">Wallpaper changed successfully</string> <string name="setting_wallpaper">Setting wallpaper&#8230;</string>
<string name="wallpaper_set_successfully">Wallpaper set successfully</string>
<!-- About --> <!-- About -->
<string name="about">About</string> <string name="about">About</string>