From ed9250df7a8089061e22c23fb2ee7796fc2122ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Solatec=20Inform=C3=A0tica?= <35220662+Solatec@users.noreply.github.com> Date: Wed, 5 Dec 2018 11:10:48 +0100 Subject: [PATCH 01/99] Update strings.xml --- app/src/main/res/values-ca/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-ca/strings.xml b/app/src/main/res/values-ca/strings.xml index 25833a288..c639078f1 100644 --- a/app/src/main/res/values-ca/strings.xml +++ b/app/src/main/res/values-ca/strings.xml @@ -89,7 +89,7 @@ Verticalment Editar amb Lliure - Other + Altres Fons de pantalla de Simple Gallery @@ -140,7 +140,7 @@ Animar les miniatures dels GIFs Brillantor màxima quan es mostra multimèdia Retallar miniatures en quadrats - Show video durations + Mostra les durades del vídeo Gira els mitjans a pantalla completa segons Configuració del sistema Rotació del dispositiu From 6f3a0a555fdc503aabdcb7aa6a59002e234982f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Solatec=20Inform=C3=A0tica?= <35220662+Solatec@users.noreply.github.com> Date: Wed, 5 Dec 2018 11:12:05 +0100 Subject: [PATCH 02/99] Update strings.xml --- app/src/main/res/values-es/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 80c2796c0..7d65f1ac2 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -89,7 +89,7 @@ Verticalmente Editar con Libre - Other + Otros Fondos de pantalla Simple Gallery @@ -140,7 +140,7 @@ Animar las miniaturas de GIFs Brillo máximo cuando se muestra multimedia Recortar miniaturas en cuadrados - Show video durations + Mostrar duración del video Rotar multimedia en pantalla completa según Configuración del sistema Rotación del dispositivo From f798811163a952fa1a423baa740824479dfca7dc Mon Sep 17 00:00:00 2001 From: sawka6630 Date: Wed, 5 Dec 2018 23:09:22 +0200 Subject: [PATCH 03/99] Update strings.xml --- app/src/main/res/values-uk/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 273982f7d..a593e2671 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -89,7 +89,7 @@ Віддзеркалити вертикально Редагувати за допомогою Вільне - Other + Інше Simple Wallpaper @@ -140,7 +140,7 @@ Анімувати ескізи GIF-файлів Максимальна яскравість екрану при повноекранному перегляді медіафайлу Обрізати ескізи у квадрат - Show video durations + Показувати тривалість відео При повноекранному перегляді обертати за… системними налаштуваннями поворотом пристрою From 904e43e8f059987ad55e0cafaa0a15fd30730226 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 6 Dec 2018 15:23:52 +0100 Subject: [PATCH 04/99] check connected OTG devices only after receiving the write_storage permission --- .../gallery/pro/activities/MainActivity.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 9fd6eb352..2ac01140e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -126,10 +126,6 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { NewAppDialog(this, NEW_APP_PACKAGE, "Simple Clock") }*/ - if (!config.wasOTGHandled && hasPermission(PERMISSION_WRITE_STORAGE)) { - checkOTGInclusion() - } - if (!config.wereFavoritesPinned) { config.addPinnedFolders(hashSetOf(FAVORITES)) config.wereFavoritesPinned = true @@ -385,6 +381,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun tryLoadGallery() { handlePermission(PERMISSION_WRITE_STORAGE) { if (it) { + if (!config.wasOTGHandled && hasPermission(PERMISSION_WRITE_STORAGE)) { + checkOTGInclusion() + } + if (config.showAll) { showAllMedia() } else { From 1df2a047e1d0a8a22e4a4c45fb4679473ca489c4 Mon Sep 17 00:00:00 2001 From: fricyo <30796677+fricyo@users.noreply.github.com> Date: Fri, 7 Dec 2018 11:22:36 +0800 Subject: [PATCH 05/99] Update Translation --- app/src/main/res/values-zh-rTW/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 423570191..f8e08f4f7 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -89,7 +89,7 @@ 垂直翻轉 用其他程式編輯 自由 - Other + 其它 簡易桌布 From 0dc1f2d90a56b9b6df3d74eaaa93254f12757a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Marques?= Date: Fri, 7 Dec 2018 13:33:00 +0000 Subject: [PATCH 06/99] Update strings.xml --- app/src/main/res/values-pt/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 681704fec..96c217a29 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -89,7 +89,7 @@ Verticalmente Editar com Livre - Other + Outro Simple Wallpaper From 490ddd82568aea5951c8fbfc29ac304c6e202eb4 Mon Sep 17 00:00:00 2001 From: siswonugroho <33504481+siswonugroho@users.noreply.github.com> Date: Mon, 10 Dec 2018 10:53:34 +0700 Subject: [PATCH 07/99] added Indonesian translation --- app/src/main/res/values-id/strings.xml | 248 +++++++++++++++++++++++++ 1 file changed, 248 insertions(+) create mode 100644 app/src/main/res/values-id/strings.xml diff --git a/app/src/main/res/values-id/strings.xml b/app/src/main/res/values-id/strings.xml new file mode 100644 index 000000000..6bc47a212 --- /dev/null +++ b/app/src/main/res/values-id/strings.xml @@ -0,0 +1,248 @@ + + + Simple Gallery + Galeri + Edit + Buka kamera + (tersembunyi) + (dikecualikan) + Pin folder + Lepas pin folder + Pin ke atas + Tampilkan semua isi folder + Semua folder + Beralih ke tampilan folder + Folder lain + Tampilkan di peta + Lokasi tidak diketahui + Tambah jumlah kolom + Kurangi jumlah kolom + Ubah sampul + Pilih foto + Gunakan default + Volume + Kecerahan + Kunci rotasi + Aktifkan rotasi + Ubah orientasi + Paksa potret + Paksa landscape + Gunakan orientasi default + Perbaiki Tanggal Diambil + Memperbaiki… + Tanggal berhasil diperbaiki + + + Filter media + Gambar + Video + GIF + Gambar RAW + SVG + Tidak ada file media ditemukan dari filter ini. + Ubah filter + + + Fungsi ini menyembunyikan folder dengan menambahkan file \'.nomedia\' ke dalamnya, juga akan menyembunyikan semua subfolder. Anda bisa melihatnya dari opsi \'Tampilkan file tersembunyi\' di Setelan. Lanjutkan? + Kecualikan + Folder yang dikecualikan + Atur folder yang dikecualikan + Ini hanya akan mengecualikan pilihan bersama dengan subfoldernya di Simple Gallery. Anda bisa mengatur pengecualian di Setelan. + Kecualikan folder induk? + Mengecualikan folder akan membuatnya bersama subfoldernya tersembunyi hanya di Simple Gallery, namun masih bisa dilihat di aplikasi lain.\n\nJika Anda ingin menyembunyikannya dari aplikasi lain juga, gunakan fitur Sembunyikan. + Bersihkan daftar + Hapus semua folder dari daftar pengecualian? Ini tidak akan menghapus folder tersebut. + Folder tersembunyi + Atur folder tersembunyi + Sepertinya tidak ada folder tersembunyi dengan file \".nomedia\" didalamnya. + + + Folder yang disertakan + Atur folder yang disertakan + Tambah folder + Jika ada folder yang berisi file media, namun tidak dikenali oleh aplikasi ini, Anda bisa menambahkannya disini secara manual.\n\nMenambah beberapa item disini tidak akan mengecualikan folder yang lain. + + + Ubah ukuran + Ubah ukuran terpilih dan simpan + Lebar + Tinggi + Jaga aspek rasio + Harap masukkan resolusi dengan benar + + + Editor + Simpan + Rotasi + Jalur + Jalur gambar tidak valid + Gagal mengedit gambar + Edit dengan: + Tidak ada aplikasi editor gambar + Lokasi file tidak diketahui + Tidak dapat mengganti file sumber + Putar ke kiri + Putar ke kanan + Putar 180º + Balik + Balik horizontal + Balik vertikal + Edit dengan + Bebas + Lainnya + + + Simple Wallpaper + Setel wallpaper + Gagal menyetel sebagai wallpaper + Setel wallpaper dengan: + Menyetel wallpaper… + Wallpaper berhasil disetel + Aspek rasio potret + Aspek rasio landscape + Layar beranda + Layar kunci + Beranda dan layar kunci + + + Slideshow + Interval (detik): + Sertakan foto + Sertakan video + Sertakan GIF + Urutan acak + Animasi memudar + Mundur + Slideshow tanpa henti + Slideshow berakhir + Tidak ditemukan media untuk slideshow + + + Ubah jenis tampilan + Kotak + Daftar + Kelompokkan langsung subfolder + + + Kelompokkan menurut + Jangan kelompokkan file + Folder + Terakhir diubah + Tanggal diambil + Jenis file + Ekstensi + + + Putar video otomatis + Ingat posisi pemutaran terakhir + Tampil/sembunyikan nama file + Ulangi video + Animasi GIF di thumbnail + Kecerahan maksimal saat melihat di layar penuh + Pangkas thumbnail menjadi persegi + Tampilkan durasi video + Rotasi layar penuh dari + Pengaturan sistem + Rotasi perangkat + Aspek rasio + Background dan status bar hitam saat layar penuh + Gulir thumbnail secara horizontal + Otomatis sembunyikan sistem UI saat layar penuh + Hapus folder kosong setelah menghapus isinya + Izinkan mengontrol kecerahan foto dengan gerakan vertikal + Izinkan mengontrol kecerahan dan volume video dengan gerakan vertikal + Tampilkan jumlah folder media di tampilan utama + Ganti tombol Bagikan dengan Rotasi di menu layar penuh + Tampilkan detail tambahan saat layar penuh + Atur detail tambahan + Izinkan zoom satu jari di layar penuh + Izinkan mengganti media dengan mengklik sisi layar + Izinkan zoom gambar lebih dalam + Sembunyikan detail tambahan ketika status bar disembunyikan + Lakukan pemeriksaan ulang untuk menghindari file yang tidak valid + Tampilkan beberapa tombol tindakan dibawah layar + Tampilkan Sampah di layar folder + Zoom gambar mendalam + Tampilkan gambar dalam kualitas tertinggi + Tampilkan Sampah sebagai item terakhir di layar utama + Izinkan keluar dari layar penuh dengan menggeser kebawah + + + Thumbnail + Media layar penuh + Detail tambahan + Tindakan di bawah + + + Sesuaikan tombol tindakan bawah + Favorit + Tampil/sembunyikan file + + + Bagaimana cara menjadikan Simple Gallery sebagai aplikasi galeri default? + Pertama Anda harus menemukan galeri default saat ini di bagian Aplikasi di Setelan perangkat, lihatlah tombol yang seperti \"Buka secara default\", klik itu, lalu pilih \"Hapus default\". + Lain kali Anda mencoba membuka gambar atau video, Anda akan disuruh memilih aplikasi, dimana Anda bisa memilih Simple Gallery dan menjadikannya default. + Saya mengunci aplikasi dengan password, tapi saya lupa. Apa yang harus dilakukan? + Anda bisa menyelesaikannya dengan 2 cara. Anda bisa instal ulang aplikasi, atau cari aplikasi ini di Setelan perangkat dan pilih \"Hapus data\". Ini akan menyetel ulang semua setelan Anda, dan tidak akan menghapus file media apapun. + Bagaimana agar sebuah album selalu muncul paling atas di daftar? + Anda bisa menekan lama album tersebut dan pilih ikon Pin di menu tindakan, itu akan menaruhnya di atas daftar. Anda juga bisa menyematkan beberapa folder, item yang di-pin akan diurutkan berdasarkan metode urutan default. + Bagaimana cara mempercepat laju video? + Anda bisa mengklik teks durasi saat ini/maksimal di dekat penggeser durasi, itu akan memajukan atau memundurkan video. + Apa perbedaan antara menyembunyikan dan mengecualikan folder? + Mengecualikan tidak akan menampilkan folder di Simple Gallery, sedangkan Sembunyikan bekerja sesuai aturan sistem dan akan menyembunyikan folder juga dari aplikasi galeri yang lain. Cara kerjanya dengan membuat file \".nomedia\" kosong pada folder yang diinginkan, yang bisa Anda hapus juga dengan aplikasi file manager. + Mengapa folder dengan gambar album musik atau stiker muncul? + Kadang Anda melihat beberapa album yang tidak biasa muncul. Anda bisa dengan mudah menyembunyikannya dengan menekan lama dan pilih Kecualikan. Pada dialog berikutnya, Anda lalu bisa memilih folder induk, yang akan mencegah album terkait muncul kembali. + Ada folder berisi gambar namun tidak muncul, apa yang harus dilakukan? + Itu bisa disebabkan berbagai alasan, namun solusinya mudah. Pergi ke Setelan -> Atur folder yang disertakan, pilih Tambah dan cari folder yang diinginkan. + Bagaimana jika saya hanya ingin beberapa folder saja yang terlihat? + Menambahkan folder di Folder yang Disertakan tidak otomatis mengecualikan folder yang lain. Yang bisa Anda lakukan adalah pergi ke Setelan -> Atur Folder yang Dikecualikan, lalu kecualikan folder root \"/\", lalu tambahkan folder yang diinginkan di Setelan -> Atur Folder yang Disertakan. + Itu akan membuat folder yang dipilih saja yang muncul, dan jika sebuah folder disertakan dan dikecualikan secara bersamaan, folder tersebut akan muncul. + Gambar layar penuh terlihat pecah, bisakah ditingkatkan kualitasnya? + Ya, ada opsi di Setelan \"Ganti zoom mendalam dengan kualitas gambar yang lebih bagus\", Anda bisa menggunakannya. Ini akan meningkatkan kualitas gambar, namun gambar akan terlihat kabur jika Anda zoom terlalu banyak. + Bisakah saya meng-crop gambar dengan aplikasi ini? + Ya, Anda bisa melakukannya di Editor, dengan menyeret sudut gambar. Anda bisa masuk ke editor dengan menekan lama thumbnail gambar dan memilih Edit, atau pilih Edit dari tampilan layar penuh. + Bisakah saya mengelompokkan thumbnail file media? + Bisa, gunakan menu \"Kelompokkan menurut\" pada tampilan thumbnail. Anda bisa mengelompokkan file dengan berbagai kriteria, termasuk Tanggal Diambil. Jika Anda menggunakan fungsi \"Tampilkan semua isi folder\", Anda juga bisa mengelompokkan berdasarkan foldernya. + Tidak dapat mengurutkan berdasarkan Tanggal Diambil, bagaimana cara memperbaikinya? + Itu umumnya disebabkan karena file yang disalin dari tempat lain. Anda bisa memperbaikinya dengan memilih thumbnail file dan pilih \"Perbaiki Tanggal Diambil\". + Saya melihat beberapa pita warna pada gambar. Bagaimana saya meningkatkan kualitasnya? + Solusi saat ini untuk menampilkan gambar berfungsi dengan baik dalam sebagian besar kasus, namun jika Anda ingin kualitas gambar yang lebih baik, Anda bisa mengaktifkan \"Tampilkan gambar dalam kualitas tertinggi\" di setelan aplikasi, pada bagian \"Zoom gambar mendalam\". + Saya punya file/folder tersembunyi. Bagaimana cara memunculkannya? + Anda bisa memilih menu \"Tampilkan sementara file tersembunyi\" di layar utama, atau \"Tampilkan file tersembunyi\" di setelan aplikasi untuk menampilkannya. Jika Anda tidak ingin menyembunyikannya, tekan lama dan pilih \"Jangan sembunyikan\". Folder disembunyikan dengan menambahkan file \".nomedia\" di dalamnya, Anda bisa menghapus file tersebut dengan aplikasi file manager. + + + + Aplikasi galeri untuk melihat foto dan video tanpa iklan. + + Aplikasi galeri dengan banyak kustomisasi dan mampu menampilkan banyak jenis gambar dan video termasuk SVG, RAW, panorama foto dan video. + + Aplikasi ini open source, tidak berisi iklan atau izin yang tidak diperlukan. + + Beberapa fiturnya antara lain: + 1. Pencarian + 2. Slideshow + 3. Dukungan notch (layar berponi) + 4. Pin folder di atas + 5. Filter media berdasarkan jenis + 6. Keranjang sampah untuk memulihkan file + 7. Kunci orientasi layar penuh + 8. Tandai file favorit agar mudah diakses + 9. Keluar dari layar penuh dengan menggeser ke bawah + 10. Editor bawaan untuk mengedit dan menambahkan filter + 11. Perlindungan password untuk item tersembunyi atau mengunci aplikasi + 12. Ubah jumlah kolom thumbnail lewat gerakan atau menu + 13. Sesuaikan tombol tindakan di bawah layar penuh untuk akses cepat + 14. Menampilkan detail tambahan di layar penuh dengan properti file yang diinginkan + 15. Berbagai cara untuk mengurutkan atau mengelompokkan item, dengan naik atau turun + 16. Sembunyikan folder (berpengaruh di aplikasi lain), kecualikan folder (hanya berpengaruh di Simple Gallery) + + Izin sidik jari diperlukan untuk mengunci item tersembunyi, mengunci aplikasi, atau melindungi agar file tidak dihapus. + + Aplikasi ini hanyalah bagian dari rangkaian aplikasi saya. Anda bisa menemukan aplikasi saya lainnya di https://www.simplemobiletools.com + + + + From 40616a6bee80747500706d4ceb1dba0e4335e383 Mon Sep 17 00:00:00 2001 From: kniddl <10777535+kniddl@users.noreply.github.com> Date: Mon, 10 Dec 2018 13:52:25 +0100 Subject: [PATCH 08/99] Update German string --- app/src/main/res/values-de/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 141cad8b7..1e8d4ddbd 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -89,7 +89,7 @@ Vertikal spiegeln Bearbeiten mit: Beliebiges - Other + Anderes Schlichter Hintergrund From b64f1647420ad6a882efdf2e28bf8130cc45a09f Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 11 Dec 2018 12:47:18 +0100 Subject: [PATCH 09/99] delete invalid files from cache at loading thumbnails --- .../gallery/pro/activities/MediaActivity.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt index 791cabd78..a8390793d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt @@ -585,7 +585,15 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { mCurrAsyncTask?.stopFetching() mCurrAsyncTask = GetMediaAsynctask(applicationContext, mPath, mIsGetImageIntent, mIsGetVideoIntent, mShowAll) { Thread { - gotMedia(it) + val oldMedia = mMedia.clone() as ArrayList + val newMedia = it + gotMedia(newMedia, false) + try { + oldMedia.filter { !newMedia.contains(it) }.mapNotNull { it as? Medium }.filter { !File(it.path).exists() }.forEach { + mMediumDao.deleteMediumPath(it.path) + } + } catch (e: Exception) { + } }.start() } @@ -820,7 +828,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { } } - private fun gotMedia(media: ArrayList, isFromCache: Boolean = false) { + private fun gotMedia(media: ArrayList, isFromCache: Boolean) { mIsGettingMedia = false checkLastMediaChanged() mMedia = media From f91f1819b0b25d4822b042f33ef9521954a982dc Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 11 Dec 2018 12:47:25 +0100 Subject: [PATCH 10/99] update kotlin to 1.3.11 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 1cfbb3a29..d93366c1c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.10' + ext.kotlin_version = '1.3.11' repositories { google() From 87436720b8a3b637e422b8ee37cce9d9679614ef Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 11 Dec 2018 21:51:27 +0100 Subject: [PATCH 11/99] updating SubsamplingScaleImageView to 4.0.0 --- app/build.gradle | 5 +++-- .../gallery/pro/fragments/PhotoFragment.kt | 21 ++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index aa7e98b3c..818617211 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -57,7 +57,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.5.4' + implementation 'com.simplemobiletools:commons:5.5.15' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'androidx.multidex:multidex:2.0.0' implementation 'it.sephiroth.android.exif:library:1.0.1' @@ -77,7 +77,8 @@ dependencies { annotationProcessor 'androidx.room:room-compiler:2.0.0' //implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0' - implementation 'com.github.tibbi:subsampling-scale-image-view:v3.10.1-fork' + //implementation 'com.github.tibbi:subsampling-scale-image-view:v3.10.1-fork' + implementation 'com.github.tibbi:subsampling-scale-image-view:4.0.0' // implementation 'com.github.chrisbanes:PhotoView:2.1.4' implementation 'com.github.tibbi:PhotoView:2.2.1-fork' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt index 0580e2a48..372bc7b0c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt @@ -26,6 +26,9 @@ import com.bumptech.glide.request.RequestListener import com.bumptech.glide.request.RequestOptions import com.davemorrissey.labs.subscaleview.ImageSource import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView +import com.davemorrissey.labs.subscaleview.decoder.DecoderFactory +import com.davemorrissey.labs.subscaleview.decoder.ImageDecoder +import com.davemorrissey.labs.subscaleview.decoder.ImageRegionDecoder import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.OTG_PATH import com.simplemobiletools.gallery.pro.R @@ -377,18 +380,26 @@ class PhotoFragment : ViewPagerFragment() { val path = getPathToLoad(medium) isSubsamplingVisible = true + val bitmapDecoder = object : DecoderFactory { + override fun make() = PicassoDecoder(path, Picasso.get(), rotation) + } + + val regionDecoder = object : DecoderFactory { + override fun make() = PicassoRegionDecoder() + } + view.subsampling_view.apply { setMaxTileSize(if (context!!.config.showHighestQuality) Integer.MAX_VALUE else 4096) setMinimumTileDpi(if (context!!.config.showHighestQuality) -1 else getMinTileDpi()) background = ColorDrawable(Color.TRANSPARENT) - setBitmapDecoderFactory { PicassoDecoder(path, Picasso.get(), rotation) } - setRegionDecoderFactory { PicassoRegionDecoder() } + setBitmapDecoderFactory(bitmapDecoder) + setRegionDecoderFactory(regionDecoder) maxScale = 10f beVisible() isQuickScaleEnabled = context.config.oneFingerZoom setResetScaleOnSizeChange(false) setImage(ImageSource.uri(path)) - orientation = rotation + setOrientation(rotation) setEagerLoadingEnabled(false) setOnImageEventListener(object : SubsamplingScaleImageView.OnImageEventListener { override fun onImageLoaded() { @@ -402,7 +413,7 @@ class PhotoFragment : ViewPagerFragment() { mOriginalSubsamplingScale = scale } - override fun onTileLoadError(e: Exception?) { + override fun onTileLoadError(e: Exception) { } override fun onPreviewReleased() { @@ -415,7 +426,7 @@ class PhotoFragment : ViewPagerFragment() { beGone() } - override fun onPreviewLoadError(e: Exception?) { + override fun onPreviewLoadError(e: Exception) { background = ColorDrawable(Color.TRANSPARENT) isSubsamplingVisible = false beGone() From 7b23d5ecd7f9f0c949f5f53517f2995a0c680236 Mon Sep 17 00:00:00 2001 From: Pzqqt <821026875@qq.com> Date: Wed, 12 Dec 2018 21:36:00 +0800 Subject: [PATCH 12/99] Update strings.xml --- app/src/main/res/values-zh-rCN/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 6dfe0a550..9f2d35ee9 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -89,7 +89,7 @@ 垂直翻转 编辑方式 自由 - Other + 其他 简约壁纸 @@ -140,7 +140,7 @@ GIF 缩略图 浏览时最大亮度 裁剪缩略图 - Show video durations + 显示视频时长 全屏方向 系统设置 设备方向 From f5248d5d53dbd2da73b9f12d5034e189874947c5 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 12 Dec 2018 19:29:05 +0100 Subject: [PATCH 13/99] add a checkbox for grouping direct subfolders at the Change View dialog --- app/build.gradle | 2 +- .../gallery/pro/activities/MainActivity.kt | 10 +--- .../pro/dialogs/ChangeViewTypeDialog.kt | 38 +++++++++++++ .../gallery/pro/helpers/Config.kt | 4 ++ .../gallery/pro/helpers/Constants.kt | 1 + .../res/layout/dialog_change_view_type.xml | 54 +++++++++++++++++++ 6 files changed, 100 insertions(+), 9 deletions(-) create mode 100644 app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeViewTypeDialog.kt create mode 100644 app/src/main/res/layout/dialog_change_view_type.xml diff --git a/app/build.gradle b/app/build.gradle index 818617211..f76beb22c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -57,7 +57,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.5.15' + implementation 'com.simplemobiletools:commons:5.5.16' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'androidx.multidex:multidex:2.0.0' implementation 'it.sephiroth.android.exif:library:1.0.1' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 2ac01140e..ec95f9935 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -19,11 +19,9 @@ import androidx.core.view.MenuItemCompat import androidx.recyclerview.widget.RecyclerView import com.simplemobiletools.commons.dialogs.CreateNewFolderDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog -import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.models.FileDirItem -import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.commons.models.Release import com.simplemobiletools.commons.views.MyGridLayoutManager import com.simplemobiletools.commons.views.MyRecyclerView @@ -32,6 +30,7 @@ import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.adapters.DirectoryAdapter import com.simplemobiletools.gallery.pro.databases.GalleryDatabase import com.simplemobiletools.gallery.pro.dialogs.ChangeSortingDialog +import com.simplemobiletools.gallery.pro.dialogs.ChangeViewTypeDialog import com.simplemobiletools.gallery.pro.dialogs.FilterMediaDialog import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.helpers.* @@ -451,12 +450,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } private fun changeViewType() { - val items = arrayListOf( - RadioItem(VIEW_TYPE_GRID, getString(R.string.grid)), - RadioItem(VIEW_TYPE_LIST, getString(R.string.list))) - - RadioGroupDialog(this, items, config.viewTypeFolders) { - config.viewTypeFolders = it as Int + ChangeViewTypeDialog(this) { invalidateOptionsMenu() setupLayoutManager() val dirs = getCurrentlyDisplayedDirs() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeViewTypeDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeViewTypeDialog.kt new file mode 100644 index 000000000..b534b5c3e --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeViewTypeDialog.kt @@ -0,0 +1,38 @@ +package com.simplemobiletools.gallery.pro.dialogs + +import android.view.View +import androidx.appcompat.app.AlertDialog +import com.simplemobiletools.commons.activities.BaseSimpleActivity +import com.simplemobiletools.commons.extensions.setupDialogStuff +import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.extensions.config +import com.simplemobiletools.gallery.pro.helpers.VIEW_TYPE_GRID +import com.simplemobiletools.gallery.pro.helpers.VIEW_TYPE_LIST +import kotlinx.android.synthetic.main.dialog_change_view_type.view.* + +class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val callback: () -> Unit) { + private var view: View + private var config = activity.config + + init { + view = activity.layoutInflater.inflate(R.layout.dialog_change_view_type, null).apply { + val viewToCheck = if (config.viewTypeFolders == VIEW_TYPE_GRID) change_view_type_dialog_radio_grid.id else change_view_type_dialog_radio_list.id + change_view_type_dialog_radio.check(viewToCheck) + change_view_type_dialog_group_direct_subfolders.isChecked = config.groupDirectSubfolders + } + + AlertDialog.Builder(activity) + .setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() } + .setNegativeButton(R.string.cancel, null) + .create().apply { + activity.setupDialogStuff(view, this) + } + } + + private fun dialogConfirmed() { + val viewType = if (view.change_view_type_dialog_radio.checkedRadioButtonId == view.change_view_type_dialog_radio_grid.id) VIEW_TYPE_GRID else VIEW_TYPE_LIST + config.viewTypeFolders = viewType + config.groupDirectSubfolders = view.change_view_type_dialog_group_direct_subfolders.isChecked + callback() + } +} diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt index e25a4073d..3016cf54f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt @@ -423,4 +423,8 @@ class Config(context: Context) : BaseConfig(context) { var lastEditorCropOtherAspectRatioY: Int get() = prefs.getInt(LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_Y, 1) set(lastEditorCropOtherAspectRatioY) = prefs.edit().putInt(LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_Y, lastEditorCropOtherAspectRatioY).apply() + + var groupDirectSubfolders: Boolean + get() = prefs.getBoolean(GROUP_DIRECT_SUBFOLDERS, false) + set(groupDirectSubfolders) = prefs.edit().putBoolean(GROUP_DIRECT_SUBFOLDERS, groupDirectSubfolders).apply() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt index f868a1747..03d5b8436 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt @@ -71,6 +71,7 @@ const val ALLOW_DOWN_GESTURE = "allow_down_gesture" const val LAST_EDITOR_CROP_ASPECT_RATIO = "last_editor_crop_aspect_ratio" const val LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_X = "last_editor_crop_other_aspect_ratio_x" const val LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_Y = "last_editor_crop_other_aspect_ratio_y" +const val GROUP_DIRECT_SUBFOLDERS = "group_direct_subfolders" // slideshow const val SLIDESHOW_INTERVAL = "slideshow_interval" diff --git a/app/src/main/res/layout/dialog_change_view_type.xml b/app/src/main/res/layout/dialog_change_view_type.xml new file mode 100644 index 000000000..003692bb9 --- /dev/null +++ b/app/src/main/res/layout/dialog_change_view_type.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + From 7dcfa167a79c6b39b44c770506f16e9a993a043c Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 12 Dec 2018 21:32:47 +0100 Subject: [PATCH 14/99] handle direct subfolder grouping if selected so --- .../gallery/pro/activities/MainActivity.kt | 55 ++++++++++++++++--- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index ec95f9935..25bac3170 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -453,9 +453,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { ChangeViewTypeDialog(this) { invalidateOptionsMenu() setupLayoutManager() - val dirs = getCurrentlyDisplayedDirs() directories_grid.adapter = null - setupAdapter(dirs) + setupAdapter(mDirs) } } @@ -762,10 +761,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } private fun gotDirectories(newDirs: ArrayList) { - // if hidden item showing is disabled but all Favorite items are hidden, hide the Favorites folder mIsGettingDirs = false mShouldStopFetching = false + // if hidden item showing is disabled but all Favorite items are hidden, hide the Favorites folder if (!config.shouldShowHidden) { val favoritesFolder = newDirs.firstOrNull { it.areFavorites() } if (favoritesFolder != null && favoritesFolder.tmb.getFilenameFromPath().startsWith('.')) { @@ -924,16 +923,57 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } } + private fun getDirectParentSubfolders(folders: HashSet): HashSet { + val internalPath = internalStoragePath + val sdPath = sdCardPath + val currentPaths = HashSet() + folders.forEach { + if (it != internalPath && it != sdPath) { + val parent = File(it).parent + currentPaths.add(parent) + } + } + + var areDirectSubfoldersAvailable = false + currentPaths.forEach { + val path = it + currentPaths.forEach { + if (it != path && it.startsWith(path)) { + areDirectSubfoldersAvailable = true + } + } + } + + folders.clear() + folders.addAll(currentPaths) + return if (areDirectSubfoldersAvailable) { + getDirectParentSubfolders(folders) + } else { + folders + } + } + private fun checkPlaceholderVisibility(dirs: ArrayList) { directories_empty_text_label.beVisibleIf(dirs.isEmpty() && mLoadedInitialPhotos) directories_empty_text.beVisibleIf(dirs.isEmpty() && mLoadedInitialPhotos) directories_grid.beVisibleIf(directories_empty_text_label.isGone()) } - private fun showSortedDirs(dirs: ArrayList) { + private fun showSortedDirs(dirs: ArrayList, checkSubfolders: Boolean = true) { val updatedDirs = getUniqueSortedDirs(dirs).toMutableList() as ArrayList + val dirsToShow = if (checkSubfolders) getDirsToShow(updatedDirs) else updatedDirs runOnUiThread { - (directories_grid.adapter as? DirectoryAdapter)?.updateDirs(updatedDirs) + (directories_grid.adapter as? DirectoryAdapter)?.updateDirs(dirsToShow) + } + } + + private fun getDirsToShow(dirs: ArrayList): ArrayList { + return if (config.groupDirectSubfolders) { + val dirFolders = dirs.map { it.path }.sorted().toMutableSet() as HashSet + val foldersToShow = getDirectParentSubfolders(dirFolders) + dirs.filter { foldersToShow.contains(it.path) } as ArrayList + } else { + dirs } } @@ -972,10 +1012,11 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun setupAdapter(dirs: ArrayList) { val currAdapter = directories_grid.adapter + val dirsToShow = getDirsToShow(dirs) if (currAdapter == null) { initZoomListener() val fastscroller = if (config.scrollHorizontally) directories_horizontal_fastscroller else directories_vertical_fastscroller - DirectoryAdapter(this, dirs.clone() as ArrayList, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent), fastscroller) { + DirectoryAdapter(this, dirsToShow.clone() as ArrayList, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent), fastscroller) { val path = (it as Directory).path if (path != config.tempFolderPath) { itemClicked(path) @@ -985,7 +1026,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { directories_grid.adapter = this } } else { - showSortedDirs(dirs) + showSortedDirs(dirsToShow, false) } getRecyclerAdapter()?.dirs?.apply { From e3fcd3c84b3c0407b5c5dcfe951101be1aa7c470 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 12 Dec 2018 23:31:12 +0100 Subject: [PATCH 15/99] tweak the way folders at grouping direct subfolders are checked --- .../gallery/pro/activities/MainActivity.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 25bac3170..3ad0ce15d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -926,11 +926,16 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun getDirectParentSubfolders(folders: HashSet): HashSet { val internalPath = internalStoragePath val sdPath = sdCardPath - val currentPaths = HashSet() + val currentPaths = LinkedHashSet() folders.forEach { + val path = it if (it != internalPath && it != sdPath) { - val parent = File(it).parent - currentPaths.add(parent) + if (folders.any { it != path && (File(path).parent == it || File(it).parent == File(path).parent) }) { + val parent = File(it).parent + currentPaths.add(parent) + } else { + currentPaths.add(it) + } } } @@ -938,7 +943,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { currentPaths.forEach { val path = it currentPaths.forEach { - if (it != path && it.startsWith(path)) { + if (it != path && File(it).parent == path) { areDirectSubfoldersAvailable = true } } From d654eca1f27c3a1a5fdf4e7d0606335063a30c33 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 13 Dec 2018 12:40:58 +0100 Subject: [PATCH 16/99] replacing some "it"s with "path"s --- .../gallery/pro/activities/MainActivity.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 3ad0ce15d..699fcf19f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -929,12 +929,12 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { val currentPaths = LinkedHashSet() folders.forEach { val path = it - if (it != internalPath && it != sdPath) { + if (path != internalPath && path != sdPath) { if (folders.any { it != path && (File(path).parent == it || File(it).parent == File(path).parent) }) { - val parent = File(it).parent + val parent = File(path).parent currentPaths.add(parent) } else { - currentPaths.add(it) + currentPaths.add(path) } } } From 77cff3dd17808dbe4ff07bebe28f693041948a7b Mon Sep 17 00:00:00 2001 From: Guillaume Date: Thu, 13 Dec 2018 15:54:06 +0100 Subject: [PATCH 17/99] Dutch --- app/src/main/res/values-nl/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 0e3a92429..175650e03 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -160,7 +160,7 @@ Verder inzoomen mogelijk maken Uitgebreide informatie niet tonen als de statusbalk is verborgen Ongeldige bestanden verbergen - Enkele actieknoppen onderaan het scherm tonen + Enkele actieknoppen onder aan het scherm tonen Prullenbak weergeven in de mapweergave Afbeeldingen ver inzoomen Afbeeldingen in de hoogst mogelijke kwaliteit weergeven @@ -171,7 +171,7 @@ Miniatuurvoorbeelden Volledig scherm Uitgebreide informatie - Acties onderaan het scherm + Acties onder aan het scherm Actieknoppen onderaan beheren From a0798bcd295ca63334dbbb673c4c4b2ab74c056c Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 13 Dec 2018 16:20:00 +0100 Subject: [PATCH 18/99] unify the directories funnel through which they are sorted, filtered etc --- .../gallery/pro/activities/MainActivity.kt | 54 +++++++------------ 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 699fcf19f..b7bdd5d4d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -313,7 +313,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { override fun onQueryTextChange(newText: String): Boolean { if (mIsSearchOpen) { - searchQueryChanged(newText) + setupAdapter(mDirs, newText) } return true } @@ -332,25 +332,13 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { if (mIsSearchOpen) { mIsSearchOpen = false directories_refresh_layout.isEnabled = config.enablePullToRefresh - searchQueryChanged("") + setupAdapter(mDirs, "") } return true } }) } - private fun searchQueryChanged(text: String) { - Thread { - val filtered = getUniqueSortedDirs(mDirs).filter { it.name.contains(text, true) } as ArrayList - filtered.sortBy { !it.name.startsWith(text, true) } - - runOnUiThread { - getRecyclerAdapter()?.updateDirs(filtered) - measureRecyclerViewContent(filtered) - } - }.start() - } - private fun removeTempFolder() { if (config.tempFolderPath.isNotEmpty()) { val newFolder = File(config.tempFolderPath) @@ -828,7 +816,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { types = newDir.types } - showSortedDirs(dirs) + setupAdapter(dirs) // update directories and media files in the local db, delete invalid items updateDBDirectory(directory, mDirectoryDao) @@ -855,7 +843,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { mDirectoryDao.deleteDirPath(it.path) } dirs.removeAll(dirsToRemove) - showSortedDirs(dirs) + setupAdapter(dirs) } val foldersToScan = mediaFetcher.getFoldersToScan() @@ -892,7 +880,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { val newDir = createDirectoryFromMedia(folder, newMedia, albumCovers, hiddenString, includedFolders, isSortingAscending) dirs.add(newDir) - showSortedDirs(dirs) + setupAdapter(dirs) mDirectoryDao.insert(newDir) if (folder != RECYCLE_BIN) { mMediumDao.insertAll(newMedia) @@ -964,14 +952,6 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { directories_grid.beVisibleIf(directories_empty_text_label.isGone()) } - private fun showSortedDirs(dirs: ArrayList, checkSubfolders: Boolean = true) { - val updatedDirs = getUniqueSortedDirs(dirs).toMutableList() as ArrayList - val dirsToShow = if (checkSubfolders) getDirsToShow(updatedDirs) else updatedDirs - runOnUiThread { - (directories_grid.adapter as? DirectoryAdapter)?.updateDirs(dirsToShow) - } - } - private fun getDirsToShow(dirs: ArrayList): ArrayList { return if (config.groupDirectSubfolders) { val dirFolders = dirs.map { it.path }.sorted().toMutableSet() as HashSet @@ -1015,29 +995,33 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { return Directory(null, path, thumbnail, dirName, curMedia.size, lastModified, dateTaken, size, getPathLocation(path), mediaTypes) } - private fun setupAdapter(dirs: ArrayList) { + private fun setupAdapter(dirs: ArrayList, textToSearch: String = "") { val currAdapter = directories_grid.adapter - val dirsToShow = getDirsToShow(dirs) + val updatedDirs = getUniqueSortedDirs(dirs).toMutableList() as ArrayList + var dirsToShow = getDirsToShow(updatedDirs).clone() as ArrayList if (currAdapter == null) { initZoomListener() val fastscroller = if (config.scrollHorizontally) directories_horizontal_fastscroller else directories_vertical_fastscroller - DirectoryAdapter(this, dirsToShow.clone() as ArrayList, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent), fastscroller) { + DirectoryAdapter(this, dirsToShow, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent), fastscroller) { val path = (it as Directory).path if (path != config.tempFolderPath) { itemClicked(path) } + measureRecyclerViewContent(dirsToShow) }.apply { setupZoomListener(mZoomListener) directories_grid.adapter = this } + setupScrollDirection() } else { - showSortedDirs(dirsToShow, false) + if (textToSearch.isNotEmpty()) { + dirsToShow = dirsToShow.filter { it.name.contains(textToSearch, true) }.sortedBy { !it.name.startsWith(textToSearch, true) }.toMutableList() as ArrayList + } + runOnUiThread { + (directories_grid.adapter as? DirectoryAdapter)?.updateDirs(dirsToShow) + measureRecyclerViewContent(dirsToShow) + } } - - getRecyclerAdapter()?.dirs?.apply { - measureRecyclerViewContent(this) - } - setupScrollDirection() } private fun setupScrollDirection() { @@ -1091,7 +1075,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { if (invalidDirs.isNotEmpty()) { dirs.removeAll(invalidDirs) - showSortedDirs(dirs) + setupAdapter(dirs) invalidDirs.forEach { mDirectoryDao.deleteDirPath(it.path) } From 32012061a65a9c059e2e181359126210d3eb1f81 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 13 Dec 2018 16:34:41 +0100 Subject: [PATCH 19/99] remove another redundant function for getting unique directories --- .../gallery/pro/activities/MainActivity.kt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index b7bdd5d4d..d09dfbcea 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -962,11 +962,6 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } } - private fun getUniqueSortedDirs(dirs: ArrayList): ArrayList { - val distinctDirs = dirs.distinctBy { it.path.getDistinctPath() } as ArrayList - return getSortedDirectories(distinctDirs) - } - private fun createDirectoryFromMedia(path: String, curMedia: ArrayList, albumCovers: ArrayList, hiddenString: String, includedFolders: MutableSet, isSortingAscending: Boolean): Directory { var thumbnail = curMedia.firstOrNull { getDoesFilePathExist(it.path) }?.path ?: "" @@ -997,8 +992,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun setupAdapter(dirs: ArrayList, textToSearch: String = "") { val currAdapter = directories_grid.adapter - val updatedDirs = getUniqueSortedDirs(dirs).toMutableList() as ArrayList - var dirsToShow = getDirsToShow(updatedDirs).clone() as ArrayList + val distinctDirs = dirs.distinctBy { it.path.getDistinctPath() }.toMutableList() as ArrayList + val sortedDirs = getSortedDirectories(distinctDirs) + var dirsToShow = getDirsToShow(sortedDirs).clone() as ArrayList + if (currAdapter == null) { initZoomListener() val fastscroller = if (config.scrollHorizontally) directories_horizontal_fastscroller else directories_vertical_fastscroller From 6bb69e3d9f6050d0c6ab6fbb5ff67985d32c3584 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 14 Dec 2018 21:07:00 +0100 Subject: [PATCH 20/99] show an additional dialog before displaying the OTG permission one --- .../gallery/pro/activities/MainActivity.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index d09dfbcea..0b6bf1658 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -17,6 +17,7 @@ import android.widget.Toast import androidx.appcompat.widget.SearchView import androidx.core.view.MenuItemCompat import androidx.recyclerview.widget.RecyclerView +import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.CreateNewFolderDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.extensions.* @@ -356,8 +357,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { Thread { if (hasOTGConnected()) { runOnUiThread { - handleOTGPermission { - config.addIncludedFolder(OTG_PATH) + ConfirmationDialog(this, getString(R.string.otg_detected), positive = R.string.ok, negative = 0) { + handleOTGPermission { + config.addIncludedFolder(OTG_PATH) + } } } config.wasOTGHandled = true From 74cfe5167e83168282cafb1e959b4dcbc53d3f1b Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 14 Dec 2018 21:40:17 +0100 Subject: [PATCH 21/99] do not make the Directory model Serializable --- .../com/simplemobiletools/gallery/pro/models/Directory.kt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Directory.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Directory.kt index c5b90b860..8b90b8bdf 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Directory.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Directory.kt @@ -12,7 +12,6 @@ import com.simplemobiletools.commons.helpers.SORT_BY_PATH import com.simplemobiletools.commons.helpers.SORT_BY_SIZE import com.simplemobiletools.gallery.pro.helpers.FAVORITES import com.simplemobiletools.gallery.pro.helpers.RECYCLE_BIN -import java.io.Serializable @Entity(tableName = "directories", indices = [Index(value = ["path"], unique = true)]) data class Directory( @@ -25,11 +24,7 @@ data class Directory( @ColumnInfo(name = "date_taken") var taken: Long, @ColumnInfo(name = "size") var size: Long, @ColumnInfo(name = "location") val location: Int, - @ColumnInfo(name = "media_types") var types: Int) : Serializable { - - companion object { - private const val serialVersionUID = -6553345863555455L - } + @ColumnInfo(name = "media_types") var types: Int) { fun getBubbleText(sorting: Int) = when { sorting and SORT_BY_NAME != 0 -> name From 3d47eac4e391fe87eba2cca53757ceb6b31368d0 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 14 Dec 2018 22:02:03 +0100 Subject: [PATCH 22/99] show the sum of all subfolder media counts with "Group direct subfolders" --- .../gallery/pro/activities/MainActivity.kt | 22 ++++++++++++++++++- .../gallery/pro/adapters/DirectoryAdapter.kt | 2 +- .../gallery/pro/models/Directory.kt | 12 +++++----- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 0b6bf1658..db11c197b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -957,10 +957,30 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun getDirsToShow(dirs: ArrayList): ArrayList { return if (config.groupDirectSubfolders) { + dirs.forEach { it.subfoldersMediaCount = it.mediaCnt } val dirFolders = dirs.map { it.path }.sorted().toMutableSet() as HashSet val foldersToShow = getDirectParentSubfolders(dirFolders) - dirs.filter { foldersToShow.contains(it.path) } as ArrayList + val newDirs = dirs.filter { foldersToShow.contains(it.path) } as ArrayList + + // update the directory media counts, add all subfolder media counts to it + dirs.forEach { + val mainDir = it + var longestSharedPath = "" + newDirs.forEach { + if (it.path != mainDir.path && mainDir.path.startsWith(it.path, true) && it.path.length > longestSharedPath.length) { + longestSharedPath = it.path + } + } + + val mainFolder = newDirs.firstOrNull { it.path == longestSharedPath } + if (mainFolder != null) { + mainFolder.subfoldersMediaCount += mainDir.mediaCnt + } + } + + newDirs } else { + dirs.forEach { it.subfoldersMediaCount = it.mediaCnt } dirs } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt index b4241f18e..61b53d188 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt @@ -503,7 +503,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList TYPE_VIDEOS directory.tmb.isGif() -> TYPE_GIFS diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Directory.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Directory.kt index 8b90b8bdf..7c968ce44 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Directory.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Directory.kt @@ -1,9 +1,6 @@ package com.simplemobiletools.gallery.pro.models -import androidx.room.ColumnInfo -import androidx.room.Entity -import androidx.room.Index -import androidx.room.PrimaryKey +import androidx.room.* import com.simplemobiletools.commons.extensions.formatDate import com.simplemobiletools.commons.extensions.formatSize import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED @@ -23,8 +20,11 @@ data class Directory( @ColumnInfo(name = "last_modified") var modified: Long, @ColumnInfo(name = "date_taken") var taken: Long, @ColumnInfo(name = "size") var size: Long, - @ColumnInfo(name = "location") val location: Int, - @ColumnInfo(name = "media_types") var types: Int) { + @ColumnInfo(name = "location") var location: Int, + @ColumnInfo(name = "media_types") var types: Int, + @Ignore var subfoldersMediaCount: Int = 0) { // used with "Group direct subfolders" enabled to count subfolder media counts + + constructor() : this(null, "", "", "", 0, 0L, 0L, 0L, 0, 0, 0) fun getBubbleText(sorting: Int) = when { sorting and SORT_BY_NAME != 0 -> name From 9488795de84dd8d0a0195b4a972e1773512cb048 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 14 Dec 2018 22:39:42 +0100 Subject: [PATCH 23/99] show subfolders count at the main screen, if grouping is enabled --- .../gallery/pro/activities/MainActivity.kt | 7 ++++++- .../gallery/pro/adapters/DirectoryAdapter.kt | 3 ++- .../com/simplemobiletools/gallery/pro/models/Directory.kt | 7 +++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index db11c197b..39d5a7b85 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -957,7 +957,11 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun getDirsToShow(dirs: ArrayList): ArrayList { return if (config.groupDirectSubfolders) { - dirs.forEach { it.subfoldersMediaCount = it.mediaCnt } + dirs.forEach { + it.subfoldersCount = 1 + it.subfoldersMediaCount = it.mediaCnt + } + val dirFolders = dirs.map { it.path }.sorted().toMutableSet() as HashSet val foldersToShow = getDirectParentSubfolders(dirFolders) val newDirs = dirs.filter { foldersToShow.contains(it.path) } as ArrayList @@ -968,6 +972,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { var longestSharedPath = "" newDirs.forEach { if (it.path != mainDir.path && mainDir.path.startsWith(it.path, true) && it.path.length > longestSharedPath.length) { + it.subfoldersCount += 1 longestSharedPath = it.path } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt index 61b53d188..bab6956e0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt @@ -38,6 +38,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList name From 1e47a6dd2f417b9d4c6c0cdee5817a43c780571c Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 14 Dec 2018 22:43:06 +0100 Subject: [PATCH 24/99] properly measure scrollview at directories adapter setup --- .../simplemobiletools/gallery/pro/activities/MainActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 39d5a7b85..33cc426fe 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -1032,11 +1032,11 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { if (path != config.tempFolderPath) { itemClicked(path) } - measureRecyclerViewContent(dirsToShow) }.apply { setupZoomListener(mZoomListener) directories_grid.adapter = this } + measureRecyclerViewContent(dirsToShow) setupScrollDirection() } else { if (textToSearch.isNotEmpty()) { From 5482059235c0e8381070ef1a6d47f7170f678048 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 14 Dec 2018 22:51:28 +0100 Subject: [PATCH 25/99] open the clicked directory only if it contains no subfolders, or grouping is disabled --- .../gallery/pro/activities/MainActivity.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 33cc426fe..651576201 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -1028,9 +1028,12 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { initZoomListener() val fastscroller = if (config.scrollHorizontally) directories_horizontal_fastscroller else directories_vertical_fastscroller DirectoryAdapter(this, dirsToShow, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent), fastscroller) { - val path = (it as Directory).path - if (path != config.tempFolderPath) { - itemClicked(path) + val clickedDir = it as Directory + if (clickedDir.subfoldersCount == 1 || !config.groupDirectSubfolders) { + val path = clickedDir.path + if (path != config.tempFolderPath) { + itemClicked(path) + } } }.apply { setupZoomListener(mZoomListener) From 98a5b7144b8d24f715a91152e296d7db3783af13 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 15 Dec 2018 21:23:00 +0100 Subject: [PATCH 26/99] fix subfolder counting at "Group direct subfolders" --- .../gallery/pro/activities/MainActivity.kt | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 651576201..3a06fc215 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -967,19 +967,27 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { val newDirs = dirs.filter { foldersToShow.contains(it.path) } as ArrayList // update the directory media counts, add all subfolder media counts to it - dirs.forEach { - val mainDir = it + for (dir in dirs) { var longestSharedPath = "" - newDirs.forEach { - if (it.path != mainDir.path && mainDir.path.startsWith(it.path, true) && it.path.length > longestSharedPath.length) { - it.subfoldersCount += 1 - longestSharedPath = it.path + for (newDir in newDirs) { + if (newDir.path == dir.path) { + longestSharedPath = dir.path + continue } + + if (dir.path.startsWith(newDir.path, true) && newDir.path.length > longestSharedPath.length) { + longestSharedPath = newDir.path + } + } + + val parentFolder = newDirs.firstOrNull { it.path == longestSharedPath } + parentFolder?.apply { + subfoldersCount++ } val mainFolder = newDirs.firstOrNull { it.path == longestSharedPath } if (mainFolder != null) { - mainFolder.subfoldersMediaCount += mainDir.mediaCnt + mainFolder.subfoldersMediaCount += dir.mediaCnt } } From 59c6f911007f3ccdfcbb9a7774f8bba0fedbf2b2 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 15 Dec 2018 21:33:32 +0100 Subject: [PATCH 27/99] move subfolder count updating in an own function --- .../gallery/pro/activities/MainActivity.kt | 56 +++++++++---------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 3a06fc215..12dd663d0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -958,46 +958,44 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun getDirsToShow(dirs: ArrayList): ArrayList { return if (config.groupDirectSubfolders) { dirs.forEach { - it.subfoldersCount = 1 + it.subfoldersCount = 0 it.subfoldersMediaCount = it.mediaCnt } val dirFolders = dirs.map { it.path }.sorted().toMutableSet() as HashSet val foldersToShow = getDirectParentSubfolders(dirFolders) - val newDirs = dirs.filter { foldersToShow.contains(it.path) } as ArrayList - - // update the directory media counts, add all subfolder media counts to it - for (dir in dirs) { - var longestSharedPath = "" - for (newDir in newDirs) { - if (newDir.path == dir.path) { - longestSharedPath = dir.path - continue - } - - if (dir.path.startsWith(newDir.path, true) && newDir.path.length > longestSharedPath.length) { - longestSharedPath = newDir.path - } - } - - val parentFolder = newDirs.firstOrNull { it.path == longestSharedPath } - parentFolder?.apply { - subfoldersCount++ - } - - val mainFolder = newDirs.firstOrNull { it.path == longestSharedPath } - if (mainFolder != null) { - mainFolder.subfoldersMediaCount += dir.mediaCnt - } - } - - newDirs + val parentDirs = dirs.filter { foldersToShow.contains(it.path) } as ArrayList + updateSubfolderCounts(dirs, parentDirs) + parentDirs } else { dirs.forEach { it.subfoldersMediaCount = it.mediaCnt } dirs } } + private fun updateSubfolderCounts(children: ArrayList, parentDirs: ArrayList) { + for (child in children) { + var longestSharedPath = "" + for (parentDir in parentDirs) { + if (parentDir.path == child.path) { + longestSharedPath = child.path + continue + } + + if (child.path.startsWith(parentDir.path, true) && parentDir.path.length > longestSharedPath.length) { + longestSharedPath = parentDir.path + } + } + + parentDirs.firstOrNull { it.path == longestSharedPath }?.apply { + subfoldersCount++ + if (path != child.path) { + subfoldersMediaCount += child.mediaCnt + } + } + } + } + private fun createDirectoryFromMedia(path: String, curMedia: ArrayList, albumCovers: ArrayList, hiddenString: String, includedFolders: MutableSet, isSortingAscending: Boolean): Directory { var thumbnail = curMedia.firstOrNull { getDoesFilePathExist(it.path) }?.path ?: "" From ce4dee2573a43f368996f1f000d219460769dcbf Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 15 Dec 2018 22:32:11 +0100 Subject: [PATCH 28/99] implement navigation between grouped direct subfolders --- .../gallery/pro/activities/MainActivity.kt | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 12dd663d0..11207297f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -67,6 +67,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private var mIsSearchOpen = false private var mLatestMediaId = 0L private var mLatestMediaDateId = 0L + private var mCurrentPathPrefix = "" // used at "Group direct subfolders" for navigation private var mLastMediaHandler = Handler() private var mTempShowHiddenHandler = Handler() private var mZoomListener: MyRecyclerView.MyZoomListener? = null @@ -920,8 +921,12 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { val currentPaths = LinkedHashSet() folders.forEach { val path = it - if (path != internalPath && path != sdPath) { - if (folders.any { it != path && (File(path).parent == it || File(it).parent == File(path).parent) }) { + if (!path.equals(internalPath, true) && !path.equals(sdPath, true)) { + if (mCurrentPathPrefix.isNotEmpty()) { + if (File(path).parent.equals(mCurrentPathPrefix, true) || path == mCurrentPathPrefix) { + currentPaths.add(path) + } + } else if (folders.any { !it.equals(path, true) && (File(path).parent.equals(it, true) || File(it).parent.equals(File(path).parent, true)) }) { val parent = File(path).parent currentPaths.add(parent) } else { @@ -934,12 +939,16 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { currentPaths.forEach { val path = it currentPaths.forEach { - if (it != path && File(it).parent == path) { + if (!it.equals(path) && File(it).parent.equals(path)) { areDirectSubfoldersAvailable = true } } } + if (folders.size == currentPaths.size) { + return currentPaths + } + folders.clear() folders.addAll(currentPaths) return if (areDirectSubfoldersAvailable) { @@ -1035,11 +1044,14 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { val fastscroller = if (config.scrollHorizontally) directories_horizontal_fastscroller else directories_vertical_fastscroller DirectoryAdapter(this, dirsToShow, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent), fastscroller) { val clickedDir = it as Directory + val path = clickedDir.path if (clickedDir.subfoldersCount == 1 || !config.groupDirectSubfolders) { - val path = clickedDir.path if (path != config.tempFolderPath) { itemClicked(path) } + } else { + mCurrentPathPrefix = path + setupAdapter(mDirs, "") } }.apply { setupZoomListener(mZoomListener) From 619e7ee3f4727f0cd356ce5c01703f01f57a0757 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 15 Dec 2018 22:40:15 +0100 Subject: [PATCH 29/99] show the current folder as an available option at grouping too, not just subfolders --- .../gallery/pro/activities/MainActivity.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 11207297f..326f9954d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -975,6 +975,16 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { val foldersToShow = getDirectParentSubfolders(dirFolders) val parentDirs = dirs.filter { foldersToShow.contains(it.path) } as ArrayList updateSubfolderCounts(dirs, parentDirs) + + // show the current folder as an available option too, not just subfolders + if (mCurrentPathPrefix.isNotEmpty()) { + val currentFolder = mDirs.firstOrNull { parentDirs.firstOrNull { it.path == mCurrentPathPrefix } == null && it.path == mCurrentPathPrefix } + currentFolder?.apply { + subfoldersCount = 1 + parentDirs.add(this) + } + } + parentDirs } else { dirs.forEach { it.subfoldersMediaCount = it.mediaCnt } From a96e3201a3b847d187595e43bb2eff03acf02f94 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 15 Dec 2018 23:51:27 +0100 Subject: [PATCH 30/99] add an extra check for handling only direct subfolders --- .../gallery/pro/activities/MainActivity.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 326f9954d..778c07f3e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -1006,10 +1006,13 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } } + // make sure we count only the proper direct subfolders, grouped the same way as on the main screen parentDirs.firstOrNull { it.path == longestSharedPath }?.apply { - subfoldersCount++ - if (path != child.path) { - subfoldersMediaCount += child.mediaCnt + if (path.equals(child.path, true) || path.equals(File(child.path).parent, true) || children.any { it.path.equals(File(child.path).parent, true) }) { + subfoldersCount++ + if (path != child.path) { + subfoldersMediaCount += child.mediaCnt + } } } } From adf02739fe18719997ae779d31b3b284d79cc4cf Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 16 Dec 2018 10:19:10 +0100 Subject: [PATCH 31/99] implement Back navigation at direct subfolder grouping --- .../gallery/pro/activities/MainActivity.kt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 778c07f3e..5fd3f08be 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -67,7 +67,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private var mIsSearchOpen = false private var mLatestMediaId = 0L private var mLatestMediaDateId = 0L - private var mCurrentPathPrefix = "" // used at "Group direct subfolders" for navigation + private var mCurrentPathPrefix = "" // used at "Group direct subfolders" for navigation + private var mOpenedSubfolders = arrayListOf("") // used at "Group direct subfolders" for navigating Up with the back button private var mLastMediaHandler = Handler() private var mTempShowHiddenHandler = Handler() private var mZoomListener: MyRecyclerView.MyZoomListener? = null @@ -243,6 +244,20 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } } + override fun onBackPressed() { + if (config.groupDirectSubfolders) { + if (mCurrentPathPrefix.isEmpty()) { + super.onBackPressed() + } else { + mOpenedSubfolders.removeAt(mOpenedSubfolders.size - 1) + mCurrentPathPrefix = mOpenedSubfolders.last() + setupAdapter(mDirs) + } + } else { + super.onBackPressed() + } + } + override fun onCreateOptionsMenu(menu: Menu): Boolean { if (mIsThirdPartyIntent) { menuInflater.inflate(R.menu.menu_main_intent, menu) @@ -1064,6 +1079,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } } else { mCurrentPathPrefix = path + mOpenedSubfolders.add(path) setupAdapter(mDirs, "") } }.apply { From ea20c282ab9a28c299e799d37e05a8373b4ea8c6 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 16 Dec 2018 10:23:17 +0100 Subject: [PATCH 32/99] avoid redundant folders adapter refreshing at direct subfolder groupind --- .../simplemobiletools/gallery/pro/activities/MainActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 5fd3f08be..3af4e7043 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -821,7 +821,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } // we are looping through the already displayed folders looking for changes, do not do anything if nothing changed - if (directory == newDir) { + if (directory.copy(subfoldersCount = 0, subfoldersMediaCount = 0) == newDir) { continue } From 1bc7616821e57a2e9df48013f42ae187b8b95c6e Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 16 Dec 2018 10:44:18 +0100 Subject: [PATCH 33/99] fix #1122, show full filename at delete confirmation, if deleting 1 item --- .../gallery/pro/activities/ViewPagerActivity.kt | 12 ++++++++++-- .../gallery/pro/adapters/DirectoryAdapter.kt | 7 ++++++- .../gallery/pro/adapters/MediaAdapter.kt | 11 +++++++++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index 55dc39a86..8ff340ec4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -936,8 +936,16 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } private fun askConfirmDelete() { - val message = if (config.useRecycleBin && !getCurrentMedium()!!.getIsInRecycleBin()) R.string.are_you_sure_recycle_bin else R.string.are_you_sure_delete - DeleteWithRememberDialog(this, getString(message)) { + val filename = "\"${getCurrentPath().getFilenameFromPath()}\"" + + val baseString = if (config.useRecycleBin && !getCurrentMedium()!!.getIsInRecycleBin()) { + R.string.move_to_recycle_bin_confirmation + } else { + R.string.deletion_confirmation + } + + val message = String.format(resources.getString(baseString), filename) + DeleteWithRememberDialog(this, message) { config.tempSkipDeleteConfirmation = it deleteConfirmed() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt index bab6956e0..80ec519f3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt @@ -372,7 +372,12 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList deleteFolders() else -> { val itemsCnt = selectedKeys.size - val items = resources.getQuantityString(R.plurals.delete_items, itemsCnt, itemsCnt) + val items = if (itemsCnt == 1) { + "\"${getSelectedPaths().first().getFilenameFromPath()}\"" + } else { + resources.getQuantityString(R.plurals.delete_items, itemsCnt, itemsCnt) + } + val fileDirItem = getFirstSelectedItem() ?: return val baseString = if (!config.useRecycleBin || (isOneItemSelected() && fileDirItem.isRecycleBin()) || (isOneItemSelected() && fileDirItem.areFavorites())) { R.string.deletion_confirmation diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt index 8731f0a30..e20ea1351 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt @@ -372,8 +372,15 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList Date: Sun, 16 Dec 2018 13:13:41 +0100 Subject: [PATCH 34/99] creating a Widget table --- .../gallery/pro/databases/GalleryDatabase.kt | 14 +++++++++++++- .../gallery/pro/interfaces/WidgetsDao.kt | 19 +++++++++++++++++++ .../gallery/pro/models/Widget.kt | 12 ++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/WidgetsDao.kt create mode 100644 app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Widget.kt diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/databases/GalleryDatabase.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/databases/GalleryDatabase.kt index d6412cda5..7f0257f9b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/databases/GalleryDatabase.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/databases/GalleryDatabase.kt @@ -8,16 +8,20 @@ import androidx.room.migration.Migration import androidx.sqlite.db.SupportSQLiteDatabase import com.simplemobiletools.gallery.pro.interfaces.DirectoryDao import com.simplemobiletools.gallery.pro.interfaces.MediumDao +import com.simplemobiletools.gallery.pro.interfaces.WidgetsDao import com.simplemobiletools.gallery.pro.models.Directory import com.simplemobiletools.gallery.pro.models.Medium +import com.simplemobiletools.gallery.pro.models.Widget -@Database(entities = [Directory::class, Medium::class], version = 5) +@Database(entities = [Directory::class, Medium::class, Widget::class], version = 6) abstract class GalleryDatabase : RoomDatabase() { abstract fun DirectoryDao(): DirectoryDao abstract fun MediumDao(): MediumDao + abstract fun WidgetsDao(): WidgetsDao + companion object { private var db: GalleryDatabase? = null @@ -27,6 +31,7 @@ abstract class GalleryDatabase : RoomDatabase() { if (db == null) { db = Room.databaseBuilder(context.applicationContext, GalleryDatabase::class.java, "gallery.db") .addMigrations(MIGRATION_4_5) + .addMigrations(MIGRATION_5_6) .build() } } @@ -43,5 +48,12 @@ abstract class GalleryDatabase : RoomDatabase() { database.execSQL("ALTER TABLE media ADD COLUMN video_duration INTEGER default 0 NOT NULL") } } + + private val MIGRATION_5_6 = object : Migration(5, 6) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL("CREATE TABLE IF NOT EXISTS `widgets` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `widget_id` INTEGER NOT NULL, `folder_path` TEXT NOT NULL)") + database.execSQL("CREATE UNIQUE INDEX `index_widgets_widget_id` ON `widgets` (`widget_id`)") + } + } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/WidgetsDao.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/WidgetsDao.kt new file mode 100644 index 000000000..72409ca35 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/WidgetsDao.kt @@ -0,0 +1,19 @@ +package com.simplemobiletools.gallery.pro.interfaces + +import androidx.room.Dao +import androidx.room.Insert +import androidx.room.OnConflictStrategy +import androidx.room.Query +import com.simplemobiletools.gallery.pro.models.Widget + +@Dao +interface WidgetsDao { + @Query("SELECT * FROM widgets") + fun getWidgets(): List + + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun insertOrUpdate(widget: Widget): Long + + @Query("DELETE FROM widgets WHERE folder_path = :folderPath") + fun deleteNoteWidgets(folderPath: String) +} diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Widget.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Widget.kt new file mode 100644 index 000000000..2ef525334 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Widget.kt @@ -0,0 +1,12 @@ +package com.simplemobiletools.gallery.pro.models + +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.Index +import androidx.room.PrimaryKey + +@Entity(tableName = "widgets", indices = [(Index(value = ["widget_id"], unique = true))]) +data class Widget( + @PrimaryKey(autoGenerate = true) var id: Int?, + @ColumnInfo(name = "widget_id") var widgetId: Int, + @ColumnInfo(name = "folder_path") var folderPath: String) From 69b77a296a51680a0be9b3c76030c3e58c71bef3 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 16 Dec 2018 15:48:44 +0100 Subject: [PATCH 35/99] adding an initial widget implementation --- app/src/main/AndroidManifest.xml | 21 ++++ .../gallery/pro/activities/MediaActivity.kt | 3 +- .../pro/activities/WidgetConfigureActivity.kt | 112 ++++++++++++++++++ .../gallery/pro/extensions/Context.kt | 3 + .../gallery/pro/helpers/MyWidgetProvider.kt | 37 ++++++ app/src/main/res/layout/widget.xml | 14 +++ app/src/main/res/layout/widget_config.xml | 62 ++++++++++ app/src/main/res/xml/widget_info.xml | 10 ++ 8 files changed, 260 insertions(+), 2 deletions(-) create mode 100644 app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt create mode 100644 app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MyWidgetProvider.kt create mode 100644 app/src/main/res/layout/widget.xml create mode 100644 app/src/main/res/layout/widget_config.xml create mode 100644 app/src/main/res/xml/widget_info.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a33b0c153..883b24d4c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -215,6 +215,15 @@ + + + + + + + + + + + + + + + if (wasPositivePressed) { + mBgColorWithoutTransparency = color + updateBackgroundColor() + } + } + } +} diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt index d7430f161..2e7cdb0a3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt @@ -25,6 +25,7 @@ import com.simplemobiletools.gallery.pro.databases.GalleryDatabase import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.interfaces.DirectoryDao import com.simplemobiletools.gallery.pro.interfaces.MediumDao +import com.simplemobiletools.gallery.pro.interfaces.WidgetsDao import com.simplemobiletools.gallery.pro.models.Directory import com.simplemobiletools.gallery.pro.models.Medium import com.simplemobiletools.gallery.pro.models.ThumbnailItem @@ -104,6 +105,8 @@ val Context.config: Config get() = Config.newInstance(applicationContext) val Context.galleryDB: GalleryDatabase get() = GalleryDatabase.getInstance(applicationContext) +val Context.widgetsDB: WidgetsDao get() = GalleryDatabase.getInstance(applicationContext).WidgetsDao() + val Context.recycleBin: File get() = filesDir val Context.recycleBinPath: String get() = filesDir.absolutePath diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MyWidgetProvider.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MyWidgetProvider.kt new file mode 100644 index 000000000..08ef3081c --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MyWidgetProvider.kt @@ -0,0 +1,37 @@ +package com.simplemobiletools.gallery.pro.helpers + +import android.app.PendingIntent +import android.appwidget.AppWidgetManager +import android.appwidget.AppWidgetProvider +import android.content.Context +import android.content.Intent +import android.widget.RemoteViews +import com.simplemobiletools.commons.extensions.setBackgroundColor +import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.activities.MediaActivity +import com.simplemobiletools.gallery.pro.extensions.config +import com.simplemobiletools.gallery.pro.extensions.widgetsDB +import com.simplemobiletools.gallery.pro.models.Widget + +class MyWidgetProvider : AppWidgetProvider() { + private fun setupAppOpenIntent(context: Context, views: RemoteViews, id: Int, widget: Widget) { + val intent = Intent(context, MediaActivity::class.java).apply { + putExtra(DIRECTORY, widget.folderPath) + } + + val pendingIntent = PendingIntent.getActivity(context, widget.widgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT) + views.setOnClickPendingIntent(id, pendingIntent) + } + + override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) { + super.onUpdate(context, appWidgetManager, appWidgetIds) + Thread { + context.widgetsDB.getWidgets().forEach { + val views = RemoteViews(context.packageName, R.layout.widget) + views.setBackgroundColor(R.id.widget_holder, context.config.widgetBgColor) + setupAppOpenIntent(context, views, R.id.widget_holder, it) + appWidgetManager.updateAppWidget(it.widgetId, views) + } + }.start() + } +} diff --git a/app/src/main/res/layout/widget.xml b/app/src/main/res/layout/widget.xml new file mode 100644 index 000000000..2be9e64d5 --- /dev/null +++ b/app/src/main/res/layout/widget.xml @@ -0,0 +1,14 @@ + + + + + + diff --git a/app/src/main/res/layout/widget_config.xml b/app/src/main/res/layout/widget_config.xml new file mode 100644 index 000000000..1b36ee583 --- /dev/null +++ b/app/src/main/res/layout/widget_config.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + +