Merge branch 'feature/recycle-bin' of github.com:esensar/Simple-Voice-Recorder
This commit is contained in:
commit
ff65d8949c
4 changed files with 68 additions and 79 deletions
|
@ -118,7 +118,9 @@ class MainActivity : SimpleActivity() {
|
||||||
main_menu.setupMenu()
|
main_menu.setupMenu()
|
||||||
|
|
||||||
main_menu.onSearchOpenListener = {
|
main_menu.onSearchOpenListener = {
|
||||||
view_pager.currentItem = 1
|
if (view_pager.currentItem == 0) {
|
||||||
|
view_pager.currentItem = 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main_menu.onSearchTextChangedListener = { text ->
|
main_menu.onSearchTextChangedListener = { text ->
|
||||||
|
@ -187,6 +189,7 @@ class MainActivity : SimpleActivity() {
|
||||||
)
|
)
|
||||||
|
|
||||||
view_pager.adapter = ViewPagerAdapter(this, config.useRecycleBin)
|
view_pager.adapter = ViewPagerAdapter(this, config.useRecycleBin)
|
||||||
|
view_pager.offscreenPageLimit = 2
|
||||||
view_pager.onPageChangeListener {
|
view_pager.onPageChangeListener {
|
||||||
main_tabs_holder.getTabAt(it)?.select()
|
main_tabs_holder.getTabAt(it)?.select()
|
||||||
(view_pager.adapter as ViewPagerAdapter).finishActMode()
|
(view_pager.adapter as ViewPagerAdapter).finishActMode()
|
||||||
|
|
|
@ -12,7 +12,6 @@ import android.provider.DocumentsContract
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.widget.SeekBar
|
import android.widget.SeekBar
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
|
||||||
import com.simplemobiletools.commons.helpers.isQPlus
|
import com.simplemobiletools.commons.helpers.isQPlus
|
||||||
import com.simplemobiletools.voicerecorder.R
|
import com.simplemobiletools.voicerecorder.R
|
||||||
import com.simplemobiletools.voicerecorder.activities.SimpleActivity
|
import com.simplemobiletools.voicerecorder.activities.SimpleActivity
|
||||||
|
@ -138,44 +137,40 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAdapter(recordings: ArrayList<Recording>) {
|
private fun setupAdapter(recordings: ArrayList<Recording>) {
|
||||||
ensureBackgroundThread {
|
recordings_fastscroller.beVisibleIf(recordings.isNotEmpty())
|
||||||
Handler(Looper.getMainLooper()).post {
|
recordings_placeholder.beVisibleIf(recordings.isEmpty())
|
||||||
recordings_fastscroller.beVisibleIf(recordings.isNotEmpty())
|
if (recordings.isEmpty()) {
|
||||||
recordings_placeholder.beVisibleIf(recordings.isEmpty())
|
val stringId = if (lastSearchQuery.isEmpty()) {
|
||||||
if (recordings.isEmpty()) {
|
if (isQPlus()) {
|
||||||
val stringId = if (lastSearchQuery.isEmpty()) {
|
R.string.no_recordings_found
|
||||||
if (isQPlus()) {
|
|
||||||
R.string.no_recordings_found
|
|
||||||
} else {
|
|
||||||
R.string.no_recordings_in_folder_found
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
R.string.no_items_found
|
|
||||||
}
|
|
||||||
|
|
||||||
recordings_placeholder.text = context.getString(stringId)
|
|
||||||
resetProgress(null)
|
|
||||||
player?.stop()
|
|
||||||
}
|
|
||||||
|
|
||||||
val adapter = getRecordingsAdapter()
|
|
||||||
if (adapter == null) {
|
|
||||||
RecordingsAdapter(context as SimpleActivity, recordings, this, recordings_list) {
|
|
||||||
playRecording(it as Recording, true)
|
|
||||||
if (playedRecordingIDs.isEmpty() || playedRecordingIDs.peek() != it.id) {
|
|
||||||
playedRecordingIDs.push(it.id)
|
|
||||||
}
|
|
||||||
}.apply {
|
|
||||||
recordings_list.adapter = this
|
|
||||||
}
|
|
||||||
|
|
||||||
if (context.areSystemAnimationsEnabled) {
|
|
||||||
recordings_list.scheduleLayoutAnimation()
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
adapter.updateItems(recordings)
|
R.string.no_recordings_in_folder_found
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
R.string.no_items_found
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recordings_placeholder.text = context.getString(stringId)
|
||||||
|
resetProgress(null)
|
||||||
|
player?.stop()
|
||||||
|
}
|
||||||
|
|
||||||
|
val adapter = getRecordingsAdapter()
|
||||||
|
if (adapter == null) {
|
||||||
|
RecordingsAdapter(context as SimpleActivity, recordings, this, recordings_list) {
|
||||||
|
playRecording(it as Recording, true)
|
||||||
|
if (playedRecordingIDs.isEmpty() || playedRecordingIDs.peek() != it.id) {
|
||||||
|
playedRecordingIDs.push(it.id)
|
||||||
|
}
|
||||||
|
}.apply {
|
||||||
|
recordings_list.adapter = this
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.areSystemAnimationsEnabled) {
|
||||||
|
recordings_list.scheduleLayoutAnimation()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
adapter.updateItems(recordings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
package com.simplemobiletools.voicerecorder.fragments
|
package com.simplemobiletools.voicerecorder.fragments
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Handler
|
|
||||||
import android.os.Looper
|
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
|
||||||
import com.simplemobiletools.voicerecorder.R
|
import com.simplemobiletools.voicerecorder.R
|
||||||
import com.simplemobiletools.voicerecorder.activities.SimpleActivity
|
import com.simplemobiletools.voicerecorder.activities.SimpleActivity
|
||||||
import com.simplemobiletools.voicerecorder.adapters.TrashAdapter
|
import com.simplemobiletools.voicerecorder.adapters.TrashAdapter
|
||||||
|
@ -14,10 +11,10 @@ import com.simplemobiletools.voicerecorder.extensions.getAllRecordings
|
||||||
import com.simplemobiletools.voicerecorder.interfaces.RefreshRecordingsListener
|
import com.simplemobiletools.voicerecorder.interfaces.RefreshRecordingsListener
|
||||||
import com.simplemobiletools.voicerecorder.models.Events
|
import com.simplemobiletools.voicerecorder.models.Events
|
||||||
import com.simplemobiletools.voicerecorder.models.Recording
|
import com.simplemobiletools.voicerecorder.models.Recording
|
||||||
import kotlinx.android.synthetic.main.fragment_trash.view.player_holder
|
import kotlinx.android.synthetic.main.fragment_trash.view.trash_fastscroller
|
||||||
import kotlinx.android.synthetic.main.fragment_trash.view.recordings_fastscroller
|
import kotlinx.android.synthetic.main.fragment_trash.view.trash_holder
|
||||||
import kotlinx.android.synthetic.main.fragment_trash.view.recordings_list
|
import kotlinx.android.synthetic.main.fragment_trash.view.trash_list
|
||||||
import kotlinx.android.synthetic.main.fragment_trash.view.recordings_placeholder
|
import kotlinx.android.synthetic.main.fragment_trash.view.trash_placeholder
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
import org.greenrobot.eventbus.Subscribe
|
import org.greenrobot.eventbus.Subscribe
|
||||||
import org.greenrobot.eventbus.ThreadMode
|
import org.greenrobot.eventbus.ThreadMode
|
||||||
|
@ -63,34 +60,29 @@ class TrashFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
||||||
override fun playRecording(recording: Recording, playOnPrepared: Boolean) {}
|
override fun playRecording(recording: Recording, playOnPrepared: Boolean) {}
|
||||||
|
|
||||||
private fun setupAdapter(recordings: ArrayList<Recording>) {
|
private fun setupAdapter(recordings: ArrayList<Recording>) {
|
||||||
ensureBackgroundThread {
|
trash_fastscroller.beVisibleIf(recordings.isNotEmpty())
|
||||||
Handler(Looper.getMainLooper()).post {
|
trash_placeholder.beVisibleIf(recordings.isEmpty())
|
||||||
recordings_fastscroller.beVisibleIf(recordings.isNotEmpty())
|
if (recordings.isEmpty()) {
|
||||||
recordings_placeholder.beVisibleIf(recordings.isEmpty())
|
val stringId = if (lastSearchQuery.isEmpty()) {
|
||||||
if (recordings.isEmpty()) {
|
R.string.recycle_bin_empty
|
||||||
val stringId = if (lastSearchQuery.isEmpty()) {
|
} else {
|
||||||
R.string.recycle_bin_empty
|
R.string.no_items_found
|
||||||
} else {
|
|
||||||
R.string.no_items_found
|
|
||||||
}
|
|
||||||
|
|
||||||
recordings_placeholder.text = context.getString(stringId)
|
|
||||||
}
|
|
||||||
|
|
||||||
val adapter = getRecordingsAdapter()
|
|
||||||
if (adapter == null) {
|
|
||||||
TrashAdapter(context as SimpleActivity, recordings, this, recordings_list)
|
|
||||||
.apply {
|
|
||||||
recordings_list.adapter = this
|
|
||||||
}
|
|
||||||
|
|
||||||
if (context.areSystemAnimationsEnabled) {
|
|
||||||
recordings_list.scheduleLayoutAnimation()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
adapter.updateItems(recordings)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trash_placeholder.text = context.getString(stringId)
|
||||||
|
}
|
||||||
|
|
||||||
|
val adapter = getRecordingsAdapter()
|
||||||
|
if (adapter == null) {
|
||||||
|
TrashAdapter(context as SimpleActivity, recordings, this, trash_list).apply {
|
||||||
|
trash_list.adapter = this
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.areSystemAnimationsEnabled) {
|
||||||
|
trash_list.scheduleLayoutAnimation()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
adapter.updateItems(recordings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +98,7 @@ class TrashFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
||||||
setupAdapter(filtered)
|
setupAdapter(filtered)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getRecordingsAdapter() = recordings_list.adapter as? TrashAdapter
|
private fun getRecordingsAdapter() = trash_list.adapter as? TrashAdapter
|
||||||
|
|
||||||
private fun storePrevPath() {
|
private fun storePrevPath() {
|
||||||
prevSavePath = context!!.config.saveRecordingsFolder
|
prevSavePath = context!!.config.saveRecordingsFolder
|
||||||
|
@ -114,8 +106,8 @@ class TrashFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
||||||
|
|
||||||
private fun setupColors() {
|
private fun setupColors() {
|
||||||
val properPrimaryColor = context.getProperPrimaryColor()
|
val properPrimaryColor = context.getProperPrimaryColor()
|
||||||
recordings_fastscroller.updateColors(properPrimaryColor)
|
trash_fastscroller.updateColors(properPrimaryColor)
|
||||||
context.updateTextColors(player_holder)
|
context.updateTextColors(trash_holder)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun finishActMode() = getRecordingsAdapter()?.finishActMode()
|
fun finishActMode() = getRecordingsAdapter()?.finishActMode()
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<com.simplemobiletools.voicerecorder.fragments.TrashFragment xmlns:android="http://schemas.android.com/apk/res/android"
|
<com.simplemobiletools.voicerecorder.fragments.TrashFragment xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/player_holder"
|
android:id="@+id/trash_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
android:id="@+id/recordings_placeholder"
|
android:id="@+id/trash_placeholder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:alpha="0.8"
|
android:alpha="0.8"
|
||||||
|
@ -19,14 +19,13 @@
|
||||||
android:visibility="visible" />
|
android:visibility="visible" />
|
||||||
|
|
||||||
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||||
android:id="@+id/recordings_fastscroller"
|
android:id="@+id/trash_fastscroller"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/player_controls_wrapper"
|
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
android:id="@+id/recordings_list"
|
android:id="@+id/trash_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
|
|
Loading…
Reference in a new issue