Skip to content

Commit 9078987

Browse files
committed
Migrate to Jetpack Compose
1 parent b949fec commit 9078987

20 files changed

+471
-562
lines changed

app/build.gradle

+15-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ android {
66

77
defaultConfig {
88
applicationId "jp.ddo.hotmist.unicodepad"
9-
minSdkVersion 19
9+
minSdkVersion 21
1010
targetSdkVersion 34
1111
versionCode 61
1212
versionName "2.13.4"
@@ -21,6 +21,14 @@ android {
2121
jvmTarget = "1.8"
2222
}
2323

24+
buildFeatures {
25+
compose true
26+
}
27+
28+
composeOptions {
29+
kotlinCompilerExtensionVersion = "1.5.2"
30+
}
31+
2432
buildTypes {
2533
release {
2634
shrinkResources true
@@ -59,6 +67,12 @@ dependencies {
5967
implementation 'com.github.woxthebox:draglistview:1.7.3'
6068
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
6169
implementation 'com.github.mreram:showcaseview:1.4.1'
70+
implementation 'androidx.compose.ui:ui-tooling-preview'
71+
debugImplementation 'androidx.compose.ui:ui-tooling'
72+
implementation 'androidx.compose.ui:ui-android:1.6.5'
73+
implementation 'androidx.activity:activity-compose:1.8.2'
74+
implementation 'androidx.compose.material3:material3:1.2.1'
75+
implementation 'androidx.compose.material:material-icons-extended:1.6.5'
6276

6377
playImplementation 'com.google.android.gms:play-services-ads-lite:22.3.0'
6478
}

app/src/fdroid/AndroidManifest.xml

+13-11
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
-->
1717
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
1818
xmlns:tools="http://schemas.android.com/tools"
19-
android:installLocation="auto">
19+
android:installLocation="auto">
2020

2121
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
2222

2323
<queries>
2424
<intent>
25-
<action android:name="android.intent.action.VIEW" />
25+
<action android:name="android.intent.action.PROCESS_TEXT" />
2626
</intent>
2727
</queries>
2828

@@ -61,20 +61,22 @@
6161

6262
<category android:name="android.intent.category.DEFAULT" />
6363
</intent-filter>
64+
<meta-data android:name="android.app.shortcuts"
65+
android:resource="@xml/shortcuts" />
66+
</activity>
67+
68+
<activity-alias
69+
android:name="UnicodeActivityAlias"
70+
android:targetActivity="UnicodeActivity"
71+
android:enabled="true"
72+
android:exported="true">
73+
6474
<intent-filter android:icon="@mipmap/ic_launcher">
6575
<action android:name="android.intent.action.PROCESS_TEXT" />
6676
<category android:name="android.intent.category.DEFAULT" />
6777
<data android:mimeType="text/plain" />
6878
</intent-filter>
69-
<intent-filter>
70-
<action android:name="android.intent.action.VIEW" />
71-
<category android:name="android.intent.category.BROWSABLE" />
72-
<data android:scheme="http" />
73-
<data android:scheme="https" />
74-
</intent-filter>
75-
<meta-data android:name="android.app.shortcuts"
76-
android:resource="@xml/shortcuts" />
77-
</activity>
79+
</activity-alias>
7880

7981
<activity android:name="SettingActivity"
8082
android:parentActivityName=".UnicodeActivity" />

app/src/fdroid/res/layout/ad_container.xml

-1
This file was deleted.

app/src/main/java/jp/ddo/hotmist/unicodepad/EmojiAdapter.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ internal class EmojiAdapter(activity: Activity, pref: SharedPreferences, private
119119
}
120120
override fun onNothingSelected(parent: AdapterView<*>?) {}
121121
} }, LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT))
122-
if (Build.VERSION.SDK_INT >= 21) hl.setPadding(0, (activity.resources.displayMetrics.density * 8f).toInt(), 0, (activity.resources.displayMetrics.density * 8f).toInt())
122+
hl.setPadding(0, (activity.resources.displayMetrics.density * 8f).toInt(), 0, (activity.resources.displayMetrics.density * 8f).toInt())
123123
layout.addView(hl, LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
124124
layout.addView(this.view, LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1f))
125125
initViews()

app/src/main/java/jp/ddo/hotmist/unicodepad/FavoriteAdapter.kt

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package jp.ddo.hotmist.unicodepad
1717

1818
import android.app.Activity
1919
import android.content.SharedPreferences
20-
import androidx.recyclerview.widget.RecyclerView
2120
import java.util.*
2221

2322
internal class FavoriteAdapter(activity: Activity, pref: SharedPreferences, db: NameDatabase, single: Boolean) : DragListUnicodeAdapter<Int>(activity, db, single) {

app/src/main/java/jp/ddo/hotmist/unicodepad/FileChooser.kt

-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ internal class FileChooser(private val activity: Activity, private val listener:
139139
try {
140140
if (path.length == 1) {
141141
val dirs = Array(4) {""}
142-
@Suppress("DEPRECATION")
143142
dirs[0] = Environment.getExternalStorageDirectory().canonicalPath
144143
dirs[1] = Environment.getDataDirectory().canonicalPath
145144
dirs[2] = Environment.getDownloadCacheDirectory().canonicalPath

app/src/main/java/jp/ddo/hotmist/unicodepad/FontChooser.kt

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import android.app.AlertDialog
1818
import android.content.Intent
1919
import android.content.SharedPreferences
2020
import android.graphics.Typeface
21-
import android.os.Build
2221
import androidx.preference.PreferenceManager
2322
import android.view.View
2423
import android.widget.AdapterView

app/src/main/java/jp/ddo/hotmist/unicodepad/ListAdapter.kt

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ internal class ListAdapter(activity: Activity, pref: SharedPreferences, db: Name
5151
private val blockToIndex: MutableList<Int> = ArrayList()
5252
private val marks: NavigableMap<Int, String> = TreeMap()
5353
private var jump: Spinner? = null
54-
private var jumpAdapter: SpinnerAdapter? = null
5554
private var mark: Spinner? = null
5655
private var code: Button? = null
5756
private var current = -1

app/src/main/java/jp/ddo/hotmist/unicodepad/LocaleChooser.kt

+1-8
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,7 @@ class LocaleChooser internal constructor(private val context: Context, private v
4242
}
4343
while (locales.last() !is String)
4444
locales.removeLast()
45-
locales.add(if (Build.VERSION.SDK_INT >= 21) Locale.forLanguageTag(locale) else {
46-
val components = locale.split("_")
47-
when (components.size) {
48-
1 -> Locale(components[0])
49-
2 -> Locale(components[0], components[1])
50-
else -> Locale(components[0], components[1], components[2])
51-
}
52-
})
45+
locales.add(Locale.forLanguageTag(locale))
5346
adapter.notifyDataSetChanged()
5447
spinner.setSelection(locales.lastIndex)
5548
}

app/src/main/java/jp/ddo/hotmist/unicodepad/RecentAdapter.kt

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package jp.ddo.hotmist.unicodepad
1717

1818
import android.app.Activity
1919
import android.content.SharedPreferences
20-
import androidx.recyclerview.widget.RecyclerView
2120
import java.util.*
2221

2322
internal class RecentAdapter(activity: Activity, pref: SharedPreferences, db: NameDatabase, single: Boolean) : DragListUnicodeAdapter<Int>(activity, db, single) {

app/src/main/java/jp/ddo/hotmist/unicodepad/SettingActivity.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class SettingActivity : BaseActivity() {
198198
super.onActivityResult(requestCode, resultCode, data)
199199
if (requestCode == SETTING_EXPORT_CODE) if (resultCode == RESULT_OK && data != null) {
200200
val uri = data.data ?: return
201-
val pref = androidx.preference.PreferenceManager.getDefaultSharedPreferences(this.activity)
201+
val pref = PreferenceManager.getDefaultSharedPreferences(this.activity)
202202
val padding = (resources.displayMetrics.density * 8f).toInt()
203203
val cbSetting = CheckBox(this.activity).also {
204204
it.setText(R.string.data_setting)
@@ -353,7 +353,7 @@ class SettingActivity : BaseActivity() {
353353
hl.addView(cbFavoriteMerge, LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
354354
hl.addView(cbScroll, LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
355355
}).setTitle(R.string.imported_data).setPositiveButton(R.string.import_confirm) { _: DialogInterface, _: Int ->
356-
val pref = androidx.preference.PreferenceManager.getDefaultSharedPreferences(this.activity)
356+
val pref = PreferenceManager.getDefaultSharedPreferences(this.activity)
357357
val edit = pref.edit()
358358
if (cbSetting.isChecked) {
359359
obj.optJSONObject("setting")?.also {

0 commit comments

Comments
 (0)