File tree Expand file tree Collapse file tree 12 files changed +129
-2
lines changed
java/com/frontegg/demo/ui/home
java/com/frontegg/demo/ui/home
java/com/frontegg/demo/ui/home
java/com/frontegg/demo/ui/home Expand file tree Collapse file tree 12 files changed +129
-2
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,27 @@ class HomeFragment : Fragment() {
140140 }
141141 }
142142
143+ binding.receiveTokenButton.setOnClickListener {
144+ val token = requireContext().fronteggAuth.accessToken.value
145+ if (token.isNullOrEmpty()) {
146+ Toast .makeText(
147+ requireContext(),
148+ " Access token is not available yet" ,
149+ Toast .LENGTH_SHORT
150+ ).show()
151+ } else {
152+ val clipboard =
153+ requireContext().getSystemService(Context .CLIPBOARD_SERVICE ) as ClipboardManager
154+ val clip = ClipData .newPlainText(" Access Token" , token)
155+ clipboard.setPrimaryClip(clip)
156+ Toast .makeText(
157+ requireContext(),
158+ " Access token was copied to clipboard" ,
159+ Toast .LENGTH_SHORT
160+ ).show()
161+ }
162+ }
163+
143164 /* *
144165 * Opens the Frontegg Android Kotlin documentation in the default browser.
145166 * This button is part of the footer and provides quick access to the official documentation.
Original file line number Diff line number Diff line change @@ -38,4 +38,5 @@ class HomeViewModel(private val fronteggAuth: FronteggAuth) : ViewModel() {
3838
3939
4040 val user: LiveData <User ?> = _user
41+ val accessToken: LiveData <String ?> = _accessToken
4142}
Original file line number Diff line number Diff line change 126126 android : layout_marginEnd =" 24dp"
127127 android : text =" Sensitive action" />
128128
129+ <Button
130+ android : id =" @+id/receive_token_button"
131+ style =" @style/CustomButton"
132+ android : layout_width =" match_parent"
133+ android : layout_height =" wrap_content"
134+ android : layout_marginBottom =" 24dp"
135+ android : layout_marginStart =" 24dp"
136+ android : layout_marginEnd =" 24dp"
137+ android : text =" Get access token" />
138+
129139
130140 </LinearLayout >
131141 </com .google.android.material.card.MaterialCardView>
Original file line number Diff line number Diff line change @@ -140,6 +140,27 @@ class HomeFragment : Fragment() {
140140 }
141141 }
142142
143+ binding.receiveTokenButton.setOnClickListener {
144+ val token = requireContext().fronteggAuth.accessToken.value
145+ if (token.isNullOrEmpty()) {
146+ Toast .makeText(
147+ requireContext(),
148+ " Access token is not available yet" ,
149+ Toast .LENGTH_SHORT
150+ ).show()
151+ } else {
152+ val clipboard =
153+ requireContext().getSystemService(Context .CLIPBOARD_SERVICE ) as ClipboardManager
154+ val clip = ClipData .newPlainText(" Access Token" , token)
155+ clipboard.setPrimaryClip(clip)
156+ Toast .makeText(
157+ requireContext(),
158+ " Access token was copied to clipboard" ,
159+ Toast .LENGTH_SHORT
160+ ).show()
161+ }
162+ }
163+
143164 /* *
144165 * Opens the Frontegg Android Kotlin documentation in the default browser.
145166 * This button is part of the footer and provides quick access to the official documentation.
Original file line number Diff line number Diff line change @@ -39,4 +39,5 @@ class HomeViewModel(
3939
4040
4141 val user: LiveData <User ?> = _user
42+ val accessToken: LiveData <String ?> = _accessToken
4243}
Original file line number Diff line number Diff line change 126126 android : layout_marginEnd =" 24dp"
127127 android : text =" Sensitive action" />
128128
129+ <Button
130+ android : id =" @+id/receive_token_button"
131+ style =" @style/CustomButton"
132+ android : layout_width =" match_parent"
133+ android : layout_height =" wrap_content"
134+ android : layout_marginBottom =" 24dp"
135+ android : layout_marginStart =" 24dp"
136+ android : layout_marginEnd =" 24dp"
137+ android : text =" Get access token" />
138+
129139
130140 </LinearLayout >
131141 </com .google.android.material.card.MaterialCardView>
Original file line number Diff line number Diff line change 4141 <!-- Enable EmbeddedAuthActivity, disable HostedAuthActivity -->
4242 <activity
4343 android : name =" com.frontegg.android.EmbeddedAuthActivity"
44- android : enabled =" true "
44+ android : enabled =" false "
4545 tools : replace =" android:enabled" />
4646 <activity
4747 android : name =" com.frontegg.android.HostedAuthActivity"
48- android : enabled =" false "
48+ android : enabled =" true "
4949 tools : replace =" android:enabled" />
5050
5151
Original file line number Diff line number Diff line change @@ -140,6 +140,27 @@ class HomeFragment : Fragment() {
140140 }
141141 }
142142
143+ binding.receiveTokenButton.setOnClickListener {
144+ val token = requireContext().fronteggAuth.accessToken.value
145+ if (token.isNullOrEmpty()) {
146+ Toast .makeText(
147+ requireContext(),
148+ " Access token is not available yet" ,
149+ Toast .LENGTH_SHORT
150+ ).show()
151+ } else {
152+ val clipboard =
153+ requireContext().getSystemService(Context .CLIPBOARD_SERVICE ) as ClipboardManager
154+ val clip = ClipData .newPlainText(" Access Token" , token)
155+ clipboard.setPrimaryClip(clip)
156+ Toast .makeText(
157+ requireContext(),
158+ " Access token was copied to clipboard" ,
159+ Toast .LENGTH_SHORT
160+ ).show()
161+ }
162+ }
163+
143164 /* *
144165 * Opens the Frontegg Android Kotlin documentation in the default browser.
145166 * This button is part of the footer and provides quick access to the official documentation.
Original file line number Diff line number Diff line change 126126 android : layout_marginEnd =" 24dp"
127127 android : text =" Sensitive action" />
128128
129+ <Button
130+ android : id =" @+id/receive_token_button"
131+ style =" @style/CustomButton"
132+ android : layout_width =" match_parent"
133+ android : layout_height =" wrap_content"
134+ android : layout_marginBottom =" 24dp"
135+ android : layout_marginStart =" 24dp"
136+ android : layout_marginEnd =" 24dp"
137+ android : text =" Get access token" />
138+
129139
130140 </LinearLayout >
131141 </com .google.android.material.card.MaterialCardView>
Original file line number Diff line number Diff line change @@ -141,6 +141,27 @@ class HomeFragment : Fragment() {
141141 }
142142 }
143143
144+ binding.receiveTokenButton.setOnClickListener {
145+ val token = requireContext().fronteggAuth.accessToken.value
146+ if (token.isNullOrEmpty()) {
147+ Toast .makeText(
148+ requireContext(),
149+ " Access token is not available yet" ,
150+ Toast .LENGTH_SHORT
151+ ).show()
152+ } else {
153+ val clipboard =
154+ requireContext().getSystemService(Context .CLIPBOARD_SERVICE ) as ClipboardManager
155+ val clip = ClipData .newPlainText(" Access Token" , token)
156+ clipboard.setPrimaryClip(clip)
157+ Toast .makeText(
158+ requireContext(),
159+ " Access token was copied to clipboard" ,
160+ Toast .LENGTH_SHORT
161+ ).show()
162+ }
163+ }
164+
144165 /* *
145166 * Opens the Frontegg Android Kotlin documentation in the default browser.
146167 * This button is part of the footer and provides quick access to the official documentation.
You can’t perform that action at this time.
0 commit comments