mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
allow toggling between portrait and landscape aspect ratio at wallpaper picker
This commit is contained in:
parent
3221d30bef
commit
da67107b83
19 changed files with 70 additions and 8 deletions
|
@ -16,6 +16,7 @@ import kotlinx.android.synthetic.main.view_crop_image.*
|
|||
|
||||
class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener {
|
||||
private val PICK_IMAGE = 1
|
||||
private var isLandscapeRatio = true
|
||||
|
||||
lateinit var uri: Uri
|
||||
lateinit var wallpaperManager: WallpaperManager
|
||||
|
@ -47,13 +48,22 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete
|
|||
crop_image_view.apply {
|
||||
guidelines = CropImageView.Guidelines.OFF
|
||||
setOnCropImageCompleteListener(this@SetWallpaperActivity)
|
||||
setImageUriAsync(intent.data)
|
||||
setAspectRatio(wallpaperManager.desiredMinimumWidth, wallpaperManager.desiredMinimumHeight)
|
||||
}
|
||||
setImageUriAsync(uri)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||
setupAspectRatio()
|
||||
}
|
||||
|
||||
private fun setupAspectRatio() {
|
||||
val wallpaperWidth = if (isLandscapeRatio) wallpaperManager.desiredMinimumWidth else wallpaperManager.desiredMinimumWidth / 2
|
||||
crop_image_view.setAspectRatio(wallpaperWidth, wallpaperManager.desiredMinimumHeight)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_set_wallpaper, menu)
|
||||
|
||||
menu.findItem(R.id.portrait_aspect_ratio).isVisible = isLandscapeRatio
|
||||
menu.findItem(R.id.landscape_aspect_ratio).isVisible = !isLandscapeRatio
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -61,11 +71,19 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete
|
|||
when (item.itemId) {
|
||||
R.id.save -> crop_image_view.getCroppedImageAsync()
|
||||
R.id.rotate -> crop_image_view.rotateImage(90)
|
||||
R.id.portrait_aspect_ratio -> changeAspectRatio(false)
|
||||
R.id.landscape_aspect_ratio -> changeAspectRatio(true)
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun changeAspectRatio(isLandscape: Boolean) {
|
||||
isLandscapeRatio = isLandscape
|
||||
setupAspectRatio()
|
||||
invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
override fun onCropImageComplete(view: CropImageView?, result: CropImageView.CropResult) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && isDestroyed)
|
||||
return
|
||||
|
|
|
@ -1,14 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/rotate"
|
||||
android:icon="@drawable/ic_rotate_right"
|
||||
android:title="@string/rotate"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/save"
|
||||
android:icon="@drawable/ic_check"
|
||||
android:title="@string/save"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/portrait_aspect_ratio"
|
||||
android:icon="@drawable/ic_minimize"
|
||||
android:title="@string/portrait_aspect_ratio"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/landscape_aspect_ratio"
|
||||
android:icon="@drawable/ic_maximize"
|
||||
android:title="@string/landscape_aspect_ratio"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/rotate"
|
||||
android:icon="@drawable/ic_rotate_right"
|
||||
android:title="@string/rotate"
|
||||
app:showAsAction="ifRoom"/>
|
||||
</menu>
|
||||
|
|
|
@ -75,6 +75,8 @@
|
|||
<string name="no_wallpaper_setter_found">Nebyla nalezena žádná vhodná aplikace</string>
|
||||
<string name="setting_wallpaper">Nastavuje se tapeta…</string>
|
||||
<string name="wallpaper_set_successfully">Tapeta byla úspěšně změněna</string>
|
||||
<string name="portrait_aspect_ratio">Portrait aspect ratio</string>
|
||||
<string name="landscape_aspect_ratio">Landscape aspect ratio</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="show_hidden_folders">Zobrazit skryté složky</string>
|
||||
|
|
|
@ -75,6 +75,8 @@
|
|||
<string name="no_wallpaper_setter_found">Keine passende App gefunden</string>
|
||||
<string name="setting_wallpaper">Setze Hintergrundbild…</string>
|
||||
<string name="wallpaper_set_successfully">Hintergrundbild erfolgreich festgelegt</string>
|
||||
<string name="portrait_aspect_ratio">Portrait aspect ratio</string>
|
||||
<string name="landscape_aspect_ratio">Landscape aspect ratio</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="show_hidden_folders">Zeige versteckte Ordner</string>
|
||||
|
|
|
@ -75,6 +75,8 @@
|
|||
<string name="no_wallpaper_setter_found">No se encontró aplicación para ello</string>
|
||||
<string name="setting_wallpaper">Estableciendo fondo de pantalla…</string>
|
||||
<string name="wallpaper_set_successfully">Fondo de pantalla establecido correctamente</string>
|
||||
<string name="portrait_aspect_ratio">Portrait aspect ratio</string>
|
||||
<string name="landscape_aspect_ratio">Landscape aspect ratio</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="show_hidden_folders">Mostrar carpetas ocultas</string>
|
||||
|
|
|
@ -75,6 +75,8 @@
|
|||
<string name="no_wallpaper_setter_found">Aucune application trouvée pour continuer cette action</string>
|
||||
<string name="setting_wallpaper">Paramètre de fond d\'écran…</string>
|
||||
<string name="wallpaper_set_successfully">Fond d\'écran défini avec succès.</string>
|
||||
<string name="portrait_aspect_ratio">Portrait aspect ratio</string>
|
||||
<string name="landscape_aspect_ratio">Landscape aspect ratio</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="show_hidden_folders">Afficher les dossiers cachés</string>
|
||||
|
|
|
@ -75,6 +75,8 @@
|
|||
<string name="no_wallpaper_setter_found">No app capable of it has been found</string>
|
||||
<string name="setting_wallpaper">Setting wallpaper…</string>
|
||||
<string name="wallpaper_set_successfully">Wallpaper set successfully</string>
|
||||
<string name="portrait_aspect_ratio">Portrait aspect ratio</string>
|
||||
<string name="landscape_aspect_ratio">Landscape aspect ratio</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="show_hidden_folders">Show hidden folders</string>
|
||||
|
|
|
@ -75,6 +75,8 @@
|
|||
<string name="no_wallpaper_setter_found">Non sono disponibili app compatibili</string>
|
||||
<string name="setting_wallpaper">Impostazione sfondo…</string>
|
||||
<string name="wallpaper_set_successfully">Sfondo impostato correttamente</string>
|
||||
<string name="portrait_aspect_ratio">Portrait aspect ratio</string>
|
||||
<string name="landscape_aspect_ratio">Landscape aspect ratio</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="show_hidden_folders">Mostra cartelle nascoste</string>
|
||||
|
|
|
@ -75,6 +75,8 @@
|
|||
<string name="no_wallpaper_setter_found">対応できるアプリが見つかりません</string>
|
||||
<string name="setting_wallpaper">壁紙の設定…</string>
|
||||
<string name="wallpaper_set_successfully">壁紙を正常に設定しました</string>
|
||||
<string name="portrait_aspect_ratio">Portrait aspect ratio</string>
|
||||
<string name="landscape_aspect_ratio">Landscape aspect ratio</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="show_hidden_folders">非表示フォルダーを表示</string>
|
||||
|
|
|
@ -75,6 +75,8 @@
|
|||
<string name="no_wallpaper_setter_found">Brak odpowiednich ustawień</string>
|
||||
<string name="setting_wallpaper">Ustawianie tapety…</string>
|
||||
<string name="wallpaper_set_successfully">Tapeta ustawiona</string>
|
||||
<string name="portrait_aspect_ratio">Portrait aspect ratio</string>
|
||||
<string name="landscape_aspect_ratio">Landscape aspect ratio</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="show_hidden_folders">Pokaż ukryte foldery</string>
|
||||
|
|
|
@ -75,6 +75,8 @@
|
|||
<string name="no_wallpaper_setter_found">Aplicativo não encontrado</string>
|
||||
<string name="setting_wallpaper">A definir como fundo de tela;</string>
|
||||
<string name="wallpaper_set_successfully">Fundo de tela definido com sucesso</string>
|
||||
<string name="portrait_aspect_ratio">Portrait aspect ratio</string>
|
||||
<string name="landscape_aspect_ratio">Landscape aspect ratio</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="show_hidden_folders">Mostrar pastas ocultas</string>
|
||||
|
|
|
@ -75,6 +75,8 @@
|
|||
<string name="no_wallpaper_setter_found">Aplicação não encontrada</string>
|
||||
<string name="setting_wallpaper">A definir como fundo de ecrã…</string>
|
||||
<string name="wallpaper_set_successfully">Fundo definido com sucesso</string>
|
||||
<string name="portrait_aspect_ratio">Portrait aspect ratio</string>
|
||||
<string name="landscape_aspect_ratio">Landscape aspect ratio</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="show_hidden_folders">Mostrar pastas ocultas</string>
|
||||
|
|
|
@ -75,6 +75,8 @@
|
|||
<string name="no_wallpaper_setter_found">Приложение не найдено</string>
|
||||
<string name="setting_wallpaper">Установка обоев…</string>
|
||||
<string name="wallpaper_set_successfully">Обои успешно установлены</string>
|
||||
<string name="portrait_aspect_ratio">Portrait aspect ratio</string>
|
||||
<string name="landscape_aspect_ratio">Landscape aspect ratio</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="show_hidden_folders">Показать скрытые папки</string>
|
||||
|
|
|
@ -75,6 +75,8 @@
|
|||
<string name="no_wallpaper_setter_found">Nenašla sa žiadna vhodná aplikácia No app capable of it has been found</string>
|
||||
<string name="setting_wallpaper">Nastavuje sa tapeta…</string>
|
||||
<string name="wallpaper_set_successfully">Tapeta bola úspešne zmenená</string>
|
||||
<string name="portrait_aspect_ratio">Orientácia nastojato</string>
|
||||
<string name="landscape_aspect_ratio">Orientácia naležato</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="show_hidden_folders">Zobraziť skryté priečinky</string>
|
||||
|
|
|
@ -75,6 +75,8 @@
|
|||
<string name="no_wallpaper_setter_found">Hittade ingen app som klarar av detta</string>
|
||||
<string name="setting_wallpaper">Inställningar för bakgrundsbild…</string>
|
||||
<string name="wallpaper_set_successfully">Bakgrundsbilden är ändrad</string>
|
||||
<string name="portrait_aspect_ratio">Portrait aspect ratio</string>
|
||||
<string name="landscape_aspect_ratio">Landscape aspect ratio</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="show_hidden_folders">Visa dolda mappar</string>
|
||||
|
|
|
@ -75,6 +75,8 @@
|
|||
<string name="no_wallpaper_setter_found">Mümkün olan herhangi bir uygulama bulunamadı</string>
|
||||
<string name="setting_wallpaper">Duvar kağıdını ayarlama…</string>
|
||||
<string name="wallpaper_set_successfully">Duvar kağıdı başarıyla ayarlandı</string>
|
||||
<string name="portrait_aspect_ratio">Portrait aspect ratio</string>
|
||||
<string name="landscape_aspect_ratio">Landscape aspect ratio</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="show_hidden_folders">Gizli klasörleri göster</string>
|
||||
|
|
|
@ -75,6 +75,8 @@
|
|||
<string name="no_wallpaper_setter_found">没有可用的软件</string>
|
||||
<string name="setting_wallpaper">壁纸应用中…</string>
|
||||
<string name="wallpaper_set_successfully">壁纸应用成功</string>
|
||||
<string name="portrait_aspect_ratio">Portrait aspect ratio</string>
|
||||
<string name="landscape_aspect_ratio">Landscape aspect ratio</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="show_hidden_folders">显示所有</string>
|
||||
|
|
|
@ -75,6 +75,8 @@
|
|||
<string name="no_wallpaper_setter_found">沒有可用的應用軟體</string>
|
||||
<string name="setting_wallpaper">正在應用軟體桌布…</string>
|
||||
<string name="wallpaper_set_successfully">成功應用軟體桌布</string>
|
||||
<string name="portrait_aspect_ratio">Portrait aspect ratio</string>
|
||||
<string name="landscape_aspect_ratio">Landscape aspect ratio</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="show_hidden_folders">秀出隱藏資料夾</string>
|
||||
|
|
|
@ -75,6 +75,8 @@
|
|||
<string name="no_wallpaper_setter_found">No app capable of it has been found</string>
|
||||
<string name="setting_wallpaper">Setting wallpaper…</string>
|
||||
<string name="wallpaper_set_successfully">Wallpaper set successfully</string>
|
||||
<string name="portrait_aspect_ratio">Portrait aspect ratio</string>
|
||||
<string name="landscape_aspect_ratio">Landscape aspect ratio</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="show_hidden_folders">Show hidden folders</string>
|
||||
|
|
Loading…
Reference in a new issue