Skip to content

Commit 4b560b5

Browse files
committed
Remove android.support
1 parent bce4d8f commit 4b560b5

File tree

13 files changed

+54
-49
lines changed

13 files changed

+54
-49
lines changed
0 Bytes
Binary file not shown.

app/build.gradle

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ android {
1010
targetSdkVersion rootProject.ext.targetSdkVersion
1111
versionCode 1
1212
versionName "1.0"
13-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1414
}
1515
buildTypes {
1616
release {
@@ -23,15 +23,12 @@ android {
2323
dependencies {
2424
implementation fileTree(dir: 'libs', include: ['*.jar'])
2525
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
26-
implementation "com.android.support:appcompat-v7:$supportVersion"
27-
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
26+
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
2827

2928
api project(':omegatypes')
30-
3129
api project(':picasso')
3230

33-
3431
testImplementation 'junit:junit:4.12'
35-
androidTestImplementation 'com.android.support.test:runner:1.0.2'
36-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
32+
androidTestImplementation 'androidx.test:runner:1.1.1'
33+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
3734
}

app/src/androidTest/java/omega_r/com/omegatypesexample/ExampleInstrumentedTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package omega_r.com.omegatypesexample
22

3-
import android.support.test.InstrumentationRegistry
4-
import android.support.test.runner.AndroidJUnit4
3+
import androidx.test.InstrumentationRegistry
4+
import androidx.test.runner.AndroidJUnit4
55

66
import org.junit.Test
77
import org.junit.runner.RunWith

app/src/main/java/omega_r/com/omegatypesexample/BaseActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package omega_r.com.omegatypesexample
22

33
import android.app.Activity
4-
import android.support.annotation.IdRes
5-
import android.support.v7.app.AppCompatActivity
4+
import androidx.annotation.IdRes
5+
import androidx.appcompat.app.AppCompatActivity
66
import android.view.View
77

88
open class BaseActivity : AppCompatActivity() {

app/src/main/java/omega_r/com/omegatypesexample/MainActivity.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import com.omega_r.libs.omegatypes.Image
99
import com.omega_r.libs.omegatypes.Text
1010
import com.omega_r.libs.omegatypes.applyTo
1111
import com.omega_r.libs.omegatypes.picasso.from
12-
import com.omega_r.libs.omegatypes.setBackground
13-
import kotlinx.android.synthetic.main.activity_main.*
1412
import kotlin.concurrent.thread
1513

1614
class MainActivity : BaseActivity() {

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# http://www.gradle.org/docs/current/userguide/build_environment.html
77
# Specifies the JVM arguments used for the daemon process.
88
# The setting is particularly useful for tweaking memory settings.
9+
android.enableJetifier=true
10+
android.useAndroidX=true
911
org.gradle.jvmargs=-Xmx1536m
1012
# When configured, Gradle will run in incubating parallel mode.
1113
# This option should only be used with decoupled projects. More details, visit

omegatypes/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ android {
1212
targetSdkVersion rootProject.ext.targetSdkVersion
1313
versionCode 1
1414
versionName "1.0"
15-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1616

1717
}
1818

@@ -28,5 +28,4 @@ android {
2828
dependencies {
2929
implementation fileTree(dir: 'libs', include: ['*.jar'])
3030
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
31-
compileOnly "com.android.support:appcompat-v7:$supportVersion"
3231
}

omegatypes/src/main/java/com/omega_r/libs/omegatypes/Image.kt

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ import android.graphics.Canvas
77
import android.graphics.Rect
88
import android.graphics.drawable.BitmapDrawable
99
import android.graphics.drawable.Drawable
10-
import android.support.annotation.DrawableRes
11-
import android.support.annotation.Px
12-
import android.support.v4.view.ViewCompat
1310
import android.view.View
1411
import android.widget.ImageView
12+
import com.omega_r.libs.omegatypes.Image.Companion.applyBackground
1513
import java.io.*
1614

1715
open class Image : Serializable {
@@ -21,9 +19,10 @@ open class Image : Serializable {
2119
}
2220

2321
open fun applyBackground(view: View) {
24-
ViewCompat.setBackground(view, null)
22+
applyBackground(view, null)
2523
}
2624

25+
2726
@Throws(IOException::class)
2827
open fun getStream(context: Context,
2928
compressFormat: Bitmap.CompressFormat = Bitmap.CompressFormat.JPEG, quality: Int = 100): InputStream {
@@ -32,22 +31,35 @@ open class Image : Serializable {
3231
}
3332
}
3433

34+
protected fun applyBackground(view: View, background: Drawable?) {
35+
Image.applyBackground(view, background)
36+
}
37+
3538
companion object {
3639

3740
@JvmStatic
3841
fun empty() = Image()
3942

4043
@JvmStatic
41-
fun from(@DrawableRes stringRes: Int): Image = ResourceImage(stringRes)
44+
fun from(stringRes: Int): Image = ResourceImage(stringRes)
4245

4346
@JvmStatic
4447
fun from(drawable: Drawable): Image = DrawableImage(drawable)
4548

4649
@JvmStatic
4750
fun from(bitmap: Bitmap): Image = BitmapImage(bitmap)
51+
52+
internal fun applyBackground(view: View, background: Drawable?) {
53+
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
54+
@Suppress("DEPRECATION")
55+
view.setBackgroundDrawable(background)
56+
} else {
57+
view.background = background;
58+
}
59+
}
4860
}
4961

50-
class ResourceImage(@DrawableRes private val resId: Int) : Image() {
62+
class ResourceImage(private val resId: Int) : Image() {
5163

5264
override fun applyImage(imageView: ImageView) {
5365
imageView.setImageResource(resId)
@@ -71,7 +83,7 @@ open class Image : Serializable {
7183
}
7284

7385
override fun applyBackground(view: View) {
74-
ViewCompat.setBackground(view, drawable)
86+
applyBackground(view, drawable)
7587
}
7688

7789
override fun getStream(context: Context, compressFormat: Bitmap.CompressFormat, quality: Int): InputStream {
@@ -87,7 +99,7 @@ open class Image : Serializable {
8799
}
88100

89101
override fun applyBackground(view: View) {
90-
ViewCompat.setBackground(view, BitmapDrawable(view.resources, bitmap))
102+
applyBackground(view, BitmapDrawable(view.resources, bitmap))
91103
}
92104

93105
override fun getStream(context: Context, compressFormat: Bitmap.CompressFormat, quality: Int): InputStream {
@@ -97,16 +109,16 @@ open class Image : Serializable {
97109

98110
}
99111

100-
fun Bitmap.toInputStream(compressFormat: Bitmap.CompressFormat, quality: Int ): InputStream {
112+
fun Bitmap.toInputStream(compressFormat: Bitmap.CompressFormat, quality: Int): InputStream {
101113
val stream = ByteArrayOutputStream()
102114
compress(compressFormat, quality, stream)
103115
val byteArray = stream.toByteArray()
104116
return ByteArrayInputStream(byteArray)
105117
}
106118

107119
fun Drawable.toBitmap(
108-
@Px width: Int = intrinsicWidth,
109-
@Px height: Int = intrinsicHeight,
120+
width: Int = intrinsicWidth,
121+
height: Int = intrinsicHeight,
110122
config: Bitmap.Config? = null
111123
): Bitmap {
112124
if (this is BitmapDrawable) {
@@ -135,7 +147,7 @@ fun ImageView.setImage(image: Image?) {
135147
}
136148

137149
fun View.setBackground(image: Image?) {
138-
image?.applyBackground(this) ?: ViewCompat.setBackground(this, null)
150+
image?.applyBackground(this) ?: applyBackground(this, null)
139151

140152
}
141153

omegatypes/src/main/java/com/omega_r/libs/omegatypes/Text.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.omega_r.libs.omegatypes
33
import android.app.Activity
44
import android.content.Context
55
import android.content.res.Resources
6-
import android.support.annotation.StringRes
76
import android.widget.EditText
87
import android.widget.TextView
98
import android.widget.Toast
@@ -36,10 +35,10 @@ open class Text private constructor() : Serializable {
3635
fun from(string: String): Text = StringText(string)
3736

3837
@JvmStatic
39-
fun from(@StringRes stringRes: Int): Text = ResourceText(stringRes)
38+
fun from(stringRes: Int): Text = ResourceText(stringRes)
4039

4140
@JvmStatic
42-
fun from(@StringRes stringRes: Int, vararg formatArgs: Any): Text =
41+
fun from(stringRes: Int, vararg formatArgs: Any): Text =
4342
FormatResourceText(stringRes, *formatArgs)
4443

4544
@JvmStatic
@@ -69,7 +68,7 @@ open class Text private constructor() : Serializable {
6968

7069
}
7170

72-
private class ResourceText internal constructor(@StringRes private val stringRes: Int) : Text() {
71+
private class ResourceText internal constructor(private val stringRes: Int) : Text() {
7372

7473
override fun isEmpty(): Boolean = stringRes <= 0
7574

@@ -92,7 +91,7 @@ open class Text private constructor() : Serializable {
9291

9392
}
9493

95-
private class FormatResourceText internal constructor(@StringRes private val stringRes: Int,
94+
private class FormatResourceText internal constructor(private val stringRes: Int,
9695
private vararg val formatArgs: Any) : Text() {
9796

9897
override fun isEmpty(): Boolean = stringRes <= 0

picasso/build.gradle

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ android {
55
compileSdkVersion 28
66

77

8-
98
defaultConfig {
109
minSdkVersion 14
1110
targetSdkVersion 28
1211
versionCode 1
1312
versionName "1.0"
1413

15-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1614

1715
}
1816

@@ -25,16 +23,17 @@ android {
2523

2624
}
2725

26+
2827
dependencies {
28+
29+
implementation project(':omegatypes')
30+
2931
implementation fileTree(dir: 'libs', include: ['*.jar'])
3032

31-
implementation "com.android.support:appcompat-v7:$supportVersion"
32-
implementation 'com.squareup.picasso:picasso:2.71828'
33-
api project(':omegatypes')
33+
implementation ('com.squareup.picasso:picasso:2.71828') {
34+
exclude group: 'com.android.support', module: 'support-annotations'
35+
}
3436

35-
testImplementation 'junit:junit:4.12'
36-
androidTestImplementation 'com.android.support.test:runner:1.0.2'
37-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
3837
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
3938
}
4039
repositories {

0 commit comments

Comments
 (0)