Skip to content

Commit

Permalink
Merge pull request #546 from kiuchikeisuke/issue515_showSNSlink
Browse files Browse the repository at this point in the history
fix:issue515 I want to be able to go to GitHub and Twitter and etc.. …
  • Loading branch information
takahirom authored Feb 1, 2018
2 parents 208e5dd + 7a50725 commit c4fc923
Show file tree
Hide file tree
Showing 14 changed files with 242 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -38,13 +41,16 @@ 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()
private var isEnterTransitionCanceled: Boolean = false
@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)
}
Expand All @@ -68,6 +74,12 @@ class SpeakerDetailFragment : Fragment(), Injectable {
false
)
activity?.supportStartPostponedEnterTransition()

dialogBinding =
BottomSheetDialogSpeakerSnsBinding.inflate(
inflater,
container,
false)
return binding.root
}

Expand All @@ -80,24 +92,55 @@ 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)
}
}
})

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<Session.SpeechSession>) {
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<View>(R.id.app_bar_background).visibility = INVISIBLE
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/drawable-v21/bg_sns_link_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/button_ripple"
>
<item android:drawable="@drawable/shape_round_corner_68dp" />
</ripple>
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/bg_sns_link_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shape_round_corner_68dp" />
</selector>
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/ic_blog_black_48dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<vector android:height="48dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M15.6,10.79c0.97,-0.67 1.65,-1.77 1.65,-2.79 0,-2.26 -1.75,-4 -4,-4L7,4v14h7.04c2.09,0 3.71,-1.7 3.71,-3.79 0,-1.52 -0.86,-2.82 -2.15,-3.42zM10,6.5h3c0.83,0 1.5,0.67 1.5,1.5s-0.67,1.5 -1.5,1.5h-3v-3zM13.5,15.5L10,15.5v-3h3.5c0.83,0 1.5,0.67 1.5,1.5s-0.67,1.5 -1.5,1.5z"/>
</vector>
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/ic_company_black_48dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<vector android:height="48dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M12,7L12,3L2,3v18h20L22,7L12,7zM6,19L4,19v-2h2v2zM6,15L4,15v-2h2v2zM6,11L4,11L4,9h2v2zM6,7L4,7L4,5h2v2zM10,19L8,19v-2h2v2zM10,15L8,15v-2h2v2zM10,11L8,11L8,9h2v2zM10,7L8,7L8,5h2v2zM20,19h-8v-2h2v-2h-2v-2h2v-2h-2L12,9h8v10zM18,11h-2v2h2v-2zM18,15h-2v2h2v-2z"/>
</vector>
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/ic_github_black_48dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<vector android:height="48dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#161514" android:fillType="evenOdd" android:pathData="M12,2.25c-5.522,0 -10,4.477 -10,10 0,4.418 2.865,8.166 6.839,9.489 0.5,0.092 0.682,-0.217 0.682,-0.482 0,-0.237 -0.008,-0.866 -0.013,-1.7 -2.782,0.603 -3.369,-1.342 -3.369,-1.342 -0.454,-1.155 -1.11,-1.462 -1.11,-1.462 -0.908,-0.62 0.069,-0.608 0.069,-0.608 1.003,0.07 1.531,1.03 1.531,1.03 0.892,1.529 2.341,1.087 2.91,0.831 0.092,-0.646 0.35,-1.086 0.636,-1.336 -2.22,-0.253 -4.555,-1.11 -4.555,-4.943 0,-1.091 0.39,-1.984 1.029,-2.683 -0.103,-0.253 -0.446,-1.27 0.098,-2.647 0,0 0.84,-0.268 2.75,1.026A9.578,9.578 0,0 1,12 7.086c0.85,0.004 1.705,0.114 2.504,0.337 1.909,-1.294 2.747,-1.026 2.747,-1.026 0.546,1.377 0.203,2.394 0.1,2.647 0.64,0.699 1.028,1.592 1.028,2.683 0,3.842 -2.339,4.687 -4.566,4.935 0.359,0.309 0.678,0.919 0.678,1.852 0,1.336 -0.012,2.415 -0.012,2.743 0,0.267 0.18,0.579 0.688,0.481C19.137,20.413 22,16.668 22,12.25c0,-5.523 -4.478,-10 -10,-10"/>
</vector>
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/ic_twitter_blue_48dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<vector android:height="48dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#55ACEE" android:fillType="nonZero" android:pathData="M22,5.8a8.201,8.201 0,0 1,-2.357 0.645,4.115 4.115,0 0,0 1.804,-2.27c-0.792,0.47 -1.67,0.812 -2.605,0.996a4.103,4.103 0,0 0,-6.992 3.742,11.65 11.65,0 0,1 -8.458,-4.287 4.083,4.083 0,0 0,-0.555 2.063c0,1.423 0.724,2.68 1.825,3.415a4.087,4.087 0,0 1,-1.858 -0.513v0.052a4.106,4.106 0,0 0,3.29 4.023,4.112 4.112,0 0,1 -1.852,0.07 4.107,4.107 0,0 0,3.833 2.85,8.233 8.233,0 0,1 -5.096,1.756c-0.331,0 -0.658,-0.019 -0.979,-0.057a11.614,11.614 0,0 0,6.29 1.844c7.547,0 11.674,-6.253 11.674,-11.675 0,-0.178 -0.004,-0.355 -0.011,-0.53A8.34,8.34 0,0 0,22 5.798"/>
</vector>
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/shape_round_corner_68dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
android:shape="rectangle"
>
<corners android:radius="48dp" />
<size
android:width="68dp"
android:height="68dp"
/>
<solid android:color="@color/card_background_color" />
</shape>
143 changes: 143 additions & 0 deletions app/src/main/res/layout/bottom_sheet_dialog_speaker_sns.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
>
<data>
<import type="android.view.View"/>
<variable
name="speaker"
type="io.github.droidkaigi.confsched2018.model.Speaker"
/>
</data>
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>

<ImageButton
android:id="@+id/speaker_detail_twitter"
style="@style/SNSLinkButton"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:contentDescription="speaker_detail_twitter"
android:visibility="@{speaker.twitterUrl == null ? View.GONE : View.VISIBLE}"
app:layout_constraintEnd_toStartOf="@+id/speaker_detail_github"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_twitter_blue_48dp"
/>
<ImageButton
android:id="@+id/speaker_detail_github"
style="@style/SNSLinkButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="speaker_detail_github"
android:visibility="@{speaker.githubUrl == null ? View.GONE : View.VISIBLE}"
app:layout_constraintBottom_toBottomOf="@+id/speaker_detail_twitter"
app:layout_constraintEnd_toStartOf="@+id/speaker_detail_company"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/speaker_detail_twitter"
app:layout_constraintTop_toTopOf="@+id/speaker_detail_twitter"
app:srcCompat="@drawable/ic_github_black_48dp"
/>
<ImageButton
android:id="@+id/speaker_detail_company"
style="@style/SNSLinkButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="speaker_detail_company"
android:visibility="@{speaker.companyUrl == null ? View.GONE : View.VISIBLE}"
app:layout_constraintBottom_toBottomOf="@+id/speaker_detail_github"
app:layout_constraintEnd_toStartOf="@+id/speaker_detail_blog"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/speaker_detail_github"
app:layout_constraintTop_toTopOf="@+id/speaker_detail_github"
app:srcCompat="@drawable/ic_company_black_48dp"
/>
<ImageButton
android:id="@+id/speaker_detail_blog"
style="@style/SNSLinkButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="speaker_detail_blog"
android:visibility="@{speaker.blogUrl == null ? View.GONE : View.VISIBLE}"
app:layout_constraintBottom_toBottomOf="@+id/speaker_detail_company"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/speaker_detail_company"
app:layout_constraintTop_toTopOf="@+id/speaker_detail_company"
app:srcCompat="@drawable/ic_blog_black_48dp"
/>
<TextView
android:id="@+id/speaker_detail_twitter_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="Twitter"
android:visibility="@{speaker.twitterUrl == null ? View.GONE : View.VISIBLE}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/speaker_detail_twitter"
app:layout_constraintStart_toStartOf="@+id/speaker_detail_twitter"
app:layout_constraintTop_toBottomOf="@+id/speaker_detail_twitter"
/>
<TextView
android:id="@+id/speaker_detail_github_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="github"
android:visibility="@{speaker.githubUrl == null ? View.GONE : View.VISIBLE}"
app:layout_constraintEnd_toEndOf="@+id/speaker_detail_github"
app:layout_constraintStart_toStartOf="@+id/speaker_detail_github"
app:layout_constraintTop_toBottomOf="@+id/speaker_detail_github"
/>
<TextView
android:id="@+id/speaker_detail_company_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="Company"
android:visibility="@{speaker.companyUrl == null ? View.GONE : View.VISIBLE}"
app:layout_constraintEnd_toEndOf="@+id/speaker_detail_company"
app:layout_constraintStart_toStartOf="@+id/speaker_detail_company"
app:layout_constraintTop_toBottomOf="@+id/speaker_detail_company"
/>
<TextView
android:id="@+id/speaker_detail_blog_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="Blog"
android:visibility="@{speaker.blogUrl == null ? View.GONE : View.VISIBLE}"
app:layout_constraintEnd_toEndOf="@+id/speaker_detail_blog"
app:layout_constraintStart_toStartOf="@+id/speaker_detail_blog"
app:layout_constraintTop_toBottomOf="@+id/speaker_detail_blog"
/>
<TextView
android:id="@+id/speaker_detail_sns_empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:layout_marginEnd="24dp"
android:layout_marginStart="24dp"
android:layout_marginTop="24dp"
android:text="@string/speaker_sns_empty_message"
android:textAppearance="@style/TextAppearance.App.Subhead"
android:visibility="@{speaker.twitterUrl == null &amp;&amp; speaker.githubUrl == null &amp;&amp; speaker.companyUrl == null &amp;&amp; speaker.blogUrl == null ? View.VISIBLE : View.GONE}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
</android.support.constraint.ConstraintLayout>
</layout>
4 changes: 2 additions & 2 deletions app/src/main/res/layout/fragment_speaker_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
/>
<ImageView
android:id="@+id/speaker_image"
android:layout_width="@{@dimen/search_speaker_image_size, default=@dimen/search_speaker_image_size}"
android:layout_height="@{@dimen/search_speaker_image_size, default=@dimen/search_speaker_image_size}"
android:layout_width="@{@dimen/speaker_detail_image_size, default=@dimen/speaker_detail_image_size}"
android:layout_height="@{@dimen/speaker_detail_image_size, default=@dimen/speaker_detail_image_size}"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<!-- Speaker -->
<string name="speaker_title_activity_detail">スピーカー</string>
<string name="speaker_content_description">スピーカー画像</string>
<string name="speaker_sns_empty_message">SNSのリンクが設定されていません</string>

<!-- Topic -->
<plurals name="topic_total_session">
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@
<dimen name="sticky_label_padding">20dp</dimen>
<dimen name="sticky_label_font_size">24sp</dimen>
<dimen name="sticky_label_content_margin">60dp</dimen>

<!-- Speaker -->
<dimen name="speaker_detail_image_size">64dp</dimen>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
<!-- Speaker -->
<string name="speaker_title_activity_detail">Speaker</string>
<string name="speaker_content_description">Speaker image</string>
<string name="speaker_sns_empty_message">Speaker has not set SNS Link..</string>

<!-- Topic -->
<plurals name="topic_total_session">
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@
<item name="android:elevation" tools:targetApi="21">2dp</item>
</style>

<style name="SNSLinkButton">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:background">@drawable/bg_sns_link_button</item>
<item name="android:elevation" tools:targetApi="21">2dp</item>
</style>

<style name="GoToFeedback">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
Expand Down

0 comments on commit c4fc923

Please sign in to comment.