UI Improvements, added artist display for track, added track duration
This commit is contained in:
@@ -12,15 +12,15 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".SettingsActivity"
|
||||
android:name=".activities.SettingsActivity"
|
||||
android:label="@string/title_activity_settings"
|
||||
android:parentActivityName=".MainActivity">
|
||||
android:parentActivityName=".activities.MainActivity">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.example.mear.MainActivity"/>
|
||||
android:value="com.example.mear.activities.MainActivity"/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:name=".activities.MainActivity"
|
||||
android:label="@string/title_activity_main"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
|
||||
+20
-3
@@ -1,4 +1,4 @@
|
||||
package com.example.mear
|
||||
package com.example.mear.activities
|
||||
|
||||
import android.graphics.BitmapFactory
|
||||
import android.media.MediaPlayer
|
||||
@@ -6,6 +6,8 @@ import android.media.MediaMetadataRetriever
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.text.format.Time
|
||||
import com.example.mear.R
|
||||
|
||||
import java.lang.Exception
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
@@ -16,6 +18,12 @@ import kotlin.random.Random
|
||||
import com.example.mear.management.MusicFiles
|
||||
import com.example.mear.management.TrackManager
|
||||
import com.example.mear.repositories.TrackRepository
|
||||
import kotlinx.android.synthetic.main.fragment_play_controls.*
|
||||
import kotlinx.android.synthetic.main.fragment_track_cover.*
|
||||
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 java.util.concurrent.TimeUnit
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
@@ -147,8 +155,13 @@ class MainActivity : AppCompatActivity() {
|
||||
private fun configureTrackDisplay() {
|
||||
val currTrack = TrackRepository(this).getTrack(currentSong!!)
|
||||
val trackTitle = currTrack.title
|
||||
val artistTitle = currTrack.artist
|
||||
val albumTitle = currTrack.album
|
||||
var trackDuration = currTrack.length
|
||||
var trackCover: ByteArray? = null
|
||||
val dur = String.format("%02d:%02d", TimeUnit.SECONDS.toMinutes(trackDuration.toLong()),
|
||||
(trackDuration % 60)
|
||||
)
|
||||
|
||||
var mmr = MediaMetadataRetriever()
|
||||
mmr.setDataSource(currTrack.songPath)
|
||||
@@ -157,12 +170,16 @@ class MainActivity : AppCompatActivity() {
|
||||
trackCover = mmr.embeddedPicture
|
||||
}
|
||||
|
||||
TrackTitle.text.clear()
|
||||
AlbumTitle.text.clear()
|
||||
TrackTitle.setText(null)
|
||||
ArtistTitle.setText(null)
|
||||
AlbumTitle.setText(null)
|
||||
CurrentPosition.setText(null)
|
||||
TrackCover.setImageBitmap(null)
|
||||
|
||||
TrackTitle.setText(trackTitle)
|
||||
ArtistTitle.setText(artistTitle)
|
||||
AlbumTitle.setText(albumTitle)
|
||||
TrackDuration.setText(dur)
|
||||
if (trackCover != null) {
|
||||
val songImage = BitmapFactory
|
||||
.decodeByteArray(trackCover, 0, trackCover.size)
|
||||
+5
-2
@@ -1,4 +1,4 @@
|
||||
package com.example.mear
|
||||
package com.example.mear.activities
|
||||
|
||||
import android.annotation.TargetApi
|
||||
import android.content.Context
|
||||
@@ -17,6 +17,8 @@ import android.preference.RingtonePreference
|
||||
import android.text.TextUtils
|
||||
import android.view.MenuItem
|
||||
import android.support.v4.app.NavUtils
|
||||
import com.example.mear.AppCompatPreferenceActivity
|
||||
import com.example.mear.R
|
||||
|
||||
/**
|
||||
* A [PreferenceActivity] that presents a set of application settings. On
|
||||
@@ -237,7 +239,8 @@ class SettingsActivity : AppCompatPreferenceActivity() {
|
||||
*/
|
||||
private fun bindPreferenceSummaryToValue(preference: Preference) {
|
||||
// Set the listener to watch for value changes.
|
||||
preference.onPreferenceChangeListener = sBindPreferenceSummaryToValueListener
|
||||
preference.onPreferenceChangeListener =
|
||||
sBindPreferenceSummaryToValueListener
|
||||
|
||||
// Trigger the listener immediately with the preference's
|
||||
// current value.
|
||||
@@ -5,7 +5,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
tools:context=".activities.MainActivity">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent">
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -1,76 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:showIn="@layout/activity_main"
|
||||
tools:context=".MainActivity">
|
||||
<android.support.constraint.ConstraintLayout 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.MainActivity"
|
||||
tools:showIn="@layout/activity_main">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" tools:layout_editor_absoluteY="16dp"
|
||||
tools:layout_editor_absoluteX="0dp">
|
||||
<ImageView
|
||||
tools:srcCompat="@tools:sample/backgrounds/scenic[2]"
|
||||
android:id="@+id/TrackCover" android:layout_height="269dp"
|
||||
android:layout_width="match_parent"/>
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textPersonName"
|
||||
android:text="Track Title"
|
||||
android:ems="10"
|
||||
android:id="@+id/TrackTitle"/>
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textPersonName"
|
||||
android:text="Album Title"
|
||||
android:ems="10"
|
||||
android:id="@+id/AlbumTitle"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<Button
|
||||
android:text="Shuffle"
|
||||
android:layout_height="wrap_content" android:id="@+id/ShuffleTracks" android:layout_weight="1"
|
||||
android:layout_width="21dp"/>
|
||||
<Button
|
||||
android:text="Repeat"
|
||||
android:layout_height="wrap_content" android:id="@+id/RepeatList" android:layout_weight="1"
|
||||
android:layout_width="1dp"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent" android:layout_height="wrap_content">
|
||||
<SeekBar
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/TrackProgress" android:layout_weight="1" android:layout_height="50dp"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<Button
|
||||
android:text="Previous"
|
||||
android:baselineAligned="false" android:layout_height="match_parent"
|
||||
android:layout_width="111dp" android:id="@+id/PreviousTrack"/>
|
||||
<Button
|
||||
android:text="Play"
|
||||
android:id="@+id/PlayTrack" android:layout_width="135dp" android:layout_height="match_parent"/>
|
||||
<Button
|
||||
android:text="Next"
|
||||
android:layout_height="match_parent" android:id="@+id/NextTrack" android:layout_width="162dp"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<include
|
||||
layout="@layout/fragment_track_cover"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<include layout="@layout/fragment_track_details" />
|
||||
|
||||
<include layout="@layout/fragment_track_flow" />
|
||||
|
||||
<include layout="@layout/fragment_track_elapsing" />
|
||||
|
||||
<include
|
||||
layout="@layout/fragment_play_controls"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout 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">
|
||||
|
||||
<Button
|
||||
android:id="@+id/PreviousTrack"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="@string/previous_button"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/PlayTrack"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="64dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="@string/play_button"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/PreviousTrack" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/NextTrack"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="@string/next_button"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.864"
|
||||
app:layout_constraintStart_toEndOf="@+id/PlayTrack" />
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout 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">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/TrackCover"
|
||||
android:layout_width="392dp"
|
||||
android:layout_height="316dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.333"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.095"
|
||||
tools:srcCompat="@tools:sample/backgrounds/scenic[1]" />
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout 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">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/TrackTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="388dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:text="TextView"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.498"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/ArtistTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:text="TextView"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.498"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/TrackTitle" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/AlbumTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="240dp"
|
||||
android:text="TextView"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.498"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/ArtistTitle"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout 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">
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/seekBar2"
|
||||
android:layout_width="261dp"
|
||||
android:layout_height="27dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/TrackDuration"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.889" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/CurrentPosition"
|
||||
android:layout_width="63dp"
|
||||
android:layout_height="22dp"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginBottom="84dp"
|
||||
android:text="TextView"
|
||||
android:textAlignment="viewStart"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/TrackDuration"
|
||||
android:layout_width="63dp"
|
||||
android:layout_height="22dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="84dp"
|
||||
android:text="TextView"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout 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">
|
||||
|
||||
<Button
|
||||
android:id="@+id/ShuffleTracks"
|
||||
android:layout_width="62dp"
|
||||
android:layout_height="47dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="S"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/RepeatTrack"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.826" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/RepeatTrack"
|
||||
android:layout_width="62dp"
|
||||
android:layout_height="47dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="R"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.826" />
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -12,6 +12,10 @@
|
||||
<string name="shuffle_off">Shuffle Off</string>
|
||||
<string name="title_activity_settings">Settings</string>
|
||||
|
||||
<string name="play_button">Play</string>
|
||||
<string name="next_button">Next</string>
|
||||
<string name="previous_button">Previous </string>
|
||||
|
||||
<!-- Strings related to Settings -->
|
||||
|
||||
<!-- Example General settings -->
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
<!-- These settings headers are only used on tablets. -->
|
||||
|
||||
<header
|
||||
android:fragment="com.example.mear.SettingsActivity$GeneralPreferenceFragment"
|
||||
android:fragment="com.example.mear.activities.SettingsActivity$GeneralPreferenceFragment"
|
||||
android:title="@string/pref_header_general"
|
||||
android:icon="@drawable/ic_info_black_24dp"/>
|
||||
|
||||
<header
|
||||
android:fragment="com.example.mear.SettingsActivity$NotificationPreferenceFragment"
|
||||
android:fragment="com.example.mear.activities.SettingsActivity$NotificationPreferenceFragment"
|
||||
android:title="@string/pref_header_notifications"
|
||||
android:icon="@drawable/ic_notifications_black_24dp"/>
|
||||
|
||||
<header
|
||||
android:fragment="com.example.mear.SettingsActivity$DataSyncPreferenceFragment"
|
||||
android:fragment="com.example.mear.activities.SettingsActivity$DataSyncPreferenceFragment"
|
||||
android:title="@string/pref_header_data_sync"
|
||||
android:icon="@drawable/ic_sync_black_24dp"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user