UI improvements. Completed #14 and #20

This commit is contained in:
amazing-username
2019-03-05 21:39:23 -05:00
parent 4effe37517
commit 48d4ffe5df
21 changed files with 280 additions and 375 deletions
+8
View File
@@ -1,5 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="Mear" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4"> <module external.linked.project.id="Mear" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
<option name="BUILDABLE" value="false" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true"> <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
<exclude-output /> <exclude-output />
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
Binary file not shown.
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RenderSettings">
<option name="showDecorations" value="true" />
</component>
</project>
+7 -1
View File
@@ -14,14 +14,20 @@
<activity <activity
android:name=".activities.SettingsActivity" android:name=".activities.SettingsActivity"
android:label="@string/title_activity_settings" android:label="@string/title_activity_settings"
android:parentActivityName=".activities.MainActivity"> android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.NoActionBar">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.mear.activities.MainActivity" /> android:value="com.example.mear.activities.MainActivity" />
</activity> </activity>
<activity
android:name=".activities.fdh"
android:label="@string/title_activity_settings"
android:screenOrientation="portrait"></activity>
<activity <activity
android:name=".activities.MainActivity" android:name=".activities.MainActivity"
android:label="@string/title_activity_main" android:label="@string/title_activity_main"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"> android:theme="@style/AppTheme.NoActionBar">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@@ -1,29 +1,28 @@
package com.example.mear.activities package com.example.mear.activities
import android.graphics.Color
import android.content.Intent
import android.graphics.BitmapFactory import android.graphics.BitmapFactory
import android.media.MediaPlayer import android.media.MediaPlayer
import android.media.MediaMetadataRetriever import android.media.MediaMetadataRetriever
import android.os.Bundle import android.os.Bundle
import android.os.Environment
import android.support.v7.app.AppCompatActivity import android.support.v7.app.AppCompatActivity
import android.text.format.Time
import com.example.mear.R
import java.lang.Exception import java.lang.Exception
import java.util.concurrent.TimeUnit
import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.content_main.*
import kotlin.io.*
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_play_controls.*
import kotlinx.android.synthetic.main.fragment_track_cover.* import kotlinx.android.synthetic.main.fragment_track_cover.*
import kotlinx.android.synthetic.main.fragment_track_details.* import kotlinx.android.synthetic.main.fragment_track_details.*
import kotlinx.android.synthetic.main.fragment_track_elapsing.* import kotlinx.android.synthetic.main.fragment_track_elapsing.*
import kotlinx.android.synthetic.main.fragment_track_flow.* import kotlinx.android.synthetic.main.fragment_track_flow.*
import java.util.concurrent.TimeUnit import kotlin.io.*
import kotlin.random.Random
import com.example.mear.R
import com.example.mear.repositories.TrackRepository
import org.jetbrains.anko.image
class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() {
@@ -32,8 +31,6 @@ class MainActivity : AppCompatActivity() {
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)
setSupportActionBar(toolbar) setSupportActionBar(toolbar)
//loadTracks(loadSongPaths())
initialize() initialize()
} }
@@ -59,6 +56,18 @@ class MainActivity : AppCompatActivity() {
ShuffleTracks.setOnClickListener { ShuffleTracks.setOnClickListener {
toggleShuffle() toggleShuffle()
} }
SettingsLink.setOnClickListener {
val intent = Intent(this, SettingsActivity::class.java)
try {
startActivity(intent)
}
catch (ex: Exception) {
val exMsg = ex.message
println(exMsg)
}
}
} }
private fun initializeCompletionListener() { private fun initializeCompletionListener() {
trackPlayer!!.setOnCompletionListener { trackPlayer!!.setOnCompletionListener {
@@ -100,10 +109,10 @@ class MainActivity : AppCompatActivity() {
try { try {
if (!trackPlayer!!.isPlaying) { if (!trackPlayer!!.isPlaying) {
trackPlayer!!.start() trackPlayer!!.start()
configureTrackDisplay()
} else { } else {
trackPlayer!!.pause() trackPlayer!!.pause()
} }
configureTrackDisplay()
} }
catch (ex: Exception) { catch (ex: Exception) {
val exMsg = ex.message val exMsg = ex.message
@@ -153,39 +162,53 @@ class MainActivity : AppCompatActivity() {
PreviousTrack.isEnabled = true PreviousTrack.isEnabled = true
} }
private fun configureTrackDisplay() { private fun configureTrackDisplay() {
configurePlayControlsDisplay()
val currTrack = TrackRepository(this).getTrack(currentSong!!) val currTrack = TrackRepository(this).getTrack(currentSong!!)
val trackTitle = currTrack.title val trackTitle = currTrack.title
val artistTitle = currTrack.artist val artistTitle = currTrack.artist
val albumTitle = currTrack.album val albumTitle = currTrack.album
var trackDuration = currTrack.length val trackDuration = currTrack.length
var trackCover: ByteArray? = null var trackCover: ByteArray? = null
val dur = String.format("%02d:%02d", TimeUnit.SECONDS.toMinutes(trackDuration.toLong()), val dur = String.format("%02d:%02d", TimeUnit.SECONDS.toMinutes(trackDuration.toLong()),
(trackDuration % 60) (trackDuration % 60)
) )
var mmr = MediaMetadataRetriever() val mmr = MediaMetadataRetriever()
mmr.setDataSource(currTrack.songPath) mmr.setDataSource(currTrack.songPath)
if (mmr.embeddedPicture != null) { if (mmr.embeddedPicture != null) {
trackCover = mmr.embeddedPicture trackCover = mmr.embeddedPicture
} }
TrackTitle.setText(null) TrackTitle.text = null
ArtistTitle.setText(null) ArtistTitle.text = null
AlbumTitle.setText(null) AlbumTitle.text = null
CurrentPosition.setText(null) CurrentPosition.text = null
TrackCover.setImageBitmap(null) TrackCover.setImageBitmap(null)
TrackTitle.setText(trackTitle) TrackTitle.text = trackTitle
ArtistTitle.setText(artistTitle) ArtistTitle.text = artistTitle
AlbumTitle.setText(albumTitle) AlbumTitle.text = albumTitle
TrackDuration.setText(dur) TrackDuration.text = dur
if (trackCover != null) { if (trackCover != null) {
val songImage = BitmapFactory val songImage = BitmapFactory
.decodeByteArray(trackCover, 0, trackCover.size) .decodeByteArray(trackCover, 0, trackCover.size)
TrackCover.setImageBitmap(songImage) TrackCover.setImageBitmap(songImage)
} }
} }
private fun configurePlayControlsDisplay() {
PlayTrack.background = null
PlayTrack.colorFilter = null
if (!trackPlayer!!.isPlaying) {
PlayTrack.setImageResource(android.R.drawable.ic_media_pause)
PlayTrack.setColorFilter(Color.RED)
}
else {
PlayTrack.setImageResource(android.R.drawable.ic_media_play)
PlayTrack.setColorFilter(Color.GREEN)
}
}
private fun fetchSongIndex(playType: PlayTypes): Int { private fun fetchSongIndex(playType: PlayTypes): Int {
var songIndex: Int? = null var songIndex: Int? = null
@@ -227,33 +250,11 @@ class MainActivity : AppCompatActivity() {
return songIndex!! return songIndex!!
} }
private fun loadSongPaths(): MutableList<String> {
val demoPath = Environment.getExternalStorageDirectory()
val mfPaths = MusicFiles(demoPath)
mfPaths.loadAllMusicPaths()
val allSongs = mfPaths.allSongs
return allSongs!!
}
private fun loadTracks(allSongs: MutableList<String>) {
try {
val trackMgr = TrackManager(allSongs)
songCount = trackMgr.configureTracks(this)
songCount = TrackRepository(this).getSongCount()
currentSong = fetchSongIndex(PlayTypes.PlaySong)
}
catch (ex: Exception) {
val exMsg = ex.message
}
}
private var trackPlayer: MediaPlayer? = null private var trackPlayer: MediaPlayer? = null
private var currentSong: Int? = null private var currentSong: Int? = null
private var playerInitialized: Boolean? = null private var playerInitialized: Boolean? = false
private var shuffleOn: Boolean? = null private var shuffleOn: Boolean? = false
private var songCount: Int? = null private var songCount: Int? = null
private enum class PlayTypes { private enum class PlayTypes {
@@ -1,255 +1,56 @@
package com.example.mear.activities package com.example.mear.activities
import android.annotation.TargetApi
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.media.RingtoneManager
import android.net.Uri
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.preference.ListPreference import android.os.Environment
import android.preference.Preference import android.support.v7.app.AppCompatActivity;
import android.preference.PreferenceActivity
import android.preference.PreferenceFragment
import android.preference.PreferenceManager
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
/** import java.lang.Exception
* A [PreferenceActivity] that presents a set of application settings. On import kotlinx.android.synthetic.main.activity_settings.*
* handset devices, settings are presented as a single list. On tablets, import kotlinx.android.synthetic.main.content_settings.*
* settings are split by category, with category headers shown to the left of
* the list of settings. import com.example.mear.R
* import com.example.mear.management.MusicFiles
* See [Android Design: Settings](http://developer.android.com/design/patterns/settings.html) import com.example.mear.management.TrackManager
* for design guidelines and the [Settings API Guide](http://developer.android.com/guide/topics/ui/settings.html) import com.example.mear.repositories.TrackRepository
* for more information on developing a Settings UI.
*/
class SettingsActivity : AppCompatPreferenceActivity() {
class SettingsActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setupActionBar() setContentView(R.layout.activity_settings)
setSupportActionBar(toolbar)
RefreshLibrary.setOnClickListener {
updateLibrary()
} }
/**
* Set up the [android.app.ActionBar], if the API is available.
*/
private fun setupActionBar() {
supportActionBar?.setDisplayHomeAsUpEnabled(true) supportActionBar?.setDisplayHomeAsUpEnabled(true)
} }
override fun onMenuItemSelected(featureId: Int, item: MenuItem): Boolean {
val id = item.itemId
if (id == android.R.id.home) {
if (!super.onMenuItemSelected(featureId, item)) {
NavUtils.navigateUpFromSameTask(this)
}
return true
}
return super.onMenuItemSelected(featureId, item)
}
/** private fun loadSongPaths(): MutableList<String> {
* {@inheritDoc} val demoPath = Environment.getExternalStorageDirectory()
*/ val mfPaths = MusicFiles(demoPath)
override fun onIsMultiPane(): Boolean { mfPaths.loadAllMusicPaths()
return isXLargeTablet(this) val allSongs = mfPaths.allSongs
}
/** return allSongs!!
* {@inheritDoc}
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
override fun onBuildHeaders(target: List<PreferenceActivity.Header>) {
loadHeadersFromResource(R.xml.pref_headers, target)
} }
private fun loadTracks(allSongs: MutableList<String>) {
/** try {
* This method stops fragment injection in malicious applications. TrackRepository(this).delete()
* Make sure to deny any unknown fragments here. val trackMgr = TrackManager(allSongs)
*/
override fun isValidFragment(fragmentName: String): Boolean {
return PreferenceFragment::class.java.name == fragmentName
|| GeneralPreferenceFragment::class.java.name == fragmentName
|| DataSyncPreferenceFragment::class.java.name == fragmentName
|| NotificationPreferenceFragment::class.java.name == fragmentName
} }
catch (ex: Exception) {
/** val exMsg = ex.message
* This fragment shows general preferences only. It is used when the
* activity is showing a two-pane settings UI.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
class GeneralPreferenceFragment : PreferenceFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
addPreferencesFromResource(R.xml.pref_general)
setHasOptionsMenu(true)
// Bind the summaries of EditText/List/Dialog/Ringtone preferences
// to their values. When their values change, their summaries are
// updated to reflect the new value, per the Android Design
// guidelines.
bindPreferenceSummaryToValue(findPreference("example_text"))
bindPreferenceSummaryToValue(findPreference("example_list"))
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
val id = item.itemId
if (id == android.R.id.home) {
startActivity(Intent(activity, SettingsActivity::class.java))
return true
}
return super.onOptionsItemSelected(item)
} }
} }
/**
* This fragment shows notification preferences only. It is used when the
* activity is showing a two-pane settings UI.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
class NotificationPreferenceFragment : PreferenceFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
addPreferencesFromResource(R.xml.pref_notification)
setHasOptionsMenu(true)
// Bind the summaries of EditText/List/Dialog/Ringtone preferences
// to their values. When their values change, their summaries are
// updated to reflect the new value, per the Android Design
// guidelines.
bindPreferenceSummaryToValue(findPreference("notifications_new_message_ringtone"))
}
override fun onOptionsItemSelected(item: MenuItem): Boolean { private fun updateLibrary() {
val id = item.itemId loadTracks(loadSongPaths())
if (id == android.R.id.home) {
startActivity(Intent(activity, SettingsActivity::class.java))
return true
}
return super.onOptionsItemSelected(item)
}
}
/**
* This fragment shows data and sync preferences only. It is used when the
* activity is showing a two-pane settings UI.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
class DataSyncPreferenceFragment : PreferenceFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
addPreferencesFromResource(R.xml.pref_data_sync)
setHasOptionsMenu(true)
// Bind the summaries of EditText/List/Dialog/Ringtone preferences
// to their values. When their values change, their summaries are
// updated to reflect the new value, per the Android Design
// guidelines.
bindPreferenceSummaryToValue(findPreference("sync_frequency"))
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
val id = item.itemId
if (id == android.R.id.home) {
startActivity(Intent(activity, SettingsActivity::class.java))
return true
}
return super.onOptionsItemSelected(item)
}
}
companion object {
/**
* A preference value change listener that updates the preference's summary
* to reflect its new value.
*/
private val sBindPreferenceSummaryToValueListener = Preference.OnPreferenceChangeListener { preference, value ->
val stringValue = value.toString()
if (preference is ListPreference) {
// For list preferences, look up the correct display value in
// the preference's 'entries' list.
val listPreference = preference
val index = listPreference.findIndexOfValue(stringValue)
// Set the summary to reflect the new value.
preference.setSummary(
if (index >= 0)
listPreference.entries[index]
else
null
)
} else if (preference is RingtonePreference) {
// For ringtone preferences, look up the correct display value
// using RingtoneManager.
if (TextUtils.isEmpty(stringValue)) {
// Empty values correspond to 'silent' (no ringtone).
preference.setSummary(R.string.pref_ringtone_silent)
} else {
val ringtone = RingtoneManager.getRingtone(
preference.getContext(), Uri.parse(stringValue)
)
if (ringtone == null) {
// Clear the summary if there was a lookup error.
preference.setSummary(null)
} else {
// Set the summary to reflect the new ringtone display
// name.
val name = ringtone.getTitle(preference.getContext())
preference.setSummary(name)
}
}
} else {
// For all other preferences, set the summary to the value's
// simple string representation.
preference.summary = stringValue
}
true
}
/**
* Helper method to determine if the device has an extra-large screen. For
* example, 10" tablets are extra-large.
*/
private fun isXLargeTablet(context: Context): Boolean {
return context.resources.configuration.screenLayout and Configuration.SCREENLAYOUT_SIZE_MASK >= Configuration.SCREENLAYOUT_SIZE_XLARGE
}
/**
* Binds a preference's summary to its value. More specifically, when the
* preference's value is changed, its summary (line of text below the
* preference title) is updated to reflect the value. The summary is also
* immediately updated upon calling this method. The exact display format is
* dependent on the type of preference.
* @see .sBindPreferenceSummaryToValueListener
*/
private fun bindPreferenceSummaryToValue(preference: Preference) {
// Set the listener to watch for value changes.
preference.onPreferenceChangeListener =
sBindPreferenceSummaryToValueListener
// Trigger the listener immediately with the preference's
// current value.
sBindPreferenceSummaryToValueListener.onPreferenceChange(
preference,
PreferenceManager
.getDefaultSharedPreferences(preference.context)
.getString(preference.key, "")
)
}
} }
} }
@@ -42,7 +42,7 @@ class DatabaseManager(ctx: Context): ManagedSQLiteOpenHelper(ctx, "Mear",
"TrackId" to INTEGER "TrackId" to INTEGER
) )
db!!.createTable( db!!.createTable(
"Settings", true, "SettingsActivity", true,
"Id" to INTEGER + PRIMARY_KEY + UNIQUE, "Id" to INTEGER + PRIMARY_KEY + UNIQUE,
"DarkTheme" to org.jetbrains.anko.db.REAL "DarkTheme" to org.jetbrains.anko.db.REAL
) )
@@ -56,7 +56,7 @@ class DatabaseManager(ctx: Context): ManagedSQLiteOpenHelper(ctx, "Mear",
db!!.dropTable("Track") db!!.dropTable("Track")
db!!.dropTable("TrackCount") db!!.dropTable("TrackCount")
db!!.dropTable("PlayCount") db!!.dropTable("PlayCount")
db!!.dropTable("Settings") db!!.dropTable("SettingsActivity")
} }
catch (ex: Exception) { catch (ex: Exception) {
@@ -42,16 +42,6 @@ class TrackManager(var allSongPath: MutableList<String>) {
} }
return id.dec() return id.dec()
} }
fun dumpToDatabase(ctx: Context) {
TrackRepository(ctx).delete()
for (songData in allTracks!!) {
TrackRepository(ctx).insertTrack(songData)
allTracks!!.removeAt(songData.id )
}
}
fun deleteTable(ctx: Context) {
TrackRepository(ctx).delete()
}
private fun dumpToDatabase(ctx: Context, track: Track) { private fun dumpToDatabase(ctx: Context, track: Track) {
TrackRepository(ctx).insertTrack(track) TrackRepository(ctx).insertTrack(track)
PlayCountRepository(ctx).insertPlayCount(track) PlayCountRepository(ctx).insertPlayCount(track)
@@ -9,7 +9,7 @@ import com.example.mear.models.Settings
class SettingRepository(val context: Context) { class SettingRepository(val context: Context) {
fun getSettings(id: Int): Settings = context.database.use { fun getSettings(id: Int): Settings = context.database.use {
select("Settings").where("Id = $id") select("SettingsActivity").where("Id = $id")
.parseSingle(object: MapRowParser<Settings>{ .parseSingle(object: MapRowParser<Settings>{
override fun parseRow(columns: Map<String, Any?>): Settings { override fun parseRow(columns: Map<String, Any?>): Settings {
val id = columns.getValue("Id").toString().toInt() val id = columns.getValue("Id").toString().toInt()
@@ -22,20 +22,20 @@ class SettingRepository(val context: Context) {
}) })
} }
fun insertSettings(settings: Settings) = context.database.use { fun insertSettings(settings: Settings) = context.database.use {
insert("Settings", insert("SettingsActivity",
"Id" to settings.id, "Id" to settings.id,
"DarkTheme" to false) "DarkTheme" to false)
} }
fun updateSettings(settings: Settings) = context.database.use { fun updateSettings(settings: Settings) = context.database.use {
update("Settings", update("SettingsActivity",
"DarkTheme" to settings.darkTheme) "DarkTheme" to settings.darkTheme)
.where("Id = {settingId}", "settingId" to settings.id).exec() .where("Id = {settingId}", "settingId" to settings.id).exec()
} }
fun delete(table: Settings?) = context.database.use { fun delete(table: Settings?) = context.database.use {
delete("Settings", whereClause = "id = {$table.id}") delete("SettingsActivity", whereClause = "id = {$table.id}")
} }
fun delete() = context.database.use { fun delete() = context.database.use {
delete("Settings") delete("SettingsActivity")
} }
} }
+21 -3
View File
@@ -8,19 +8,37 @@
tools:context=".activities.MainActivity"> tools:context=".activities.MainActivity">
<android.support.design.widget.AppBarLayout <android.support.design.widget.AppBarLayout
android:layout_height="wrap_content" android:id="@+id/appBarLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<android.support.v7.widget.Toolbar <android.support.v7.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="324dp"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" android:background="?attr/colorPrimary"
android:baselineAligned="false"
app:popupTheme="@style/AppTheme.PopupOverlay" /> app:popupTheme="@style/AppTheme.PopupOverlay" />
<ImageButton
android:id="@+id/SettingsLink"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:contentDescription="@string/settings_link"
app:srcCompat="@android:drawable/ic_menu_manage" />
</LinearLayout>
</android.support.design.widget.AppBarLayout> </android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main"/> <include
android:id="@+id/include"
layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout> </android.support.design.widget.CoordinatorLayout>
@@ -1,5 +0,0 @@
<?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>
@@ -0,0 +1,25 @@
<?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"
tools:context=".activities.SettingsActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_settings" />
</android.support.design.widget.CoordinatorLayout>
+1
View File
@@ -21,4 +21,5 @@
<include <include
layout="@layout/fragment_play_controls" layout="@layout/fragment_play_controls"
app:layout_constraintEnd_toEndOf="parent" /> app:layout_constraintEnd_toEndOf="parent" />
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>
@@ -0,0 +1,34 @@
<?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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".activities.SettingsActivity"
tools:showIn="@layout/activity_settings">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/dm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/RefreshLibrary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:lineSpacingExtra="12sp"
android:text="@string/update_library"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</FrameLayout>
</android.support.constraint.ConstraintLayout>
@@ -5,36 +5,42 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<Button <ImageButton
android:id="@+id/PreviousTrack" android:id="@+id/PreviousTrack"
android:layout_width="wrap_content" android:layout_width="66dp"
android:layout_height="wrap_content" android:layout_height="66dp"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:text="@string/previous_button" android:background="@android:drawable/screen_background_light_transparent"
android:tint="@color/colorPrimaryDark"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent"
app:srcCompat="@android:drawable/ic_media_previous" />
<Button <ImageButton
android:id="@+id/PlayTrack" android:id="@+id/PlayTrack"
android:layout_width="wrap_content" android:layout_width="66dp"
android:layout_height="wrap_content" android:layout_height="66dp"
android:layout_marginStart="64dp" android:layout_marginStart="96dp"
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_marginEnd="8dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:text="@string/next_button" android:background="@android:drawable/screen_background_light_transparent"
android:tint="@color/color_player_not_initialized"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/NextTrack"
app:layout_constraintHorizontal_bias="0.021"
app:layout_constraintStart_toEndOf="@+id/PreviousTrack"
app:srcCompat="@android:drawable/ic_media_play" />
<ImageButton
android:id="@+id/NextTrack"
android:layout_width="66dp"
android:layout_height="66dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@android:drawable/screen_background_light_transparent"
android:tint="@color/colorPrimaryDark"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.864" app:srcCompat="@android:drawable/ic_media_next" />
app:layout_constraintStart_toEndOf="@+id/PlayTrack" />
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>
@@ -6,34 +6,35 @@
<SeekBar <SeekBar
android:id="@+id/seekBar2" android:id="@+id/seekBar2"
android:layout_width="261dp" android:layout_width="284dp"
android:layout_height="27dp" android:layout_height="26dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/TrackDuration" app:layout_constraintEnd_toStartOf="@+id/TrackDuration"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.889" /> app:layout_constraintVertical_bias="0.869" />
<TextView <TextView
android:id="@+id/CurrentPosition" android:id="@+id/CurrentPosition"
android:layout_width="63dp" android:layout_width="50dp"
android:layout_height="22dp" android:layout_height="22dp"
android:layout_marginStart="4dp" android:layout_marginStart="4dp"
android:layout_marginBottom="84dp" android:layout_marginBottom="84dp"
android:text="TextView" android:text="@string/track_start"
android:textAlignment="viewStart" android:textAlignment="viewStart"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
<TextView <TextView
android:id="@+id/TrackDuration" android:id="@+id/TrackDuration"
android:layout_width="63dp" android:layout_width="50dp"
android:layout_height="22dp" android:layout_height="22dp"
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp"
android:layout_marginBottom="84dp" android:layout_marginBottom="84dp"
android:text="TextView" android:text="@string/track_end"
android:textAlignment="textEnd"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" /> app:layout_constraintEnd_toEndOf="parent" />
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>
@@ -11,7 +11,7 @@
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:text="S" android:text="@string/shuffle_off"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/RepeatTrack" app:layout_constraintEnd_toStartOf="@+id/RepeatTrack"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
@@ -24,7 +24,7 @@
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:text="R" android:text="ROff"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
+3 -2
View File
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="colorPrimary">#008577</color> <color name="colorPrimary">#6A6A6A</color>
<color name="colorPrimaryDark">#00574B</color> <color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color> <color name="colorAccent">#ED0057</color>
<color name="color_player_not_initialized">#585858</color>
</resources> </resources>
+13 -4
View File
@@ -6,17 +6,26 @@
<string name="nav_header_subtitle">android.studio@android.com</string> <string name="nav_header_subtitle">android.studio@android.com</string>
<string name="nav_header_desc">Navigation header</string> <string name="nav_header_desc">Navigation header</string>
<string name="action_settings">Settings</string> <string name="action_settings">Settings</string>
<string name="title_activity_main">MainActivity</string> <string name="title_activity_main">Mear</string>
<string name="shuffle_on">Shuffle On</string> <string name="shuffle_on">SOn</string>
<string name="shuffle_off">Shuffle Off</string> <string name="shuffle_off">SOff</string>
<string name="title_activity_settings">Settings</string> <string name="title_activity_settings">Settings</string>
<string name="track_start">0:00</string>
<string name="track_end">0:00</string>
<string name="play_button">Play</string> <string name="play_button">Play</string>
<string name="next_button">Next</string> <string name="next_button">Next</string>
<string name="previous_button">Previous</string> <string name="previous_button">Previous</string>
<string name="settings_link">Settings list</string>
<!-- Strings related to Settings --> <!-- Strings related to SettingsActivity -->
<string name="update_library">Update Music Library</string>
<string name="update_library_description">Clear your music databas
e and search for musiczf
dhdfhfdhdfh
</string>
<!-- Example General settings --> <!-- Example General settings -->
<string name="pref_header_general">General</string> <string name="pref_header_general">General</string>
+3
View File
@@ -7,11 +7,14 @@
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>
</style> </style>
<style name="AppTheme.NoActionBar"> <style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item> <item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item> <item name="windowNoTitle">true</item>
</style> </style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources> </resources>
+3 -3
View File
@@ -3,17 +3,17 @@
<!-- These settings headers are only used on tablets. --> <!-- These settings headers are only used on tablets. -->
<header <header
android:fragment="com.example.mear.activities.SettingsActivity$GeneralPreferenceFragment" android:fragment="com.example.mear.activities.fdh$GeneralPreferenceFragment"
android:title="@string/pref_header_general" android:title="@string/pref_header_general"
android:icon="@drawable/ic_info_black_24dp"/> android:icon="@drawable/ic_info_black_24dp"/>
<header <header
android:fragment="com.example.mear.activities.SettingsActivity$NotificationPreferenceFragment" android:fragment="com.example.mear.activities.fdh$NotificationPreferenceFragment"
android:title="@string/pref_header_notifications" android:title="@string/pref_header_notifications"
android:icon="@drawable/ic_notifications_black_24dp"/> android:icon="@drawable/ic_notifications_black_24dp"/>
<header <header
android:fragment="com.example.mear.activities.SettingsActivity$DataSyncPreferenceFragment" android:fragment="com.example.mear.activities.fdh$DataSyncPreferenceFragment"
android:title="@string/pref_header_data_sync" android:title="@string/pref_header_data_sync"
android:icon="@drawable/ic_sync_black_24dp"/> android:icon="@drawable/ic_sync_black_24dp"/>