diff --git a/app/src/main/java/io/github/droidkaigi/confsched2018/presentation/speaker/SpeakerDetailFragment.kt b/app/src/main/java/io/github/droidkaigi/confsched2018/presentation/speaker/SpeakerDetailFragment.kt index 7c6e4dc9..0e4819f7 100644 --- a/app/src/main/java/io/github/droidkaigi/confsched2018/presentation/speaker/SpeakerDetailFragment.kt +++ b/app/src/main/java/io/github/droidkaigi/confsched2018/presentation/speaker/SpeakerDetailFragment.kt @@ -7,6 +7,7 @@ import android.arch.lifecycle.ViewModelProvider import android.arch.lifecycle.ViewModelProviders import android.os.Build import android.os.Bundle +import android.support.design.widget.BottomSheetDialog import android.support.v4.app.Fragment import android.support.v4.view.ViewCompat import android.support.v7.widget.LinearLayoutManager @@ -23,9 +24,11 @@ import android.view.ViewGroup import com.xwray.groupie.GroupAdapter import com.xwray.groupie.ViewHolder import io.github.droidkaigi.confsched2018.R +import io.github.droidkaigi.confsched2018.databinding.BottomSheetDialogSpeakerSnsBinding import io.github.droidkaigi.confsched2018.databinding.FragmentSpeakerDetailBinding import io.github.droidkaigi.confsched2018.di.Injectable import io.github.droidkaigi.confsched2018.model.Session +import io.github.droidkaigi.confsched2018.model.Speaker import io.github.droidkaigi.confsched2018.presentation.NavigationController import io.github.droidkaigi.confsched2018.presentation.Result import io.github.droidkaigi.confsched2018.presentation.sessions.item.SimpleSessionsSection @@ -38,6 +41,7 @@ import javax.inject.Inject class SpeakerDetailFragment : Fragment(), Injectable { private lateinit var binding: FragmentSpeakerDetailBinding + private lateinit var dialogBinding: BottomSheetDialogSpeakerSnsBinding @Inject lateinit var viewModelFactory: ViewModelProvider.Factory private val sessionsSection = SimpleSessionsSection() @@ -45,6 +49,8 @@ class SpeakerDetailFragment : Fragment(), Injectable { @Inject lateinit var navigationController: NavigationController @Inject lateinit var sessionAlarm: SessionAlarm + private lateinit var bottomSheetDialog: BottomSheetDialog + private val speakerDetailViewModel: SpeakerDetailViewModel by lazy { ViewModelProviders.of(this, viewModelFactory).get(SpeakerDetailViewModel::class.java) } @@ -68,6 +74,12 @@ class SpeakerDetailFragment : Fragment(), Injectable { false ) activity?.supportStartPostponedEnterTransition() + + dialogBinding = + BottomSheetDialogSpeakerSnsBinding.inflate( + inflater, + container, + false) return binding.root } @@ -80,11 +92,8 @@ class SpeakerDetailFragment : Fragment(), Injectable { when (result) { is Result.Success -> { val speaker = result.data.first - binding.speaker = speaker - sessionsSection.updateSessions(result.data.second, - onFavoriteClickListener, - onFeedbackListener, - userIdInDetail = speaker.id) + val sessions = result.data.second + bindSpeaker(speaker, sessions) } is Result.Failure -> { Timber.e(result.e) @@ -92,12 +101,46 @@ class SpeakerDetailFragment : Fragment(), Injectable { } }) + bottomSheetDialog = BottomSheetDialog(context!!).apply { + setContentView(dialogBinding.root) + setCancelable(true) + } + if (!TextUtils.isEmpty(arguments!!.getString(EXTRA_TRANSITION_NAME)) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { initViewTransition(view, savedInstanceState) } } + private fun bindSpeaker(speaker: Speaker, sessions: List) { + binding.speaker = speaker + dialogBinding.speaker = speaker + sessionsSection.updateSessions(sessions, + onFavoriteClickListener, + onFeedbackListener, + userIdInDetail = speaker.id) + binding.speakerImage.setOnClickListener { + bottomSheetDialog.show() + } + + val navigateBrowserAndDismissDialog: (String) -> Unit = { url -> + navigationController.navigateToExternalBrowser(url) + bottomSheetDialog.dismiss() + } + dialogBinding.speakerDetailTwitter.setOnClickListener { + speaker.twitterUrl?.let(navigateBrowserAndDismissDialog) + } + dialogBinding.speakerDetailGithub.setOnClickListener { + speaker.githubUrl?.let(navigateBrowserAndDismissDialog) + } + dialogBinding.speakerDetailCompany.setOnClickListener { + speaker.companyUrl?.let(navigateBrowserAndDismissDialog) + } + dialogBinding.speakerDetailBlog.setOnClickListener { + speaker.blogUrl?.let(navigateBrowserAndDismissDialog) + } + } + @TargetApi(Build.VERSION_CODES.LOLLIPOP) private fun initViewTransition(view: View, savedInstanceState: Bundle?) { view.findViewById(R.id.app_bar_background).visibility = INVISIBLE diff --git a/app/src/main/res/drawable-v21/bg_sns_link_button.xml b/app/src/main/res/drawable-v21/bg_sns_link_button.xml new file mode 100644 index 00000000..100495df --- /dev/null +++ b/app/src/main/res/drawable-v21/bg_sns_link_button.xml @@ -0,0 +1,6 @@ + + + + diff --git a/app/src/main/res/drawable/bg_sns_link_button.xml b/app/src/main/res/drawable/bg_sns_link_button.xml new file mode 100644 index 00000000..83456df3 --- /dev/null +++ b/app/src/main/res/drawable/bg_sns_link_button.xml @@ -0,0 +1,4 @@ + + + + diff --git a/app/src/main/res/drawable/ic_blog_black_48dp.xml b/app/src/main/res/drawable/ic_blog_black_48dp.xml new file mode 100644 index 00000000..5db17d8d --- /dev/null +++ b/app/src/main/res/drawable/ic_blog_black_48dp.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_company_black_48dp.xml b/app/src/main/res/drawable/ic_company_black_48dp.xml new file mode 100644 index 00000000..9545d4fa --- /dev/null +++ b/app/src/main/res/drawable/ic_company_black_48dp.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_github_black_48dp.xml b/app/src/main/res/drawable/ic_github_black_48dp.xml new file mode 100644 index 00000000..f9dfe5fb --- /dev/null +++ b/app/src/main/res/drawable/ic_github_black_48dp.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_twitter_blue_48dp.xml b/app/src/main/res/drawable/ic_twitter_blue_48dp.xml new file mode 100644 index 00000000..a71f5f73 --- /dev/null +++ b/app/src/main/res/drawable/ic_twitter_blue_48dp.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/shape_round_corner_68dp.xml b/app/src/main/res/drawable/shape_round_corner_68dp.xml new file mode 100644 index 00000000..8de69308 --- /dev/null +++ b/app/src/main/res/drawable/shape_round_corner_68dp.xml @@ -0,0 +1,11 @@ + + + android:shape="rectangle" + > + + + + diff --git a/app/src/main/res/layout/bottom_sheet_dialog_speaker_sns.xml b/app/src/main/res/layout/bottom_sheet_dialog_speaker_sns.xml new file mode 100644 index 00000000..10e6532d --- /dev/null +++ b/app/src/main/res/layout/bottom_sheet_dialog_speaker_sns.xml @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_speaker_detail.xml b/app/src/main/res/layout/fragment_speaker_detail.xml index 9c12aa98..25c768d9 100644 --- a/app/src/main/res/layout/fragment_speaker_detail.xml +++ b/app/src/main/res/layout/fragment_speaker_detail.xml @@ -26,8 +26,8 @@ /> スピーカー スピーカー画像 + SNSのリンクが設定されていません diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 17140453..ee2cd84c 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -26,4 +26,7 @@ 20dp 24sp 60dp + + + 64dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2be8420e..f4a04d49 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -95,6 +95,7 @@ Speaker Speaker image + Speaker has not set SNS Link.. diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index bf5634bd..b7eefc98 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -86,6 +86,13 @@ 2dp + +