Skip to content

Commit

Permalink
Merge pull request #19 from jarnedemeulemeester/develop
Browse files Browse the repository at this point in the history
Version 0.1.1
  • Loading branch information
jarnedemeulemeester authored Aug 22, 2021
2 parents 71dbd1b + 90681c6 commit 2726509
Show file tree
Hide file tree
Showing 48 changed files with 617 additions and 409 deletions.
14 changes: 8 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
id 'kotlin-kapt'
id 'androidx.navigation.safeargs.kotlin'
id 'dagger.hilt.android.plugin'
id 'com.google.android.gms.oss-licenses-plugin'
id "com.mikepenz.aboutlibraries.plugin"
}

android {
Expand All @@ -16,8 +16,8 @@ android {
applicationId "dev.jdtech.jellyfin"
minSdkVersion 24
targetSdkVersion 31
versionCode 1
versionName "0.1.0"
versionCode 2
versionName "0.1.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -42,6 +42,7 @@ android {

buildFeatures {
dataBinding true
viewBinding true
}
}

Expand Down Expand Up @@ -96,11 +97,12 @@ dependencies {
implementation files('libs/extension-ffmpeg-release.aar')

// Timber
def timber_version = "5.0.0"
def timber_version = "5.0.1"
implementation "com.jakewharton.timber:timber:$timber_version"

def oss_licenses_version = "17.0.0"
implementation "com.google.android.gms:play-services-oss-licenses:$oss_licenses_version"
def about_libraries_version = "8.9.1"
implementation "com.mikepenz:aboutlibraries-core:$about_libraries_version"
implementation "com.mikepenz:aboutlibraries:$about_libraries_version"

// Testing
testImplementation 'junit:junit:4.13.2'
Expand Down
5 changes: 0 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
android:theme="@style/Theme.AppCompat.DayNight.DarkActionBar"/>

<activity android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
android:theme="@style/Theme.AppCompat.DayNight.DarkActionBar"/>

</application>

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/dev/jdtech/jellyfin/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ class MainActivity : AppCompatActivity() {

navController.addOnDestinationChangedListener { _, destination, _ ->
binding.navView.visibility = when (destination.id) {
R.id.settingsFragment, R.id.serverSelectFragment, R.id.addServerFragment, R.id.loginFragment -> View.GONE
R.id.settingsFragment, R.id.serverSelectFragment, R.id.addServerFragment, R.id.loginFragment, R.id.about_libraries_dest -> View.GONE
else -> View.VISIBLE
}
if (destination.id == R.id.about_libraries_dest) binding.mainToolbar.title = getString(R.string.app_info)
}

viewModel.navigateToAddServer.observe(this, {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package dev.jdtech.jellyfin.dialogs

import android.app.Dialog
import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.DialogFragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import dev.jdtech.jellyfin.R
import java.lang.IllegalStateException

class ErrorDialogFragment(private val errorMessage: String) : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return activity?.let {
val builder = MaterialAlertDialogBuilder(it, R.style.ErrorDialogStyle)
builder
.setMessage(errorMessage)
.setPositiveButton("close") { _, _ ->
}
.setNeutralButton("share") { _, _ ->
val sendIntent: Intent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, errorMessage)
type = "text/plain"
}

val shareIntent = Intent.createChooser(sendIntent, null)
startActivity(shareIntent)

}
builder.create()
} ?: throw IllegalStateException("Activity cannot be null")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import dagger.hilt.android.AndroidEntryPoint
import dev.jdtech.jellyfin.R
import dev.jdtech.jellyfin.databinding.EpisodeBottomSheetBinding
import dev.jdtech.jellyfin.dialogs.ErrorDialogFragment
import dev.jdtech.jellyfin.models.PlayerItem
import dev.jdtech.jellyfin.viewmodels.EpisodeBottomSheetViewModel

Expand Down Expand Up @@ -98,17 +99,20 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() {
}
})

viewModel.playerItemsError.observe(viewLifecycleOwner, {
when (it) {
true -> {
binding.playerItemsError.visibility = View.VISIBLE
binding.playButton.setImageDrawable(ContextCompat.getDrawable(requireActivity(), R.drawable.ic_play))
binding.progressCircular.visibility = View.INVISIBLE
}
false -> binding.playerItemsError.visibility = View.GONE
viewModel.playerItemsError.observe(viewLifecycleOwner, { errorMessage ->
if (errorMessage != null) {
binding.playerItemsError.visibility = View.VISIBLE
binding.playButton.setImageDrawable(ContextCompat.getDrawable(requireActivity(), R.drawable.ic_play))
binding.progressCircular.visibility = View.INVISIBLE
} else {
binding.playerItemsError.visibility = View.GONE
}
})

binding.playerItemsErrorDetails.setOnClickListener {
ErrorDialogFragment(viewModel.playerItemsError.value ?: getString(R.string.unknown_error)).show(parentFragmentManager, "errordialog")
}

viewModel.loadEpisode(args.episodeId)

return binding.root
Expand Down
28 changes: 15 additions & 13 deletions app/src/main/java/dev/jdtech/jellyfin/fragments/FavoriteFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import com.google.android.material.snackbar.Snackbar
import dagger.hilt.android.AndroidEntryPoint
import dev.jdtech.jellyfin.R
import dev.jdtech.jellyfin.adapters.FavoritesListAdapter
import dev.jdtech.jellyfin.adapters.HomeEpisodeListAdapter
import dev.jdtech.jellyfin.adapters.ViewItemListAdapter
import dev.jdtech.jellyfin.databinding.FragmentFavoriteBinding
import dev.jdtech.jellyfin.dialogs.ErrorDialogFragment
import dev.jdtech.jellyfin.viewmodels.FavoriteViewModel
import org.jellyfin.sdk.model.api.BaseItemDto

Expand All @@ -29,16 +29,6 @@ class FavoriteFragment : Fragment() {
): View {
binding = FragmentFavoriteBinding.inflate(inflater, container, false)

val snackbar =
Snackbar.make(
binding.mainLayout,
getString(R.string.error_loading_data),
Snackbar.LENGTH_INDEFINITE
)
snackbar.setAction(getString(R.string.retry)) {
viewModel.loadData()
}

binding.lifecycleOwner = viewLifecycleOwner
binding.viewModel = viewModel
binding.favoritesRecyclerView.adapter = FavoritesListAdapter(
Expand All @@ -53,11 +43,23 @@ class FavoriteFragment : Fragment() {
})

viewModel.error.observe(viewLifecycleOwner, { error ->
if (error) {
snackbar.show()
if (error != null) {
binding.errorLayout.errorPanel.visibility = View.VISIBLE
binding.favoritesRecyclerView.visibility = View.GONE
} else {
binding.errorLayout.errorPanel.visibility = View.GONE
binding.favoritesRecyclerView.visibility = View.VISIBLE
}
})

binding.errorLayout.errorRetryButton.setOnClickListener {
viewModel.loadData()
}

binding.errorLayout.errorDetailsButton.setOnClickListener {
ErrorDialogFragment(viewModel.error.value ?: getString(R.string.unknown_error)).show(parentFragmentManager, "errordialog")
}

viewModel.favoriteSections.observe(viewLifecycleOwner, { sections ->
if (sections.isEmpty()) {
binding.noFavoritesText.visibility = View.VISIBLE
Expand Down
24 changes: 15 additions & 9 deletions app/src/main/java/dev/jdtech/jellyfin/fragments/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import android.view.*
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import com.google.android.material.snackbar.Snackbar
import dagger.hilt.android.AndroidEntryPoint
import dev.jdtech.jellyfin.R
import dev.jdtech.jellyfin.adapters.HomeEpisodeListAdapter
import dev.jdtech.jellyfin.adapters.ViewItemListAdapter
import dev.jdtech.jellyfin.adapters.ViewListAdapter
import dev.jdtech.jellyfin.databinding.FragmentHomeBinding
import dev.jdtech.jellyfin.dialogs.ErrorDialogFragment
import dev.jdtech.jellyfin.viewmodels.HomeViewModel
import org.jellyfin.sdk.model.api.BaseItemDto

Expand Down Expand Up @@ -49,12 +49,6 @@ class HomeFragment : Fragment() {
): View {
binding = FragmentHomeBinding.inflate(inflater, container, false)

val snackbar =
Snackbar.make(binding.mainLayout, getString(R.string.error_loading_data), Snackbar.LENGTH_INDEFINITE)
snackbar.setAction(getString(R.string.retry)) {
viewModel.loadData()
}

binding.lifecycleOwner = viewLifecycleOwner
binding.viewModel = viewModel
binding.viewsRecyclerView.adapter = ViewListAdapter(ViewListAdapter.OnClickListener {
Expand All @@ -78,11 +72,23 @@ class HomeFragment : Fragment() {
})

viewModel.error.observe(viewLifecycleOwner, { error ->
if (error) {
snackbar.show()
if (error != null) {
binding.errorLayout.errorPanel.visibility = View.VISIBLE
binding.viewsRecyclerView.visibility = View.GONE
} else {
binding.errorLayout.errorPanel.visibility = View.GONE
binding.viewsRecyclerView.visibility = View.VISIBLE
}
})

binding.errorLayout.errorRetryButton.setOnClickListener {
viewModel.loadData()
}

binding.errorLayout.errorDetailsButton.setOnClickListener {
ErrorDialogFragment(viewModel.error.value ?: getString(R.string.unknown_error)).show(parentFragmentManager, "errordialog")
}

return binding.root
}

Expand Down
28 changes: 15 additions & 13 deletions app/src/main/java/dev/jdtech/jellyfin/fragments/LibraryFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import android.view.ViewGroup
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import com.google.android.material.snackbar.Snackbar
import dagger.hilt.android.AndroidEntryPoint
import dev.jdtech.jellyfin.R
import dev.jdtech.jellyfin.viewmodels.LibraryViewModel
import dev.jdtech.jellyfin.adapters.ViewItemListAdapter
import dev.jdtech.jellyfin.databinding.FragmentLibraryBinding
import dev.jdtech.jellyfin.dialogs.ErrorDialogFragment
import org.jellyfin.sdk.model.api.BaseItemDto

@AndroidEntryPoint
Expand All @@ -39,22 +39,24 @@ class LibraryFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)
binding.viewModel = viewModel

val snackbar =
Snackbar.make(
binding.mainLayout,
getString(R.string.error_loading_data),
Snackbar.LENGTH_INDEFINITE
)
snackbar.setAction(getString(R.string.retry)) {
viewModel.loadItems(args.libraryId)
}

viewModel.error.observe(viewLifecycleOwner, { error ->
if (error) {
snackbar.show()
if (error != null) {
binding.errorLayout.errorPanel.visibility = View.VISIBLE
binding.itemsRecyclerView.visibility = View.GONE
} else {
binding.errorLayout.errorPanel.visibility = View.GONE
binding.itemsRecyclerView.visibility = View.VISIBLE
}
})

binding.errorLayout.errorRetryButton.setOnClickListener {
viewModel.loadItems(args.libraryId)
}

binding.errorLayout.errorDetailsButton.setOnClickListener {
ErrorDialogFragment(viewModel.error.value ?: getString(R.string.unknown_error)).show(parentFragmentManager, "errordialog")
}

viewModel.finishedLoading.observe(viewLifecycleOwner, {
binding.loadingIndicator.visibility = if (it) View.GONE else View.VISIBLE
})
Expand Down
28 changes: 15 additions & 13 deletions app/src/main/java/dev/jdtech/jellyfin/fragments/MediaFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import androidx.appcompat.widget.SearchView
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import com.google.android.material.snackbar.Snackbar
import dagger.hilt.android.AndroidEntryPoint
import dev.jdtech.jellyfin.R
import dev.jdtech.jellyfin.adapters.CollectionListAdapter
import dev.jdtech.jellyfin.databinding.FragmentMediaBinding
import dev.jdtech.jellyfin.dialogs.ErrorDialogFragment
import dev.jdtech.jellyfin.viewmodels.MediaViewModel
import org.jellyfin.sdk.model.api.BaseItemDto

Expand Down Expand Up @@ -53,16 +53,6 @@ class MediaFragment : Fragment() {
): View {
binding = FragmentMediaBinding.inflate(inflater, container, false)

val snackbar =
Snackbar.make(
binding.mainLayout,
getString(R.string.error_loading_data),
Snackbar.LENGTH_INDEFINITE
)
snackbar.setAction(getString(R.string.retry)) {
viewModel.loadData()
}

binding.lifecycleOwner = viewLifecycleOwner
binding.viewModel = viewModel
binding.viewsRecyclerView.adapter =
Expand All @@ -75,11 +65,23 @@ class MediaFragment : Fragment() {
})

viewModel.error.observe(viewLifecycleOwner, { error ->
if (error) {
snackbar.show()
if (error != null) {
binding.errorLayout.errorPanel.visibility = View.VISIBLE
binding.viewsRecyclerView.visibility = View.GONE
} else {
binding.errorLayout.errorPanel.visibility = View.GONE
binding.viewsRecyclerView.visibility = View.VISIBLE
}
})

binding.errorLayout.errorRetryButton.setOnClickListener {
viewModel.loadData()
}

binding.errorLayout.errorDetailsButton.setOnClickListener {
ErrorDialogFragment(viewModel.error.value ?: getString(R.string.unknown_error)).show(parentFragmentManager, "errordialog")
}

return binding.root
}

Expand Down
Loading

0 comments on commit 2726509

Please sign in to comment.