diff --git a/app/build.gradle b/app/build.gradle index 85af34e8..1691dd87 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId 'com.stevenschoen.putionew' minSdkVersion 19 targetSdkVersion 25 - versionCode 102 - versionName '4.0' + versionCode 103 + versionName '4.0.1' } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 @@ -41,13 +41,13 @@ dependencies { compile 'com.android.support:palette-v7:25.0.0' compile 'com.google.android.gms:play-services-cast-framework:9.6.1' compile 'commons-io:commons-io:2.5' - compile 'joda-time:joda-time:2.9.4' + compile 'joda-time:joda-time:2.9.5' compile 'io.reactivex:rxandroid:1.2.1' - compile 'com.trello:rxlifecycle:0.8.0' - compile 'com.trello:rxlifecycle-components:0.8.0' - compile 'com.trello:rxlifecycle-kotlin:0.8.0' - compile 'com.squareup.okhttp3:okhttp:3.4.1' - compile 'com.squareup.okhttp3:logging-interceptor:3.4.1' + compile 'com.trello:rxlifecycle:1.0' + compile 'com.trello:rxlifecycle-components:1.0' + compile 'com.trello:rxlifecycle-kotlin:1.0' + compile 'com.squareup.okhttp3:okhttp:3.4.2' + compile 'com.squareup.okhttp3:logging-interceptor:3.4.2' compile 'com.squareup.retrofit2:retrofit:2.1.0' compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0' compile 'com.squareup.retrofit2:converter-gson:2.1.0' diff --git a/app/src/main/java/com/stevenschoen/putionew/files/FileListFragment.kt b/app/src/main/java/com/stevenschoen/putionew/files/FileListFragment.kt index 6c1da2af..e2654bd9 100644 --- a/app/src/main/java/com/stevenschoen/putionew/files/FileListFragment.kt +++ b/app/src/main/java/com/stevenschoen/putionew/files/FileListFragment.kt @@ -57,7 +57,7 @@ abstract class FileListFragment : Rx var filesAdapter: FilesAdapter? = null - val actionModeHelper by lazy { ActionModeHelper() } + val selectionHelper by lazy { SelectionHelper() } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -77,12 +77,12 @@ abstract class FileListFragment : Rx }) filesAdapter!!.setItemsCheckedChangedListener(object : FilesAdapter.OnItemsCheckedChangedListener { override fun onItemsCheckedChanged() { - if (!actionModeHelper.hasActionMode()) { + if (!selectionHelper.isShowing()) { if (filesAdapter!!.isInCheckMode()) { - actionModeHelper.startFloatingActionMode() + selectionHelper.show() } } else { - actionModeHelper.invalidateActionMode() + selectionHelper.invalidate() } } }) @@ -283,12 +283,12 @@ abstract class FileListFragment : Rx abstract fun refresh() abstract fun isRefreshing(): Boolean - inner class ActionModeHelper() { - fun hasActionMode(): Boolean { + inner class SelectionHelper() { + fun isShowing(): Boolean { return getSelectionFragment() != null } - fun invalidateActionMode() { + fun invalidate() { val count = filesAdapter!!.checkedCount() if (count == 0) { childFragmentManager.beginTransaction() @@ -300,7 +300,7 @@ abstract class FileListFragment : Rx } } - fun startFloatingActionMode() { + fun show() { callbacks?.onSelectionStarted() val selectionFragment = Fragment.instantiate(context, FileSelectionFragment::class.java.name) as FileSelectionFragment childFragmentManager.beginTransaction() diff --git a/app/src/main/java/com/stevenschoen/putionew/files/FileSelectionFragment.kt b/app/src/main/java/com/stevenschoen/putionew/files/FileSelectionFragment.kt index 788527ab..d43a3fcf 100644 --- a/app/src/main/java/com/stevenschoen/putionew/files/FileSelectionFragment.kt +++ b/app/src/main/java/com/stevenschoen/putionew/files/FileSelectionFragment.kt @@ -2,7 +2,10 @@ package com.stevenschoen.putionew.files import android.os.Bundle import android.support.v4.app.Fragment +import android.support.v4.widget.PopupMenuCompat +import android.support.v7.widget.PopupMenu import android.view.LayoutInflater +import android.view.MenuItem import android.view.View import android.view.ViewGroup import android.widget.TextView @@ -29,13 +32,6 @@ class FileSelectionFragment : Fragment() { callbacks?.onCancel() } - val renameView = view.findViewById(R.id.file_selection_rename) - renameView.setOnClickListener { callbacks?.onRenameSelected()} - renameView.setOnLongClickListener { - Toast.makeText(context, R.string.rename, Toast.LENGTH_SHORT).show() - true - } - val downloadView = view.findViewById(R.id.file_selection_download) downloadView.setOnClickListener { callbacks?.onDownloadSelected() } downloadView.setOnLongClickListener { @@ -50,13 +46,6 @@ class FileSelectionFragment : Fragment() { true } - val moveView = view.findViewById(R.id.file_selection_move) - moveView.setOnClickListener { callbacks?.onMoveSelected() } - moveView.setOnLongClickListener { - Toast.makeText(context, R.string.move, Toast.LENGTH_SHORT).show() - true - } - val deleteView = view.findViewById(R.id.file_selection_delete) deleteView.setOnClickListener { callbacks?.onDeleteSelected() } deleteView.setOnLongClickListener { @@ -64,15 +53,34 @@ class FileSelectionFragment : Fragment() { true } + val idRename = 1 + val idMove = 2 + + val moreView = view.findViewById(R.id.file_selection_more) + moreView.setOnClickListener { + val popup = PopupMenu(context, moreView) + if (amountSelected.value == 1) popup.menu.add(0, idRename, 0, R.string.rename) + popup.menu.add(0, idMove, 0, R.string.move) + popup.setOnMenuItemClickListener { menuItem -> + when (menuItem.itemId) { + idRename -> { + callbacks?.onRenameSelected(); + return@setOnMenuItemClickListener true + } + idMove -> { + callbacks?.onMoveSelected() + return@setOnMenuItemClickListener true + } + } + false + } + popup.show() + } + val titleView = view.findViewById(R.id.file_selection_title) as TextView fun updateAmount(amount: Int) { titleView.text = getString(R.string.x_selected, amount) - if (amount > 1) { - renameView.visibility = View.GONE - } else { - renameView.visibility = View.VISIBLE - } } if (savedInstanceState != null) { diff --git a/app/src/main/res/drawable/ic_selection_copy.xml b/app/src/main/res/drawable/ic_selection_copy.xml index 182f1dc5..4101f5e3 100644 --- a/app/src/main/res/drawable/ic_selection_copy.xml +++ b/app/src/main/res/drawable/ic_selection_copy.xml @@ -1,6 +1,6 @@ - + + diff --git a/app/src/main/res/drawable/ic_selection_download.xml b/app/src/main/res/drawable/ic_selection_download.xml index d715086e..d0e7b91d 100644 --- a/app/src/main/res/drawable/ic_selection_download.xml +++ b/app/src/main/res/drawable/ic_selection_download.xml @@ -1,6 +1,6 @@ + + diff --git a/app/src/main/res/drawable/ic_selection_move.xml b/app/src/main/res/drawable/ic_selection_move.xml deleted file mode 100644 index 8895c7d0..00000000 --- a/app/src/main/res/drawable/ic_selection_move.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_selection_rename.xml b/app/src/main/res/drawable/ic_selection_rename.xml deleted file mode 100644 index 9b2ea64d..00000000 --- a/app/src/main/res/drawable/ic_selection_rename.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/app/src/main/res/layout/file_selection.xml b/app/src/main/res/layout/file_selection.xml index 9987a078..919df342 100644 --- a/app/src/main/res/layout/file_selection.xml +++ b/app/src/main/res/layout/file_selection.xml @@ -25,24 +25,11 @@ android:textAppearance="@style/TextAppearance.AppCompat.Subhead" tools:text="1 selected"/> - - + android:src="@drawable/ic_selection_delete"/> + android:src="@drawable/ic_selection_more"/> \ No newline at end of file