2019-03-03 09:20:15 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Hemanth Savarala.
|
|
|
|
*
|
|
|
|
* Licensed under the GNU General Public License v3
|
|
|
|
*
|
|
|
|
* This is free software: you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2018-12-06 08:52:57 +00:00
|
|
|
package code.name.monkey.retromusic.dialogs
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint
|
|
|
|
import android.content.Intent
|
|
|
|
import android.os.Bundle
|
|
|
|
import android.view.LayoutInflater
|
|
|
|
import android.view.View
|
|
|
|
import android.view.ViewGroup
|
2019-01-28 10:45:51 +00:00
|
|
|
import androidx.core.content.ContextCompat
|
2018-12-06 08:52:57 +00:00
|
|
|
import code.name.monkey.appthemehelper.ThemeStore
|
2019-01-28 10:45:51 +00:00
|
|
|
import code.name.monkey.appthemehelper.util.MaterialUtil
|
2019-03-04 03:55:09 +00:00
|
|
|
|
2018-12-06 08:52:57 +00:00
|
|
|
import code.name.monkey.retromusic.R
|
|
|
|
import code.name.monkey.retromusic.model.Song
|
|
|
|
import code.name.monkey.retromusic.util.MusicUtil
|
|
|
|
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment
|
2019-02-17 17:01:35 +00:00
|
|
|
import kotlinx.android.synthetic.main.dialog_file_share.*
|
2018-12-06 08:52:57 +00:00
|
|
|
|
2019-03-04 03:55:09 +00:00
|
|
|
|
2018-12-06 08:52:57 +00:00
|
|
|
class SongShareDialog : RoundedBottomSheetDialogFragment() {
|
|
|
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
2019-02-17 17:01:35 +00:00
|
|
|
return inflater.inflate(R.layout.dialog_file_share, container, false)
|
2018-12-06 08:52:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressLint("StringFormatInvalid")
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
|
super.onViewCreated(view, savedInstanceState)
|
2019-03-05 02:40:57 +00:00
|
|
|
val song: Song = arguments!!.getParcelable("song") ?: return
|
2018-12-06 08:52:57 +00:00
|
|
|
|
2019-03-05 02:40:57 +00:00
|
|
|
dialogTitle.setTextColor(ThemeStore.textColorPrimary(context!!))
|
2019-02-17 17:01:35 +00:00
|
|
|
audioText.apply {
|
2019-01-28 10:45:51 +00:00
|
|
|
text = getString(R.string.currently_listening_to_x_by_x, song.title, song.artistName)
|
|
|
|
setTextColor(ThemeStore.textColorSecondary(context!!))
|
|
|
|
setOnClickListener {
|
|
|
|
val currentlyListening = getString(R.string.currently_listening_to_x_by_x, song.title, song.artistName)
|
|
|
|
activity!!.startActivity(Intent.createChooser(Intent().setAction(Intent.ACTION_SEND)
|
|
|
|
.putExtra(Intent.EXTRA_TEXT, currentlyListening)
|
|
|
|
.setType("text/plain"), null))
|
|
|
|
dismiss()
|
|
|
|
}
|
|
|
|
icon = ContextCompat.getDrawable(context, R.drawable.ic_text_fields_black_24dp)
|
|
|
|
MaterialUtil.setTint(this)
|
2018-12-06 08:52:57 +00:00
|
|
|
}
|
|
|
|
|
2019-02-17 17:01:35 +00:00
|
|
|
audioFile.apply {
|
2019-01-28 10:45:51 +00:00
|
|
|
setTextColor(ThemeStore.textColorSecondary(context!!))
|
|
|
|
setOnClickListener {
|
2019-03-04 03:55:09 +00:00
|
|
|
activity!!.startActivity(Intent.createChooser(MusicUtil.createShareSongFileIntent(song, context), null))
|
2019-01-28 10:45:51 +00:00
|
|
|
dismiss()
|
|
|
|
}
|
|
|
|
icon = ContextCompat.getDrawable(context, R.drawable.ic_share_white_24dp)
|
|
|
|
MaterialUtil.setTint(this, false)
|
|
|
|
}
|
2019-02-17 17:01:35 +00:00
|
|
|
|
2018-12-06 08:52:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
|
|
|
|
fun create(song: Song): SongShareDialog {
|
|
|
|
val dialog = SongShareDialog()
|
|
|
|
val args = Bundle()
|
|
|
|
args.putParcelable("song", song)
|
|
|
|
dialog.arguments = args
|
|
|
|
return dialog
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|