Track view refactor #46
This commit is contained in:
+16
-16
File diff suppressed because one or more lines are too long
@@ -6,8 +6,12 @@ import android.content.pm.PackageManager
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.R as RDroid
|
||||
import android.support.v4.app.ActivityCompat
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.widget.PopupMenu
|
||||
|
||||
import java.lang.Exception
|
||||
import java.lang.Runnable
|
||||
@@ -64,15 +68,6 @@ class MainActivity : BaseServiceActivity() {
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
try {
|
||||
if (musicService!! != null) {
|
||||
val tr = musicService!!.getCurrentTrack().title
|
||||
val artist = musicService!!.getCurrentTrack().artist
|
||||
}
|
||||
}
|
||||
catch (ex: Exception) {
|
||||
val exMsg = ex.message
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
@@ -128,12 +123,14 @@ class MainActivity : BaseServiceActivity() {
|
||||
RepeatTrack.setOnClickListener {
|
||||
toggleRepeat()
|
||||
}
|
||||
SongView.setOnClickListener {
|
||||
startActivity(Intent(this, SongViewActivity::class.java))
|
||||
}
|
||||
SettingsLink.setOnClickListener {
|
||||
startActivity(Intent(this, SettingsActivity::class.java))
|
||||
val clickListener = View.OnClickListener { view ->
|
||||
when (view.id) {
|
||||
R.id.SettingsLink-> {
|
||||
showPopup(view)
|
||||
}
|
||||
}
|
||||
}
|
||||
SettingsLink.setOnClickListener (clickListener )
|
||||
}
|
||||
private fun initializeServices() {
|
||||
doBindService()
|
||||
@@ -305,6 +302,7 @@ class MainActivity : BaseServiceActivity() {
|
||||
PlayTrack.setColorFilter(Color.GREEN)
|
||||
}
|
||||
}
|
||||
|
||||
private fun permissionPrompt() {
|
||||
if (ContextCompat.checkSelfPermission(this,
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
@@ -318,24 +316,44 @@ class MainActivity : BaseServiceActivity() {
|
||||
arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), 0)
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
|
||||
private fun showPopup(view: View) {
|
||||
try {
|
||||
var popup = PopupMenu(this, view)
|
||||
popup.inflate(R.menu.popup_menu)
|
||||
|
||||
popup.setOnMenuItemClickListener{ item: MenuItem? ->
|
||||
when (item!!.itemId) {
|
||||
R.id.action_settings-> {
|
||||
startActivity(Intent(this, SettingsActivity::class.java))
|
||||
}
|
||||
R.id.action_song_view -> {
|
||||
startActivity(Intent(this, SongViewActivity::class.java))
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
popup.show()
|
||||
}
|
||||
catch (ex: Exception) {
|
||||
val exMsg = ex.message
|
||||
}
|
||||
}
|
||||
|
||||
private var musicTrackTimeUpdateTask = object: Runnable {
|
||||
override fun run() {
|
||||
try {
|
||||
val currentPosition = musicService!!.currentPositionOfTrack() / 1000
|
||||
val dur = String.format( "%02d:%02d",
|
||||
TimeUnit.SECONDS.toMinutes(currentPosition.toLong()),
|
||||
(currentPosition % 60) )
|
||||
val dur = String.format( "%02d:%02d", TimeUnit.SECONDS.toMinutes(currentPosition.toLong()),
|
||||
(currentPosition % 60) )
|
||||
|
||||
CurrentPosition.text = dur
|
||||
|
||||
val tTitle = musicService!!.getCurrentTrack().title
|
||||
val trackTitle = musicService!!.getCurrentTrack().title
|
||||
|
||||
if (!(TrackTitle.text.equals(musicService!!.getCurrentTrack().title))) {
|
||||
if (!(TrackTitle.text == trackTitle)) {
|
||||
configureTrackDisplay()
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 85 B |
Binary file not shown.
|
After Width: | Height: | Size: 81 B |
Binary file not shown.
|
After Width: | Height: | Size: 88 B |
Binary file not shown.
|
After Width: | Height: | Size: 100 B |
Binary file not shown.
|
After Width: | Height: | Size: 116 B |
@@ -12,36 +12,31 @@
|
||||
android:id="@+id/appBarLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
android:theme="@style/AppTheme.AppBarOverlay"
|
||||
app:layout_anchorGravity="top|right|end">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="end"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="170dp"
|
||||
android:layout_width="354dp"
|
||||
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"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/color_background"
|
||||
android:layout_weight="1"
|
||||
android:background="@color/color_background"
|
||||
android:contentDescription="@string/settings_link"
|
||||
app:srcCompat="@android:drawable/ic_menu_manage" />
|
||||
app:srcCompat="@drawable/ic_action_more_vert" />
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item android:id="@+id/action_settings"
|
||||
android:title="@string/settings"
|
||||
app:showAsAction="never"/>
|
||||
<item android:id="@+id/action_song_view"
|
||||
android:title="@string/song_view"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
@@ -9,4 +9,7 @@
|
||||
<!-- Play Controls -->
|
||||
<color name="track_details">#FFFFFF</color>
|
||||
<color name="track_seek">#333399</color>
|
||||
|
||||
<!-- Popup colors -->
|
||||
<color name="popup_text">#FFFFFF</color>
|
||||
</resources>
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
dhdfhfdhdfh
|
||||
</string>
|
||||
|
||||
<!-- Music Player popup strings -->
|
||||
<string name="settings">Settings</string>
|
||||
<string name="song_view">Songs</string>
|
||||
|
||||
<!-- Example General settings -->
|
||||
<string name="pref_header_general">General</string>
|
||||
|
||||
|
||||
@@ -6,6 +6,25 @@
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
|
||||
<item name="android:popupMenuStyle">@style/PopupMenu</item>
|
||||
<item name="android:textAppearanceSmallPopupMenu">@style/myPopupMenuTextAppearanceSmall</item>
|
||||
<item name="android:textAppearanceLargePopupMenu">@style/myPopupMenuTextAppearanceLarge</item>
|
||||
</style>
|
||||
|
||||
<style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
|
||||
<item name="android:popupBackground">@color/color_background</item>
|
||||
</style>
|
||||
|
||||
|
||||
<style name="myPopupMenuTextAppearanceSmall" parent="@android:style/TextAppearance.DeviceDefault.Widget.PopupMenu.Small">
|
||||
<item name="android:textColor">@color/popup_text</item>
|
||||
<item name="android:textSize">16sp</item>
|
||||
</style>
|
||||
|
||||
<style name="myPopupMenuTextAppearanceLarge" parent="@android:style/TextAppearance.DeviceDefault.Widget.PopupMenu.Large">
|
||||
<item name="android:textColor">@color/popup_text</item>
|
||||
<item name="android:textSize">20sp</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
|
||||
Reference in New Issue
Block a user