diff --git a/app/build.gradle b/app/build.gradle index 6634facfb..6c2af3e29 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -47,7 +47,7 @@ ext { } dependencies { - implementation 'com.simplemobiletools:commons:2.41.8' + implementation 'com.simplemobiletools:commons:3.0.20' implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.8.0' implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.0' implementation 'com.android.support:multidex:1.0.2' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e0e44d1c3..a6e97ccb7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,18 +1,18 @@ + package="com.simplemobiletools.gallery" + android:installLocation="auto"> - @@ -60,8 +60,7 @@ + android:parentActivityName=".activities.MediaActivity"> @@ -96,8 +95,7 @@ + android:configChanges="orientation|keyboardHidden|screenSize"/> + android:configChanges="orientation|keyboardHidden|screenSize"> @@ -125,8 +122,7 @@ + android:configChanges="orientation|keyboardHidden|screenSize"> diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/App.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/App.kt index 350f990c2..2099d83cc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/App.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/App.kt @@ -2,24 +2,21 @@ package com.simplemobiletools.gallery import android.support.multidex.MultiDexApplication import com.github.ajalt.reprint.core.Reprint -import com.simplemobiletools.gallery.extensions.config -import java.util.* +import com.simplemobiletools.commons.extensions.checkUseEnglish +import com.simplemobiletools.gallery.BuildConfig.USE_LEAK_CANARY +import com.squareup.leakcanary.LeakCanary class App : MultiDexApplication() { override fun onCreate() { super.onCreate() - /*if (USE_LEAK_CANARY) { + if (USE_LEAK_CANARY) { if (LeakCanary.isInAnalyzerProcess(this)) { return } LeakCanary.install(this) - }*/ - - if (config.useEnglish) { - val conf = resources.configuration - conf.locale = Locale.ENGLISH - resources.updateConfiguration(conf, resources.displayMetrics) } + + checkUseEnglish() Reprint.initialize(this) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 232e2835a..b8d3cfc77 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -68,7 +68,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) - storeStoragePaths() + appLaunched() mIsPickImageIntent = isPickImageIntent(intent) mIsPickVideoIntent = isPickVideoIntent(intent) @@ -81,7 +81,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { mIsGetAnyContentIntent || mIsSetWallpaperIntent removeTempFolder() - directories_refresh_layout.setOnRefreshListener({ getDirectories() }) + directories_refresh_layout.setOnRefreshListener { getDirectories() } mDirs = ArrayList() storeStateVariables() checkWhatsNewDialog() @@ -324,12 +324,10 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } } - override fun tryDeleteFolders(folders: ArrayList) { - for (file in folders) { - deleteFolders(folders) { - runOnUiThread { - refreshItems() - } + override fun deleteFolders(folders: ArrayList) { + deleteFolders(folders) { + runOnUiThread { + refreshItems() } } } @@ -342,11 +340,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } else { setupListLayoutManager() } - - getDirectoryAdapter()?.apply { - setupZoomListener(mZoomListener) - setupDragListener(true) - } } private fun setupGridLayoutManager() { @@ -360,20 +353,28 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } layoutManager.spanCount = config.dirColumnCnt - mZoomListener = object : MyRecyclerView.MyZoomListener { - override fun zoomIn() { - if (layoutManager.spanCount > 1) { - reduceColumnCount() - getRecyclerAdapter().finishActMode() - } - } + } - override fun zoomOut() { - if (layoutManager.spanCount < MAX_COLUMN_COUNT) { - increaseColumnCount() - getRecyclerAdapter().finishActMode() + private fun initZoomListener() { + if (config.viewTypeFolders == VIEW_TYPE_GRID) { + val layoutManager = directories_grid.layoutManager as GridLayoutManager + mZoomListener = object : MyRecyclerView.MyZoomListener { + override fun zoomIn() { + if (layoutManager.spanCount > 1) { + reduceColumnCount() + getRecyclerAdapter().finishActMode() + } + } + + override fun zoomOut() { + if (layoutManager.spanCount < MAX_COLUMN_COUNT) { + increaseColumnCount() + getRecyclerAdapter().finishActMode() + } } } + } else { + mZoomListener = null } } @@ -554,12 +555,18 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun setupAdapter() { val currAdapter = directories_grid.adapter if (currAdapter == null) { - directories_grid.adapter = DirectoryAdapter(this, mDirs, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent)) { + initZoomListener() + DirectoryAdapter(this, mDirs, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent)) { itemClicked((it as Directory).path) + }.apply { + setupZoomListener(mZoomListener) + setupDragListener(true) + directories_grid.adapter = this } } else { (currAdapter as DirectoryAdapter).updateDirs(mDirs) } + setupScrollDirection() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index d4fdd4955..0b5622186 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -176,8 +176,13 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { val currAdapter = media_grid.adapter if (currAdapter == null) { - media_grid.adapter = MediaAdapter(this, mMedia, this, mIsGetImageIntent || mIsGetVideoIntent || mIsGetAnyIntent, mAllowPickingMultiple, media_grid) { + initZoomListener() + MediaAdapter(this, mMedia, this, mIsGetImageIntent || mIsGetVideoIntent || mIsGetAnyIntent, mAllowPickingMultiple, media_grid) { itemClicked((it as Medium).path) + }.apply { + setupZoomListener(mZoomListener) + setupDragListener(true) + media_grid.adapter = this } } else { (currAdapter as MediaAdapter).updateMedia(mMedia) @@ -402,11 +407,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } else { setupListLayoutManager() } - - getMediaAdapter()?.apply { - setupZoomListener(mZoomListener) - setupDragListener(true) - } } private fun setupGridLayoutManager() { @@ -420,20 +420,28 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } layoutManager.spanCount = config.mediaColumnCnt - mZoomListener = object : MyRecyclerView.MyZoomListener { - override fun zoomIn() { - if (layoutManager.spanCount > 1) { - reduceColumnCount() - getRecyclerAdapter().finishActMode() - } - } + } - override fun zoomOut() { - if (layoutManager.spanCount < MAX_COLUMN_COUNT) { - increaseColumnCount() - getRecyclerAdapter().finishActMode() + private fun initZoomListener() { + if (config.viewTypeFiles == VIEW_TYPE_GRID) { + val layoutManager = media_grid.layoutManager as GridLayoutManager + mZoomListener = object : MyRecyclerView.MyZoomListener { + override fun zoomIn() { + if (layoutManager.spanCount > 1) { + reduceColumnCount() + getRecyclerAdapter().finishActMode() + } + } + + override fun zoomOut() { + if (layoutManager.spanCount < MAX_COLUMN_COUNT) { + increaseColumnCount() + getRecyclerAdapter().finishActMode() + } } } + } else { + mZoomListener = null } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt index e92593e3b..4711f1c62 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt @@ -40,6 +40,8 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList public override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.fragment_holder) + setTranslucentNavigation() + handlePermission(PERMISSION_WRITE_STORAGE) { if (it) { checkIntent(savedInstanceState) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SplashActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SplashActivity.kt index 13e968dcf..a0d0c7acd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SplashActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SplashActivity.kt @@ -1,12 +1,10 @@ package com.simplemobiletools.gallery.activities import android.content.Intent -import android.os.Bundle -import android.support.v7.app.AppCompatActivity +import com.simplemobiletools.commons.activities.BaseSplashActivity -class SplashActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) +class SplashActivity : BaseSplashActivity() { + override fun initActivity() { startActivity(Intent(this, MainActivity::class.java)) finish() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index d0c9b7a61..47b0f6e53 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -80,6 +80,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_medium) + setTranslucentNavigation() handlePermission(PERMISSION_WRITE_STORAGE) { if (it) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index 74a25b4a9..dbd4cd7de 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -1,7 +1,6 @@ package com.simplemobiletools.gallery.adapters import android.graphics.PorterDuff -import android.util.SparseArray import android.view.Menu import android.view.View import android.view.ViewGroup @@ -36,10 +35,6 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList + setupView(itemView, dir) } bindViewHolder(holder, position, view) } @@ -93,6 +88,15 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList(selectedPositions.size) val removeFolders = ArrayList(selectedPositions.size) - var needPermissionForPath = "" + var SAFPath = "" selectedPositions.forEach { if (dirs.size > it) { val path = dirs[it].path if (activity.needsStupidWritePermissions(path) && config.treeUri.isEmpty()) { - needPermissionForPath = path + SAFPath = path } } } - activity.handleSAFDialog(File(needPermissionForPath)) { + activity.handleSAFDialog(File(SAFPath)) { selectedPositions.sortedDescending().forEach { - if (dirs.size > it) { - val directory = dirs[it] - folders.add(File(directory.path)) - removeFolders.add(directory) - notifyItemRemoved(it) - itemViews.put(it, null) - } + val directory = dirs[it] + folders.add(File(directory.path)) + removeFolders.add(directory) } dirs.removeAll(removeFolders) - selectedPositions.clear() - listener?.tryDeleteFolders(folders) - - val newItems = SparseArray() - (0 until itemViews.size()) - .filter { itemViews[it] != null } - .forEachIndexed { curIndex, i -> newItems.put(curIndex, itemViews[i]) } - - itemViews = newItems - selectableItemCount = dirs.size - finishActMode() + listener?.deleteFolders(folders) + removeSelectedItems() } } @@ -306,16 +302,8 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList) { dirs = newDirs - selectableItemCount = dirs.size notifyDataSetChanged() finishActMode() } @@ -363,7 +351,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList) + fun deleteFolders(folders: ArrayList) fun recheckPinnedFolders() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/ManageFoldersAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/ManageFoldersAdapter.kt index 675490a0c..73818a600 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/ManageFoldersAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/ManageFoldersAdapter.kt @@ -1,6 +1,5 @@ package com.simplemobiletools.gallery.adapters -import android.util.SparseArray import android.view.Menu import android.view.View import android.view.ViewGroup @@ -19,10 +18,6 @@ class ManageFoldersAdapter(activity: BaseSimpleActivity, var folders: ArrayList< private val config = activity.config - init { - selectableItemCount = folders.size - } - override fun getActionMenuId() = R.menu.cab_delete_only override fun prepareActionMode(menu: Menu) {} @@ -39,12 +34,14 @@ class ManageFoldersAdapter(activity: BaseSimpleActivity, var folders: ArrayList< } } + override fun getSelectableItemCount() = folders.size + override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int) = createViewHolder(R.layout.item_manage_folder, parent) override fun onBindViewHolder(holder: ViewHolder, position: Int) { val folder = folders[position] - val view = holder.bindView(folder) { - setupView(it, folder) + val view = holder.bindView(folder) { itemView, layoutPosition -> + setupView(itemView, folder) } bindViewHolder(holder, position, view) } @@ -72,8 +69,6 @@ class ManageFoldersAdapter(activity: BaseSimpleActivity, var folders: ArrayList< selectedPositions.sortedDescending().forEach { val folder = folders[it] removeFolders.add(folder) - notifyItemRemoved(it) - itemViews.put(it, null) if (isShowingExcludedFolders) { config.removeExcludedFolder(folder) } else { @@ -82,16 +77,7 @@ class ManageFoldersAdapter(activity: BaseSimpleActivity, var folders: ArrayList< } folders.removeAll(removeFolders) - selectedPositions.clear() - - val newItems = SparseArray() - (0 until itemViews.size()) - .filter { itemViews[it] != null } - .forEachIndexed { curIndex, i -> newItems.put(curIndex, itemViews[i]) } - - itemViews = newItems - selectableItemCount = folders.size - finishActMode() + removeSelectedItems() if (folders.isEmpty()) { listener?.refreshItems() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index c1a4a2c1d..58a76c181 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -2,7 +2,6 @@ package com.simplemobiletools.gallery.adapters import android.graphics.PorterDuff import android.net.Uri -import android.util.SparseArray import android.view.Menu import android.view.View import android.view.ViewGroup @@ -36,10 +35,6 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList, private var cropThumbnails = config.cropThumbnails private var displayFilenames = config.displayFileNames - init { - selectableItemCount = media.count() - } - override fun getActionMenuId() = R.menu.cab_media override fun prepareItemSelection(view: View) { @@ -57,8 +52,8 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList, override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) { val medium = media[position] - val view = holder.bindView(medium, !allowMultiplePicks) { - setupView(it, medium) + val view = holder.bindView(medium, !allowMultiplePicks) { itemView, layoutPosition -> + setupView(itemView, medium) } bindViewHolder(holder, position, view) } @@ -93,6 +88,15 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList, } } + override fun getSelectableItemCount() = media.size + + override fun onViewRecycled(holder: ViewHolder?) { + super.onViewRecycled(holder) + if (!activity.isActivityDestroyed()) { + Glide.with(activity).clear(holder?.itemView?.medium_thumbnail) + } + } + private fun checkHideBtnVisibility(menu: Menu) { var hiddenCnt = 0 var unhiddenCnt = 0 @@ -205,26 +209,17 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList, return } - activity.handleSAFDialog(File(media[selectedPositions.first()].path)) { + val SAFPath = media[selectedPositions.first()].path + activity.handleSAFDialog(File(SAFPath)) { selectedPositions.sortedDescending().forEach { val medium = media[it] files.add(File(medium.path)) removeMedia.add(medium) - notifyItemRemoved(it) - itemViews.put(it, null) } media.removeAll(removeMedia) listener?.deleteFiles(files) - - val newItems = SparseArray() - (0 until itemViews.size()) - .filter { itemViews[it] != null } - .forEachIndexed { curIndex, i -> newItems.put(curIndex, itemViews[i]) } - - itemViews = newItems - selectableItemCount = media.size - finishActMode() + removeSelectedItems() } } @@ -234,16 +229,8 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList, return selectedMedia } - override fun onViewRecycled(holder: ViewHolder?) { - super.onViewRecycled(holder) - if (!activity.isActivityDestroyed()) { - Glide.with(activity).clear(holder?.itemView?.medium_thumbnail) - } - } - fun updateMedia(newMedia: ArrayList) { media = newMedia - selectableItemCount = media.size notifyDataSetChanged() finishActMode() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MyPagerAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MyPagerAdapter.kt index 69c389d9e..0f5d7fee3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MyPagerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MyPagerAdapter.kt @@ -14,7 +14,7 @@ import com.simplemobiletools.gallery.helpers.MEDIUM import com.simplemobiletools.gallery.models.Medium class MyPagerAdapter(val activity: ViewPagerActivity, fm: FragmentManager, val media: MutableList) : FragmentStatePagerAdapter(fm) { - private val mFragments = HashMap() + private val fragments = HashMap() override fun getCount() = media.size override fun getItem(position: Int): Fragment { @@ -38,19 +38,19 @@ class MyPagerAdapter(val activity: ViewPagerActivity, fm: FragmentManager, val m override fun instantiateItem(container: ViewGroup, position: Int): Any { val fragment = super.instantiateItem(container, position) as ViewPagerFragment - mFragments.put(position, fragment) + fragments.put(position, fragment) return fragment } override fun destroyItem(container: ViewGroup, position: Int, any: Any) { - mFragments.remove(position) + fragments.remove(position) super.destroyItem(container, position, any) } - fun getCurrentFragment(position: Int) = mFragments.get(position) + fun getCurrentFragment(position: Int) = fragments.get(position) fun toggleFullscreen(isFullscreen: Boolean) { - for ((pos, fragment) in mFragments) { + for ((pos, fragment) in fragments) { fragment.fullscreenToggled(isFullscreen) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ChangeSortingDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ChangeSortingDialog.kt index 0af86fd6a..5ea179dad 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ChangeSortingDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ChangeSortingDialog.kt @@ -40,13 +40,13 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti private fun setupSortRadio() { val sortingRadio = view.sorting_dialog_radio_sorting - var sortBtn = sortingRadio.sorting_dialog_radio_name - when { - currSorting and SORT_BY_PATH != 0 -> sortBtn = sortingRadio.sorting_dialog_radio_path - currSorting and SORT_BY_SIZE != 0 -> sortBtn = sortingRadio.sorting_dialog_radio_size - currSorting and SORT_BY_DATE_MODIFIED != 0 -> sortBtn = sortingRadio.sorting_dialog_radio_last_modified - currSorting and SORT_BY_DATE_TAKEN != 0 -> sortBtn = sortingRadio.sorting_dialog_radio_date_taken + val sortBtn = when { + currSorting and SORT_BY_PATH != 0 -> sortingRadio.sorting_dialog_radio_path + currSorting and SORT_BY_SIZE != 0 -> sortingRadio.sorting_dialog_radio_size + currSorting and SORT_BY_DATE_MODIFIED != 0 -> sortingRadio.sorting_dialog_radio_last_modified + currSorting and SORT_BY_DATE_TAKEN != 0 -> sortingRadio.sorting_dialog_radio_date_taken + else -> sortingRadio.sorting_dialog_radio_name } sortBtn.isChecked = true } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/DeleteWithRememberDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/DeleteWithRememberDialog.kt index 05a240577..b506b894f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/DeleteWithRememberDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/DeleteWithRememberDialog.kt @@ -1,23 +1,22 @@ package com.simplemobiletools.gallery.dialogs -import android.content.Context +import android.app.Activity import android.support.v7.app.AlertDialog -import android.view.LayoutInflater import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.gallery.R import kotlinx.android.synthetic.main.dialog_delete_with_remember.view.* -class DeleteWithRememberDialog(val context: Context, val callback: (remember: Boolean) -> Unit) { - var dialog: AlertDialog - val view = LayoutInflater.from(context).inflate(R.layout.dialog_delete_with_remember, null) +class DeleteWithRememberDialog(val activity: Activity, val callback: (remember: Boolean) -> Unit) { + private var dialog: AlertDialog + val view = activity.layoutInflater.inflate(R.layout.dialog_delete_with_remember, null)!! init { - val builder = AlertDialog.Builder(context) + val builder = AlertDialog.Builder(activity) .setPositiveButton(R.string.yes, { dialog, which -> dialogConfirmed() }) .setNegativeButton(R.string.no, null) dialog = builder.create().apply { - context.setupDialogStuff(view, this) + activity.setupDialogStuff(view, this) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt index cc2e9432f..7486849d6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt @@ -74,19 +74,20 @@ class ResizeDialog(val activity: BaseSimpleActivity, val size: Point, val callba .setNegativeButton(R.string.cancel, null) .create().apply { window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) - activity.setupDialogStuff(view, this, R.string.resize_and_save) - getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ - val width = getViewValue(widthView) - val height = getViewValue(heightView) - if (width <= 0 || height <= 0) { - activity.toast(R.string.invalid_values) - return@setOnClickListener - } + activity.setupDialogStuff(view, this, R.string.resize_and_save) { + getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { + val width = getViewValue(widthView) + val height = getViewValue(heightView) + if (width <= 0 || height <= 0) { + activity.toast(R.string.invalid_values) + return@setOnClickListener + } - val newSize = Point(getViewValue(widthView), getViewValue(heightView)) - callback(newSize) - dismiss() - }) + val newSize = Point(getViewValue(widthView), getViewValue(heightView)) + callback(newSize) + dismiss() + } + } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt index 4a401e289..8bd25c1ea 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt @@ -46,38 +46,39 @@ class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appen .setNegativeButton(R.string.cancel, null) .create().apply { window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) - activity.setupDialogStuff(view, this, R.string.save_as) - getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ - val filename = view.save_as_name.value - val extension = view.save_as_extension.value + activity.setupDialogStuff(view, this, R.string.save_as) { + getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { + val filename = view.save_as_name.value + val extension = view.save_as_extension.value - if (filename.isEmpty()) { - activity.toast(R.string.filename_cannot_be_empty) - return@setOnClickListener - } + if (filename.isEmpty()) { + activity.toast(R.string.filename_cannot_be_empty) + return@setOnClickListener + } - if (extension.isEmpty()) { - activity.toast(R.string.extension_cannot_be_empty) - return@setOnClickListener - } + if (extension.isEmpty()) { + activity.toast(R.string.extension_cannot_be_empty) + return@setOnClickListener + } - val newFile = File(realPath, "$filename.$extension") - if (!newFile.name.isAValidFilename()) { - activity.toast(R.string.filename_invalid_characters) - return@setOnClickListener - } + val newFile = File(realPath, "$filename.$extension") + if (!newFile.name.isAValidFilename()) { + activity.toast(R.string.filename_invalid_characters) + return@setOnClickListener + } - if (newFile.exists()) { - val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFile.name) - ConfirmationDialog(activity, title) { + if (newFile.exists()) { + val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFile.name) + ConfirmationDialog(activity, title) { + callback(newFile.absolutePath) + dismiss() + } + } else { callback(newFile.absolutePath) dismiss() } - } else { - callback(newFile.absolutePath) - dismiss() } - }) + } } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SlideshowDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SlideshowDialog.kt index e9dc60b49..5eda40879 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SlideshowDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SlideshowDialog.kt @@ -73,17 +73,18 @@ class SlideshowDialog(val activity: BaseSimpleActivity, val callback: () -> Unit .setNegativeButton(R.string.cancel, null) .create().apply { window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN) - activity.setupDialogStuff(view, this) - getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ - if (!view.include_photos.isChecked && !view.include_videos.isChecked && !view.include_gifs.isChecked) { - activity.toast(R.string.no_media_for_slideshow) - return@setOnClickListener - } + activity.setupDialogStuff(view, this) { + getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { + if (!view.include_photos.isChecked && !view.include_videos.isChecked && !view.include_gifs.isChecked) { + activity.toast(R.string.no_media_for_slideshow) + return@setOnClickListener + } - storeValues() - callback() - dismiss() - }) + storeValues() + callback() + dismiss() + } + } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt index 9910aa225..08b204cce 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt @@ -43,7 +43,7 @@ fun Activity.shareMedium(medium: Medium) { } fun Activity.shareMedia(media: List) { - val uris = media.map { getFilePublicUri(File(it.path), BuildConfig.APPLICATION_ID) } as ArrayList + val uris = media.map { Uri.fromFile(File(it.path)) } as ArrayList shareUris(uris) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index bffd0b422..599b17d3a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -224,12 +224,15 @@ class PhotoFragment : ViewPagerFragment() { private fun addZoomableView() { if ((medium.isImage()) && isFragmentVisible && view.subsampling_view.isGone()) { + val exif = android.media.ExifInterface(medium.path) + val orientation = exif.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, android.media.ExifInterface.ORIENTATION_NORMAL) + ViewPagerActivity.wasDecodedByGlide = false view.subsampling_view.apply { maxScale = 10f beVisible() setImage(ImageSource.uri(medium.path)) - orientation = SubsamplingScaleImageView.ORIENTATION_USE_EXIF + this.orientation = degreesForRotation(orientation) setOnImageEventListener(object : SubsamplingScaleImageView.OnImageEventListener { override fun onImageLoaded() { } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt index f4b7f4b67..e6b0831d5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt @@ -119,7 +119,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee mSurfaceView = mView.video_surface mSurfaceHolder = mSurfaceView!!.holder mSurfaceHolder!!.addCallback(this) - mSurfaceView!!.setOnClickListener({ toggleFullscreen() }) + mSurfaceView!!.setOnClickListener { toggleFullscreen() } mView.video_holder.setOnClickListener { toggleFullscreen() } mView.video_volume_controller.setOnTouchListener { v, event -> handleVolumeTouched(event) @@ -423,7 +423,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee setDataSource(context, Uri.parse(mediumPath)) setDisplay(mSurfaceHolder) setOnCompletionListener { videoCompleted() } - setOnVideoSizeChangedListener({ mediaPlayer, width, height -> setVideoSize() }) + setOnVideoSizeChangedListener { mediaPlayer, width, height -> setVideoSize() } setOnPreparedListener { videoPrepared(it) } setAudioStreamType(AudioManager.STREAM_MUSIC) prepare() diff --git a/app/src/main/res/drawable-v26/ic_launcher_foreground.xml b/app/src/main/res/drawable-v26/ic_launcher_foreground.xml new file mode 100644 index 000000000..4a7af2a01 --- /dev/null +++ b/app/src/main/res/drawable-v26/ic_launcher_foreground.xml @@ -0,0 +1,15 @@ + + + + diff --git a/app/src/main/res/layout/photo_video_item_grid.xml b/app/src/main/res/layout/photo_video_item_grid.xml index 4ec84403d..ef873d244 100644 --- a/app/src/main/res/layout/photo_video_item_grid.xml +++ b/app/src/main/res/layout/photo_video_item_grid.xml @@ -23,7 +23,8 @@ android:layout_margin="@dimen/small_margin" android:background="@drawable/circle_background" android:padding="@dimen/tiny_margin" - android:src="@drawable/ic_check"/> + android:src="@drawable/ic_check" + android:visibility="gone"/> + android:src="@drawable/ic_check" + android:visibility="gone"/> + + + + diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml index 07b53a1c9..9512ead0c 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -1,5 +1,5 @@ - + diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml deleted file mode 100644 index 07b53a1c9..000000000 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png index 26e7bfbd2..a92b5df68 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png deleted file mode 100644 index a92b5df68..000000000 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ diff --git a/app/src/main/res/mipmap-nodpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-nodpi/ic_launcher_foreground.png deleted file mode 100644 index 24b7f2986..000000000 Binary files a/app/src/main/res/mipmap-nodpi/ic_launcher_foreground.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png index 456d42d33..078605ea0 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png deleted file mode 100644 index 078605ea0..000000000 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index c1aff4f42..647664221 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png deleted file mode 100644 index 647664221..000000000 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index c8ab44455..ad7d85e12 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png deleted file mode 100644 index ad7d85e12..000000000 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/app/src/main/res/values-hr/strings.xml b/app/src/main/res/values-hr/strings.xml new file mode 100644 index 000000000..7ab987bca --- /dev/null +++ b/app/src/main/res/values-hr/strings.xml @@ -0,0 +1,149 @@ + + + Simple Gallery + Galerija + Uredi + Otvori kameru + (skriveno) + Prikači direktorij + Otkači direktorij + Prikaži cijeli sadržaj direktorija + Svi direktoriji + Prebaci se na pogled direktorija + Ostali direktoriji + Prikaži na karti + Nepoznata lokacija + Nije pronađena aplikacija za kartame + Nije pronađena aplikacija za kameru + Povećaj broj stupaca + Smanji broj stupaca + Promjeni naslovnu sliku + Odaberi sliku + Koristi zadano + Glasnoća + Svjetlina + Ne pitaj me više u ovoj sesiji + Zaključaj orijentaciju + Otključaj orijentaciju + + + Filtriraj slike i videe + Slike + Videi + GIFovi + Nije pronađena nijedna datoteka s odabranim filterom. + Promjeni filter + + + Ova funkcija skriva direktorij dodavajući \'.nomedia\' datoteku u njega. Također će sakriti i sve poddirektorije. Možete ih vidjeti uključivanjem opcije \'Show hidden folders\' u Postavkama. Nastaviti? + Izostavi + Izostavljeni direktoriji + Upravljaj izostavljenim direktorijima + Ovo će izostaviti izabrano zajedno s poddirektorijima samo iz Simple Gallery aplikacije. Možete upravljati izostavljenim direktorijima u Postavkama. + Izostavi glavni direktorij umjesto? + Izostavljanje direktorija učiniti će ih nevidljivim zajedno s njihovim poddirektorijima samo u Simple Gallery, ali će oni biti vidljivi u drugim aplikacijama.\n\nAko ih želite sakriti od drugih aplikacija također, koristite Sakrij opciju. + Ukloni sve + Ukloni sve direktorije iz liste izostavljenih? Ovo neće izbrisati direktorije. + + + Dodaj direktorije + Upravljaj dodanim direktorijima + Dodaj direktorij + Ako postoji direktorij koji sadrži slike i video sadržaj, ali ga aplikacija ne prepoznaje, možete ih ručno dodati ovdje.\n\nDodavanjem nekoliko stavki ovdje, neće se izostaviti niti jedan drugi direktorij. + + + Promjeni veličinu + Promjeni veličinu odabranog i spremi + Širina + Visina + Zadrži omjer slike + Molimo unesite valjanu rezoluciju + + + Uređivač + Spremi + Rotiraj + Putanja + Neispravna putanja slike + Neuspješno uređivanje slike + Uredi sliku s: + Nije pronađen uređivač slika + Nepoznata lokacija datoteke + Nije moguće presnimiti izvornu datoteku + Rotiraj lijevo + Rotiraj desno + Rotiraj za 180º + Okreni + Okreni horizontalno + Okreni vertikalno + Uredi s + + + Jednostavna pozadina + Postavi kao pozadinu + Neuspješno postavljanje pozadine + Postavi kao pozadinu s: + Nije pronađena aplikacija s ovim mogućnostima + Postavljanje pozadine… + Uspješno postavljanje pozadine + Portretni omjer slike + Pejzažni omjer slike + + + Dijaprojekcija + Interval (sekunde): + Dodaj slike + Dodaj videe + Dodaj GIFove + Nasumični redoslijed + Koristi animaciju izbljeđivanja + Pomakni unatrag + Prikaži dijaprojekciju kao petlju + Kraj dijaprojekcije + Nema datoteka za dijaprojekciju + + + Promjeni način pregleda + Rešetka + Lista + + + Prikaži skrivene datoteke + Automatsko pokretanje videa + Uključi prikaz naziva datoteka + Ponavljanje videa + Prikaz animacije GIFova na sličicama + Maksimalna svjetlina pri pregledu datoteka + Izreži sličice u kvadrate + Rotiraj datoteku u punom zaslonu za + Postavke sustava + Rotacija uređaja + Omjer slike + Crna pozadina pri pregledu datoteka + Listaj sličice horizontalno + Automatski sakrij UI sustava pri pregledu datoteka + Izbriži prazne direktorije nakon brisanja njihovog sadržaja + Omogući kontrolu glasnoće videa i svjetline pomoću vertikalnih gesti + Prikaži broj datoteka u direktoriju na glavnom zaslonu + Zamjeni Dijeli s Rotiraj pri pregledu datoteka + Prikaži detaljne informacije pri pregledu datoteka + Upravljaj detaljnim informacijama + + + + Galerija za pregledavanje slika, GIFova i videa bez reklama. + + Jednostavan alat za pregled slika, GIFova i videa. Datoteke možete sortirati po datumu, veličini, imenu i to uzlazno i silazno. Također možete zumirati slike. Medijski sadržaj se prikazuje u višestrukim stupcima ovisno o veličini ekrana, a vi samo možete birati broj stupaca s gestom štipkanja. Možete preimenovati, dijeliti, brisati, kopirati, premještati datoteke. Slike također možete izrezati, rotirati ili postaviki kao pozadinu ekrana, odmah iz aplikacije. + + Galerija se također može koristiti za pregledavanje slika i videa u drugim aplikacijama, prikačivanja datoteka u e-mail aplikacije itd. Savršeno za svakodnevno korištenje. + + Ne sadrži reklame niti nepotrebna dopuštenja. Aplikacije je otvorenog koda, te pruža mogućnost promjene boja. + + Ova aplikacija je samo dio veće skupine aplikacije. Ostatak možete pronaći na http://www.simplemobiletools.com + + + + diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml deleted file mode 100644 index 78a798255..000000000 --- a/app/src/main/res/values-v21/styles.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index aa12be2c9..0e6fe6ec4 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -22,9 +22,9 @@ 使用預設 音量 亮度 - Do not ask again in this session - Lock orientation - Unlock orientation + 這情況不再詢問 + 鎖定方向 + 解除鎖定方向 篩選媒體檔案 @@ -92,20 +92,20 @@ 投影片 間隔 (秒): - Include photos + 包含照片 包含影片 - Include GIFs + 包含GIF 隨機順序 使用淡入淡出動畫 反向播放 - Loop slideshow + 投影片循環 投影片結束 找不到投影片的媒體檔案 - Change view type - Grid - List + 改變瀏覽類型 + 格狀 + 列表 顯示隱藏的媒體檔案 @@ -124,10 +124,10 @@ 全螢幕時自動隱藏系統介面 刪除內容後刪除空白資料夾 允許用上下手勢來控制影片的音量和亮度 - Show folder media count on the main view + 主畫面顯示資料夾內媒體檔案數量 將全螢幕選單的分享取代為旋轉 - Show extended details over fullscreen media - Manage extended details + 全螢幕時顯示詳細資訊 + 管理詳細資訊 diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 8cb25a2bb..96b5c1cdf 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -5,6 +5,6 @@ #66000000 - @color/default_dark_theme_text_color - @color/default_dark_theme_background_color + @color/theme_dark_text_color + @color/theme_dark_background_color diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 54db9f7d0..0be50415b 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -2,16 +2,4 @@ - - - diff --git a/build.gradle b/build.gradle index 60b648170..89e92a15c 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.1.60' + ext.kotlin_version = '1.2.0' repositories { jcenter()