Skip to content

Commit 035857c

Browse files
committed
added share button: creates deep link which is handled in manifest. havent involved API in visualization yet
1 parent 63b87f9 commit 035857c

6 files changed

Lines changed: 152 additions & 0 deletions

File tree

PennMobile/src/main/AndroidManifest.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@
6666

6767
<action android:name="android.intent.action.VIEW" />
6868
</intent-filter>
69+
70+
<intent-filter>
71+
<action android:name="android.intent.action.VIEW" />
72+
<category android:name="android.intent.category.DEFAULT" />
73+
<category android:name="android.intent.category.BROWSABLE" />
74+
<data
75+
android:scheme="pennmobile"
76+
android:host="gsr"
77+
android:pathPrefix="/reservation" />
78+
</intent-filter>
6979
</activity>
7080

7181
<service android:name=".dining.widget.DiningHallWidgetAdapter"

PennMobile/src/main/java/com/pennapps/labs/pennmobile/MainActivity.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import com.pennapps.labs.pennmobile.dining.classes.Venue
5555
import com.pennapps.labs.pennmobile.fling.classes.FlingEvent
5656
import com.pennapps.labs.pennmobile.gsr.classes.GSRLocation
5757
import com.pennapps.labs.pennmobile.gsr.classes.GSRReservation
58+
import com.pennapps.labs.pennmobile.gsr.fragments.GsrReservationDetailFragment
5859
import com.pennapps.labs.pennmobile.gsr.widget.GsrReservationWidget
5960
import com.pennapps.labs.pennmobile.home.classes.Post
6061
import com.pennapps.labs.pennmobile.laundry.classes.LaundryRoom
@@ -134,6 +135,8 @@ class MainActivity : AppCompatActivity() {
134135
startHomeFragment()
135136
}
136137

138+
handleIntent(intent)
139+
137140
setUpAuthStateListener()
138141

139142
// Did diningWidgetIntentSetup not as separate function as for some reason when
@@ -156,6 +159,20 @@ class MainActivity : AppCompatActivity() {
156159
}
157160
}
158161

162+
override fun onNewIntent(intent: Intent) {
163+
super.onNewIntent(intent)
164+
handleIntent(intent)
165+
}
166+
167+
private fun handleIntent(intent: Intent) {
168+
if (intent.action == Intent.ACTION_VIEW) {
169+
val bookingId = intent.data?.lastPathSegment ?: return
170+
binding.include.mainViewPager.visibility = View.GONE
171+
hideBottomBar()
172+
fragmentTransact(GsrReservationDetailFragment.newInstance(bookingId), false)
173+
}
174+
}
175+
159176
override fun onConfigurationChanged(newConfig: Configuration) {
160177
super.onConfigurationChanged(newConfig)
161178

@@ -364,6 +381,7 @@ class MainActivity : AppCompatActivity() {
364381

365382
override fun onBackPressed() {
366383
super.onBackPressed()
384+
binding.include.mainViewPager.visibility = View.VISIBLE
367385
showBottomBar()
368386
}
369387

PennMobile/src/main/java/com/pennapps/labs/pennmobile/gsr/adapters/GsrReservationsAdapter.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,24 @@ class GsrReservationsAdapter(
144144

145145
builder.show()
146146
}
147+
148+
holder.gsrReservationShareButton.setOnClickListener {
149+
val bookingId = reservation.bookingId
150+
151+
// Create Deep Link
152+
val deepLink = "pennmobile://gsr/reservation/${reservation.bookingId}"
153+
154+
val shareIntent = Intent(Intent.ACTION_SEND).apply {
155+
type = "text/plain"
156+
putExtra(Intent.EXTRA_SUBJECT, "GSR Booking: $roomName")
157+
putExtra(
158+
Intent.EXTRA_TEXT,
159+
"Join my GSR booking!\n$roomName\n$day, $fromHour - $toHour\n\n$deepLink"
160+
)
161+
}
162+
163+
mContext.startActivity(Intent.createChooser(shareIntent, "Share Reservation"))
164+
}
147165
}
148166

149167
override fun getItemCount(): Int = reservations.size
@@ -152,6 +170,7 @@ class GsrReservationsAdapter(
152170
itemBinding: GsrReservationBinding,
153171
) : RecyclerView.ViewHolder(itemBinding.root) {
154172
val gsrReservationCancelButton = itemBinding.gsrReservationCancelBtn
173+
val gsrReservationShareButton = itemBinding.gsrReservationShareBtn
155174
val gsrReservationLocationTv = itemBinding.gsrReservationLocationTv
156175
val gsrReservationDateTv = itemBinding.gsrReservationDateTv
157176
val gsrReservationIv = itemBinding.gsrReservationIv
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.pennapps.labs.pennmobile.gsr.fragments
2+
3+
import android.os.Bundle
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import androidx.fragment.app.Fragment
8+
import com.pennapps.labs.pennmobile.databinding.FragmentGsrReservationDetailBinding
9+
10+
11+
class GsrReservationDetailFragment : Fragment() {
12+
13+
companion object {
14+
private const val ARG_BOOKING_ID = "booking_id"
15+
16+
fun newInstance(bookingId: String): GsrReservationDetailFragment {
17+
return GsrReservationDetailFragment().apply {
18+
arguments = Bundle().apply {
19+
putString(ARG_BOOKING_ID, bookingId)
20+
}
21+
}
22+
}
23+
}
24+
25+
override fun onCreateView(
26+
inflater: LayoutInflater, container: ViewGroup?,
27+
savedInstanceState: Bundle?
28+
): View {
29+
val binding = FragmentGsrReservationDetailBinding.inflate(inflater, container, false)
30+
val bookingId = arguments?.getString(ARG_BOOKING_ID)
31+
32+
// need to fetch full reservation details from API using bookingId
33+
// right now, just show booking id
34+
binding.gsrDetailBookingIdTv.text = "Booking ID: $bookingId"
35+
36+
return binding.root
37+
}
38+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:app="http://schemas.android.com/apk/res-auto"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
android:padding="16dp">
8+
9+
<ImageView
10+
android:id="@+id/gsr_detail_iv"
11+
android:layout_width="match_parent"
12+
android:layout_height="200dp"
13+
android:scaleType="centerCrop"
14+
app:layout_constraintTop_toTopOf="parent"
15+
app:layout_constraintStart_toStartOf="parent"
16+
app:layout_constraintEnd_toEndOf="parent" />
17+
18+
<TextView
19+
android:id="@+id/gsr_detail_location_tv"
20+
android:layout_width="0dp"
21+
android:layout_height="wrap_content"
22+
android:layout_marginTop="16dp"
23+
android:textSize="20sp"
24+
android:textStyle="bold"
25+
app:layout_constraintTop_toBottomOf="@id/gsr_detail_iv"
26+
app:layout_constraintStart_toStartOf="parent"
27+
app:layout_constraintEnd_toEndOf="parent" />
28+
29+
<TextView
30+
android:id="@+id/gsr_detail_date_tv"
31+
android:layout_width="0dp"
32+
android:layout_height="wrap_content"
33+
android:layout_marginTop="8dp"
34+
android:textSize="16sp"
35+
app:layout_constraintTop_toBottomOf="@id/gsr_detail_location_tv"
36+
app:layout_constraintStart_toStartOf="parent"
37+
app:layout_constraintEnd_toEndOf="parent" />
38+
39+
<TextView
40+
android:id="@+id/gsr_detail_booking_id_tv"
41+
android:layout_width="0dp"
42+
android:layout_height="wrap_content"
43+
android:layout_marginTop="8dp"
44+
android:textSize="14sp"
45+
android:textColor="@color/gray"
46+
app:layout_constraintTop_toBottomOf="@id/gsr_detail_date_tv"
47+
app:layout_constraintStart_toStartOf="parent"
48+
app:layout_constraintEnd_toEndOf="parent" />
49+
50+
</androidx.constraintlayout.widget.ConstraintLayout>

PennMobile/src/main/res/layout/gsr_reservation.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,23 @@
2222
app:layout_constraintBottom_toBottomOf="parent"
2323
app:layout_constraintStart_toEndOf="@+id/gsr_reservation_cardview" />
2424

25+
<Button
26+
android:id="@+id/gsr_reservation_share_btn"
27+
android:layout_width="wrap_content"
28+
android:layout_height="20dp"
29+
android:layout_marginStart="8dp"
30+
android:layout_marginLeft="8dp"
31+
android:layout_marginBottom="12dp"
32+
android:background="@drawable/rounded_corners"
33+
android:backgroundTint="@color/logo_light_blue"
34+
android:fontFamily="Roboto"
35+
android:text="Share"
36+
android:textAllCaps="false"
37+
android:textColor="@color/white"
38+
android:textSize="12dp"
39+
app:layout_constraintBottom_toBottomOf="parent"
40+
app:layout_constraintStart_toEndOf="@+id/gsr_reservation_cancel_btn" />
41+
2542
<androidx.cardview.widget.CardView
2643
android:id="@+id/gsr_reservation_cardview"
2744
android:layout_width="140dp"

0 commit comments

Comments
 (0)