update commons to 3.0.21
This commit is contained in:
parent
61c627a2e3
commit
f01973f1ad
7 changed files with 77 additions and 76 deletions
|
@ -46,7 +46,7 @@ ext {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:3.0.12'
|
implementation 'com.simplemobiletools:commons:3.0.21'
|
||||||
implementation 'com.squareup:otto:1.3.8'
|
implementation 'com.squareup:otto:1.3.8'
|
||||||
implementation 'com.facebook.stetho:stetho:1.5.0'
|
implementation 'com.facebook.stetho:stetho:1.5.0'
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,8 @@ import java.util.*
|
||||||
class MainActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener {
|
class MainActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener {
|
||||||
private var isThirdPartyIntent = false
|
private var isThirdPartyIntent = false
|
||||||
private var storedUseEnglish = false
|
private var storedUseEnglish = false
|
||||||
|
private var songs = ArrayList<Song>()
|
||||||
lateinit var bus: Bus
|
lateinit var bus: Bus
|
||||||
private var songs: ArrayList<Song> = ArrayList()
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
@ -211,11 +211,11 @@ class MainActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener {
|
||||||
val initialPath = if (songs.isEmpty()) Environment.getExternalStorageDirectory().toString() else songs[0].path
|
val initialPath = if (songs.isEmpty()) Environment.getExternalStorageDirectory().toString() else songs[0].path
|
||||||
FilePickerDialog(this, initialPath, pickFile = false) {
|
FilePickerDialog(this, initialPath, pickFile = false) {
|
||||||
toast(R.string.fetching_songs)
|
toast(R.string.fetching_songs)
|
||||||
Thread({
|
Thread {
|
||||||
val songs = getFolderSongs(File(it))
|
val songs = getFolderSongs(File(it))
|
||||||
dbHelper.addSongsToPlaylist(songs)
|
dbHelper.addSongsToPlaylist(songs)
|
||||||
sendIntent(REFRESH_LIST)
|
sendIntent(REFRESH_LIST)
|
||||||
}).start()
|
}.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.simplemobiletools.musicplayer.dialogs
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.helpers.SORT_DESCENDING
|
import com.simplemobiletools.commons.helpers.SORT_DESCENDING
|
||||||
|
@ -17,7 +16,7 @@ import kotlinx.android.synthetic.main.dialog_change_sorting.view.*
|
||||||
class ChangeSortingDialog(val activity: Activity, val callback: () -> Unit) {
|
class ChangeSortingDialog(val activity: Activity, val callback: () -> Unit) {
|
||||||
private var currSorting = 0
|
private var currSorting = 0
|
||||||
var config = activity.config
|
var config = activity.config
|
||||||
var view: View = LayoutInflater.from(activity).inflate(R.layout.dialog_change_sorting, null)
|
var view: View = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
AlertDialog.Builder(activity)
|
AlertDialog.Builder(activity)
|
||||||
|
|
|
@ -5,7 +5,6 @@ import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
|
@ -16,7 +15,7 @@ import java.io.File
|
||||||
|
|
||||||
class EditDialog(val activity: BaseSimpleActivity, val song: Song, val callback: (Song) -> Unit) {
|
class EditDialog(val activity: BaseSimpleActivity, val song: Song, val callback: (Song) -> Unit) {
|
||||||
init {
|
init {
|
||||||
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_rename_song, null).apply {
|
val view = activity.layoutInflater.inflate(R.layout.dialog_rename_song, null).apply {
|
||||||
title.setText(song.title)
|
title.setText(song.title)
|
||||||
artist.setText(song.artist)
|
artist.setText(song.artist)
|
||||||
|
|
||||||
|
@ -30,45 +29,46 @@ class EditDialog(val activity: BaseSimpleActivity, val song: Song, val callback:
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.create().apply {
|
.create().apply {
|
||||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||||
activity.setupDialogStuff(view, this, R.string.rename_song)
|
activity.setupDialogStuff(view, this, R.string.rename_song) {
|
||||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
|
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
val newTitle = view.title.value
|
val newTitle = view.title.value
|
||||||
val newArtist = view.artist.value
|
val newArtist = view.artist.value
|
||||||
val newFilename = view.file_name.value
|
val newFilename = view.file_name.value
|
||||||
val newFileExtension = view.extension.value
|
val newFileExtension = view.extension.value
|
||||||
|
|
||||||
if (newTitle.isEmpty() || newArtist.isEmpty() || newFilename.isEmpty() || newFileExtension.isEmpty()) {
|
if (newTitle.isEmpty() || newArtist.isEmpty() || newFilename.isEmpty() || newFileExtension.isEmpty()) {
|
||||||
activity.toast(R.string.rename_song_empty)
|
activity.toast(R.string.rename_song_empty)
|
||||||
return@setOnClickListener
|
|
||||||
}
|
|
||||||
|
|
||||||
val uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI
|
|
||||||
song.artist = newArtist
|
|
||||||
song.title = newTitle
|
|
||||||
|
|
||||||
if (updateContentResolver(context, uri, song.id, newTitle, newArtist)) {
|
|
||||||
context.contentResolver.notifyChange(uri, null)
|
|
||||||
|
|
||||||
val file = File(song.path)
|
|
||||||
val newFile = File(file.parent, "$newFilename.$newFileExtension")
|
|
||||||
if (file == newFile) {
|
|
||||||
callback(song)
|
|
||||||
dismiss()
|
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file.renameTo(newFile)) {
|
val uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI
|
||||||
context.scanFiles(arrayListOf(file, newFile)) {
|
song.artist = newArtist
|
||||||
song.path = newFile.absolutePath
|
song.title = newTitle
|
||||||
|
|
||||||
|
if (updateContentResolver(context, uri, song.id, newTitle, newArtist)) {
|
||||||
|
context.contentResolver.notifyChange(uri, null)
|
||||||
|
|
||||||
|
val file = File(song.path)
|
||||||
|
val newFile = File(file.parent, "$newFilename.$newFileExtension")
|
||||||
|
if (file == newFile) {
|
||||||
callback(song)
|
callback(song)
|
||||||
|
dismiss()
|
||||||
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
dismiss()
|
|
||||||
return@setOnClickListener
|
|
||||||
}
|
|
||||||
|
|
||||||
activity.toast(R.string.rename_song_error)
|
if (file.renameTo(newFile)) {
|
||||||
|
context.scanFiles(arrayListOf(file, newFile)) {
|
||||||
|
song.path = newFile.absolutePath
|
||||||
|
callback(song)
|
||||||
|
}
|
||||||
|
dismiss()
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
|
||||||
|
activity.toast(R.string.rename_song_error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,37 +27,39 @@ class NewPlaylistDialog(val activity: Activity, var playlist: Playlist? = null,
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.create().apply {
|
.create().apply {
|
||||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||||
activity.setupDialogStuff(view, this, if (isNewPlaylist) R.string.create_playlist else R.string.rename_playlist)
|
val dialogTitle = if (isNewPlaylist) R.string.create_playlist else R.string.rename_playlist
|
||||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
|
activity.setupDialogStuff(view, this, dialogTitle) {
|
||||||
val title = view.new_playlist_title.value
|
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
val playlistIdWithTitle = activity.dbHelper.getPlaylistIdWithTitle(title)
|
val title = view.new_playlist_title.value
|
||||||
var isPlaylistTitleTaken = isNewPlaylist && playlistIdWithTitle != -1
|
val playlistIdWithTitle = activity.dbHelper.getPlaylistIdWithTitle(title)
|
||||||
if (!isPlaylistTitleTaken)
|
var isPlaylistTitleTaken = isNewPlaylist && playlistIdWithTitle != -1
|
||||||
isPlaylistTitleTaken = !isNewPlaylist && playlist!!.id != playlistIdWithTitle && playlistIdWithTitle != -1
|
if (!isPlaylistTitleTaken)
|
||||||
|
isPlaylistTitleTaken = !isNewPlaylist && playlist!!.id != playlistIdWithTitle && playlistIdWithTitle != -1
|
||||||
|
|
||||||
if (title.isEmpty()) {
|
if (title.isEmpty()) {
|
||||||
activity.toast(R.string.empty_name)
|
activity.toast(R.string.empty_name)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
} else if (isPlaylistTitleTaken) {
|
} else if (isPlaylistTitleTaken) {
|
||||||
activity.toast(R.string.playlist_name_exists)
|
activity.toast(R.string.playlist_name_exists)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
|
||||||
|
playlist!!.title = title
|
||||||
|
|
||||||
|
val eventTypeId = if (isNewPlaylist) {
|
||||||
|
activity.dbHelper.insertPlaylist(playlist!!)
|
||||||
|
} else {
|
||||||
|
activity.dbHelper.updatePlaylist(playlist!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eventTypeId != -1) {
|
||||||
|
dismiss()
|
||||||
|
callback(eventTypeId)
|
||||||
|
} else {
|
||||||
|
activity.toast(R.string.unknown_error_occurred)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
playlist!!.title = title
|
|
||||||
|
|
||||||
val eventTypeId = if (isNewPlaylist) {
|
|
||||||
activity.dbHelper.insertPlaylist(playlist!!)
|
|
||||||
} else {
|
|
||||||
activity.dbHelper.updatePlaylist(playlist!!)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eventTypeId != -1) {
|
|
||||||
dismiss()
|
|
||||||
callback(eventTypeId)
|
|
||||||
} else {
|
|
||||||
activity.toast(R.string.unknown_error_occurred)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,8 +105,6 @@
|
||||||
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"
|
||||||
android:paddingLeft="@dimen/activity_margin"
|
|
||||||
android:paddingRight="@dimen/activity_margin"
|
|
||||||
app:layoutManager="android.support.v7.widget.LinearLayoutManager"/>
|
app:layoutManager="android.support.v7.widget.LinearLayoutManager"/>
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.FastScroller
|
<com.simplemobiletools.commons.views.FastScroller
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/song_frame"
|
android:id="@+id/song_frame"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:foreground="@drawable/selector">
|
android:foreground="@drawable/selector"
|
||||||
|
android:paddingLeft="@dimen/activity_margin"
|
||||||
|
android:paddingRight="@dimen/activity_margin">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/song_holder"
|
android:id="@+id/song_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingBottom="@dimen/medium_margin"
|
android:paddingBottom="@dimen/medium_margin"
|
||||||
android:paddingLeft="@dimen/medium_margin"
|
|
||||||
android:paddingTop="@dimen/medium_margin">
|
android:paddingTop="@dimen/medium_margin">
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
|
@ -24,8 +26,8 @@
|
||||||
android:layout_toLeftOf="@+id/song_note_image"
|
android:layout_toLeftOf="@+id/song_note_image"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="3"
|
android:maxLines="3"
|
||||||
android:text="Song Title"
|
android:textSize="@dimen/bigger_text_size"
|
||||||
android:textSize="@dimen/bigger_text_size"/>
|
tools:text="Song Title"/>
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
android:id="@+id/song_artist"
|
android:id="@+id/song_artist"
|
||||||
|
@ -35,8 +37,8 @@
|
||||||
android:layout_toLeftOf="@+id/song_note_image"
|
android:layout_toLeftOf="@+id/song_note_image"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="3"
|
android:maxLines="3"
|
||||||
android:text="Song Artist"
|
android:textSize="@dimen/normal_text_size"
|
||||||
android:textSize="@dimen/normal_text_size"/>
|
tools:text="Song Artist"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/song_note_image"
|
android:id="@+id/song_note_image"
|
||||||
|
|
Loading…
Reference in a new issue