Skip to content

Commit

Permalink
Merge pull request #31 from emreesen27/develop
Browse files Browse the repository at this point in the history
v100-beta2 is completed
  • Loading branch information
emreesen27 authored Sep 28, 2024
2 parents b56d63c + 35e3a3d commit 73f079a
Show file tree
Hide file tree
Showing 22 changed files with 352 additions and 72 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v1.0.0-Beta2 (28.09.2024)

* [FIX] The explode error in the search has been resolved.
* [FIX] The index error that occurred after reordering playlists has been resolved.

## v1.0.0-Beta1 (12.09.2024)

* [FIX] The issue of songs not being listed when adding music to the playlist has been resolved.
Expand Down
44 changes: 44 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
### Run

Clone the project.
```
git clone
```
You first need to navigate into the explode module.
```
cd explode
```

Fetch the dependencies:
```
flutter pub get
```
Build it as an AAR:
```
flutter build aar
```

After these steps, you should be able to build the project. The google.service.json file is added through the pipeline during the release process. To compile the project locally, you need to create and add your own google.service.json file.

#### Contribute

During the commit process, both commit-msg and lint checks are automatically executed. Committing triggers the lint task. If any issues arise, you can manually trigger the lint check with the following command:

```
./gradlew ktlintFormat
```
Ensure your commit message follows this format:
```
[DEV]||[FIX]|[REFACTOR] [commit message]
```

Git hooks are set up to enforce linting and commit message checks. If you encounter any issues with the hooks, you can reinstall them by running:

```
./gradlew installGitHook
```

If you make any changes in the <b>explode</b> module, don’t forget to run
```
cd explode && flutter build aar
```
23 changes: 23 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Hyper-N License

1. Permitted Uses:

This license allows you to use Hyper-N under the following conditions:
It may be used for personal, academic, research, and non-commercial purposes.
Modification of the software and creation of derivative works are permitted.

2. Commercial Use Prohibition:

The software may not be used for any commercial purposes.
It cannot be used in any product or service sales or in any profit-driven business model.

3. Sharing of Modifications:

If any modifications or derivative works are made based on this software:
The modified version or derivative work must be publicly shared on a platform like GitHub.
The modifications must include this license and provide attribution to the original author.

4. Disclaimer of Liability:

The software is provided "as is," without any warranty of any kind.
The authors are not liable for any damages or issues arising from the use of this software.
5 changes: 5 additions & 0 deletions PREVIEW.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Preview
---
| Home | Search | Library | Playlist |
|--------------|---------------|--------------|--------------|
| <img src="https://github.com/emreesen27/Hyper-N/blob/assets/home-min.png?raw=true" width="180" height="400"></img> | <img src="https://github.com/emreesen27/Hyper-N/blob/assets/search-min.png?raw=true" width="180" height="400"></img> | <img src="https://github.com/emreesen27/Hyper-N/blob/assets/library-min.png?raw=true" width="180" height="400"></img> | <img src="https://github.com/emreesen27/Hyper-N/blob/assets/playlist-min.png?raw=true" width="180" height="400"></img> |
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Simple Music Downloader for Android

Overview
---
### Run & Contributing
Read [this](https://github.com/emreesen27/Hyper-N/blob/develop/CONTRIBUTING.md) before running the project or contributing

### Preview
Look [here](https://github.com/emreesen27/Hyper-N/blob/develop/PREVIEW.md) for application screenshots.

### Features

- **Open Source, Light, and Smooth** <br/>
Expand All @@ -24,6 +30,9 @@ Seamlessly download your favorite songs and play them directly within the app, e
- **High-Quality Music Downloads** <br/>
Get access to high-quality audio files for the best listening experience.




<div align="center">
<img src="https://github.com/emreesen27/Hyper-N/blob/assets/assets/title.png?raw=true" width="18%" height="100%">
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ android {
applicationId = "com.snstudio.hyper"
minSdk = 26
targetSdk = 34
versionCode = 1
versionName = "1.0.0-Beta1"
versionCode = 3
versionName = "1.0.0-Beta2"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

Expand Down
74 changes: 38 additions & 36 deletions app/dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,64 +1,66 @@
dependencies {
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.11.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.legacy:legacy-support-v4:1.0.0")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.7.0")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0")
implementation(libs.core.ktx)
implementation(libs.appcompat)
implementation(libs.material)
implementation(libs.constraint.layout)
implementation(libs.legacy.support)
implementation(libs.lifecycle.livedata)
implementation(libs.lifecycle.viewmodel)

// Http
implementation("com.squareup.okhttp3:okhttp:4.12.0")
implementation(libs.okhttp)

// Navigation-ktx
implementation("androidx.navigation:navigation-fragment-ktx:2.7.7")
implementation("androidx.navigation:navigation-ui-ktx:2.7.7")
implementation(libs.navigation.fragment)
implementation(libs.navigation.ui)

// Hilt
implementation("com.google.dagger:hilt-android:2.48")
kapt("com.google.dagger:hilt-android-compiler:2.48")
implementation(libs.hilt.android)
kapt(libs.hilt.compiler)

// Splash
implementation("androidx.core:core-splashscreen:1.1.0-rc01")
implementation(libs.splashscreen)

// Recycler
implementation("com.github.sparrow007:carouselrecyclerview:1.2.6")
implementation(libs.carousel.recyclerview)

// Glide
implementation("com.github.bumptech.glide:glide:4.16.0")
annotationProcessor("com.github.bumptech.glide:compiler:4.15.0")
implementation(libs.glide.bump)
annotationProcessor(libs.glide.compiler)

// Sdp & Ssp
implementation("com.intuit.sdp:sdp-android:1.1.0")
implementation("com.intuit.ssp:ssp-android:1.1.0")
implementation(libs.sdp)
implementation(libs.ssp)

// Progress
implementation("com.github.emreesen27:Android-Nested-Progress:v1.0.2")
implementation("com.github.tingyik90:snackprogressbar:6.4.2")
implementation(libs.nested.progress)
implementation(libs.snackprogressbar)

// Expo-Media
implementation("androidx.media3:media3-exoplayer:1.3.0")
implementation("androidx.media3:media3-exoplayer-dash:1.3.0")
implementation("androidx.media3:media3-ui:1.3.0")
implementation("androidx.media3:media3-session:1.3.0")
implementation(libs.media3.exoplayer.player)
implementation(libs.media3.exoplayer.dash)
implementation(libs.media3.ui)
implementation(libs.media3.session)

// Hyper-Explode
debugImplementation("com.snstudio.hyper.explode:flutter_debug:1.0")
releaseImplementation("com.snstudio.hyper.explode:flutter_release:1.0")
debugImplementation(libs.hyper.explode.debug)
releaseImplementation(libs.hyper.explode.release)

// Room
implementation 'androidx.room:room-ktx:2.6.1'
kapt "androidx.room:room-compiler:2.6.1"
implementation(libs.room.ktx)
//noinspection KaptUsageInsteadOfKsp
kapt(libs.room.compiler)

// Toast
implementation 'com.github.GrenderG:Toasty:1.5.2'
implementation(libs.toasty)

// Firebase
implementation(platform("com.google.firebase:firebase-bom:33.2.0"))
implementation("com.google.firebase:firebase-analytics")
implementation("com.google.firebase:firebase-crashlytics")
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.analytics)
implementation(libs.firebase.crashlytics)

testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}
// Test
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.espresso.core)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class LibraryFragment : BaseFragment<FragmentLibraryBinding, LibraryViewModel>()
private lateinit var mediaViewModel: MediaViewModel

private val mediaItemAdapter: MediaItemAdapter by lazy {
MediaItemAdapter(onClick = { media ->
MediaItemAdapter(onClick = { media, _ ->
playMedia(media)
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.snstudio.hyper.core.extension.click
import com.snstudio.hyper.core.extension.infoToast
import com.snstudio.hyper.core.extension.observe
import com.snstudio.hyper.data.MediaItemBuilder
import com.snstudio.hyper.data.model.Media
import com.snstudio.hyper.databinding.FragmentPlaylistDetailBinding
import com.snstudio.hyper.feature.picker.MediaPickerDialog
import com.snstudio.hyper.shared.MediaItemAdapter
Expand All @@ -22,8 +21,8 @@ class PlaylistDetailFragment : BaseFragment<FragmentPlaylistDetailBinding, Playl
private lateinit var mediaViewModel: MediaViewModel
private val args: PlaylistDetailFragmentArgs by navArgs()
private val mediaItemAdapter by lazy {
MediaItemAdapter(onClick = {
setPlayList(it)
MediaItemAdapter(onClick = { _, pos ->
setPlayList(pos)
})
}

Expand Down Expand Up @@ -74,17 +73,15 @@ class PlaylistDetailFragment : BaseFragment<FragmentPlaylistDetailBinding, Playl
viewModel.getMediaForPlaylistOrdered(args.playListId)
}

private fun setPlayList(media: Media) {
mediaItemAdapter.getSubMediaItems(media).let { mediaList ->
val mediaItems =
mediaList.map { media ->
MediaItemBuilder()
.setMediaId(media.localPath.orEmpty())
.setMediaTitle(media.title)
.build()
}
mediaViewModel.setPlaylist(mediaItems)
}
private fun setPlayList(pos: Int) {
val mediaItems =
mediaItemAdapter.mediaItems.map { media ->
MediaItemBuilder()
.setMediaId(media.localPath.orEmpty())
.setMediaTitle(media.title)
.build()
}
mediaViewModel.setPlaylist(mediaItems, pos)
}

private fun showMediaPickerDialog() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import com.snstudio.hyper.shared.MediaItemAdapter
import com.snstudio.hyper.shared.MediaViewModel
import com.snstudio.hyper.shared.ProgressLiveData
import com.snstudio.hyper.util.DATA_KEY
import com.snstudio.hyper.util.EXCEPTION
import com.snstudio.hyper.util.ErrorDialog
import com.snstudio.hyper.util.InfoDialog
import com.snstudio.hyper.util.ItemTouchHelperCallback
import com.snstudio.hyper.util.MediaItemType
Expand All @@ -40,7 +42,7 @@ class SearchFragment :
private lateinit var mediaViewModel: MediaViewModel

private val mediaItemAdapter by lazy {
MediaItemAdapter(onClick = { media ->
MediaItemAdapter(onClick = { media, _ ->
viewModel.invokeAudioUrl(media, SearchViewModel.AudioActionType.PLAY)
})
}
Expand Down Expand Up @@ -74,7 +76,13 @@ class SearchFragment :
}

RECEIVED.AUDIO_URL_RECEIVED.received -> {
it.argument<String>(DATA_KEY)?.let { url ->
it.argument<HashMap<String, String>>(DATA_KEY)?.let { data ->
val url = data["url"].orEmpty()
val errorCode = data["errorCode"]
if (!errorCode.isNullOrEmpty()) {
showErrorDialog(errorCode)
return@observe
}
when (audioActionType) {
SearchViewModel.AudioActionType.PLAY -> {
playMedia(url)
Expand Down Expand Up @@ -226,4 +234,14 @@ class SearchFragment :
viewModel.setTrueInfoDialogStatus()
}
}

private fun showErrorDialog(code: String) {
val errMessage =
if (code == EXCEPTION.YT_EXPLODE_EXCEPTION.code) {
R.string.yt_explode_error
} else {
R.string.unexpected_error
}
ErrorDialog(errMessage = errMessage).showDialog(childFragmentManager)
}
}
11 changes: 3 additions & 8 deletions app/src/main/java/com/snstudio/hyper/shared/MediaItemAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import com.snstudio.hyper.databinding.ItemMediaSearchBinding
import com.snstudio.hyper.util.MediaItemType

class MediaItemAdapter(
private val onClick: ((Media) -> Unit)? = null,
private val onClick: ((Media, Int) -> Unit)? = null,
) : RecyclerView.Adapter<MediaItemAdapter.AutoCompleteViewHolder>() {
var mediaItems: MutableList<Media> = mutableListOf()
private set
Expand All @@ -33,11 +33,6 @@ class MediaItemAdapter(
diffResult.dispatchUpdatesTo(this)
}

fun getSubMediaItems(media: Media): MutableList<Media> {
val index = mediaItems.indexOf(media)
return mediaItems.subList(index, mediaItems.size)
}

fun moveItem(
fromPosition: Int,
toPosition: Int,
Expand Down Expand Up @@ -109,14 +104,14 @@ class MediaItemAdapter(
private fun bindMedia(media: Media) {
val itemBinding = binding as ItemMediaBinding
itemBinding.root.click {
adapter.onClick?.invoke(media)
adapter.onClick?.invoke(media, absoluteAdapterPosition)
}
}

private fun bindMediaSearchType(media: Media) {
val itemBinding = binding as ItemMediaSearchBinding
itemBinding.root.click {
adapter.onClick?.invoke(media)
adapter.onClick?.invoke(media, absoluteAdapterPosition)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,15 @@ class MediaViewModel(application: Application) : AndroidViewModel(application) {
player.stop()
}

fun setPlaylist(mediaItems: List<MediaItem>) {
fun setPlaylist(
mediaItems: List<MediaItem>,
startPosition: Int = 0,
) {
playlist.clear()
playlist.addAll(mediaItems)
player.setMediaItems(mediaItems)
player.prepare()
player.seekTo(startPosition, 0)
player.play()
}
}
Loading

0 comments on commit 73f079a

Please sign in to comment.