Skip to content

Commit

Permalink
Merge pull request #15 from vadiole/dev
Browse files Browse the repository at this point in the history
Release 1.4.0
  • Loading branch information
vadiole committed Jul 15, 2023
2 parents 6f0996e + 9b4f244 commit 7f62c56
Show file tree
Hide file tree
Showing 60 changed files with 2,179 additions and 413 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/main.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,11 @@ jobs:
steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Build the App
- name: Setup java
uses: actions/setup-java@v3
with:
distribution: 'oracle'
java-version: '17'
cache: 'gradle'
- name: Build the project
run: ./gradlew build
33 changes: 16 additions & 17 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ plugins {
}

android {
compileSdk = 31
compileSdk = 33

defaultConfig {
applicationId = "vadiole.unicode"
minSdk = 26
targetSdk = 31
versionCode = 122
versionName = "1.2.2"
targetSdk = 33
versionCode = 140
versionName = "1.4.0"
resourceConfigurations.addAll(listOf("en"))
setProperty("archivesBaseName", "unicode-v$versionName")
}
Expand All @@ -31,7 +31,7 @@ android {
}
}

packagingOptions {
packaging {
resources.excludes.addAll(
listOf(
"META-INF/LICENSE",
Expand All @@ -42,13 +42,11 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = "1.8"
languageVersion = "1.6"
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
kotlinOptions {
jvmTarget = "11"
}
}

lint {
Expand All @@ -64,13 +62,14 @@ android {
)
)
}
namespace = "vadiole.unicode"
}

dependencies {
implementation("androidx.core:core-ktx:1.7.0")
implementation("androidx.recyclerview:recyclerview:1.2.1")
implementation("androidx.core:core-ktx:1.10.1")
implementation("androidx.recyclerview:recyclerview:1.3.0")
implementation("androidx.dynamicanimation:dynamicanimation:1.1.0-alpha03")
implementation("androidx.dynamicanimation:dynamicanimation-ktx:1.0.0-alpha03")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0")
}
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4")
}
15 changes: 7 additions & 8 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="vadiole.unicode">
xmlns:tools="http://schemas.android.com/tools">

<application
android:name=".UnicodeApp"
Expand All @@ -20,24 +19,24 @@
android:configChanges="uiMode|orientation"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait">
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="http" />
<data android:scheme="https" />
<data
android:host="vadiole.github.io"
android:path="/unicode" />
<data android:host="vadiole.github.io" />
<data android:path="/unicode" />
</intent-filter>

</activity>
Expand All @@ -48,4 +47,4 @@

</application>

</manifest>
</manifest>
18 changes: 0 additions & 18 deletions app/src/main/kotlin/vadiole/unicode/AppComponent.kt

This file was deleted.

29 changes: 25 additions & 4 deletions app/src/main/kotlin/vadiole/unicode/UnicodeApp.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
package vadiole.unicode

import android.annotation.SuppressLint
import android.app.Application
import vadiole.unicode.data.UnicodeStorage
import vadiole.unicode.data.config.UserConfig
import vadiole.unicode.ui.theme.ThemeManager
import vadiole.unicode.ui.theme.blue_dark
import vadiole.unicode.ui.theme.blue_light
import vadiole.unicode.utils.extension.isDarkMode

@SuppressLint("StaticFieldLeak")
class UnicodeApp : Application() {
private var _appComponent: AppComponent? = null
val appComponent: AppComponent get() = requireNotNull(_appComponent) { "app isn not created yet" }

override fun onCreate() {
super.onCreate()
_appComponent = AppComponent(this)
unicodeStorageInternal = UnicodeStorage(this)
userConfigInternal = UserConfig(this)
themeManagerInternal = ThemeManager(if (resources.configuration.isDarkMode) blue_dark else blue_light)
}
}

companion object {
private var unicodeStorageInternal: UnicodeStorage? = null
val unicodeStorage: UnicodeStorage
get() = requireNotNull(unicodeStorageInternal)

private var userConfigInternal: UserConfig? = null
val userConfig: UserConfig
get() = requireNotNull(userConfigInternal)
private var themeManagerInternal: ThemeManager? = null
val themeManager: ThemeManager
get() = requireNotNull(themeManagerInternal)
}
}
2 changes: 1 addition & 1 deletion app/src/main/kotlin/vadiole/unicode/data/Block.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class Block(val id: Int, val start: Int, val end: Int, val name: String) {
codePoint.value > end -> -1
else -> 0
}
}
}
14 changes: 7 additions & 7 deletions app/src/main/kotlin/vadiole/unicode/data/CharObj.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package vadiole.unicode.data

import java.util.Locale
import vadiole.unicode.utils.extension.leftPad
import java.util.*

class CharObj(val id: Int, val codePoint: Int, val name: String, val version: String, val blockName: String) {
val char: String = String(Character.toChars(codePoint))
val hex = codePoint.toString(16).uppercase(Locale.ENGLISH).leftPad(4, '0')
class CharObj(val id: Int, val codePointRaw: Int, val name: String, val version: String, val blockName: String) {
val char: String = String(Character.toChars(codePointRaw))
val hex = codePointRaw.toString(16).uppercase(Locale.ENGLISH).leftPad(4, '0')
val infoValues: Array<String> = arrayOf(
"U+$hex",
"&#$codePoint",
"&#$codePointRaw",
"\\$hex",
version,
)
val link = "vadiole.github.io/unicode?c=$codePoint"
}
val link = "vadiole.github.io/unicode?c=$codePointRaw"
}
40 changes: 39 additions & 1 deletion app/src/main/kotlin/vadiole/unicode/data/CodePoint.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,42 @@ package vadiole.unicode.data
value class CodePoint(val value: Int) {
val char: String
get() = String(Character.toChars(value))
}
}

@JvmInline
value class CodePointArray(val storage: IntArray) : Collection<CodePoint> {
constructor(size: Int) : this(IntArray(size))

override val size: Int get() = storage.size

override fun isEmpty() = storage.isEmpty()

override fun iterator(): Iterator<CodePoint> = object : Iterator<CodePoint> {
private var index = 0
override fun hasNext() = index < storage.size
override fun next() = if (index < storage.size) CodePoint(storage[index++]) else throw NoSuchElementException(index.toString())
}

override fun containsAll(elements: Collection<CodePoint>) = elements.all { storage.contains(it.value) }

override fun contains(element: CodePoint): Boolean = storage.contains(element.value)

operator fun get(index: Int) = CodePoint(storage[index])

operator fun set(index: Int, value: CodePoint) {
storage[index] = value.value
}
}

inline fun CodePointArray(size: Int, init: (Int) -> CodePoint): CodePointArray {
return CodePointArray(IntArray(size) { index -> (init(index)).value })
}

inline fun CodePointArray.filterMaybe(predicate: (CodePoint) -> Boolean): CodePointArray {
val filtered = storage.filterTo(ArrayList(size)) { predicate(CodePoint(it)) }
return CodePointArray(filtered.toIntArray())
}

fun CodePointArray.binarySearch(element: CodePoint, fromIndex: Int = 0, toIndex: Int = size): Int {
return java.util.Arrays.binarySearch(storage, fromIndex, toIndex, element.value)
}
3 changes: 3 additions & 0 deletions app/src/main/kotlin/vadiole/unicode/data/SearchResult.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package vadiole.unicode.data

class SearchResult(val codePoint: CodePoint,val name: String)
Loading

0 comments on commit 7f62c56

Please sign in to comment.