Skip to content

Commit 08675bd

Browse files
committed
Update sample project
1 parent 1b203d7 commit 08675bd

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

sdk-example-kt/src/main/java/jp/studyplus/android/sdk_example_kt/MainActivity.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ class MainActivity : AppCompatActivity() {
3838
}
3939
}
4040

41+
findViewById<View>(R.id.cancel_auth)?.apply {
42+
setOnClickListener {
43+
Studyplus.instance.cancelAuth(this@MainActivity)
44+
updateAuthText()
45+
}
46+
}
47+
4148
findViewById<View>(R.id.post_study_record)?.apply {
4249
setOnClickListener {
4350
val record = StudyRecord(
@@ -64,7 +71,10 @@ class MainActivity : AppCompatActivity() {
6471

6572
override fun onResume() {
6673
super.onResume()
74+
updateAuthText()
75+
}
6776

77+
private fun updateAuthText() {
6878
val authStatusText = findViewById<TextView>(R.id.auth_status)
6979
authStatusText.text = when (Studyplus.instance.isAuthenticated(this)) {
7080
true -> getString(R.string.status_authenticated)

sdk-example-kt/src/main/res/layout/activity_main.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@
3535
android:layout_width="match_parent"
3636
android:layout_height="24dp" />
3737

38+
<Button
39+
android:id="@+id/cancel_auth"
40+
android:layout_width="match_parent"
41+
android:layout_height="wrap_content"
42+
android:padding="8dp"
43+
android:text="@string/cancel_auth_button" />
44+
45+
<Space
46+
android:layout_width="match_parent"
47+
android:layout_height="24dp" />
48+
3849
<Button
3950
android:id="@+id/post_study_record"
4051
android:layout_width="match_parent"

sdk-example-kt/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<string name="status_authenticated">認証済</string>
66

77
<string name="start_auth_button">認証画面を開く</string>
8+
<string name="cancel_auth_button">認証を解除する</string>
89
<string name="post_study_record_button">投稿!</string>
910

1011
<string name="consumer_key"></string>

0 commit comments

Comments
 (0)