mirror of
https://github.com/SimpleMobileTools/Simple-Voice-Recorder.git
synced 2025-01-25 13:38:48 +01:00
show a couple extra fields at the recordings
This commit is contained in:
parent
95a0630688
commit
2d6fce812e
@ -57,7 +57,7 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:5.24.5'
|
||||
implementation 'com.simplemobiletools:commons:5.24.6'
|
||||
implementation 'org.greenrobot:eventbus:3.2.0'
|
||||
implementation 'com.github.Armen101:AudioRecordView:1.0.2'
|
||||
}
|
||||
|
@ -3,7 +3,11 @@ package com.simplemobiletools.voicerecorder.adapters
|
||||
import android.view.Menu
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
import com.simplemobiletools.commons.extensions.formatDate
|
||||
import com.simplemobiletools.commons.extensions.formatSize
|
||||
import com.simplemobiletools.commons.extensions.getFormattedDuration
|
||||
import com.simplemobiletools.commons.views.FastScroller
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
import com.simplemobiletools.voicerecorder.R
|
||||
@ -53,7 +57,14 @@ class RecordingsAdapter(activity: SimpleActivity, var recordings: ArrayList<Reco
|
||||
view.apply {
|
||||
recording_frame?.isSelected = selectedKeys.contains(recording.id)
|
||||
recording_title.text = recording.title
|
||||
recording_title.setTextColor(textColor)
|
||||
|
||||
recording_date.text = recording.timestamp.formatDate(context)
|
||||
recording_duration.text = recording.duration.getFormattedDuration()
|
||||
recording_size.text = recording.size.formatSize()
|
||||
|
||||
arrayListOf<TextView>(recording_title, recording_date, recording_duration, recording_size).forEach {
|
||||
it.setTextColor(textColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import android.database.Cursor
|
||||
import android.provider.MediaStore
|
||||
import android.util.AttributeSet
|
||||
import com.simplemobiletools.commons.extensions.getIntValue
|
||||
import com.simplemobiletools.commons.extensions.getLongValue
|
||||
import com.simplemobiletools.commons.extensions.getStringValue
|
||||
import com.simplemobiletools.commons.extensions.showErrorToast
|
||||
import com.simplemobiletools.voicerecorder.activities.SimpleActivity
|
||||
@ -44,8 +45,11 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
||||
|
||||
val uri = MediaStore.Audio.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY)
|
||||
val projection = arrayOf(
|
||||
MediaStore.Audio.Media._ID,
|
||||
MediaStore.Audio.Media.TITLE,
|
||||
MediaStore.Audio.Media._ID
|
||||
MediaStore.Audio.Media.DATE_ADDED,
|
||||
MediaStore.Audio.Media.DURATION,
|
||||
MediaStore.Audio.Media.SIZE
|
||||
)
|
||||
|
||||
val selection = "${MediaStore.Audio.Media.OWNER_PACKAGE_NAME} = ?"
|
||||
@ -57,9 +61,13 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
||||
cursor = context.contentResolver.query(uri, projection, selection, selectionArgs, sorting)
|
||||
if (cursor?.moveToFirst() == true) {
|
||||
do {
|
||||
val title = cursor.getStringValue(MediaStore.Audio.Media.TITLE)
|
||||
val id = cursor.getIntValue(MediaStore.Audio.Media._ID)
|
||||
val recording = Recording(id, title, "")
|
||||
val title = cursor.getStringValue(MediaStore.Audio.Media.TITLE)
|
||||
val path = ""
|
||||
val timestamp = cursor.getIntValue(MediaStore.Audio.Media.DATE_ADDED)
|
||||
val duration = cursor.getLongValue(MediaStore.Audio.Media.DURATION) / 1000
|
||||
val size = cursor.getIntValue(MediaStore.Audio.Media.SIZE)
|
||||
val recording = Recording(id, title, "", timestamp, duration.toInt(), size)
|
||||
recordings.add(recording)
|
||||
} while (cursor.moveToNext())
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
package com.simplemobiletools.voicerecorder.models
|
||||
|
||||
data class Recording(val id: Int, val title: String, val path: String)
|
||||
data class Recording(val id: Int, val title: String, val path: String, val timestamp: Int, val duration: Int, val size: Int)
|
||||
|
@ -9,15 +9,62 @@
|
||||
android:focusable="true"
|
||||
android:foreground="@drawable/selector">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/recording_title"
|
||||
<RelativeLayout
|
||||
android:id="@+id/item_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:padding="@dimen/activity_margin"
|
||||
android:textSize="@dimen/big_text_size"
|
||||
tools:text="2020_03_30_22_49_52.mp3" />
|
||||
android:padding="@dimen/activity_margin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/recording_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toStartOf="@+id/recording_duration"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:paddingEnd="@dimen/activity_margin"
|
||||
android:textSize="@dimen/big_text_size"
|
||||
tools:text="2020_03_30_22_49_52" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/recording_date"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/recording_title"
|
||||
android:layout_toStartOf="@+id/recording_size"
|
||||
android:alpha="0.6"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:paddingEnd="@dimen/activity_margin"
|
||||
android:textSize="@dimen/normal_text_size"
|
||||
tools:text="28 March, 20:20" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/recording_duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@+id/recording_title"
|
||||
android:layout_alignBottom="@+id/recording_title"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:textSize="@dimen/normal_text_size"
|
||||
tools:text="00:05" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/recording_size"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@+id/recording_date"
|
||||
android:layout_alignBottom="@+id/recording_date"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:alpha="0.6"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:textSize="@dimen/normal_text_size"
|
||||
tools:text="3 MB" />
|
||||
|
||||
</RelativeLayout>
|
||||
</FrameLayout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user