Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add share button to the Session Detail Screen #578

Closed
wants to merge 13 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.github.droidkaigi.confsched2018.presentation.detail

import android.arch.lifecycle.ViewModelProvider
import android.arch.lifecycle.ViewModelProviders
import android.content.Intent
import android.graphics.drawable.Animatable
import android.os.Bundle
import android.support.v4.app.Fragment
Expand Down Expand Up @@ -52,7 +53,7 @@ class SessionDetailFragment : Fragment(), Injectable {
is Result.Success -> {
val sessions = result.data
val position = sessions.indexOfFirst { it.id == sessionId }
bindSession(sessions[position])
bindSession(sessions[position], sessionId)
setSessionIndicator(sessions.getOrNull(position - 1),
sessions.getOrNull(position + 1))
}
Expand All @@ -77,13 +78,29 @@ class SessionDetailFragment : Fragment(), Injectable {
binding.toolbar.setNavigationOnClickListener { activity?.finish() }
}

private fun bindSession(session: Session.SpeechSession) {
private fun bindSession(session: Session.SpeechSession, sessionId: String) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can get sessionId by session.id.
What do you think? 👀

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I'll fix

binding.session = session
binding.fab.setOnClickListener {
updateDrawable()
sessionDetailViewModel.onFavoriteClick(session)
sessionAlarm.toggleRegister(session)
}
binding.fabShare.setOnClickListener {
val shareIntent = Intent(Intent.ACTION_SEND).apply {
type = "text/plain"
var speakerList = listOf<String>()
session.speakers.forEach { speakerList += it.name }
val speakers = speakerList.joinToString(", ")
val title = resources.getString(R.string.session_share_title,
session.title,
session.room.name,
speakers)
val url = resources.getString(R.string.session_share_url, sessionId)
putExtra(Intent.EXTRA_TEXT, "$title\n$url")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

example

ConstraintLayout, now and future at Room 6 by Nicolas Roard, John Hoford, thagikura
https://droidkaigi.jp/2018/timetable?session=16988

Copy link
Collaborator Author

@rkowase rkowase Feb 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Q] Should I add a hashtag or any text?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please wait. I will talk with staff🙏

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The staff has decided to #droidkaigi_room1...#droidkaigi_room7 #droidkaigi_hall.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added

e.g.

ConstraintLayout, now and future (Nicolas Roard, John Hoford, thagikura) #droidkaigi_room6
https://droidkaigi.jp/2018/timetable/?session=16988

}
startActivity(Intent.createChooser(shareIntent,
resources.getString(R.string.session_share_via)))
}
binding.sessionTopic.text = session.topic.getNameByLang(lang())
val levelDrawable = binding.context.drawable(when (session.level) {
is Level.Beginner -> R.drawable.ic_beginner_lightgreen_20dp
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_share_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
</vector>
11 changes: 11 additions & 0 deletions app/src/main/res/layout/fragment_session_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,17 @@
app:tintCompat="@{@colorStateList/state_favorite_color}"
android:scaleType="center"/>

<android.support.design.widget.FloatingActionButton
android:id="@+id/fabShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="80dp"
app:backgroundTint="#FFF"
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|end"
app:srcCompat="@drawable/ic_share_black_24dp"
android:scaleType="center"/>

</android.support.design.widget.CoordinatorLayout>
</FrameLayout>
</layout>
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 @@ -29,6 +29,7 @@
<string name="session_load_retry">リトライ</string>
<string name="session_finished">終了済みのセッション</string>
<string name="session_go_to_feedback">アンケートへ</string>
<string name="session_share_via">シェア</string>

<!-- Session detail -->
<string name="detail_sessions_next">Next</string>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
<string name="session_finished">Finished Session</string>
<string name="session_go_to_feedback">Go To Feedback</string>
<string name="session_current_badge" translatable="false">NOW!</string>
<string name="session_share_url" translatable="false">https://droidkaigi.jp/2018/timetable?session=%s</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for translatable="false" 👍

<string name="session_share_title" translatable="false">%1$s at %2$s by %3$s</string>
<string name="session_share_via">Share via</string>

<!-- Session detail -->
<string name="detail_sessions_next">Next</string>
Expand Down