Skip to content

Commit 4a0583b

Browse files
authoredDec 17, 2020
Merge pull request android#210 from pfmaggi/pfm/updates
Update dependencies, add and enforce Android's Kotlin style.
2 parents ff5db72 + 53d940b commit 4a0583b

15 files changed

+237
-192
lines changed
 

‎.github/workflows/android.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
with:
3131
java-version: 1.8
3232

33-
- uses: malinskiy/action-android/install-sdk@release/0.0.5
33+
- uses: malinskiy/action-android/install-sdk@release/0.1.0
3434

3535
- name: Build project
3636
run: .github/scripts/gradlew_recursive.sh assembleDebug

‎WindowManager/app/build.gradle

+16-21
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,29 @@
11
/*
2+
* Copyright 2020 The Android Open Source Project
23
*
3-
* * Copyright 2020 The Android Open Source Project
4-
* *
5-
* * Licensed under the Apache License, Version 2.0 (the "License");
6-
* * you may not use this file except in compliance with the License.
7-
* * You may obtain a copy of the License at
8-
* *
9-
* * http://www.apache.org/licenses/LICENSE-2.0
10-
* *
11-
* * Unless required by applicable law or agreed to in writing, software
12-
* * distributed under the License is distributed on an "AS IS" BASIS,
13-
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* * See the License for the specific language governing permissions and
15-
* * limitations under the License.
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
167
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1715
*/
1816

1917
apply plugin: 'com.android.application'
20-
2118
apply plugin: 'kotlin-android'
22-
2319
apply plugin: 'kotlin-android-extensions'
2420

2521
android {
26-
compileSdkVersion 29
27-
buildToolsVersion "29.0.2"
22+
compileSdkVersion 30
2823
defaultConfig {
2924
applicationId "com.example.windowmanagersample"
3025
minSdkVersion 23
31-
targetSdkVersion 29
26+
targetSdkVersion 30
3227
versionCode 1
3328
versionName "1.0"
3429
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -48,8 +43,8 @@ android {
4843

4944
dependencies {
5045
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
51-
implementation 'androidx.appcompat:appcompat:1.1.0'
52-
implementation 'androidx.core:core-ktx:1.2.0'
53-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
46+
implementation 'androidx.appcompat:appcompat:1.2.0'
47+
implementation 'androidx.core:core-ktx:1.3.2'
48+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
5449
implementation "androidx.window:window:1.0.0-alpha01"
5550
}

‎WindowManager/app/src/main/java/com/example/windowmanagersample/BaseSampleActivity.kt

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
/*
2+
* Copyright 2020 The Android Open Source Project
23
*
3-
* * Copyright 2020 The Android Open Source Project
4-
* *
5-
* * Licensed under the Apache License, Version 2.0 (the "License");
6-
* * you may not use this file except in compliance with the License.
7-
* * You may obtain a copy of the License at
8-
* *
9-
* * http://www.apache.org/licenses/LICENSE-2.0
10-
* *
11-
* * Unless required by applicable law or agreed to in writing, software
12-
* * distributed under the License is distributed on an "AS IS" BASIS,
13-
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* * See the License for the specific language governing permissions and
15-
* * limitations under the License.
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
167
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1715
*/
1816

1917
package com.example.windowmanagersample
@@ -54,4 +52,4 @@ abstract class BaseSampleActivity : AppCompatActivity() {
5452
else -> null
5553
}
5654
}
57-
}
55+
}

‎WindowManager/app/src/main/java/com/example/windowmanagersample/DisplayFeaturesActivity.kt

+14-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
/*
2+
* Copyright 2020 The Android Open Source Project
23
*
3-
* * Copyright 2020 The Android Open Source Project
4-
* *
5-
* * Licensed under the Apache License, Version 2.0 (the "License");
6-
* * you may not use this file except in compliance with the License.
7-
* * You may obtain a copy of the License at
8-
* *
9-
* * http://www.apache.org/licenses/LICENSE-2.0
10-
* *
11-
* * Unless required by applicable law or agreed to in writing, software
12-
* * distributed under the License is distributed on an "AS IS" BASIS,
13-
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* * See the License for the specific language governing permissions and
15-
* * limitations under the License.
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
167
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1715
*/
1816

1917
package com.example.windowmanagersample
@@ -30,7 +28,8 @@ import androidx.window.WindowManager
3028
import com.example.windowmanagersample.backend.MidScreenFoldBackend
3129
import com.example.windowmanagersample.databinding.ActivityDisplayFeaturesBinding
3230
import java.text.SimpleDateFormat
33-
import java.util.*
31+
import java.util.Date
32+
import java.util.Locale
3433

3534
/**
3635
* Demo activity that shows all display features and current device state on the screen.
@@ -56,7 +55,7 @@ class DisplayFeaturesActivity : BaseSampleActivity() {
5655
windowBackend = getTestBackend()
5756
windowManager = WindowManager(this, windowBackend)
5857

59-
//if our windowBackend isn't null, we're using the test implementation so enable our
58+
// if our windowBackend isn't null, we're using the test implementation so enable our
6059
// DeviceState toggle
6160
if (windowBackend != null) {
6261
binding.deviceStateToggleButton.visibility = View.VISIBLE

‎WindowManager/app/src/main/java/com/example/windowmanagersample/SampleTools.kt

+26-28
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
/*
2+
* Copyright 2020 The Android Open Source Project
23
*
3-
* * Copyright 2020 The Android Open Source Project
4-
* *
5-
* * Licensed under the Apache License, Version 2.0 (the "License");
6-
* * you may not use this file except in compliance with the License.
7-
* * You may obtain a copy of the License at
8-
* *
9-
* * http://www.apache.org/licenses/LICENSE-2.0
10-
* *
11-
* * Unless required by applicable law or agreed to in writing, software
12-
* * distributed under the License is distributed on an "AS IS" BASIS,
13-
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* * See the License for the specific language governing permissions and
15-
* * limitations under the License.
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
167
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1715
*/
1816

1917
package com.example.windowmanagersample
@@ -55,7 +53,7 @@ fun getFeatureBoundsInWindow(
5553
val featureRectInView = Rect(displayFeature.bounds)
5654
val intersects = featureRectInView.intersect(viewRect)
5755

58-
//Checks to see if the display feature overlaps with our view at all
56+
// Checks to see if the display feature overlaps with our view at all
5957
if ((featureRectInView.width() == 0 && featureRectInView.height() == 0) ||
6058
!intersects
6159
) {
@@ -73,20 +71,20 @@ fun getFeatureBoundsInWindow(
7371
* [FrameLayout].
7472
*/
7573
fun getLayoutParamsForFeature(displayFeature: DisplayFeature, viewGroup: ViewGroup):
76-
MarginLayoutParams? {
77-
val featureRectInView = getFeatureBoundsInWindow(displayFeature, viewGroup) ?: return null
74+
MarginLayoutParams? {
75+
val featureRectInView = getFeatureBoundsInWindow(displayFeature, viewGroup) ?: return null
7876

79-
val lp = MarginLayoutParams(featureRectInView.width(), featureRectInView.height())
80-
lp.leftMargin = featureRectInView.left
81-
lp.topMargin = featureRectInView.top
77+
val lp = MarginLayoutParams(featureRectInView.width(), featureRectInView.height())
78+
lp.leftMargin = featureRectInView.left
79+
lp.topMargin = featureRectInView.top
8280

83-
// Make sure that zero-wide and zero-high features are still shown
84-
if (featureRectInView.left == featureRectInView.right) {
85-
lp.width = 1
86-
}
87-
if (featureRectInView.top == featureRectInView.bottom) {
88-
lp.height = 1
89-
}
81+
// Make sure that zero-wide and zero-high features are still shown
82+
if (featureRectInView.left == featureRectInView.right) {
83+
lp.width = 1
84+
}
85+
if (featureRectInView.top == featureRectInView.bottom) {
86+
lp.height = 1
87+
}
9088

91-
return lp
92-
}
89+
return lp
90+
}

‎WindowManager/app/src/main/java/com/example/windowmanagersample/SplitLayout.kt

+13-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
/*
2+
* Copyright 2020 The Android Open Source Project
23
*
3-
* * Copyright 2020 The Android Open Source Project
4-
* *
5-
* * Licensed under the Apache License, Version 2.0 (the "License");
6-
* * you may not use this file except in compliance with the License.
7-
* * You may obtain a copy of the License at
8-
* *
9-
* * http://www.apache.org/licenses/LICENSE-2.0
10-
* *
11-
* * Unless required by applicable law or agreed to in writing, software
12-
* * distributed under the License is distributed on an "AS IS" BASIS,
13-
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* * See the License for the specific language governing permissions and
15-
* * limitations under the License.
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
167
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1715
*/
1816

1917
package com.example.windowmanagersample
@@ -158,6 +156,6 @@ class SplitLayout : FrameLayout {
158156
val heightSpec = MeasureSpec.makeMeasureSpec(rect.height(), AT_MOST)
159157
childView.measure(widthSpec, heightSpec)
160158
return childView.measuredWidthAndState and MEASURED_STATE_TOO_SMALL == 0 &&
161-
childView.measuredHeightAndState and MEASURED_STATE_TOO_SMALL == 0
159+
childView.measuredHeightAndState and MEASURED_STATE_TOO_SMALL == 0
162160
}
163-
}
161+
}

‎WindowManager/app/src/main/java/com/example/windowmanagersample/SplitLayoutActivity.kt

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
/*
2+
* Copyright 2020 The Android Open Source Project
23
*
3-
* * Copyright 2020 The Android Open Source Project
4-
* *
5-
* * Licensed under the Apache License, Version 2.0 (the "License");
6-
* * you may not use this file except in compliance with the License.
7-
* * You may obtain a copy of the License at
8-
* *
9-
* * http://www.apache.org/licenses/LICENSE-2.0
10-
* *
11-
* * Unless required by applicable law or agreed to in writing, software
12-
* * distributed under the License is distributed on an "AS IS" BASIS,
13-
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* * See the License for the specific language governing permissions and
15-
* * limitations under the License.
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
167
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1715
*/
1816

1917
package com.example.windowmanagersample
@@ -58,4 +56,4 @@ class SplitLayoutActivity : BaseSampleActivity() {
5856
binding.splitLayout.updateWindowLayout(newLayoutInfo)
5957
}
6058
}
61-
}
59+
}

‎WindowManager/app/src/main/java/com/example/windowmanagersample/WindowDemosActivity.kt

+12-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
/*
2+
* Copyright 2020 The Android Open Source Project
23
*
3-
* * Copyright 2020 The Android Open Source Project
4-
* *
5-
* * Licensed under the Apache License, Version 2.0 (the "License");
6-
* * you may not use this file except in compliance with the License.
7-
* * You may obtain a copy of the License at
8-
* *
9-
* * http://www.apache.org/licenses/LICENSE-2.0
10-
* *
11-
* * Unless required by applicable law or agreed to in writing, software
12-
* * distributed under the License is distributed on an "AS IS" BASIS,
13-
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* * See the License for the specific language governing permissions and
15-
* * limitations under the License.
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
167
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1715
*/
1816

1917
package com.example.windowmanagersample
@@ -26,7 +24,6 @@ import com.example.windowmanagersample.BaseSampleActivity.Companion.BACKEND_TYPE
2624
import com.example.windowmanagersample.BaseSampleActivity.Companion.BACKEND_TYPE_MID_SCREEN_FOLD
2725
import com.example.windowmanagersample.databinding.ActivityWindowDemosBinding
2826

29-
3027
/**
3128
* Main activity that launches WindowManager demos. Allows the user to choose the backend to use
3229
* with the [androidx.window.WindowManager] library interface, which can be helpful if the test
@@ -85,4 +82,4 @@ class WindowDemosActivity : AppCompatActivity() {
8582
intent.putExtra(BACKEND_TYPE_EXTRA, selectedBackend)
8683
startActivity(intent)
8784
}
88-
}
85+
}

0 commit comments

Comments
 (0)
Please sign in to comment.