Skip to content

Commit fe3caf4

Browse files
Updated SDKs
1 parent 00be48a commit fe3caf4

File tree

20 files changed

+175
-110
lines changed

20 files changed

+175
-110
lines changed

.idea/compiler.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/kotlinc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.

AutoFitTextViewLibrary/build.gradle

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
apply plugin: 'com.android.library'
2-
apply plugin: 'kotlin-android-extensions'
32
apply plugin: 'kotlin-android'
43

54
android {
6-
compileSdkVersion 28
5+
compileSdkVersion 33
76

87
defaultConfig {
98
minSdkVersion 14
10-
targetSdkVersion 28
11-
versionCode 1
12-
versionName "1.0"
9+
targetSdkVersion 33
1310
}
1411

1512
sourceSets {
@@ -30,15 +27,17 @@ android {
3027
}
3128
}
3229
compileOptions {
33-
sourceCompatibility = '1.8'
34-
targetCompatibility = '1.8'
30+
sourceCompatibility JavaVersion.VERSION_11
31+
targetCompatibility JavaVersion.VERSION_11
32+
}
33+
kotlinOptions {
34+
jvmTarget = "11"
3535
}
3636
}
3737

3838
dependencies {
39-
implementation 'androidx.appcompat:appcompat:1.0.2'
40-
implementation "androidx.core:core-ktx:1.0.1"
41-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
39+
implementation 'androidx.appcompat:appcompat:1.5.1'
40+
implementation "androidx.core:core-ktx:1.9.0"
4241
}
4342
repositories {
4443
mavenCentral()

AutoFitTextViewLibrary/project.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@
1010
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
1111
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
1212
# Project target.
13-
target=android-21
14-
android.library=true

AutoFitTextViewLibrary/src/com/lb/auto_fit_textview/AutoResizeTextView.kt

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class AutoResizeTextView @JvmOverloads constructor(context: Context, attrs: Attr
3030
private var widthLimit: Int = 0
3131
private var maxLines: Int = 0
3232
private var initialized = false
33-
private var textPaint: TextPaint? = null
33+
private var textPaint: TextPaint
3434

3535
private interface SizeTester {
3636
/**
@@ -43,6 +43,8 @@ class AutoResizeTextView @JvmOverloads constructor(context: Context, attrs: Attr
4343
fun onTestSize(suggestedSize: Int, availableSpace: RectF): Int
4444
}
4545

46+
47+
4648
init {
4749
// using the minimal recommended font size
4850
minTextSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12f, resources.displayMetrics)
@@ -53,24 +55,22 @@ class AutoResizeTextView @JvmOverloads constructor(context: Context, attrs: Attr
5355
maxLines = NO_LINE_LIMIT
5456
// prepare size tester:
5557
sizeTester = object : SizeTester {
56-
internal val textRect = RectF()
58+
val textRect = RectF()
5759

5860
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
5961
override fun onTestSize(suggestedSize: Int, availableSpace: RectF): Int {
60-
textPaint!!.textSize = suggestedSize.toFloat()
62+
textPaint.textSize = suggestedSize.toFloat()
6163
val transformationMethod = transformationMethod
62-
val text: String
63-
if (transformationMethod != null)
64-
text = transformationMethod.getTransformation(getText(), this@AutoResizeTextView).toString()
65-
else
66-
text = getText().toString()
64+
val text: String = transformationMethod?.getTransformation(text, this@AutoResizeTextView)
65+
?.toString()
66+
?: text.toString()
6767
val singleLine = maxLines == 1
6868
if (singleLine) {
69-
textRect.bottom = textPaint!!.fontSpacing
70-
textRect.right = textPaint!!.measureText(text)
69+
textRect.bottom = textPaint.fontSpacing
70+
textRect.right = textPaint.measureText(text)
7171
} else {
7272
val layout: StaticLayout = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
73-
StaticLayout.Builder.obtain(text, 0, text.length, textPaint!!, widthLimit).setLineSpacing(spacingAdd, spacingMult).setAlignment(Alignment.ALIGN_NORMAL).setIncludePad(true).build()
73+
StaticLayout.Builder.obtain(text, 0, text.length, textPaint, widthLimit).setLineSpacing(spacingAdd, spacingMult).setAlignment(Alignment.ALIGN_NORMAL).setIncludePad(true).build()
7474
} else StaticLayout(text, textPaint, widthLimit, Alignment.ALIGN_NORMAL, spacingMult, spacingAdd, true)
7575
// return early if we have more lines
7676
if (maxLines != NO_LINE_LIMIT && layout.lineCount > maxLines)
@@ -135,10 +135,10 @@ class AutoResizeTextView @JvmOverloads constructor(context: Context, attrs: Attr
135135

136136
override fun setSingleLine(singleLine: Boolean) {
137137
super.setSingleLine(singleLine)
138-
if (singleLine)
139-
maxLines = 1
138+
maxLines = if (singleLine)
139+
1
140140
else
141-
maxLines = NO_LINE_LIMIT
141+
NO_LINE_LIMIT
142142
adjustTextSize()
143143
}
144144

@@ -150,8 +150,7 @@ class AutoResizeTextView @JvmOverloads constructor(context: Context, attrs: Attr
150150

151151
override fun setTextSize(unit: Int, size: Float) {
152152
val c = context
153-
val r: Resources
154-
r = if (c == null)
153+
val r: Resources = if (c == null)
155154
Resources.getSystem()
156155
else
157156
c.resources
@@ -167,9 +166,8 @@ class AutoResizeTextView @JvmOverloads constructor(context: Context, attrs: Attr
167166

168167
/**
169168
* Set the lower text size limit and invalidate the view
170-
*
171-
* @param minTextSize
172169
*/
170+
@Suppress("unused")
173171
fun setMinTextSize(minTextSize: Float) {
174172
this.minTextSize = minTextSize
175173
adjustTextSize()
@@ -237,6 +235,6 @@ class AutoResizeTextView @JvmOverloads constructor(context: Context, attrs: Attr
237235
}
238236

239237
companion object {
240-
private val NO_LINE_LIMIT = -1
238+
private const val NO_LINE_LIMIT = -1
241239
}
242240
}

AutoFitTextViewSample/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
<application
55
android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/Theme.AppCompat.Light">
66
<activity
7-
android:name=".MainActivity" android:label="@string/app_name">
7+
android:name=".MainActivity" android:label="@string/app_name" android:exported="true">
88
<intent-filter>
99
<action android:name="android.intent.action.MAIN"/>
1010

1111
<category android:name="android.intent.category.LAUNCHER"/>
1212
</intent-filter>
1313
</activity>
14-
<activity android:name=".Main2Activity"></activity>
14+
<activity android:name=".Main2Activity" />
1515
</application>
1616

1717
</manifest>

AutoFitTextViewSample/build.gradle

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
apply plugin: 'com.android.application'
2-
apply plugin: 'kotlin-android-extensions'
32
apply plugin: 'kotlin-android'
43

54
android {
6-
compileSdkVersion 28
5+
compileSdkVersion 33
76

87
defaultConfig {
98
applicationId "com.example.autofittextviewsample"
109
minSdkVersion 17
11-
targetSdkVersion 28
10+
targetSdkVersion 33
1211
versionCode 1
1312
versionName "1.0"
1413
}
@@ -30,20 +29,24 @@ android {
3029
}
3130
}
3231
compileOptions {
33-
sourceCompatibility = '1.8'
34-
targetCompatibility = '1.8'
32+
sourceCompatibility JavaVersion.VERSION_11
33+
targetCompatibility JavaVersion.VERSION_11
34+
}
35+
kotlinOptions {
36+
jvmTarget = "11"
37+
}
38+
buildFeatures {
39+
viewBinding true
3540
}
36-
3741
}
3842

3943
dependencies {
4044
implementation fileTree(dir: 'libs', include: ['*.jar'])
41-
implementation 'androidx.appcompat:appcompat:1.0.2'
42-
implementation 'androidx.recyclerview:recyclerview:1.0.0'
45+
implementation 'androidx.appcompat:appcompat:1.5.1'
46+
implementation 'androidx.recyclerview:recyclerview:1.2.1'
4347
implementation project(':AutoFitTextViewLibrary')
44-
implementation 'androidx.core:core-ktx:1.0.1'
45-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
46-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
48+
implementation 'androidx.core:core-ktx:1.9.0'
49+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
4750
}
4851
repositories {
4952
mavenCentral()

AutoFitTextViewSample/lint.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<lint></lint>
2+
<lint />

AutoFitTextViewSample/project.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@
1010
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
1111
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
1212
# Project target.
13-
target=android-21
14-
android.library.reference.1=..\\AutoFitTextViewLibrary

AutoFitTextViewSample/res/layout/activity_main.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
android:text="2" app:layout_constraintBottom_toBottomOf="@id/minusLineCountButton" app:layout_constraintStart_toEndOf="@id/minusLineCountButton"
2121
app:layout_constraintTop_toBottomOf="@id/contentEditText"/>
2222

23-
2423
<Button
2524
android:id="@+id/plusLineCountButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/contentEditText" android:text="+"
2625
app:layout_constraintStart_toEndOf="@id/linesCountTextView" app:layout_constraintTop_toBottomOf="@id/contentEditText"/>

AutoFitTextViewSample/res/menu/main.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
<menu>
55
<group android:checkableBehavior="none" android:menuCategory="container">
66
<item android:id="@+id/menuItem_show_recyclerViewSample" android:title="show RecyclerView sample"/>
7-
<item android:id="@+id/menuItem_current_repository_website" android:title="Repository website"></item>
8-
<item android:id="@+id/menuItem_all_my_repositories" android:title="All my repositories"></item>
9-
<item android:id="@+id/menuItem_all_my_apps" android:title="All my apps"></item>
7+
<item
8+
android:id="@+id/menuItem_current_repository_website" android:title="Repository website" />
9+
<item
10+
android:id="@+id/menuItem_all_my_repositories" android:title="All my repositories" />
11+
<item
12+
android:id="@+id/menuItem_all_my_apps" android:title="All my apps" />
1013
</group>
1114
</menu>
1215
</item>

0 commit comments

Comments
 (0)