Skip to content

Commit

Permalink
Merge pull request #127 from pravinyo/add_tooltip
Browse files Browse the repository at this point in the history
Add tooltip for opening main player
  • Loading branch information
pravinyo committed May 27, 2020
2 parents bf31e9f + 7170205 commit 35a8c33
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.allsoftdroid.buildsrc
import CoreVersion

private object LibraryVersion {
const val TOOL_TIP = "2.0.3"
const val FIREBASE_CRASHLYTICS = "17.0.0"
const val FIREBASE_VERSION = "17.4.2"
const val OSS_LICENSES = "17.0.0"
Expand Down Expand Up @@ -125,4 +126,6 @@ object LibraryDependency {
const val FIREBASE_ANALYTICS = "com.google.firebase:firebase-analytics:${LibraryVersion.FIREBASE_VERSION}"
const val FIREBASE_ANALYTICS_KTX = "com.google.firebase:firebase-analytics-ktx:${LibraryVersion.FIREBASE_VERSION}"
const val FIREBASE_CRASHLYTICS = "com.google.firebase:firebase-crashlytics:${LibraryVersion.FIREBASE_CRASHLYTICS}"

const val TOOL_TIP = "it.sephiroth.android.library.targettooltip:target-tooltip-library:${LibraryVersion.TOOL_TIP}"
}
1 change: 1 addition & 0 deletions feature_mini_player/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ dependencies {
implementation(LibraryDependency.GLIDE)
kapt(LibraryDependency.GLIDE_COMPILER)
implementation(LibraryDependency.KOIN_X_VIEWMODEL)
implementation(LibraryDependency.TOOL_TIP)

//Test
testImplementation(TestLibraryDependency.JUNIT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.allsoftdroid.audiobook.feature_mini_player.databinding.FragmentMiniPl
import com.allsoftdroid.audiobook.feature_mini_player.di.FeatureMiniPlayerModule
import com.allsoftdroid.audiobook.feature_mini_player.presentation.viewModel.MiniPlayerViewModel
import com.allsoftdroid.common.base.fragment.BaseContainerFragment
import it.sephiroth.android.library.xtooltip.Tooltip
import org.koin.android.ext.android.inject
import timber.log.Timber

Expand All @@ -20,8 +21,8 @@ class MiniPlayerFragment : BaseContainerFragment() {
Lazily initialize the view model
*/
private val miniPlayerViewModel: MiniPlayerViewModel by inject()


var tooltip:Tooltip? = null
private lateinit var refBinding:FragmentMiniPlayerBinding

override fun onCreateView(
inflater: LayoutInflater,
Expand All @@ -42,10 +43,31 @@ class MiniPlayerFragment : BaseContainerFragment() {
}
})

refBinding = binding

return binding.root
}

override fun onDestroy() {
super.onDestroy()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

val metrics = resources.displayMetrics
val gravity = Tooltip.Gravity.TOP

tooltip = Tooltip.Builder(view.context)
.anchor(refBinding.ivMiniPlayerAlbumArt,70,70,false)
.text(getString(R.string.tooltip_open_player_message))
.maxWidth(metrics.widthPixels / 2)
.arrow(true)
.floatingAnimation(Tooltip.Animation.DEFAULT)
.showDuration(4000)
.overlay(true)
.create()

tooltip
?.doOnHidden {
tooltip = null
}
?.show(refBinding.root, gravity, true)
}
}
1 change: 1 addition & 0 deletions feature_mini_player/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<resources>
<string name="app_name">feature_mini_player</string>
<string name="audio_book_album_art">audio book album art</string>
<string name="tooltip_open_player_message">Open Player</string>
</resources>

0 comments on commit 35a8c33

Please sign in to comment.