Skip to content

Commit

Permalink
Merge pull request #140 from Ryosuke839/develop
Browse files Browse the repository at this point in the history
Release 2.13.1
  • Loading branch information
Ryosuke839 authored Sep 16, 2023
2 parents 1493aef + 5f3a23d commit 662bce5
Show file tree
Hide file tree
Showing 44 changed files with 1,699 additions and 492 deletions.
3 changes: 1 addition & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 11 additions & 15 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 33
compileSdkVersion 34

defaultConfig {
applicationId "jp.ddo.hotmist.unicodepad"
minSdkVersion 16
targetSdkVersion 33
versionCode 54
versionName "2.12.1"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
minSdkVersion 19
targetSdkVersion 34
versionCode 57
versionName "2.13.1"
}

compileOptions {
Expand Down Expand Up @@ -56,13 +51,14 @@ android {
dependencies {
implementation "androidx.core:core-ktx:$kotlin_version"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'androidx.emoji2:emoji2:1.2.0'
implementation 'androidx.preference:preference-ktx:1.2.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.emoji2:emoji2:1.4.0'
implementation 'androidx.preference:preference-ktx:1.2.1'
implementation 'com.mobeta.android.dslv:library:0.9.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'com.github.mreram:showcaseview:1.4.1'

playImplementation 'com.google.android.gms:play-services-ads-lite:20.6.0'
playImplementation 'com.google.android.gms:play-services-ads-lite:22.3.0'
}
repositories {
mavenCentral()
Expand Down
98 changes: 98 additions & 0 deletions app/src/fdroid/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2018 Ryosuke839
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="jp.ddo.hotmist.unicodepad"
android:installLocation="auto">

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

<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
</intent>
</queries>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:theme="@style/Theme"
android:supportsRtl="false"
android:fullBackupContent="@xml/backup_descriptor"
android:dataExtractionRules="@xml/data_extraction_rules">
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />

<activity
android:name="jp.ddo.hotmist.unicodepad.UnicodeActivity"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="com.adamrocker.android.simeji.ACTION_INTERCEPT" />

<category android:name="com.adamrocker.android.simeji.REPLACE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />

<data android:mimeType="text/plain" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:icon="@mipmap/ic_launcher">
<action android:name="android.intent.action.PROCESS_TEXT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
</intent-filter>
<meta-data android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>

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

<activity android:name="TabsActivity"
android:parentActivityName=".SettingActivity"/>

<activity android:name="RestartActivity"
android:parentActivityName=".UnicodeActivity"/>

<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge">
<meta-data android:name="androidx.emoji2.text.EmojiCompatInitializer"
tools:node="remove" />
</provider>
</application>
</manifest>
19 changes: 14 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
android:label="@string/app_name"
android:theme="@style/Theme"
android:supportsRtl="false"
android:fullBackupContent="@xml/backup_descriptor">
android:fullBackupContent="@xml/backup_descriptor"
android:dataExtractionRules="@xml/data_extraction_rules">
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-8779692709020298~3817697917"/>
Expand All @@ -45,7 +46,6 @@

<activity
android:name="jp.ddo.hotmist.unicodepad.UnicodeActivity"
android:label="@string/app_name"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
Expand All @@ -71,15 +71,24 @@
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
</intent-filter>
<meta-data android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>

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

<activity android:name="TabsActivity" />
<activity android:name="TabsActivity"
android:parentActivityName=".SettingActivity"/>

<activity android:name="RestartActivity" />
<activity android:name="RestartActivity"
android:parentActivityName=".UnicodeActivity"/>

<provider
android:name="androidx.startup.InitializationProvider"
Expand Down
Binary file added app/src/main/assets/namedb.zip
Binary file not shown.
12 changes: 6 additions & 6 deletions app/src/main/java/jp/ddo/hotmist/unicodepad/CharacterAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ internal class CharacterAdapter(private val activity: UnicodeActivity, private v
activity.theme.resolveAttribute(android.R.attr.selectableItemBackground, it, true)
}.resourceId
override fun getCount(): Int {
return adapter.count
return adapter.getCount()
}

override fun getPageTitle(position: Int): CharSequence {
return (if (adapter.getItemId(position) != -1L) String.format("U+%04X ", adapter.getItemId(position)) else adapter.getItemString(position) + " ") + adapter.getItem(position)
return (if (adapter.getItemCodePoint(position) >= 0) String.format("U+%04X ", adapter.getItemCodePoint(position)) else adapter.getItemString(position) + " ") + adapter.getItem(position)
}

override fun instantiateItem(collection: ViewGroup, position: Int): Any {
Expand All @@ -59,8 +59,8 @@ internal class CharacterAdapter(private val activity: UnicodeActivity, private v
val layout = LinearLayout(activity)
layout.orientation = LinearLayout.VERTICAL
layout.addView(text, LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
val itemid = adapter.getItemId(position).toInt()
val emoji = itemid == -1
val itemid = adapter.getItemCodePoint(position).toInt()
val emoji = adapter.getItemCodePoint(position) < 0
val ver = if (!emoji) db.getInt(itemid, "version") else db.getInt(adapter.getItemString(position), "version")
text.setValid(ver != 0 && ver <= UnicodeActivity.univer)
val str = StringBuilder()
Expand Down Expand Up @@ -191,7 +191,7 @@ internal class CharacterAdapter(private val activity: UnicodeActivity, private v
}
}
hl.setOnLongClickListener { view ->
activity.adpPage.showDesc(view, view.id - 0x3F000000, StringAdapter(str.toString(), activity, db))
activity.adpPage.showDesc(null, view.id - 0x3F000000, StringAdapter(str.toString(), activity, db))
true
}
hl.setBackgroundResource(reslist)
Expand Down Expand Up @@ -220,7 +220,7 @@ internal class CharacterAdapter(private val activity: UnicodeActivity, private v
}

val id: Long
get() = adapter.getItemId(index)
get() = adapter.getItemCodePoint(index)

companion object {
var fontsize = 160f
Expand Down
44 changes: 14 additions & 30 deletions app/src/main/java/jp/ddo/hotmist/unicodepad/CharacterView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,15 @@ class CharacterView @JvmOverloads constructor(context: Context, attrs: Attribute
span = spans[0]
}
}
} catch (e: IllegalStateException) {
} catch (_: IllegalStateException) {
}
requestLayout()
}

fun setTypeface(tf: Typeface?, locale: Locale) {
if (paint.typeface != tf) invalid = true
paint.typeface = tf
if (Build.VERSION.SDK_INT >= 17) {
paint.textLocale = locale
}
paint.textLocale = locale
requestLayout()
}

Expand Down Expand Up @@ -171,10 +169,8 @@ class CharacterView @JvmOverloads constructor(context: Context, attrs: Attribute
val measure = (Build.VERSION.SDK_INT < 23 || paint.hasGlyph(str)) && validChar || !drawSlash
var widthNew: Int
widthNew = (if (measure) paint.measureText(str) else fm.descent - fm.ascent).toInt() + paddingLeft + paddingRight
if (Build.VERSION.SDK_INT >= 19) {
span?.let{
widthNew = it.getSize(paint, str, 0, str.length, fmi) + paddingLeft + paddingRight
}
span?.let{
widthNew = it.getSize(paint, str, 0, str.length, fmi) + paddingLeft + paddingRight
}
if (widthMode != MeasureSpec.EXACTLY) if (widthMode == MeasureSpec.UNSPECIFIED || widthSize > widthNew) widthSize = widthNew
if (!shrinkHeight) if (heightMode != MeasureSpec.EXACTLY) if (heightMode == MeasureSpec.UNSPECIFIED || heightSize > heightNew) heightSize = heightNew
Expand All @@ -184,10 +180,8 @@ class CharacterView @JvmOverloads constructor(context: Context, attrs: Attribute
fm = paint.fontMetrics
fmi = paint.fontMetricsInt
widthNew = (if (measure) paint.measureText(str) else fm.descent - fm.ascent).toInt() + paddingLeft + paddingRight
if (Build.VERSION.SDK_INT >= 19) {
span?.let {
widthNew = it.getSize(paint, str, 0, str.length, fmi) + paddingLeft + paddingRight
}
span?.let {
widthNew = it.getSize(paint, str, 0, str.length, fmi) + paddingLeft + paddingRight
}
heightNew = (-fm.top + fm.bottom).toInt()
heightNew += paddingTop + paddingBottom
Expand Down Expand Up @@ -249,45 +243,35 @@ class CharacterView @JvmOverloads constructor(context: Context, attrs: Attribute
if (span != null || (Build.VERSION.SDK_INT < 23 || paint.hasGlyph(str)) && validChar && paint.measureText(str) > 0f) {
var w = paint.measureText(str)
span?.let {
if (Build.VERSION.SDK_INT >= 19) {
w = it.getSize(paint, str, 0, str.length, paint.fontMetricsInt).toFloat()
}
w = it.getSize(paint, str, 0, str.length, paint.fontMetricsInt).toFloat()
}
if (w > 256f) {
val size = paint.textSize
paint.textSize = size * 256f / w
val fm = paint.fontMetrics
var w2 = paint.measureText(str).toInt()
span?.let {
if (Build.VERSION.SDK_INT >= 19) {
w2 = it.getSize(paint, str, 0, str.length, paint.fontMetricsInt)
}
w2 = it.getSize(paint, str, 0, str.length, paint.fontMetricsInt)
}
val bm = Bitmap.createBitmap(w2, (-fm.top + fm.bottom).toInt(), Bitmap.Config.ARGB_8888)
val tr = Bitmap.createBitmap(w2, (-fm.top + fm.bottom).toInt(), Bitmap.Config.ARGB_8888)
val cv = Canvas(bm)
span?.let {
if (Build.VERSION.SDK_INT >= 19) {
it.draw(cv, str, 0, str.length, 0f, 0, (-fm.top).toInt(), (-fm.top + fm.descent).toInt(), paint)
true
} else null
it.draw(cv, str, 0, str.length, 0f, 0, (-fm.top).toInt(), (-fm.top + fm.descent).toInt(), paint)
true
} ?: cv.drawText(str, 0f, -fm.top, paint)
if (!bm.sameAs(tr)) {
cv.drawColor(0, PorterDuff.Mode.CLEAR)
paint.style = Paint.Style.STROKE
span?.let {
if (Build.VERSION.SDK_INT >= 19) {
it.draw(cv, str, 0, str.length, 0f, 0, (-fm.top).toInt(), (-fm.top + fm.descent).toInt(), paint)
true
} else null
it.draw(cv, str, 0, str.length, 0f, 0, (-fm.top).toInt(), (-fm.top + fm.descent).toInt(), paint)
true
} ?: cv.drawText(str, 0f, -fm.top, paint)
if (bm.sameAs(tr)) {
paint.style = Paint.Style.FILL
span?.let {
if (Build.VERSION.SDK_INT >= 19) {
it.draw(cv, str, 0, str.length, 0f, 0, (-fm.top).toInt(), (-fm.top + fm.descent).toInt(), paint)
true
} else null
it.draw(cv, str, 0, str.length, 0f, 0, (-fm.top).toInt(), (-fm.top + fm.descent).toInt(), paint)
true
} ?: cv.drawText(str, 0f, -fm.top, paint)
emojicache = bm
cacheRect.set(0, 0, bm.width, bm.height)
Expand Down
Loading

0 comments on commit 662bce5

Please sign in to comment.