File tree Expand file tree Collapse file tree 4 files changed +20
-2
lines changed
Expand file tree Collapse file tree 4 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import android.widget.Toast
1616import androidx.activity.result.contract.ActivityResultContracts
1717import androidx.appcompat.app.AppCompatActivity
1818import androidx.core.app.ActivityCompat
19+ import com.google.android.material.button.MaterialButton
1920import com.google.android.material.switchmaterial.SwitchMaterial
2021import timber.log.Timber
2122import java.util.*
@@ -41,6 +42,8 @@ class MainActivity : AppCompatActivity() {
4142
4243 setOwner(getPhoneNumber(this ))
4344 setActiveStatus(this )
45+ registerListeners()
46+ refreshToken()
4447 }
4548
4649 override fun onResume () {
@@ -49,12 +52,26 @@ class MainActivity : AppCompatActivity() {
4952 redirectToLogin()
5053 }
5154
55+ private fun refreshToken () {
56+
57+ }
58+
5259 private fun initTimber () {
5360 if (BuildConfig .DEBUG ) {
5461 Timber .plant(Timber .DebugTree ())
5562 }
5663 }
5764
65+ private fun registerListeners () {
66+ findViewById<MaterialButton >(R .id.mainLogoutButton).setOnClickListener { onLogoutClick() }
67+ }
68+
69+ private fun onLogoutClick () {
70+ Timber .d(" logout button clicked" )
71+ Settings .setApiKeyAsync(this , null )
72+ redirectToLogin()
73+ }
74+
5875 private fun redirectToLogin () {
5976 if (Settings .isLoggedIn(this )) {
6077 return
Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ object Settings {
8080 return getApiKey(context) ? : " "
8181 }
8282
83- fun setApiKeyAsync (context : Context , apiKey : String ) {
83+ fun setApiKeyAsync (context : Context , apiKey : String? ) {
8484 Timber .d(Settings ::setApiKeyAsync.name)
8585
8686 PreferenceManager .getDefaultSharedPreferences(context)
Original file line number Diff line number Diff line change 9292 android : indeterminate =" true"
9393 android : layout_marginTop =" 4dp"
9494 app : indicatorColor =" @color/pink_500"
95- app : layout_constraintTop_toBottomOf =" @+id/button "
95+ app : layout_constraintTop_toBottomOf =" @+id/loginButton "
9696 tools : layout_editor_absoluteX =" 16dp" />
9797 </LinearLayout >
9898
Original file line number Diff line number Diff line change 8080 </LinearLayout >
8181
8282 <com .google.android.material.button.MaterialButton
83+ android : id =" @+id/mainLogoutButton"
8384 style =" @style/Widget.MaterialComponents.Button.Icon"
8485 android : layout_width =" wrap_content"
8586 android : layout_height =" wrap_content"
You can’t perform that action at this time.
0 commit comments