Skip to content

Commit 9f6c35a

Browse files
authored
Merge pull request #25 from studyplus/feature/cancel_auth
認証キャンセル処理追加
2 parents 2256b3b + 5a072fb commit 9f6c35a

File tree

17 files changed

+150
-75
lines changed

17 files changed

+150
-75
lines changed

.github/workflows/pr_check.yml

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,70 @@ jobs:
99
danger:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v1
12+
- name: Checkout
13+
uses: actions/[email protected]
14+
15+
- name: Bundler Cache
16+
uses: actions/[email protected]
17+
with:
18+
path: vendor/bundle
19+
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
20+
restore-keys: |
21+
${{ runner.os }}-gems-
1322
- name: Setup Ruby for use with actions
1423
uses: actions/[email protected]
1524
with:
16-
ruby-version: '2.6'
17-
architecture: 'x64'
18-
- name: Install danger
25+
ruby-version: '2.7'
26+
- name: Install Danger
1927
run: |
2028
gem install bundler
21-
bundle install
29+
bundle config set path 'vendor/bundle'
30+
bundle config set clean 'true'
31+
bundle check || bundle install --jobs 4 --retry 3
32+
33+
- name: Gradle dist Cache
34+
uses: actions/[email protected]
35+
with:
36+
path: ~/.gradle/wrapper
37+
key: ${{ runner.os }}-dist-gradle-${{ hashFiles('**/gradle-wrapper.properties') }}
38+
- name: Gradle dependencies Cache
39+
uses: actions/[email protected]
40+
with:
41+
path: ~/.gradle/caches
42+
key: ${{ runner.os }}-v1-gradle-${{ hashFiles('./build.gradle') }}-${{ hashFiles('**/build.gradle') }}
43+
restore-keys: |
44+
${{ runner.os }}-v1-gradle-${{ hashFiles('./build.gradle') }}-
45+
${{ runner.os }}-v1-gradle-
46+
- name: Download Dependencies
47+
run: |
48+
./gradlew androidDependencies --no-daemon
49+
2250
- name: Run danger
2351
env:
2452
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25-
run: danger
53+
run: bundle exec danger
54+
2655
unit_test:
2756
runs-on: ubuntu-latest
2857
steps:
29-
- uses: actions/checkout@v1
58+
- name: Checkout
59+
uses: actions/[email protected]
60+
61+
- name: Gradle dist Cache
62+
uses: actions/[email protected]
63+
with:
64+
path: ~/.gradle/wrapper
65+
key: ${{ runner.os }}-dist-gradle-${{ hashFiles('**/gradle-wrapper.properties') }}
66+
- name: Gradle dependencies Cache
67+
uses: actions/[email protected]
68+
with:
69+
path: ~/.gradle/caches
70+
key: ${{ runner.os }}-v1-gradle-${{ hashFiles('**/build.gradle') }}
71+
restore-keys: |
72+
${{ runner.os }}-v1-gradle-
73+
- name: Download Dependencies
74+
run: |
75+
./gradlew androidDependencies --no-daemon
76+
3077
- name: Run unit test
3178
run: ./gradlew studyplus-android-sdk:test
32-

Gemfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
# frozen_string_literal: true
12
source "https://rubygems.org"
23

3-
gem "danger"
4-
gem 'danger-android_lint'
4+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
5+
6+
gem 'danger'
7+
gem 'danger-android_lint'

Gemfile.lock

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,66 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
addressable (2.5.2)
5-
public_suffix (>= 2.0.2, < 4.0)
4+
addressable (2.7.0)
5+
public_suffix (>= 2.0.2, < 5.0)
66
ansi (1.5.0)
77
ast (2.4.0)
8-
claide (1.0.2)
8+
claide (1.0.3)
99
claide-plugins (0.9.2)
1010
cork
1111
nap
1212
open4 (~> 1.3)
1313
colored2 (3.1.2)
1414
cork (0.3.0)
1515
colored2 (~> 3.1)
16-
danger (6.0.6)
16+
danger (6.3.2)
1717
claide (~> 1.0)
1818
claide-plugins (>= 0.9.2)
1919
colored2 (~> 3.1)
2020
cork (~> 0.1)
2121
faraday (~> 0.9)
22-
faraday-http-cache (~> 1.0)
23-
git (~> 1.5)
22+
faraday-http-cache (~> 2.0)
23+
git (~> 1.6)
2424
kramdown (~> 2.0)
2525
kramdown-parser-gfm (~> 1.0)
2626
no_proxy_fix
2727
octokit (~> 4.7)
2828
terminal-table (~> 1)
29-
danger-android_lint (0.0.7)
29+
danger-android_lint (0.0.8)
3030
danger-plugin-api (~> 1.0)
3131
oga
3232
danger-plugin-api (1.0.0)
3333
danger (> 2.0)
34-
faraday (0.15.4)
34+
faraday (0.17.3)
3535
multipart-post (>= 1.2, < 3)
36-
faraday-http-cache (1.3.1)
36+
faraday-http-cache (2.0.0)
3737
faraday (~> 0.8)
38-
git (1.5.0)
38+
git (1.6.0)
39+
rchardet (~> 1.8)
3940
kramdown (2.1.0)
40-
kramdown-parser-gfm (1.0.1)
41+
kramdown-parser-gfm (1.1.0)
4142
kramdown (~> 2.0)
42-
multipart-post (2.0.0)
43+
multipart-post (2.1.1)
4344
nap (1.1.0)
4445
no_proxy_fix (0.1.2)
45-
octokit (4.14.0)
46+
octokit (4.18.0)
47+
faraday (>= 0.9)
4648
sawyer (~> 0.8.0, >= 0.5.3)
47-
oga (2.15)
49+
oga (3.2)
4850
ast
4951
ruby-ll (~> 2.1)
5052
open4 (1.3.4)
51-
public_suffix (3.0.3)
53+
public_suffix (4.0.3)
54+
rchardet (1.8.0)
5255
ruby-ll (2.1.2)
5356
ansi
5457
ast
55-
sawyer (0.8.1)
56-
addressable (>= 2.3.5, < 2.6)
57-
faraday (~> 0.8, < 1.0)
58+
sawyer (0.8.2)
59+
addressable (>= 2.3.5)
60+
faraday (> 0.8, < 2.0)
5861
terminal-table (1.8.0)
5962
unicode-display_width (~> 1.1, >= 1.1.1)
60-
unicode-display_width (1.5.0)
63+
unicode-display_width (1.7.0)
6164

6265
PLATFORMS
6366
ruby
@@ -67,4 +70,4 @@ DEPENDENCIES
6770
danger-android_lint
6871

6972
BUNDLED WITH
70-
2.0.1
73+
2.1.4

build.gradle

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,25 @@
22

33
buildscript {
44
ext {
5-
kotlin_version = '1.3.50'
6-
kotlin_cotoutines_version = '1.3.1'
5+
kotlin_version = '1.3.71'
6+
kotlin_cotoutines_version = '1.3.5'
77
}
88
ext.versions = [
99
'compileSdk' : 29,
1010
'minSdk' : 21,
1111
'targetSdk' : 29,
1212
'annotation' : '1.1.0',
13-
'core_ktx' : '1.1.0',
1413
'appcompat' : '1.1.0',
15-
'constraintLayout': '1.1.3'
14+
'constraintLayout': '1.1.3',
15+
'junit' : '4.13',
16+
'robolectric' : '4.3.1'
1617
]
1718
repositories {
1819
google()
1920
jcenter()
2021
}
2122
dependencies {
22-
classpath 'com.android.tools.build:gradle:3.5.0'
23+
classpath 'com.android.tools.build:gradle:3.6.2'
2324
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
2425
}
2526
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Wed Sep 25 14:10:00 JST 2019
1+
#Thu Apr 02 08:45:00 JST 2020
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

sdk-example-java/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ repositories {
3434
dependencies {
3535
implementation fileTree(dir: 'libs', include: ['*.jar'])
3636

37-
implementation "androidx.appcompat:appcompat:${versions.appcompat}"
38-
implementation "androidx.constraintlayout:constraintlayout:${versions.constraintLayout}"
37+
implementation "androidx.appcompat:appcompat:$versions.appcompat"
38+
implementation "androidx.constraintlayout:constraintlayout:$versions.constraintLayout"
3939

4040
implementation 'com.github.studyplus:Studyplus-Android-SDK:2.5.1'
4141

42-
testImplementation 'junit:junit:4.12'
42+
testImplementation "junit:junit:$versions.junit"
4343
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
4444
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
4545
}

sdk-example-kt/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ repositories {
3333
dependencies {
3434
implementation fileTree(include: ['*.jar'], dir: 'libs')
3535
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
36-
implementation "androidx.appcompat:appcompat:${versions.appcompat}"
37-
implementation "androidx.constraintlayout:constraintlayout:${versions.constraintLayout}"
36+
implementation "androidx.appcompat:appcompat:$versions.appcompat"
37+
implementation "androidx.constraintlayout:constraintlayout:$versions.constraintLayout"
3838

3939
implementation 'com.github.studyplus:Studyplus-Android-SDK:2.5.1'
4040

41-
testImplementation 'junit:junit:4.12'
41+
testImplementation "junit:junit:$versions.junit"
4242
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
4343
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
4444
}

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)