This commit is contained in:
1 parent
8371f60d4e
commit
01e7f3869a
14 files changed
+298
-79
No files matched your search
+3
-2
@@ -17,7 +17,7 @@
|
||||
<option name="ALLOW_USER_CONFIGURATION" value="false" />
|
||||
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
|
||||
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
|
||||
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
|
||||
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res;file://$MODULE_DIR$/build/generated/res/rs/debug;file://$MODULE_DIR$/build/generated/res/resValues/debug" />
|
||||
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
|
||||
</configuration>
|
||||
</facet>
|
||||
@@ -26,7 +26,7 @@
|
||||
<compilerSettings />
|
||||
<compilerArguments>
|
||||
<option name="destination" value="$MODULE_DIR$/build/tmp/kotlin-classes/debug" />
|
||||
<option name="classpath" value="$USER_HOME$/.gradle/caches/transforms-1/files-1.1/ealvalog-android-0.3.0.aar/2b810c66e283f4588239acd3521b8aab/jars/classes.jar:/home/phoenix/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.20/aa17d6fd473ce53061a7b2b9d2ae96f547cae93d/kotlin-stdlib-jdk7-1.3.20.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/design-28.0.0.aar/d59fd701b5968e30960f3f4e2d557686/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-0.10.8.aar/f3b6204555a7e1dd001a1960b3290cc4/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-appcompat-v7-0.10.8.aar/b23de49cbde22b6c6ed093aeeee5b459/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-appcompat-v7-coroutines-0.10.8.aar/8429b99cbbe70ed40aacc2a7283e7a9b/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-appcompat-v7-commons-0.10.8.aar/ebc06c61ada7710c09c81f8e08af31e5/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/appcompatV7-base-0.10.8.aar/ad5fe789a038d85b57848e38ca22f0c5/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0.aar/c471ff528fa222252cbe6fd7c91f4ff7/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-support-v4-0.10.8.aar/9332521615a00fcdede48cda4f134346/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-support-v4-commons-0.10.8.aar/79486f7481af6571bf0894a12dfaadb4/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/supportV4-base-0.10.8.aar/4540b6362490e70d165b5262722442a5/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/support-v4-28.0.0.aar/da83f7dd4ca67caa13f3288fd4403c3b/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/constraint-layout-1.1.3.aar/42c1ae14bcacf4cebf776fbf856e657d/jars/classes.jar:/home/phoenix/.gradle/caches/modules-2/files-2.1/com.ealva/ealvatag/0.4.2/7136882680aafa19f4d1323c71b547898b898ca5/ealvatag-0.4.2.jar:/home/phoenix/.gradle/caches/modules-2/files-2.1/com.ealva/ealvalog-core/0.3.0/84ac9309ccdf8667a2f2692aeffa5de76961dc12/ealvalog-core-0.3.0.jar:/home/phoenix/.gradle/caches/modules-2/files-2.1/com.ealva/ealvalog/0.3.0/cea6faf07e4bd965413d0c3139a5f3682c4d92a2/ealvalog-0.3.0.jar:/home/phoenix/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/20.0/89507701249388e1ed5ddcf8c41f4ce1be7831ef/guava-20.0.jar:/home/phoenix/.gradle/caches/modules-2/files-2.1/com.squareup.okio/okio/1.11.0/840897fcd7223a8143f1d9b6f69714e7be34fd50/okio-1.11.0.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-sqlite-0.10.8.aar/3a4cd46802cdc615c14583aa1f5a751f/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-sdk27-0.10.8.aar/c1ac6c41c021bab12b3511dc369626a4/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-sdk27-coroutines-0.10.8.aar/f82f7fff91b234fa3991e8db962c1be5/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-commons-0.10.8.aar/f6c2087ee285802f64f0d3e6f834c1a8/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-coroutines-0.10.8.aar/ae94bbcd3d6f3d8fbd8d06433b55f0eb/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/sqlite-base-0.10.8.aar/ad15d8c9a5ccf1d35c68c242e02c365f/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/platform-base-0.10.8.aar/34a4d54664357342edec2fd1547eefe2/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/commons-base-0.10.8.aar/d087c0432ac85d858353622b7a92e0c2/jars/classes.jar:/home/phoenix/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-android/1.0.0/2102040565a29061ab7aaea6ea548ad51eafb11d/kotlinx-coroutines-android-1.0.0.jar:/home/phoenix/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.0.0/a33c4bf7581f71f01d4ed660b09ca199abbb44da/kotlinx-coroutines-core-1.0.0.jar:/home/phoenix/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.20/eb2a232734e09fcd1b958a5c7520a93c6de38b32/kotlin-stdlib-1.3.20.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/support-fragment-28.0.0.aar/08e22231533273dfb70a1da0d55c7412/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/animated-vector-drawable-28.0.0.aar/3275334232144b76331d1b3577f3a1fb/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/recyclerview-v7-28.0.0.aar/4fc4551a42ecc9330403e82489fb2049/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/support-core-ui-28.0.0.aar/e25894a8d2a2c4729e45cf8aa75490ab/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/support-core-utils-28.0.0.aar/245809fe88a64d3516d37c1a4f6c72a5/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/support-vector-drawable-28.0.0.aar/c6777092eb31eb9dabf24d601db0bb26/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/support-media-compat-28.0.0.aar/6be8a08430c8456f3Line truncated
|
||||
<option name="classpath" value="$USER_HOME$/.gradle/caches/transforms-1/files-1.1/ealvalog-android-0.3.0.aar/6049363148a2a3ae4b2c516cb07803e4/jars/classes.jar:/home/phoenix/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.20/aa17d6fd473ce53061a7b2b9d2ae96f547cae93d/kotlin-stdlib-jdk7-1.3.20.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/design-28.0.0.aar/26d67245a807b0f8ded0b7a7f48b2608/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-0.10.8.aar/1bc534e6e73cec355c4f8280398b94af/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-appcompat-v7-0.10.8.aar/4be14d3e66cf17732fad2338eb045357/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-appcompat-v7-coroutines-0.10.8.aar/c2bcc68b37c7f12bc1c4be2ae762341e/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-appcompat-v7-commons-0.10.8.aar/3767a4a6e0c67373b2caacb87a78cc2b/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/appcompatV7-base-0.10.8.aar/79c7424f3d5b03daceae5e01dc8b4965/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0.aar/a8c85024244067a848b7c360a00e196c/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-support-v4-0.10.8.aar/18c9eb80ae265552398aa0fb8dfa6783/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-support-v4-commons-0.10.8.aar/03c6117d7fb869f6e4e8e72bdb31277b/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/supportV4-base-0.10.8.aar/087a99a70870025bf79d5add922b7243/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/support-v4-28.0.0.aar/fdc9983b273436bf5696eaee53d6cf49/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/constraint-layout-1.1.3.aar/26d9c3d9d0d279a2cc29ed12c49956c9/jars/classes.jar:/home/phoenix/.gradle/caches/modules-2/files-2.1/com.ealva/ealvatag/0.4.2/7136882680aafa19f4d1323c71b547898b898ca5/ealvatag-0.4.2.jar:/home/phoenix/.gradle/caches/modules-2/files-2.1/com.ealva/ealvalog-core/0.3.0/84ac9309ccdf8667a2f2692aeffa5de76961dc12/ealvalog-core-0.3.0.jar:/home/phoenix/.gradle/caches/modules-2/files-2.1/com.ealva/ealvalog/0.3.0/cea6faf07e4bd965413d0c3139a5f3682c4d92a2/ealvalog-0.3.0.jar:/home/phoenix/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/20.0/89507701249388e1ed5ddcf8c41f4ce1be7831ef/guava-20.0.jar:/home/phoenix/.gradle/caches/modules-2/files-2.1/com.squareup.okio/okio/1.11.0/840897fcd7223a8143f1d9b6f69714e7be34fd50/okio-1.11.0.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/cardview-v7-28.0.0.aar/aa4db57966ef1bcb6b45ee186c0ecafe/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-sqlite-0.10.8.aar/a27bc91b0f6ba0deaaf07f2bc380fe20/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-sdk27-0.10.8.aar/5b5c87feead2909bf0bee50d3989ff72/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-sdk27-coroutines-0.10.8.aar/ae1dfb5f7455068c78881d8a4248924b/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-commons-0.10.8.aar/0b3288d87fea213387175c2e4b905364/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/anko-coroutines-0.10.8.aar/3dbadbc39aff28f9789b6f1266135a23/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/sqlite-base-0.10.8.aar/fa70a91fabd4e7944498dde4bbba43ac/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/platform-base-0.10.8.aar/e15de60bb74bb1a544dafdeb60cf0434/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/commons-base-0.10.8.aar/c5dae5cd20ea4139cd839e5b52a9eec4/jars/classes.jar:/home/phoenix/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-android/1.0.0/2102040565a29061ab7aaea6ea548ad51eafb11d/kotlinx-coroutines-android-1.0.0.jar:/home/phoenix/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.0.0/a33c4bf7581f71f01d4ed660b09ca199abbb44da/kotlinx-coroutines-core-1.0.0.jar:/home/phoenix/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.20/eb2a232734e09fcd1b958a5c7520a93c6de38b32/kotlin-stdlib-1.3.20.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/support-fragment-28.0.0.aar/ce4600674841de0de5d9f4fb996aa13f/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/animated-vector-drawable-28.0.0.aar/8f93afd5cf1977aae90ab9745758f98f/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/recyclerview-v7-28.0.0.aar/7783fcf2dae4908a25580e65696d1df9/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/support-core-ui-28.0.0.aar/a3018d28d0637f4b358c8d83b9e6b138/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/support-core-utils-28.0.0.aar/731578a4ac8e0f02227c4e6e6016c670/jars/classes.jar:/home/phoenix/.gradle/caches/transforms-1/files-1.1/support-vector-drawable-28.0.0.aar/775e06fb97847614b1656388f1Line truncated
|
||||
<option name="noStdlib" value="true" />
|
||||
<option name="noReflect" value="true" />
|
||||
<option name="moduleName" value="app_debug" />
|
||||
@@ -151,6 +151,7 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/split-apk" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/validate_signing_config" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/kotlin" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
||||
|
||||
@@ -39,4 +39,5 @@ dependencies {
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||
implementation 'com.android.support:cardview-v7:28.0.0'
|
||||
}
|
||||
@@ -11,6 +11,15 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".activities.SongViewActivity"
|
||||
android:label="@string/title_activity_song_view"
|
||||
android:parentActivityName=".activities.MainActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.example.mear.activities.MainActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activities.SettingsActivity"
|
||||
android:label="@string/title_activity_settings"
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.example.mear.activities
|
||||
|
||||
import android.app.ActivityManager
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.ServiceConnection
|
||||
import android.os.IBinder
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.widget.Toast
|
||||
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
||||
import com.example.mear.playback.service.MusicService
|
||||
|
||||
open class BaseServiceActivity: AppCompatActivity() {
|
||||
protected var musicService: MusicService? = null
|
||||
|
||||
|
||||
protected open fun resetControls() {
|
||||
val d = "l"
|
||||
}
|
||||
protected open fun initializeChangeListeners() {
|
||||
val d = "l"
|
||||
}
|
||||
protected open fun updateTrackProgress() {
|
||||
val d = "l"
|
||||
}
|
||||
protected open fun configureTrackDisplay() {
|
||||
val d = "l"
|
||||
}
|
||||
|
||||
protected fun isServiceRunning(serviceClass: Class<*>): Boolean {
|
||||
val activityManager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
|
||||
|
||||
for (service in activityManager.getRunningServices(Integer.MAX_VALUE)) {
|
||||
if (serviceClass.name == service.service.className) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
protected val mConnection = object : ServiceConnection {
|
||||
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
||||
resetControls()
|
||||
|
||||
runBlocking {
|
||||
val demo = launch {
|
||||
musicService = (service as MusicService.LocalBinder).service
|
||||
initializeChangeListeners()
|
||||
updateTrackProgress()
|
||||
}
|
||||
demo.start()
|
||||
}
|
||||
if (musicService != null) {
|
||||
if (musicService!!.isPlaying()) {
|
||||
configureTrackDisplay()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onServiceDisconnected(className: ComponentName) {
|
||||
resetControls()
|
||||
Toast.makeText(
|
||||
this@BaseServiceActivity, "Music Service Stopped",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
protected fun doBindService() {
|
||||
val intent = Intent(this, MusicService::class.java)
|
||||
if (isServiceRunning(MusicService::class.java)) {
|
||||
val suc = "Service is already running"
|
||||
}
|
||||
else {
|
||||
startService(intent)
|
||||
}
|
||||
|
||||
var result = bindService(intent, mConnection, Context.BIND_AUTO_CREATE)
|
||||
if (result) {
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,15 @@
|
||||
package com.example.mear.activities
|
||||
|
||||
import android.app.ActivityManager
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.ServiceConnection
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.Color
|
||||
import android.media.MediaMetadataRetriever
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.IBinder
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.widget.Toast
|
||||
|
||||
import java.lang.Exception
|
||||
import java.lang.Runnable
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlin.io.*
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.fragment_play_controls.*
|
||||
@@ -27,21 +18,18 @@ import kotlinx.android.synthetic.main.fragment_track_details.*
|
||||
import kotlinx.android.synthetic.main.fragment_track_elapsing.*
|
||||
import kotlinx.android.synthetic.main.fragment_track_flow.*
|
||||
|
||||
import org.jetbrains.anko.image
|
||||
import org.jetbrains.anko.imageBitmap
|
||||
|
||||
import com.example.mear.constants.ControlTypes
|
||||
import com.example.mear.listeners.TrackElaspingChange
|
||||
import com.example.mear.playback.service.MusicService
|
||||
import com.example.mear.models.PlayControls
|
||||
import com.example.mear.R
|
||||
import com.example.mear.constants.ControlTypes
|
||||
import com.example.mear.repositories.RepeatRepository
|
||||
import com.example.mear.repositories.ShuffleRepository
|
||||
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
class MainActivity : BaseServiceActivity() {
|
||||
|
||||
private var musicService: MusicService? = null
|
||||
private var musicHandler: Handler? = Handler()
|
||||
private var serviceBinded: Boolean? = false
|
||||
private var repeatOn: Boolean? = false
|
||||
@@ -97,7 +85,7 @@ class MainActivity : AppCompatActivity() {
|
||||
val exMsg = ex.message
|
||||
}
|
||||
}
|
||||
private fun initializeChangeListeners() {
|
||||
override fun initializeChangeListeners() {
|
||||
val newListener = TrackElaspingChange(TrackElapsing)
|
||||
if (musicService != null) {
|
||||
newListener.musicService = musicService
|
||||
@@ -121,6 +109,9 @@ class MainActivity : AppCompatActivity() {
|
||||
RepeatTrack.setOnClickListener {
|
||||
toggleRepeat()
|
||||
}
|
||||
SongView.setOnClickListener {
|
||||
startActivity(Intent(this, SongViewActivity::class.java))
|
||||
}
|
||||
SettingsLink.setOnClickListener {
|
||||
val intent = Intent(this, SettingsActivity::class.java)
|
||||
startActivity(intent)
|
||||
@@ -236,7 +227,7 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
PreviousTrack.isEnabled = true
|
||||
}
|
||||
private fun configureTrackDisplay() {
|
||||
override fun configureTrackDisplay() {
|
||||
try {
|
||||
runOnUiThread {
|
||||
configurePlayControlsDisplay()
|
||||
@@ -275,14 +266,14 @@ class MainActivity : AppCompatActivity() {
|
||||
val msg = ex.message
|
||||
}
|
||||
}
|
||||
private fun resetControls() {
|
||||
override fun resetControls() {
|
||||
TrackTitle!!.text = null
|
||||
ArtistTitle!!.text = null
|
||||
AlbumTitle!!.text = null
|
||||
CurrentPosition!!.text = null
|
||||
TrackCover!!.imageBitmap = null
|
||||
}
|
||||
private fun updateTrackProgress() {
|
||||
override fun updateTrackProgress() {
|
||||
musicHandler!!.postDelayed(musicTrackTimeUpdateTask, 100)
|
||||
}
|
||||
private fun configurePlayControlsDisplay() {
|
||||
@@ -300,17 +291,6 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
|
||||
private fun isServiceRunning(serviceClass: Class<*>): Boolean {
|
||||
val activityManager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
|
||||
|
||||
for (service in activityManager.getRunningServices(Integer.MAX_VALUE)) {
|
||||
if (serviceClass.name == service.service.className) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private var musicTrackTimeUpdateTask = object: Runnable {
|
||||
override fun run() {
|
||||
try {
|
||||
@@ -332,49 +312,4 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val mConnection = object : ServiceConnection {
|
||||
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
||||
resetControls()
|
||||
|
||||
runBlocking {
|
||||
val demo = launch {
|
||||
musicService = (service as MusicService.LocalBinder).service
|
||||
initializeChangeListeners()
|
||||
updateTrackProgress()
|
||||
}
|
||||
demo.start()
|
||||
}
|
||||
if (musicService != null) {
|
||||
if (musicService!!.isPlaying()) {
|
||||
configureTrackDisplay()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onServiceDisconnected(className: ComponentName) {
|
||||
resetControls()
|
||||
Toast.makeText(
|
||||
this@MainActivity, "Music Service Stopped",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun doBindService() {
|
||||
val intent = Intent(this, MusicService::class.java)
|
||||
if (isServiceRunning(MusicService::class.java)) {
|
||||
val suc = "Service is already running"
|
||||
}
|
||||
else {
|
||||
startService(intent)
|
||||
}
|
||||
|
||||
var result = bindService(intent, mConnection, Context.BIND_AUTO_CREATE)
|
||||
if (result) {
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.example.mear.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.widget.LinearLayout
|
||||
|
||||
import kotlinx.android.synthetic.main.activity_song_view.*
|
||||
import kotlinx.android.synthetic.main.content_song_view.*
|
||||
|
||||
import com.example.mear.R
|
||||
import com.example.mear.repositories.TrackRepository
|
||||
|
||||
class SongViewActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_song_view)
|
||||
setSupportActionBar(toolbar)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
}
|
||||
}
|
||||
@@ -21,12 +21,19 @@
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="324dp"
|
||||
android:layout_width="170dp"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/color_background"
|
||||
android:baselineAligned="false"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/SongView"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
tools:srcCompat="@tools:sample/backgrounds/scenic[6]" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/SettingsLink"
|
||||
android:layout_width="0dp"
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context=".activities.SongViewActivity">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/app_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/app_bar_height"
|
||||
android:fitsSystemWindows="true"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.design.widget.CollapsingToolbarLayout
|
||||
android:id="@+id/toolbar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
app:contentScrim="?attr/colorPrimary"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed"
|
||||
app:toolbarId="@+id/toolbar">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_collapseMode="pin"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
|
||||
</android.support.design.widget.CollapsingToolbarLayout>
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<include layout="@layout/content_song_view" />
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:context=".activities.SongViewActivity"
|
||||
tools:showIn="@layout/activity_song_view">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/SongViewList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
@@ -0,0 +1,10 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.example.mear.activities.SongViewActivity">
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/action_settings"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
@@ -5,4 +5,6 @@
|
||||
<dimen name="nav_header_vertical_spacing">8dp</dimen>
|
||||
<dimen name="nav_header_height">176dp</dimen>
|
||||
<dimen name="fab_margin">16dp</dimen>
|
||||
<dimen name="app_bar_height">180dp</dimen>
|
||||
<dimen name="text_margin">16dp</dimen>
|
||||
</resources>
|
||||
@@ -98,4 +98,94 @@
|
||||
<string name="pref_ringtone_silent">Silent</string>
|
||||
|
||||
<string name="pref_title_vibrate">Vibrate</string>
|
||||
<string name="title_activity_song_view">SongViewActivity</string>
|
||||
<string name="large_text">
|
||||
"Material is the metaphor.\n\n"
|
||||
|
||||
"A material metaphor is the unifying theory of a rationalized space and a system of motion."
|
||||
"The material is grounded in tactile reality, inspired by the study of paper and ink, yet "
|
||||
"technologically advanced and open to imagination and magic.\n"
|
||||
"Surfaces and edges of the material provide visual cues that are grounded in reality. The "
|
||||
"use of familiar tactile attributes helps users quickly understand affordances. Yet the "
|
||||
"flexibility of the material creates new affordances that supercede those in the physical "
|
||||
"world, without breaking the rules of physics.\n"
|
||||
"The fundamentals of light, surface, and movement are key to conveying how objects move, "
|
||||
"interact, and exist in space and in relation to each other. Realistic lighting shows "
|
||||
"seams, divides space, and indicates moving parts.\n\n"
|
||||
|
||||
"Bold, graphic, intentional.\n\n"
|
||||
|
||||
"The foundational elements of print based design typography, grids, space, scale, color, "
|
||||
"and use of imagery guide visual treatments. These elements do far more than please the "
|
||||
"eye. They create hierarchy, meaning, and focus. Deliberate color choices, edge to edge "
|
||||
"imagery, large scale typography, and intentional white space create a bold and graphic "
|
||||
"interface that immerse the user in the experience.\n"
|
||||
"An emphasis on user actions makes core functionality immediately apparent and provides "
|
||||
"waypoints for the user.\n\n"
|
||||
|
||||
"Motion provides meaning.\n\n"
|
||||
|
||||
"Motion respects and reinforces the user as the prime mover. Primary user actions are "
|
||||
"inflection points that initiate motion, transforming the whole design.\n"
|
||||
"All action takes place in a single environment. Objects are presented to the user without "
|
||||
"breaking the continuity of experience even as they transform and reorganize.\n"
|
||||
"Motion is meaningful and appropriate, serving to focus attention and maintain continuity. "
|
||||
"Feedback is subtle yet clear. Transitions are efficient yet coherent.\n\n"
|
||||
|
||||
"3D world.\n\n"
|
||||
|
||||
"The material environment is a 3D space, which means all objects have x, y, and z "
|
||||
"dimensions. The z-axis is perpendicularly aligned to the plane of the display, with the "
|
||||
"positive z-axis extending towards the viewer. Every sheet of material occupies a single "
|
||||
"position along the z-axis and has a standard 1dp thickness.\n"
|
||||
"On the web, the z-axis is used for layering and not for perspective. The 3D world is "
|
||||
"emulated by manipulating the y-axis.\n\n"
|
||||
|
||||
"Light and shadow.\n\n"
|
||||
|
||||
"Within the material environment, virtual lights illuminate the scene. Key lights create "
|
||||
"directional shadows, while ambient light creates soft shadows from all angles.\n"
|
||||
"Shadows in the material environment are cast by these two light sources. In Android "
|
||||
"development, shadows occur when light sources are blocked by sheets of material at "
|
||||
"various positions along the z-axis. On the web, shadows are depicted by manipulating the "
|
||||
"y-axis only. The following example shows the card with a height of 6dp.\n\n"
|
||||
|
||||
"Resting elevation.\n\n"
|
||||
|
||||
"All material objects, regardless of size, have a resting elevation, or default elevation "
|
||||
"that does not change. If an object changes elevation, it should return to its resting "
|
||||
"elevation as soon as possible.\n\n"
|
||||
|
||||
"Component elevations.\n\n"
|
||||
|
||||
"The resting elevation for a component type is consistent across apps (e.g., FAB elevation "
|
||||
"does not vary from 6dp in one app to 16dp in another app).\n"
|
||||
"Components may have different resting elevations across platforms, depending on the depth "
|
||||
"of the environment (e.g., TV has a greater depth than mobile or desktop).\n\n"
|
||||
|
||||
"Responsive elevation and dynamic elevation offsets.\n\n"
|
||||
|
||||
"Some component types have responsive elevation, meaning they change elevation in response "
|
||||
"to user input (e.g., normal, focused, and pressed) or system events. These elevation "
|
||||
"changes are consistently implemented using dynamic elevation offsets.\n"
|
||||
"Dynamic elevation offsets are the goal elevation that a component moves towards, relative "
|
||||
"to the component’s resting state. They ensure that elevation changes are consistent "
|
||||
"across actions and component types. For example, all components that lift on press have "
|
||||
"the same elevation change relative to their resting elevation.\n"
|
||||
"Once the input event is completed or cancelled, the component will return to its resting "
|
||||
"elevation.\n\n"
|
||||
|
||||
"Avoiding elevation interference.\n\n"
|
||||
|
||||
"Components with responsive elevations may encounter other components as they move between "
|
||||
"their resting elevations and dynamic elevation offsets. Because material cannot pass "
|
||||
"through other material, components avoid interfering with one another any number of ways, "
|
||||
"whether on a per component basis or using the entire app layout.\n"
|
||||
"On a component level, components can move or be removed before they cause interference. "
|
||||
"For example, a floating action button (FAB) can disappear or move off screen before a "
|
||||
"user picks up a card, or it can move if a snackbar appears.\n"
|
||||
"On the layout level, design your app layout to minimize opportunities for interference. "
|
||||
"For example, position the FAB to one side of stream of a cards so the FAB won’t interfere "
|
||||
"when a user tries to pick up one of cards.\n\n"
|
||||
</string>
|
||||
</resources>
|
||||
+1
-1
@@ -8,7 +8,7 @@ buildscript {
|
||||
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.3.1'
|
||||
classpath 'com.android.tools.build:gradle:3.3.2'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
||||
|
||||
Reference in new issue
Block a user