From 826092f1540fdd0cf405125dd2d8203abc329006 Mon Sep 17 00:00:00 2001 From: Derin Arda Alpay Date: Thu, 12 May 2022 14:34:52 +0200 Subject: [PATCH 1/7] Edited downloadActivity to store the API call result --- .../sdp/vibester/activity/DownloadActivity.kt | 18 ++++++++++++++++++ app/src/main/res/layout/activity_download.xml | 17 +++++++++++++---- app/src/main/res/values/strings.xml | 1 + 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/ch/sdp/vibester/activity/DownloadActivity.kt b/app/src/main/java/ch/sdp/vibester/activity/DownloadActivity.kt index a6d005053..dd9c1c96a 100644 --- a/app/src/main/java/ch/sdp/vibester/activity/DownloadActivity.kt +++ b/app/src/main/java/ch/sdp/vibester/activity/DownloadActivity.kt @@ -204,8 +204,26 @@ class DownloadActivity : AppCompatActivity() { records.createNewFile() } records.appendText("$songName\n") + recordProperties() } + /** + * Records the properties of a song. + * Order of storage: Track name - artist name - artwork URL - preview URL. + */ + private fun recordProperties() { + var properties = File(applicationContext.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), "properties.txt") + + if(!properties.exists()) { + properties.createNewFile() + } + + val trackName = song.getTrackName() + val artistName = song.getArtistName() + val artworkURL = song.getArtworkUrl() + val previewURL = song.getPreviewUrl() + properties.appendText("$trackName - $artistName - $artworkURL - $previewURL\n") + } fun switchToDeleteSongs(view: View) { val intent = Intent(this, DeleteSongsActivity::class.java) diff --git a/app/src/main/res/layout/activity_download.xml b/app/src/main/res/layout/activity_download.xml index 3ec313442..8bbd6f604 100644 --- a/app/src/main/res/layout/activity_download.xml +++ b/app/src/main/res/layout/activity_download.xml @@ -23,15 +23,13 @@ android:id="@+id/download_songName" android:layout_width="253dp" android:layout_height="50dp" - android:layout_marginTop="100dp" - android:layout_marginBottom="50dp" + android:layout_marginTop="39dp" android:ems="10" android:hint="@string/download_songname" android:inputType="textPersonName" - app:layout_constraintBottom_toTopOf="@+id/download_downloadsong" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" + app:layout_constraintTop_toBottomOf="@+id/download_indicator" tools:ignore="TextContrastCheck" />