Skip to content

Commit 76f7ead

Browse files
committed
Albums two step flow implemented -> create new album then choose media to add
1 parent 45c6e86 commit 76f7ead

File tree

4 files changed

+29
-16
lines changed

4 files changed

+29
-16
lines changed

app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2142,7 +2142,7 @@ private void onCreateAlbumOperationFinish(CreateNewAlbumOperation operation, Rem
21422142
if (result.isSuccess()) {
21432143
Fragment fragment = getSupportFragmentManager().findFragmentByTag(AlbumsFragment.Companion.getTAG());
21442144
if (fragment instanceof AlbumsFragment albumsFragment) {
2145-
albumsFragment.newAlbumCreated(operation.getNewAlbumName());
2145+
albumsFragment.navigateToAlbumItemsFragment(operation.getNewAlbumName(), true);
21462146
}
21472147
} else {
21482148
try {

app/src/main/java/com/owncloud/android/ui/fragment/albums/AlbumItemsFragment.kt

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
package com.owncloud.android.ui.fragment.albums
99

10+
import android.annotation.SuppressLint
1011
import android.app.Activity
1112
import android.content.Context
1213
import android.content.Intent
@@ -113,6 +114,7 @@ class AlbumItemsFragment : Fragment(), OCFileListFragmentInterface, Injectable {
113114
private var columnSize = 0
114115

115116
private lateinit var albumName: String
117+
private var isNewAlbum: Boolean = false
116118

117119
private var mMultiChoiceModeListener: MultiChoiceModeListener? = null
118120

@@ -128,6 +130,7 @@ class AlbumItemsFragment : Fragment(), OCFileListFragmentInterface, Injectable {
128130
}
129131
arguments?.let {
130132
albumName = it.getString(ARG_ALBUM_NAME) ?: ""
133+
isNewAlbum = it.getBoolean(ARG_IS_NEW_ALBUM)
131134
}
132135
}
133136

@@ -139,9 +142,9 @@ class AlbumItemsFragment : Fragment(), OCFileListFragmentInterface, Injectable {
139142
override fun onCreate(savedInstanceState: Bundle?) {
140143
super.onCreate(savedInstanceState)
141144
columnSize = if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
142-
maxColumnSizeLandscape;
145+
MAX_COLUMN_SIZE_LANDSCAPE
143146
} else {
144-
maxColumnSizePortrait;
147+
MAX_COLUMN_SIZE_PORTRAIT
145148
}
146149
}
147150

@@ -159,6 +162,12 @@ class AlbumItemsFragment : Fragment(), OCFileListFragmentInterface, Injectable {
159162
createMenu()
160163
setupContainingList()
161164
setupContent()
165+
166+
// if fragment is opened when new albums is created
167+
// then open gallery to choose media to add
168+
if (isNewAlbum) {
169+
openGalleryToAddMedia()
170+
}
162171
}
163172

164173
private fun setUpActionMode() {
@@ -168,7 +177,7 @@ class AlbumItemsFragment : Fragment(), OCFileListFragmentInterface, Injectable {
168177
requireActivity(),
169178
adapter,
170179
viewThemeUtils
171-
) { filesCount, checkedFiles -> openActionsMenu(filesCount, checkedFiles, true) }
180+
) { filesCount, checkedFiles -> openActionsMenu(filesCount, checkedFiles) }
172181
(requireActivity() as FileDisplayActivity).addDrawerListener(mMultiChoiceModeListener)
173182
}
174183

@@ -417,13 +426,14 @@ class AlbumItemsFragment : Fragment(), OCFileListFragmentInterface, Injectable {
417426
adapter?.cancelAllPendingTasks()
418427
}
419428

429+
@SuppressLint("NotifyDataSetChanged")
420430
override fun onConfigurationChanged(newConfig: Configuration) {
421431
super.onConfigurationChanged(newConfig)
422432

423433
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
424-
columnSize = maxColumnSizeLandscape
434+
columnSize = MAX_COLUMN_SIZE_LANDSCAPE
425435
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
426-
columnSize = maxColumnSizePortrait
436+
columnSize = MAX_COLUMN_SIZE_PORTRAIT
427437
}
428438
adapter?.changeColumn(columnSize)
429439
adapter?.notifyDataSetChanged()
@@ -519,7 +529,7 @@ class AlbumItemsFragment : Fragment(), OCFileListFragmentInterface, Injectable {
519529
requireActivity().supportFragmentManager.popBackStack()
520530
}
521531

522-
private fun openActionsMenu(filesCount: Int, checkedFiles: Set<OCFile>, isOverflow: Boolean) {
532+
private fun openActionsMenu(filesCount: Int, checkedFiles: Set<OCFile>) {
523533
throttler.run("overflowClick") {
524534
var toHide: MutableList<Int>? = ArrayList()
525535
for (file in checkedFiles) {
@@ -562,7 +572,7 @@ class AlbumItemsFragment : Fragment(), OCFileListFragmentInterface, Injectable {
562572
}
563573

564574
val childFragmentManager = childFragmentManager
565-
val actionBottomSheet = newInstance(filesCount, checkedFiles, isOverflow, toHide)
575+
val actionBottomSheet = newInstance(filesCount, checkedFiles, true, toHide)
566576
.setResultListener(
567577
childFragmentManager, this
568578
) { id: Int -> onFileActionChosen(id, checkedFiles) }
@@ -612,6 +622,7 @@ class AlbumItemsFragment : Fragment(), OCFileListFragmentInterface, Injectable {
612622
*
613623
* @param select `true` to select all, `false` to deselect all
614624
*/
625+
@SuppressLint("NotifyDataSetChanged")
615626
private fun selectAllFiles(select: Boolean) {
616627
adapter?.let {
617628
it.selectAll(select)
@@ -937,17 +948,19 @@ class AlbumItemsFragment : Fragment(), OCFileListFragmentInterface, Injectable {
937948
companion object {
938949
val TAG: String = AlbumItemsFragment::class.java.simpleName
939950
private const val ARG_ALBUM_NAME = "album_name"
951+
private const val ARG_IS_NEW_ALBUM = "is_new_album"
940952
var lastMediaItemPosition: Int? = null
941953

942-
private const val maxColumnSizeLandscape: Int = 5
943-
private const val maxColumnSizePortrait: Int = 2
954+
private const val MAX_COLUMN_SIZE_LANDSCAPE: Int = 5
955+
private const val MAX_COLUMN_SIZE_PORTRAIT: Int = 2
944956

945-
fun newInstance(albumName: String): AlbumItemsFragment {
957+
fun newInstance(albumName: String, isNewAlbum: Boolean = false): AlbumItemsFragment {
946958
val args = Bundle()
947959

948960
val fragment = AlbumItemsFragment()
949961
fragment.arguments = args
950962
args.putString(ARG_ALBUM_NAME, albumName)
963+
args.putBoolean(ARG_IS_NEW_ALBUM, isNewAlbum)
951964
return fragment
952965
}
953966
}

app/src/main/java/com/owncloud/android/ui/fragment/albums/AlbumsFragment.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,19 +316,19 @@ class AlbumsFragment : Fragment(), AlbumFragmentInterface, Injectable {
316316
}
317317
}
318318

319-
fun newAlbumCreated(albumName: String) {
319+
fun navigateToAlbumItemsFragment(albumName: String, isNewAlbum: Boolean = false) {
320320
requireActivity().supportFragmentManager.beginTransaction().apply {
321321
addToBackStack(null)
322322
replace(
323323
R.id.left_fragment_container,
324-
AlbumItemsFragment.newInstance(albumName),
324+
AlbumItemsFragment.newInstance(albumName, isNewAlbum = isNewAlbum),
325325
AlbumItemsFragment.TAG
326326
)
327327
commit()
328328
}
329329
}
330330

331-
fun newAlbumCreated() {
331+
fun refreshAlbums() {
332332
fetchAndSetData()
333333
}
334334

@@ -377,6 +377,6 @@ class AlbumsFragment : Fragment(), AlbumFragmentInterface, Injectable {
377377
requireActivity().finish()
378378
return
379379
}
380-
newAlbumCreated(album.albumName)
380+
navigateToAlbumItemsFragment(album.albumName)
381381
}
382382
}

app/src/main/java/com/owncloud/android/ui/fragment/albums/AlbumsPickerActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class AlbumsPickerActivity : FileActivity(), FileFragment.ContainerActivity, OnE
147147
private fun onCreateAlbumOperationFinish(operation: CreateNewAlbumOperation, result: RemoteOperationResult<*>) {
148148
if (result.isSuccess) {
149149
val fileListFragment = listOfFilesFragment
150-
fileListFragment?.newAlbumCreated()
150+
fileListFragment?.refreshAlbums()
151151
} else {
152152
try {
153153
DisplayUtils.showSnackMessage(

0 commit comments

Comments
 (0)