├── app
├── .gitignore
├── src
│ └── main
│ │ ├── ic_launcher-web.png
│ │ ├── res
│ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── values
│ │ │ ├── styles.xml
│ │ │ ├── strings.xml
│ │ │ └── colors.xml
│ │ └── layout
│ │ │ ├── activity_large_text.xml
│ │ │ └── activity_main.xml
│ │ ├── java
│ │ └── me
│ │ │ └── myatminsoe
│ │ │ └── mdetectsample
│ │ │ ├── MyApplication.kt
│ │ │ ├── LargeTextActivity.kt
│ │ │ └── MainActivity.kt
│ │ └── AndroidManifest.xml
├── proguard-rules.pro
└── build.gradle
├── mdetect
├── .gitignore
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ ├── me
│ │ └── myatminsoe
│ │ │ └── mdetect
│ │ │ ├── MMToast.kt
│ │ │ ├── MMButtonView.kt
│ │ │ ├── MMEditText.kt
│ │ │ ├── MMTextView.kt
│ │ │ ├── JobExecutor.kt
│ │ │ └── MDetect.kt
│ │ └── com
│ │ └── comquas
│ │ └── rabbit
│ │ └── Rabbit.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── Screenshot_Zawgyi.png
├── Screenshot_Unicode.png
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── License.md
├── gradlew.bat
├── README.md
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/mdetect/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':mdetect'
2 |
--------------------------------------------------------------------------------
/mdetect/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Screenshot_Zawgyi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-myatminsoe/mdetect-android/HEAD/Screenshot_Zawgyi.png
--------------------------------------------------------------------------------
/Screenshot_Unicode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-myatminsoe/mdetect-android/HEAD/Screenshot_Unicode.png
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-myatminsoe/mdetect-android/HEAD/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-myatminsoe/mdetect-android/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-myatminsoe/mdetect-android/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-myatminsoe/mdetect-android/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-myatminsoe/mdetect-android/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-myatminsoe/mdetect-android/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-myatminsoe/mdetect-android/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jan 12 15:16:18 MMT 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/java/me/myatminsoe/mdetectsample/MyApplication.kt:
--------------------------------------------------------------------------------
1 | package me.myatminsoe.mdetectsample
2 |
3 | import android.app.Application
4 |
5 | import me.myatminsoe.mdetect.MDetect
6 |
7 | /**
8 | * Created by myatminsoe on 4/20/17.
9 | */
10 |
11 | class MyApplication : Application() {
12 |
13 | override fun onCreate() {
14 | super.onCreate()
15 | MDetect.init(this)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/*
38 | .idea/
39 |
40 | # Keystore files
41 | *.jks
42 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_large_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
13 |
14 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/mdetect/src/main/java/me/myatminsoe/mdetect/MMToast.kt:
--------------------------------------------------------------------------------
1 | package me.myatminsoe.mdetect
2 |
3 | import android.content.Context
4 | import android.widget.Toast
5 |
6 | object MMToast {
7 |
8 | private var toast: Toast? = null
9 |
10 | fun showShortToast(context: Context, message: CharSequence) {
11 | toast?.cancel()
12 | toast = Toast.makeText(context, MDetect.getText(message.toString()), Toast.LENGTH_SHORT)
13 | toast!!.show()
14 | }
15 |
16 | fun showLongToast(context: Context, message: CharSequence) {
17 | toast?.cancel()
18 | toast = Toast.makeText(context, MDetect.getText(message.toString()), Toast.LENGTH_LONG)
19 | toast!!.show()
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/myatminsoe/Library/Android/android-sdk-macosx/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/mdetect/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/myatminsoe/Library/Android/android-sdk-macosx/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 |
4 | def versionMajor = 3
5 | def versionMinor = 2
6 | def versionPatch = 0
7 |
8 | android {
9 | compileSdkVersion 26
10 | defaultConfig {
11 | applicationId "me.myatminsoe.mdetectsample"
12 | minSdkVersion 14
13 | targetSdkVersion 26
14 | versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100
15 | versionName "${versionMajor}.${versionMinor}.${versionPatch}"
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | compile 'com.android.support:appcompat-v7:26.1.0'
27 | compile project(':mdetect')
28 | compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
29 | }
30 |
31 | repositories {
32 | mavenCentral()
33 | }
34 |
--------------------------------------------------------------------------------
/mdetect/src/main/java/me/myatminsoe/mdetect/MMButtonView.kt:
--------------------------------------------------------------------------------
1 | package me.myatminsoe.mdetect
2 |
3 | import android.content.Context
4 | import android.util.AttributeSet
5 | import android.widget.Button
6 |
7 | class MMButtonView : Button {
8 |
9 | constructor(context: Context) : super(context) {
10 | setMMText(text.toString())
11 | }
12 |
13 | constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
14 | setMMText(text.toString())
15 | }
16 |
17 | constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {
18 | setMMText(text.toString())
19 | }
20 |
21 | /**
22 | * method for setting text
23 |
24 | * @param unicodeString string in Myanmar Unicode
25 | */
26 | fun setMMText(unicodeString: String) {
27 | text = MDetect.getText(unicodeString)
28 | }
29 |
30 | /**
31 | * method for getting text
32 | * @return CharSequence in Myanmar Unicode
33 | */
34 | val mmText: String
35 | get() = MDetect.getText(text.toString())
36 | }
--------------------------------------------------------------------------------
/mdetect/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 |
4 | def versionMajor = 3
5 | def versionMinor = 2
6 | def versionPatch = 0
7 |
8 | ext {
9 | PUBLISH_GROUP_ID = 'myatminsoe.mdetect.android'
10 | PUBLISH_ARTIFACT_ID = 'mdetect-android'
11 | PUBLISH_VERSION = '3.2'
12 | }
13 |
14 | android {
15 | compileSdkVersion 26
16 |
17 | defaultConfig {
18 | minSdkVersion 9
19 | targetSdkVersion 26
20 | versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100
21 | versionName "${versionMajor}.${versionMinor}.${versionPatch}"
22 | }
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
27 | }
28 | }
29 | }
30 |
31 | dependencies {
32 | compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
33 |
34 | }
35 |
36 | apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle'
37 | repositories {
38 | mavenCentral()
39 | }
40 |
--------------------------------------------------------------------------------
/License.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Myat Min Soe
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/mdetect/src/main/java/me/myatminsoe/mdetect/MMEditText.kt:
--------------------------------------------------------------------------------
1 | package me.myatminsoe.mdetect
2 |
3 | import android.content.Context
4 | import android.util.AttributeSet
5 | import android.widget.EditText
6 |
7 | class MMEditText : EditText {
8 |
9 | constructor(context: Context) : super(context) {
10 | if (hint != null) {
11 | hint = MDetect.getText(hint.toString())
12 | }
13 | }
14 |
15 | constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
16 | if (hint != null) {
17 | hint = MDetect.getText(hint.toString())
18 | }
19 | }
20 |
21 | constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {
22 | if (hint != null) {
23 | hint = MDetect.getText(hint.toString())
24 | }
25 | }
26 |
27 | /**
28 | * method for setting text
29 |
30 | * @param unicodeString string in Myanmar Unicode
31 | */
32 | fun setMMText(unicodeString: String) {
33 | setText(MDetect.getText(unicodeString))
34 | }
35 |
36 | /**
37 | * method for getting text
38 |
39 | * @return CharSequence in Myanmar Unicode
40 | */
41 | val mmText: CharSequence
42 | get() = MDetect.getText(text.toString())
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/me/myatminsoe/mdetectsample/LargeTextActivity.kt:
--------------------------------------------------------------------------------
1 | package me.myatminsoe.mdetectsample
2 |
3 | import android.content.Context
4 | import android.content.Intent
5 | import android.os.Bundle
6 | import android.support.v7.app.AppCompatActivity
7 | import android.widget.TextView
8 | import me.myatminsoe.mdetect.MMTextView
9 |
10 | class LargeTextActivity : AppCompatActivity() {
11 |
12 | companion object {
13 |
14 | private const val IE_ENABLE_BACKGROUND_CONVERT = "IE_ENABLE_BACKGROUND_CONVERT"
15 |
16 | fun newIntent(context: Context, enableBackgroundConvert: Boolean): Intent {
17 | val intent = Intent(context, LargeTextActivity::class.java)
18 | intent.putExtra(IE_ENABLE_BACKGROUND_CONVERT, enableBackgroundConvert)
19 | return intent
20 | }
21 | }
22 |
23 | override fun onCreate(savedInstanceState: Bundle?) {
24 | super.onCreate(savedInstanceState)
25 | setContentView(R.layout.activity_large_text)
26 |
27 | supportActionBar?.setDisplayHomeAsUpEnabled(true)
28 | val enableBackgroundConvert = intent.getBooleanExtra(IE_ENABLE_BACKGROUND_CONVERT, true)
29 |
30 | val textView = findViewById(R.id.tvLargeText)
31 | val string = getString(R.string.large_text)
32 | if (enableBackgroundConvert) {
33 | textView.setMMText(string)
34 | } else {
35 | textView.setMMText(string, null)
36 | }
37 |
38 | }
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
16 |
17 |
23 |
24 |
30 |
31 |
37 |
38 |
44 |
45 |
--------------------------------------------------------------------------------
/mdetect/src/main/java/me/myatminsoe/mdetect/MMTextView.kt:
--------------------------------------------------------------------------------
1 | package me.myatminsoe.mdetect
2 |
3 | import android.content.Context
4 | import android.util.AttributeSet
5 | import android.widget.TextView
6 | import java.util.concurrent.Executor
7 |
8 | class MMTextView : TextView {
9 |
10 | constructor(context: Context) : super(context) {
11 | setMMText(text.toString(), null)
12 | }
13 |
14 | constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
15 | setMMText(text.toString(), null)
16 | }
17 |
18 | constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(
19 | context,
20 | attrs,
21 | defStyle
22 | ) {
23 | setMMText(text.toString(), null)
24 | }
25 |
26 | /**
27 | * Convert the text to proper encoding method and set the text of the TextView
28 | *
29 | * @param unicodeString string in Myanmar Unicode
30 | * @param executor An Executor to do the converting process in the background
31 | * By default will use a default {@link JobExecutor} Implementation
32 | * Passing null will cause the conversion process to run in UI Thread, useful in cases where you
33 | * need immediate result such as RecyclerView items
34 | */
35 | fun setMMText(unicodeString: String, executor: Executor? = JobExecutor()) {
36 | if (executor == null) {
37 | text = MDetect.getText(unicodeString)
38 | } else {
39 | executor.execute {
40 | val convertedString = MDetect.getText(unicodeString)
41 | this.post {
42 | text = convertedString
43 | }
44 | }
45 | }
46 | }
47 |
48 | /**
49 | * method for getting text
50 |
51 | * @return CharSequence in Myanmar Unicode
52 | */
53 | val mmText: CharSequence
54 | get() = MDetect.getText(text.toString())
55 | }
56 |
--------------------------------------------------------------------------------
/mdetect/src/main/java/me/myatminsoe/mdetect/JobExecutor.kt:
--------------------------------------------------------------------------------
1 | package me.myatminsoe.mdetect
2 |
3 | import java.util.concurrent.BlockingQueue
4 | import java.util.concurrent.Executor
5 | import java.util.concurrent.LinkedBlockingQueue
6 | import java.util.concurrent.ThreadFactory
7 | import java.util.concurrent.ThreadPoolExecutor
8 | import java.util.concurrent.TimeUnit
9 |
10 | class JobExecutor : Executor {
11 |
12 | private val workQueue: BlockingQueue
13 |
14 | private val threadPoolExecutor: ThreadPoolExecutor
15 |
16 | private val threadFactory: ThreadFactory
17 |
18 | init {
19 | this.workQueue = LinkedBlockingQueue()
20 | this.threadFactory = JobThreadFactory()
21 | this.threadPoolExecutor = ThreadPoolExecutor(
22 | INITIAL_POOL_SIZE, MAX_POOL_SIZE, KEEP_ALIVE_TIME.toLong(),
23 | KEEP_ALIVE_TIME_UNIT, this.workQueue, this.threadFactory
24 | )
25 | }
26 |
27 | override fun execute(runnable: Runnable?) {
28 | if (runnable == null) {
29 | throw IllegalArgumentException("Runnable to execute cannot be null")
30 | }
31 | this.threadPoolExecutor.execute(runnable)
32 | }
33 |
34 | private class JobThreadFactory : ThreadFactory {
35 | private var counter = 0
36 |
37 | override fun newThread(runnable: Runnable): Thread {
38 | return Thread(runnable, THREAD_NAME + counter++)
39 | }
40 |
41 | companion object {
42 | private val THREAD_NAME = "android_"
43 | }
44 | }
45 |
46 | companion object {
47 |
48 | private val INITIAL_POOL_SIZE = 3
49 | private val MAX_POOL_SIZE = 5
50 |
51 | // Sets the amount of time an idle thread waits before terminating
52 | private val KEEP_ALIVE_TIME = 10
53 |
54 | // Sets the Time Unit to seconds
55 | private val KEEP_ALIVE_TIME_UNIT = TimeUnit.SECONDS
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/java/me/myatminsoe/mdetectsample/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package me.myatminsoe.mdetectsample
2 |
3 | import android.os.Bundle
4 | import android.support.v7.app.AlertDialog
5 | import android.support.v7.app.AppCompatActivity
6 | import android.view.View
7 | import me.myatminsoe.mdetect.MDetect
8 | import me.myatminsoe.mdetect.MMButtonView
9 | import me.myatminsoe.mdetect.MMTextView
10 | import me.myatminsoe.mdetect.MMToast
11 |
12 | class MainActivity : AppCompatActivity() {
13 |
14 | private val items = arrayOf(
15 | "ဧရာဝတီတိုင်းဒေသကြီး",
16 | "ပဲခူးတိုင်းဒေသကြီး",
17 | "ချင်းပြည်နယ်",
18 | "ကချင်ပြည်နယ်",
19 | "ကယားပြည်နယ်",
20 | "ကရင်ပြည်နယ်",
21 | "မကွေးတိုင်းဒေသကြီး",
22 | "မန္တလေးတိုင်းဒေသကြီး",
23 | "မွန်ပြည်နယ်",
24 | "ရခိုင်ပြည်နယ်",
25 | "ရှမ်းပြည်နယ်",
26 | "စစ်ကိုင်းတိုင်းဒေသကြီး",
27 | "တနင်္သာရီတိုင်းဒေသကြီး",
28 | "ရန်ကုန်တိုင်းဒေသကြီး",
29 | "နေပြည်တော် ပြည်ထောင်စုနယ်မြေ"
30 | )
31 |
32 | override fun onCreate(savedInstanceState: Bundle?) {
33 | super.onCreate(savedInstanceState)
34 | setContentView(R.layout.activity_main)
35 |
36 | val tv = findViewById(R.id.tv_main)
37 |
38 | title = MDetect.getText("မြန်မာ")
39 |
40 | if (MDetect.isUnicode()) {
41 | tv.text = "ယူနီကုဒ်စနစ်ကိုအသုံးပြုထားပါသည်။"
42 | tv.setTextColor(resources.getColor(R.color.green_500))
43 | } else {
44 | tv.text = "ေဇာ္ဂ်ီစနစ္ကိုအသံုးျပဳထားပါသည္။"
45 | tv.setTextColor(resources.getColor(R.color.red_500))
46 | }
47 |
48 | }
49 |
50 | fun divisions(v: View) {
51 | val builder = AlertDialog.Builder(this)
52 | builder.setItems(MDetect.getStringArray(items)) { dialog, which ->
53 | (v as MMButtonView).setMMText(items[which])
54 | }.show()
55 | }
56 |
57 | fun showMyanmarToast(v: View) {
58 | MMToast.showShortToast(this, "မင်္ဂလာပါ")
59 | }
60 |
61 | fun foreground(v: View) {
62 | startActivity(LargeTextActivity.newIntent(this, false))
63 | }
64 |
65 | fun background(v: View) {
66 | startActivity(LargeTextActivity.newIntent(this, true))
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/mdetect/src/main/java/me/myatminsoe/mdetect/MDetect.kt:
--------------------------------------------------------------------------------
1 | package me.myatminsoe.mdetect
2 |
3 | import android.content.Context
4 | import android.util.Log
5 | import android.view.ViewGroup
6 | import android.widget.TextView
7 | import com.comquas.rabbit.Rabbit
8 |
9 | object MDetect {
10 |
11 | private var cacheUnicode: Boolean? = null
12 |
13 |
14 | fun init(context: Context) {
15 | if (cacheUnicode != null) {
16 | Log.i("MDetect", "MDetect was already initialized.")
17 | return
18 | }
19 | val textView = TextView(context, null)
20 | textView.layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
21 | ViewGroup.LayoutParams.WRAP_CONTENT)
22 |
23 | textView.text = "\u1000"
24 | textView.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
25 | val length1 = textView.measuredWidth
26 |
27 | textView.text = "\u1000\u1039\u1000"
28 | textView.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
29 | val length2 = textView.measuredWidth
30 |
31 | cacheUnicode = length1 == length2
32 | }
33 |
34 | /**
35 | * method for getting user's encoding
36 |
37 | * @return whether the device follows myanmar unicode standard
38 | */
39 | fun isUnicode(): Boolean {
40 | if (null == cacheUnicode)
41 | throw UnsupportedOperationException("MDetect was not initialized.")
42 | return cacheUnicode!!
43 | }
44 |
45 | /**
46 | * method for getting display text
47 | * @param unicodeString Unicode String
48 | * @return appropriate String according to device's encoding
49 | */
50 | fun getText(unicodeString: String): String {
51 | return if (isUnicode()) unicodeString else Rabbit.uni2zg(unicodeString)
52 | }
53 |
54 | /**
55 | * method for getting String from user input
56 | * @param inputString String inputted by user
57 | * @return Unicode String
58 | */
59 | fun getInputText(inputString: String): String {
60 | return if (isUnicode()) inputString else Rabbit.zg2uni(inputString)
61 | }
62 |
63 | /**
64 | * method for getting string array
65 | * @param unicodeStringArray Unicode String Array
66 | * @return appropriate String Array according to device's encoding
67 | */
68 | fun getStringArray(unicodeStringArray: Array): Array {
69 | if (isUnicode())
70 | return unicodeStringArray
71 | val zawgyiStringArray = unicodeStringArray.clone()
72 | for (i in zawgyiStringArray.indices) {
73 | zawgyiStringArray[i] = Rabbit.uni2zg(zawgyiStringArray[i])
74 | }
75 | return zawgyiStringArray
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MDetect Sample
3 |
4 |
5 | မြန်မာစာသည်တို့စာ
6 | တစ်ခုခုရိုက်ထည့်ကြည့်ပါ
7 | နှိပ်ပါ
8 | မင်္ဂလာပါ
9 | ပြည်နယ်/တိုင်းဒေသကြီး
10 | Background မှာ convert လုပ်မယ်
11 |
12 | UI မှာ convert လုပ်မယ်
13 | ဇွန်လ၂၃ရက်နေ့မှာထိုင်းနိုင်ငံချင်းရိုင်ခရိုင်မှာရှိတဲ့တောင်တန်းတွေအောက်ကကျောက်ဂူကြီးတစ်ခုထဲကိုဒေသခံဘောလုံးအသင်းကကလေးငယ်၁၂ယောက်နဲ့သူတို့ရဲ့နည်းပြတို့ဝင်သွားခဲ့ကြပါတယ်။ဂူထဲကပြန်ထွက်လို့မရတော့ပဲပိတ်မိသွားခဲ့တဲ့သူတို့၁၃ယောက်ကိုနှစ်ပတ်ကြာပြီးတဲ့အချိန်မှာပြန်လည်ကယ်ထုတ်လာနိုင်ခဲ့တဲ့ဖြစ်ရပ်ဟာတကမ္ဘာလုံးကိုဖမ်းစားထားနိုင်ခဲ့ပါတယ်။အခုတော့အဲဒီရှာဖွေကယ်ဆယ်ရေးလုပ်ငန်းစဉ်၊အသက်ငယ်ပေမဲ့မျှော်လင့်ချက်မဲ့အခြေအနေမှာကြံ့ကြံ့ခံဇွဲတင်းရပ်တည်စိတ်ဓာတ်ခိုင်မာခဲ့တဲ့ဘောလုံးသမားကလေးတွေနဲ့သူတို့ကိုစောင့်ရှောက်ပေးနေခဲ့တဲ့နည်းပြတို့ရဲ့စည်းလုံးမှု၊လူသားတို့ရဲ့မေတ္တာတရားနဲ့တခြားလူတစ်ယောက်ယောက်ရဲ့သားသမီးတွေကိုကိုယ့်အသက်ကိုရင်းပြီးကယ်တင်ခဲ့တဲ့စွန့်လွှတ်စွန့်စားသူ၊စွန့်ဝံ့သူတွေအကြောင်းကိုဘီဘီစီကဒီဆောင်းပါးကနေဖြစ်စဉ်အပြည့်အစုံရေးသားတင်ပြသွားပါမယ်။ဓာတ်ပုံမူပိုင်AFPImagecaptionမွေးနေ့ပွဲအတွက်အိမ်ပြန်ရောက်မလာခဲ့အလွဲလွဲအချော်ချော်ဖြစ်ခဲ့ရတဲ့မွေးနေ့ပွဲအခုဖြစ်ရပ်ရဲ့အစပထမကတော့မွေးနေ့တစ်ခုကလို့ဆိုရပါမယ်။ဇွန်လ၂၃ရက်စနေနေ့မှာပီရာပတ်နိုက်ဆွမ်ပီယန်ဂျိုင်းအသက်၁၇နှစ်ပြည့်ပါတယ်။၁၇နှစ်ဆိုတာလူပျိုဖော်ဝင်စအချိန်ဖြစ်တဲ့အတွက်ဒီမွေးနေ့ကိုအထိမ်းအမှတ်လုပ်ကျင်းပကြတာတကမ္ဘာလုံးလိုလိုမှာရှိကြပါတယ်။မယ်ဆိုင်ပြည်နယ်ထဲကကျေးရွာလေးတစ်ခုမှာတော့နိုက်ရဲ့မိသားစုကလည်းသူ့အတွက်မွေးနေ့ပွဲလေးလုပ်ပေးဖို့အတွက်အဝါရောင်ချီဇာမုန့်မွေးနေ့ကိတ်ကိုပြင်ထားပြီး၊ရောင်စုံစက္ကူတွေနဲ့ပတ်ထားတဲ့သူ့အတွက်မွေးနေ့လက်ဆောင်တွေကိုလည်းအသင့်ပြင်ထားပါတယ်။ထိုင်းလိုဏ်ဂူထဲလူ၁၂ယောက်ပျောက်ဆုံးနေဒါပေမယ့်အဲဒီနေ့မှာနိုက်ကတော့အိမ်ကိုအမြန်ပြန်ပြေးဖို့စိတ်ကူးမရှိခဲ့ပါဘူး။သူဟာသူ့တောဝက်ဘောလုံးကလပ်ကကစားဖော်တွေရယ်၊လက်ထောက်နည်းပြအက်ကပိုအိက်ခ်ချန်တာဝမ်တို့နဲ့အတူဘောလုံးလေ့ကျင့်ကွင်းကိုရောက်နေခဲ့ပါတယ်။လေ့ကျင့်ချိန်ပြီးတဲ့အခါမှတော့သူတို့အားလုံးစက်ဘီးကိုယ်စီနဲ့လယ်ကွင်းတွေကိုဖြတ်လို့တောအုပ်လေးဆီသွားခဲ့ပါတယ်။ပြီးခဲ့တဲ့ရက်ပိုင်းကမိုးတွေဆက်တိုက်ရွာထားတဲ့အတွက်တောအုပ်လေးကလည်းရေတွေစွတ်စိုနေခဲ့ပါတယ်။သူတို့ဦးတည်သွားနေခဲ့တာကတော့ထမ့်လွန်ဂူဆီပါ။ကလေးတွေဟာမယ်ဆိုင်မြို့ကိုအပေါ်စီးကလှမ်းပြီးအုပ်မိုးထားသလိုရှိတဲ့တောင်တန်းတွေပေါ်ကထမ့်လွန်ဂူဆီသွားရင်းတောလမ်းတလျှောက်စူးစမ်းတိုးဝင်လေ့လာရတာကိုနှစ်သက်ကြသူတွေဖြစ်ပါတယ်။ဓာတ်ပုံမူပိုင်FACEBOOK/NOPPARATKANTHAWONGImagecaptionတောဝက်ဘောလုံးအသင်းသားလေးတွေထမ့်လွန်ဂူအဝကိုရောက်တဲ့အခါမှာတော့သူတို့တွေစီးလာတဲ့စက်ဘီးတွေပေါ်ကဆင်း၊ပါလာတဲ့အိတ်တွေကိုစက်ဘီးတွေနဲ့အတူဂူဝမှာထားလိုက်ကြပါတယ်။ကလေးတွေနဲ့နည်းပြလေးတို့ဟာနိုက်ရဲ့မွေးနေ့ပွဲကိုသူတို့နည်းသူတို့ဟန်နဲ့ဆင်နွှဲကြဖို့ဖြစ်ပါတယ်။ဒီဂူဟာသူတို့နဲ့မစိမ်းပါဘူး။အရင်တုန်းကလည်းဘောလုံးအသင်းထဲကိုအသင်းသားအသစ်တစ်ယောက်ရောက်လာတဲ့အခါဂူအတွင်းပိုင်း၈ကီလိုမီတာလောက်အထိဝင်ကြပြီးအသင်းသားအသစ်တွေရဲ့နာမည်ကိုဂူနံရံမှာရေးခဲ့ကြဖူးပါတယ်။အခုတစ်ခေါက်လည်းတက်ကြွပျော်ရွှင်နေကြတဲ့ကလေးတွေဟာလက်နှိပ်ဓာတ်မီးလေးတွေကိုပဲယူပြီးဂူထဲကိုဝင်ခဲ့ကြပါတယ်။သူတို့ဂူထဲမှာတစ်နာရီလောက်ပဲနေဖို့အစီအစဉ်ရှိတဲ့အတွက်တခြားဘာကိုမှယူမသွားခဲ့ကြပါဘူး။အဲဒီတစ်နာရီလောက်ဆိုပြီးဝင်သွားတဲ့ခရီးစဉ်ဟာနောက်ထပ်နှစ်ပတ်ကြာမှပဲဂူထဲကထွက်လာနိုင်ခဲ့ကြပါတော့တယ်။နိုက်ရဲ့အိမ်မှာတော့သူ့မိသားစုကစိတ်ပူစပြုလာပါတယ်။သူ့အတွက်ပြင်ထားတဲ့မွေးနေ့ကိတ်ကလည်းမထိရမတို့ရသေးပါဘူး။Imagecaptionတာချီလိတ်တစ်ဘက်မယ်ဆိုင်ကထမ့်လွန်ဂူတာချီလိတ်တစ်ဘက်ထိုင်းနိုင်ငံထဲကထမ့်လွန်ဂူတောဝက်ကလေးတွေဘယ်ရောက်သွားကြပါသလဲ။ထိုင်းနဲ့မြန်မာနှစ်နိုင်ငံနယ်စပ်ကိုပိုင်းခြားထားတဲ့တောင်တန်းတွေအောက်မှာတော့၁၀ကီလိုမီတာရှည်ထဲ့ထမ့်လွန်ဂူကြီးရှိပါတယ်။အဲဒီဂူဟာထိုင်းမှာရှိတဲ့ဂူတွေအထဲမှာစတုတ္ထမြောက်အကြီးဆုံးဂူဖြစ်ပါတယ်။ဒီဂူရှိတဲ့တောင်တန်းတွေဟာအဝေးကကြည့်ရင်အမျိုးသမီးတစ်ယောက်လဲလျောင်းနေတဲ့ပုံနဲ့တူလို့ဂူကိုလည်းနာမည်အပြည့်အစုံဆိုရင်ထမ့်လွန်ခွန်လန်နမ်းနွမ်လို့ခေါ်ပါတယ်။အဓိပ္ဗါယ်ကတော့လျောင်းနေတဲ့မိန်းမပျိုတောင်ကရေတွေထွက်ရှိရာဂူမဟာကြီးလို့ပြန်ဆိုနိုင်မယ်ထင်ပါတယ်။ဒေသခံတွေအကြားဒဏ္ဍာရီတွေ၊ရိုးရာပုံပြင်တွေမျိုးစုံရှိတဲ့ဒီတောင်ဟာတစ်နေ့တာအပန်းဖြေခရီးထွက်လာသူတွေအကြားရေပန်းစားသလို၊စွန့်စားခန်းဝင်ချင်ကြတဲ့လူငယ်တွေအတွက်လည်းအကြိုက်တွေ့စရာနေရာတစ်ခုဖြစ်လို့နေပါတယ်။ဒါပေမယ့်အန္တရာယ်လုံးဝကင်းတာတော့မဟုတ်ပါဘူး။ထမ့်လွန်ဂူထဲမှာလူပျောက်သွားတာတွေအရင်ကလည်းရှိခဲ့ဖူးပါတယ်။အထူးသဖြင့်တော့မုတ်သုန်ရာသီစဝင်လာတဲ့ဇူလိုင်နောက်ပိုင်းဆိုဂူထဲဝင်ရတာအင်မတန်အန္တရာယ်ကြီးပါတယ်။ဒီဂူထဲမှာမိုးတွင်းဆိုရေက၁၆ပေလောက်အထိပြည့်နေတတ်ပါတယ်။ဒါကြောင့်နိုဝင်ဘာကနေဧပြီလအတွင်းလောက်ပဲဂူထဲကိုဝင်နိုင်တယ်၊ဝင်သင့်တယ်လို့ဆိုကြပါတယ်။ဂူထဲမှာရေစီးကလည်းသိပ်သန်ပြီး၊ရေတွေကလည်းရွှံ့ရေတွေ၊ရှေ့ကိုလည်းဘာမှမမြင်ရနိုင်ဘူးလို့ချင်းရိုင်ခရိုင်မှာခရီးသွားဧည့်လမ်းညွှန်လုပ်နေတဲ့ဂျိုရှုဝါမောရစ်ကဘီဘီစီကိုပြောပြပါတယ်။ဂူထဲရေတွေပြည့်လာပြီဆိုရင်တော့အတွေ့အကြုံများတဲ့ရေငုပ်သမားတွေအတွက်တောင်တော်တော်အန္တရာယ်ကြီးတယ်လို့ဆိုပါတယ်။Imageca်ဂူဟာကမ္ဘာ့မြေပုံပေါ်မှာအထင်ကရဖြစ်လို့သွားခဲ့ပါပြီ။ဒေသခံအာဏာပိုင်တွေကလည်းထမ့်လွန်ဂူကိုပြတိုက်တစ်ခုအဖြစ်အသွင်ပြောင်းပြီးကမ္ဘာလှည့်ခရီးသည်တွေလာကြည့်ဖို့ဆွဲဆောင်နိုင်မယ့်နေရာလုပ်ဖို့စစီစဉ်နေပါပြီ။ရုပ်ရှင်ထုတ်လုပ်သူတချို့ကလည်းကလေးတွေနဲ့ကယ်ဆယ်ရေးလုပ်ငန်းအကြောင်းဟောလီးဝုဒ်ရုပ်ရှင်ကားကြီးအဖြစ်ရိုက်ကူးဖို့စိတ်ကူးကြံစည်နေကြပါပြီ။ထိုင်းလူငယ်တွေကိုဘယ်လိုကယ်တင်ခဲ့ရသလဲပြတိုက်ဖြစ်လာတော့မယ့်ထမ့်လွန်ဂူတောဝက်ဘောလုံးသမားလေးတွေနဲ့သူတို့ရဲ့နည်းပြကတော့ဆေးရုံကဆင်းလာရင်သာသနာ့ဘောင်ဝင်ပြီးဒုလ္လဘရဟန်းခံရှင်သာမဏေဝတ်ကြဖို့အစီအစဉ်တွေရှိနေတယ်လို့သိရပါတယ်။ဗုဒ္ဓဘာသာဝင်မိသားစုတွေအနေနဲ့လည်းဒီလိုသာသနာ့ဘောင်ကိုရက်ပိုင်းပဲဖြစ်ဖြစ်ဝင်လိုက်ရင်သူတို့အတွက်အဆိုးအညစ်တွေပပျောက်ပြီးခံစားကြုံတွေ့ခဲ့ရတဲ့ဖြစ်ရပ်ဆိုးကြီးကနေလွန်မြောက်နိုင်လိမ့်မယ်လို့ယုံကြည်ကြပါတယ်။။။နိုက်အတွက်ဆိုလည်းမွေးနေ့ပွဲလုပ်ဖို့ရှိနေပါသေးတယ်။
14 |
15 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MDetect
2 |
3 | MDetect is yet another library for displaying Burmese texts for Android.
4 |
5 |
6 |
7 | Zawgyi device and Unicode device
8 |
9 | ## How it works
10 |
11 | MDetect detects the device's font i.e. whether the user is using Unicode or Zawgyi by drawing က္က and compare the width with က. It doesnt embed any font and convert the text to Zawgyi if the user is using Zawgyi and it doesn't effect the performance of the app much.
12 |
13 | ## Download
14 | Gradle:
15 | ```groovy
16 | compile 'myatminsoe.mdetect.android:mdetect-android:3.2'
17 | ```
18 | or Maven:
19 | ```xml
20 |
21 | myatminsoe.mdetect.android
22 | mdetect-android
23 | 3.2
24 | pom
25 |
26 | ```
27 | ## How to use
28 |
29 | ### Kotlin
30 | Initialize MDetect on your Application class onCreate.
31 | ```kotlin
32 | override fun onCreate() {
33 | super.onCreate()
34 | MDetect.init(this)
35 | }
36 | ```
37 | MDetect can be used for deciding whether the user is using Unicode.
38 | ```kotlin
39 | if (MDetect.isUnicode()){
40 | //user is using Unicode
41 | } else {
42 | //user is using Zawgyi or showing squares
43 | }
44 | ```
45 |
46 | ### Java
47 | Initialize MDetect on your Application class onCreate.
48 | ```java
49 | @Override
50 | public void onCreate() {
51 | super.onCreate();
52 | MDetect.INSTANCE.init(this);
53 | }
54 | ```
55 |
56 | MDetect can be used for deciding whether the user is using Unicode.
57 | ```java
58 | if (MDetect.INSTANCE.isUnicode()){
59 | //user is using Unicode
60 | } else {
61 | //user is using Zawgyi or showing squares
62 | }
63 | ```
64 |
65 | MDetect have custom views for **TextView**, **EditText** and **Button**
66 | ```xml
67 |
74 |
75 |
82 |
83 |
89 |
90 |
97 |
98 |
99 | ```
100 |
101 | ## Setting and Getting Text for custom views
102 | use setMMText() and getMMText() instead of setText() and getText() for custom views.
103 |
104 | ## Getting Text
105 | ### Kotlin
106 | ```kotlin
107 | MDetect.getText("မင်္ဂလာပါ") //return မဂၤလာပါ is the device is using zawgyi
108 | ```
109 | ### Java
110 | ```java
111 | MDetect.INSTANCE.getText("မင်္ဂလာပါ") //return မဂၤလာပါ is the device is using zawgyi
112 | ```
113 |
114 | ## Toast
115 | ### Kotlin
116 | ```kotlin
117 | MMToast.showShortToast(this, "မင်္ဂလာပါ")
118 | MMToast.showLongToast(this, "မင်္ဂလာပါ")
119 | ```
120 |
121 | ### Java
122 | ```java
123 | MMToast.INSTANCE.showShortToast(this, "မင်္ဂလာပါ")
124 | MMToast.INSTANCE.showLongToast(this, "မင်္ဂလာပါ")
125 | ```
126 |
127 | ## Zawgyi <-> Unicode Converter
128 | MDetect use [Rabbit Converter](https://github.com/Rabbit-Converter/Rabbit) for converting Zawgyi and Unicode and you can also use the features from Rabbit Converter.
129 | ### Kotlin
130 | ```kotlin
131 | val uniSt = Rabbit.zg2uni("ေနေကာင္းလား"); //နေကောင်းလား
132 | val zgSt = Rabbit.uni2zg("နေကောင်းလား"); //ေနေကာင္းလား
133 | ```
134 |
135 | ### Java
136 | ```java
137 | String uniSt = Rabbit.zg2uni("ေနေကာင္းလား"); //နေကောင်းလား
138 | String zgSt = Rabbit.uni2zg("နေကောင်းလား"); //ေနေကာင္းလား
139 | ```
140 |
141 |
142 | See the sample app for more detail.
143 |
144 | # License
145 | ```
146 | MIT License
147 |
148 | Copyright (c) 2016 Myat Min Soe
149 |
150 | Permission is hereby granted, free of charge, to any person obtaining a copy
151 | of this software and associated documentation files (the "Software"), to deal
152 | in the Software without restriction, including without limitation the rights
153 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
154 | copies of the Software, and to permit persons to whom the Software is
155 | furnished to do so, subject to the following conditions:
156 |
157 | The above copyright notice and this permission notice shall be included in all
158 | copies or substantial portions of the Software.
159 |
160 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
161 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
162 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
163 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
164 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
165 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
166 | SOFTWARE.
167 | ```
168 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFEBEE
4 | #FFCDD2
5 | #EF9A9A
6 | #E57373
7 | #EF5350
8 | #F44336
9 | #E53935
10 | #D32F2F
11 | #C62828
12 | #B71C1C
13 | #FF8A80
14 | #FF5252
15 | #FF1744
16 | #D50000
17 |
18 | #EDE7F6
19 | #D1C4E9
20 | #B39DDB
21 | #9575CD
22 | #7E57C2
23 | #673AB7
24 | #5E35B1
25 | #512DA8
26 | #4527A0
27 | #311B92
28 | #B388FF
29 | #7C4DFF
30 | #651FFF
31 | #6200EA
32 |
33 | #E1F5FE
34 | #B3E5FC
35 | #81D4FA
36 | #4FC3F7
37 | #29B6F6
38 | #03A9F4
39 | #039BE5
40 | #0288D1
41 | #0277BD
42 | #01579B
43 | #80D8FF
44 | #40C4FF
45 | #00B0FF
46 | #0091EA
47 |
48 | #E8F5E9
49 | #C8E6C9
50 | #A5D6A7
51 | #81C784
52 | #66BB6A
53 | #4CAF50
54 | #43A047
55 | #388E3C
56 | #2E7D32
57 | #1B5E20
58 | #B9F6CA
59 | #69F0AE
60 | #00E676
61 | #00C853
62 |
63 | #FFFDE7
64 | #FFF9C4
65 | #FFF59D
66 | #FFF176
67 | #FFEE58
68 | #FFEB3B
69 | #FDD835
70 | #FBC02D
71 | #F9A825
72 | #F57F17
73 | #FFFF8D
74 | #FFFF00
75 | #FFEA00
76 | #FFD600
77 |
78 | #FBE9E7
79 | #FFCCBC
80 | #FFAB91
81 | #FF8A65
82 | #FF7043
83 | #FF5722
84 | #F4511E
85 | #E64A19
86 | #D84315
87 | #BF360C
88 | #FF9E80
89 | #FF6E40
90 | #FF3D00
91 | #DD2C00
92 |
93 | #ECEFF1
94 | #CFD8DC
95 | #B0BEC5
96 | #90A4AE
97 | #78909C
98 | #607D8B
99 | #546E7A
100 | #455A64
101 | #37474F
102 | #263238
103 |
104 | #FCE4EC
105 | #F8BBD0
106 | #F48FB1
107 | #F06292
108 | #EC407A
109 | #E91E63
110 | #D81B60
111 | #C2185B
112 | #AD1457
113 | #880E4F
114 | #FF80AB
115 | #FF4081
116 | #F50057
117 | #C51162
118 |
119 | #E8EAF6
120 | #C5CAE9
121 | #9FA8DA
122 | #7986CB
123 | #5C6BC0
124 | #3F51B5
125 | #3949AB
126 | #303F9F
127 | #283593
128 | #1A237E
129 | #8C9EFF
130 | #536DFE
131 | #3D5AFE
132 | #304FFE
133 |
134 | #E0F7FA
135 | #B2EBF2
136 | #80DEEA
137 | #4DD0E1
138 | #26C6DA
139 | #00BCD4
140 | #00ACC1
141 | #0097A7
142 | #00838F
143 | #006064
144 | #84FFFF
145 | #18FFFF
146 | #00E5FF
147 | #00B8D4
148 |
149 | #F1F8E9
150 | #DCEDC8
151 | #C5E1A5
152 | #AED581
153 | #9CCC65
154 | #8BC34A
155 | #7CB342
156 | #689F38
157 | #558B2F
158 | #33691E
159 | #CCFF90
160 | #B2FF59
161 | #76FF03
162 | #64DD17
163 |
164 | #FFF8E1
165 | #FFECB3
166 | #FFE082
167 | #FFD54F
168 | #FFCA28
169 | #FFC107
170 | #FFB300
171 | #FFA000
172 | #FF8F00
173 | #FF6F00
174 | #FFE57F
175 | #FFD740
176 | #FFC400
177 | #FFAB00
178 |
179 | #EFEBE9
180 | #D7CCC8
181 | #BCAAA4
182 | #A1887F
183 | #8D6E63
184 | #795548
185 | #6D4C41
186 | #5D4037
187 | #4E342E
188 | #3E2723
189 |
190 | #F3E5F5
191 | #E1BEE7
192 | #CE93D8
193 | #BA68C8
194 | #AB47BC
195 | #9C27B0
196 | #8E24AA
197 | #7B1FA2
198 | #6A1B9A
199 | #4A148C
200 | #EA80FC
201 | #E040FB
202 | #D500F9
203 | #AA00FF
204 |
205 | #E3F2FD
206 | #BBDEFB
207 | #90CAF9
208 | #64B5F6
209 | #42A5F5
210 | #2196F3
211 | #1E88E5
212 | #1976D2
213 | #1565C0
214 | #0D47A1
215 | #82B1FF
216 | #448AFF
217 | #2979FF
218 | #2962FF
219 |
220 | #E0F2F1
221 | #B2DFDB
222 | #80CBC4
223 | #4DB6AC
224 | #26A69A
225 | #009688
226 | #00897B
227 | #00796B
228 | #00695C
229 | #004D40
230 | #A7FFEB
231 | #64FFDA
232 | #1DE9B6
233 | #00BFA5
234 |
235 | #F9FBE7
236 | #F0F4C3
237 | #E6EE9C
238 | #DCE775
239 | #D4E157
240 | #CDDC39
241 | #C0CA33
242 | #AFB42B
243 | #9E9D24
244 | #827717
245 | #F4FF81
246 | #EEFF41
247 | #C6FF00
248 | #AEEA00
249 |
250 | #FFF3E0
251 | #FFE0B2
252 | #FFCC80
253 | #FFB74D
254 | #FFA726
255 | #FF9800
256 | #FB8C00
257 | #F57C00
258 | #EF6C00
259 | #E65100
260 | #FFD180
261 | #FFAB40
262 | #FF9100
263 | #FF6D00
264 |
265 | #FAFAFA
266 | #F5F5F5
267 | #EEEEEE
268 | #E0E0E0
269 | #BDBDBD
270 | #9E9E9E
271 | #757575
272 | #616161
273 | #424242
274 | #212121
275 |
276 | #000000
277 | #FFFFFF
278 |
279 |
280 | @color/blue_500
281 | @color/blue_700
282 | @color/red_500
283 |
284 |
--------------------------------------------------------------------------------
/mdetect/src/main/java/com/comquas/rabbit/Rabbit.java:
--------------------------------------------------------------------------------
1 | package com.comquas.rabbit;
2 |
3 | import org.json.JSONArray;
4 | import org.json.JSONException;
5 | import org.json.JSONObject;
6 |
7 | /**
8 | * Created by saturngod on 23/1/15.
9 | */
10 | public class Rabbit {
11 |
12 | public static String uni2zg(String input) {
13 |
14 | String rule = "[ { \"from\": \"\u1004\u103a\u1039\", \"to\": \"\u1064\" }, { \"from\": \"\u1039\u1010\u103d\", \"to\": \"\u1096\" }, { \"from\": \"\u102b\u103a\", \"to\": \"\u105a\" }, { \"from\": \"\u100b\u1039\u100c\", \"to\": \"\u1092\" }, { \"from\": \"\u102d\u1036\", \"to\": \"\u108e\" }, { \"from\": \"\u104e\u1004\u103a\u1038\", \"to\": \"\u104e\" }, { \"from\": \"[\u1025\u1009](?=[\u1039\u102f\u1030])\", \"to\": \"\u106a\" }, { \"from\": \"[\u1025\u1009](?=[\u1037]?[\u103a])\", \"to\": \"\u1025\" }, { \"from\": \"\u100a(?=[\u1039\u103d])\", \"to\": \"\u106b\" }, { \"from\": \"(\u1039[\u1000-\u1021])(\u102D){0,1}\u102f\", \"to\": \"$1$2\u1033\" }, { \"from\": \"(\u1039[\u1000-\u1021])\u1030\", \"to\": \"$1\u1034\" }, { \"from\": \"\u1014(?=[\u102d\u102e]?[\u1030\u103d\u103e\u102f\u1039])\", \"to\": \"\u108f\" }, { \"from\" : \"\u1014\u103c\", \"to\" : \"\u108f\u103c\" }, { \"from\": \"\u1039\u1000\", \"to\": \"\u1060\" }, { \"from\": \"\u1039\u1001\", \"to\": \"\u1061\" }, { \"from\": \"\u1039\u1002\", \"to\": \"\u1062\" }, { \"from\": \"\u1039\u1003\", \"to\": \"\u1063\" }, { \"from\": \"\u1039\u1005\", \"to\": \"\u1065\" }, { \"from\": \"\u1039\u1006\", \"to\": \"\u1066\" }, { \"from\": \"\u1039\u1007\", \"to\": \"\u1068\" }, { \"from\": \"\u1039\u1008\", \"to\": \"\u1069\" }, { \"from\": \"\u1039\u100b\", \"to\": \"\u106c\" }, { \"from\": \"\u1039\u100c\", \"to\": \"\u106d\" }, { \"from\": \"\u100d\u1039\u100d\", \"to\": \"\u106e\" }, { \"from\": \"\u100e\u1039\u100d\", \"to\": \"\u106f\" }, { \"from\": \"\u1039\u100f\", \"to\": \"\u1070\" }, { \"from\": \"\u1039\u1010\", \"to\": \"\u1071\" }, { \"from\": \"\u1039\u1011\", \"to\": \"\u1073\" }, { \"from\": \"\u1039\u1012\", \"to\": \"\u1075\" }, { \"from\": \"\u1039\u1013\", \"to\": \"\u1076\" }, { \"from\": \"\u1039[\u1014\u108f]\", \"to\": \"\u1077\" }, { \"from\": \"\u1039\u1015\", \"to\": \"\u1078\" }, { \"from\": \"\u1039\u1016\", \"to\": \"\u1079\" }, { \"from\": \"\u1039\u1017\", \"to\": \"\u107a\" }, { \"from\": \"\u1039\u1018\", \"to\": \"\u107b\" }, { \"from\": \"\u1039\u1019\", \"to\": \"\u107c\" }, { \"from\": \"\u1039\u101c\", \"to\": \"\u1085\" }, { \"from\": \"\u103f\", \"to\": \"\u1086\" }, { \"from\": \"\u103d\u103e\", \"to\": \"\u108a\" }, { \"from\": \"(\u1064)([\u1000-\u1021])([\u103b\u103c]?)\u102d\", \"to\": \"$2$3\u108b\" }, { \"from\": \"(\u1064)([\u1000-\u1021])([\u103b\u103c]?)\u102e\", \"to\": \"$2$3\u108c\" }, { \"from\": \"(\u1064)([\u1000-\u1021])([\u103b\u103c]?)\u1036\", \"to\": \"$2$3\u108d\" }, { \"from\": \"(\u1064)([\u1000-\u1021])([\u103b\u103c]?)([\u1031]?)\", \"to\": \"$2$3$4$1\" }, { \"from\": \"\u101b(?=([\u102d\u102e]?)[\u102f\u1030\u103d\u108a])\", \"to\": \"\u1090\" }, { \"from\": \"\u100f\u1039\u100d\", \"to\": \"\u1091\" }, { \"from\": \"\u100b\u1039\u100b\", \"to\": \"\u1097\" }, { \"from\": \"([\u1000-\u1021\u108f\u1029\u1090])([\u1060-\u1069\u106c\u106d\u1070-\u107c\u1085\u108a])?([\u103b-\u103e]*)?\u1031\", \"to\": \"\u1031$1$2$3\" }, { \"from\": \"\u103c\u103e\", \"to\": \"\u103c\u1087\" }, { \"from\": \"([\u1000-\u1021\u108f\u1029])([\u1060-\u1069\u106c\u106d\u1070-\u107c\u1085])?(\u103c)\", \"to\": \"$3$1$2\" }, { \"from\": \"\u103a\", \"to\": \"\u1039\" }, { \"from\": \"\u103b\", \"to\": \"\u103a\" }, { \"from\": \"\u103c\", \"to\": \"\u103b\" }, { \"from\": \"\u103d\", \"to\": \"\u103c\" }, { \"from\": \"\u103e\", \"to\": \"\u103d\" }, { \"from\": \"([^\u103a\u100a])\u103d([\u102d\u102e]?)\u102f\", \"to\": \"$1\u1088$2\" }, { \"from\": \"([\u101b\u103a\u103c\u108a\u1088\u1090])([\u1030\u103d])?([\u1032\u1036\u1039\u102d\u102e\u108b\u108c\u108d\u108e]?)(\u102f)?\u1037\", \"to\": \"$1$2$3$4\u1095\" }, { \"from\": \"([\u102f\u1014\u1030\u103d])([\u1032\u1036\u1039\u102d\u102e\u108b\u108c\u108d\u108e]?)\u1037\", \"to\": \"$1$2\u1094\" }, { \"from\": \"([\u103b])([\u1000-\u1021])([\u1087]?)([\u1036\u102d\u102e\u108b\u108c\u108d\u108e]?)\u102f\", \"to\": \"$1$2$3$4\u1033\" }, { \"from\": \"([\u103b])([\u1000-\u1021])([\u1087]?)([\u1036\u102d\u102e\u108b\u108c\u108d\u108e]?)\u1030\", \"to\": \"$1$2$3$4\u1034\" }, { \"from\": \"([\u103a\u103c\u100a\u1020\u1025])([\u103d]?)([\u1036\u102d\u102e\u108b\u108c\u108d\u108e]?)\u102f\", \"to\": \"$1$2$3\u1033\" }, { \"from\": \"([\u103a\u103c\u100a\u101b])(\u103d?)([\u1036\u102d\u102e\u108b\u108c\u108d\u108e]?)\u1030\", \"to\": \"$1$2$3\u1034\" }, { \"from\": \"\u100a\u103d\", \"to\": \"\u100a\u1087\" }, { \"from\": \"\u103d\u1030\", \"to\": \"\u1089\" }, { \"from\": \"\u103b([\u1000\u1003\u1006\u100f\u1010\u1011\u1018\u101a\u101c\u101a\u101e\u101f])\", \"to\": \"\u107e$1\" }, { \"from\": \"\u107e([\u1000\u1003\u1006\u100f\u1010\u1011\u1018\u101a\u101c\u101a\u101e\u101f])([\u103c\u108a])([\u1032\u1036\u102d\u102e\u108b\u108c\u108d\u108e])\", \"to\": \"\u1084$1$2$3\" }, { \"from\": \"\u107e([\u1000\u1003\u1006\u100f\u1010\u1011\u1018\u101a\u101c\u101a\u101e\u101f])([\u103c\u108a])\", \"to\": \"\u1082$1$2\" }, { \"from\": \"\u107e([\u1000\u1003\u1006\u100f\u1010\u1011\u1018\u101a\u101c\u101a\u101e\u101f])([\u1033\u1034]?)([\u1032\u1036\u102d\u102e\u108b\u108c\u108d\u108e])\", \"to\": \"\u1080$1$2$3\" }, { \"from\": \"\u103b([\u1000-\u1021])([\u103c\u108a])([\u1032\u1036\u102d\u102e\u108b\u108c\u108d\u108e])\", \"to\": \"\u1083$1$2$3\" }, { \"from\": \"\u103b([\u1000-\u1021])([\u103c\u108a])\", \"to\": \"\u1081$1$2\" }, { \"from\": \"\u103b([\u1000-\u1021])([\u1033\u1034]?)([\u1032\u1036\u102d\u102e\u108b\u108c\u108d\u108e])\", \"to\": \"\u107f$1$2$3\" }, { \"from\": \"\u103a\u103d\", \"to\": \"\u103d\u103a\" }, { \"from\": \"\u103a([\u103c\u108a])\", \"to\": \"$1\u107d\" }, { \"from\": \"([\u1033\u1034])\u1094\", \"to\": \"$1\u1095\" }, { \"from\": \"\u108F\u1071\", \"to\" : \"\u108F\u1072\" }, { \"from\": \"([\u1000-\u1021])([\u107B\u1066])\u102C\", \"to\": \"$1\u102C$2\" }, { \"from\": \"\u102C([\u107B\u1066])\u1037\", \"to\": \"\u102C$1\u1094\" }]";
15 | return replace_with_rule(rule, input);
16 | }
17 |
18 | public static String zg2uni(String input) {
19 |
20 | String rule = "[{ \"from\": \"\u200B\", \"to\": \"\" }, { \"from\": \"(\u103d|\u1087)\", \"to\": \"\u103e\" }, { \"from\": \"\u103c\", \"to\": \"\u103d\" }, { \"from\": \"(\u103b|\u107e|\u107f|\u1080|\u1081|\u1082|\u1083|\u1084)\", \"to\": \"\u103c\" }, { \"from\": \"(\u103a|\u107d)\", \"to\": \"\u103b\" }, { \"from\": \"\u1039\", \"to\": \"\u103a\" }, { \"from\": \"(\u1066|\u1067)\", \"to\": \"\u1039\u1006\" }, { \"from\": \"\u106a\", \"to\": \"\u1009\" }, { \"from\": \"\u106b\", \"to\": \"\u100a\" }, { \"from\": \"\u106c\", \"to\": \"\u1039\u100b\" }, { \"from\": \"\u106d\", \"to\": \"\u1039\u100c\" }, { \"from\": \"\u106e\", \"to\": \"\u100d\u1039\u100d\" }, { \"from\": \"\u106f\", \"to\": \"\u100d\u1039\u100e\" }, { \"from\": \"\u1070\", \"to\": \"\u1039\u100f\" }, { \"from\": \"(\u1071|\u1072)\", \"to\": \"\u1039\u1010\" }, { \"from\": \"\u1060\", \"to\": \"\u1039\u1000\" }, { \"from\": \"\u1061\", \"to\": \"\u1039\u1001\" }, { \"from\": \"\u1062\", \"to\": \"\u1039\u1002\" }, { \"from\": \"\u1063\", \"to\": \"\u1039\u1003\" }, { \"from\": \"\u1065\", \"to\": \"\u1039\u1005\" }, { \"from\": \"\u1068\", \"to\": \"\u1039\u1007\" }, { \"from\": \"\u1069\", \"to\": \"\u1039\u1008\" }, { \"from\": \"(\u1073|\u1074)\", \"to\": \"\u1039\u1011\" }, { \"from\": \"\u1075\", \"to\": \"\u1039\u1012\" }, { \"from\": \"\u1076\", \"to\": \"\u1039\u1013\" }, { \"from\": \"\u1077\", \"to\": \"\u1039\u1014\" }, { \"from\": \"\u1078\", \"to\": \"\u1039\u1015\" }, { \"from\": \"\u1079\", \"to\": \"\u1039\u1016\" }, { \"from\": \"\u107a\", \"to\": \"\u1039\u1017\" }, { \"from\": \"\u107c\", \"to\": \"\u1039\u1019\" }, { \"from\": \"\u1085\", \"to\": \"\u1039\u101c\" }, { \"from\": \"\u1033\", \"to\": \"\u102f\" }, { \"from\": \"\u1034\", \"to\": \"\u1030\" }, { \"from\": \"\u103f\", \"to\": \"\u1030\" }, { \"from\": \"\u1086\", \"to\": \"\u103f\" }, { \"from\": \"\u1036\u1088\", \"to\": \"\u1088\u1036\" }, { \"from\": \"\u1088\", \"to\": \"\u103e\u102f\" }, { \"from\": \"\u1089\", \"to\": \"\u103e\u1030\" }, { \"from\": \"\u108a\", \"to\": \"\u103d\u103e\" }, { \"from\": \"\u103B\u1064\", \"to\": \"\u1064\u103B\" }, { \"from\": \"(\u1031)?([\u1000-\u1021])\u1064\", \"to\": \"\u1004\u103a\u1039$1$2\" }, { \"from\": \"(\u1031)?([\u1000-\u1021])\u108b\", \"to\": \"\u1004\u103a\u1039$1$2\u102d\" }, { \"from\": \"(\u1031)?([\u1000-\u1021])\u108c\", \"to\": \"\u1004\u103a\u1039$1$2\u102e\" }, { \"from\": \"(\u1031)?([\u1000-\u1021])\u108d\", \"to\": \"\u1004\u103a\u1039$1$2\u1036\" }, { \"from\": \"\u108e\", \"to\": \"\u102d\u1036\" }, { \"from\": \"\u108f\", \"to\": \"\u1014\" }, { \"from\": \"\u1090\", \"to\": \"\u101b\" }, { \"from\": \"\u1091\", \"to\": \"\u100f\u1039\u100d\" }, { \"from\": \"\u1019\u102c(\u107b|\u1093)\", \"to\": \"\u1019\u1039\u1018\u102c\" }, { \"from\": \"(\u107b|\u1093)\", \"to\": \"\u1039\u1018\" }, { \"from\": \"(\u1094|\u1095)\", \"to\": \"\u1037\" }, { \"from\": \"([\u1000-\u1021])\u1037\u1032\", \"to\": \"$1\u1032\u1037\" }, { \"from\": \"\u1096\", \"to\": \"\u1039\u1010\u103d\" }, { \"from\": \"\u1097\", \"to\": \"\u100b\u1039\u100b\" }, { \"from\": \"\u103c([\u1000-\u1021])([\u1000-\u1021])?\", \"to\": \"$1\u103c$2\" }, { \"from\": \"([\u1000-\u1021])\u103c\u103a\", \"to\": \"\u103c$1\u103a\" }, { \"from\": \"\u1047(?=[\u102c-\u1030\u1032\u1036-\u1038\u103d\u1038])\", \"to\": \"\u101b\" }, { \"from\": \"\u1031\u1047\", \"to\": \"\u1031\u101b\" }, { \"from\": \"\u1040(\u102e|\u102f|\u102d\u102f|\u1030|\u1036|\u103d|\u103e)\", \"to\": \"\u101d$1\" }, { \"from\": \"([^\u1040\u1041\u1042\u1043\u1044\u1045\u1046\u1047\u1048\u1049])\u1040\u102b\", \"to\": \"$1\u101d\u102b\" }, { \"from\": \"([\u1040\u1041\u1042\u1043\u1044\u1045\u1046\u1047\u1048\u1049])\u1040\u102b(?!\u1038)\", \"to\": \"$1\u101d\u102b\" }, { \"from\": \"^\u1040(?=\u102b)\", \"to\": \"\u101d\" }, { \"from\": \"\u1040\u102d(?!\u0020?/)\", \"to\": \"\u101d\u102d\" }, { \"from\": \"([^\u1040-\u1049])\u1040([^\u1040-\u1049\u0020]|[\u104a\u104b])\", \"to\": \"$1\u101d$2\" }, { \"from\": \"([^\u1040-\u1049])\u1040(?=[\\f\\n\\r])\", \"to\": \"$1\u101d\" }, { \"from\": \"([^\u1040-\u1049])\u1040$\", \"to\": \"$1\u101d\" }, { \"from\": \"\u1031([\u1000-\u1021])(\u103e)?(\u103b)?\", \"to\": \"$1$2$3\u1031\" }, { \"from\": \"([\u1000-\u1021])\u1031([\u103b\u103c\u103d\u103e]+)\", \"to\": \"$1$2\u1031\" }, { \"from\": \"\u1032\u103d\", \"to\": \"\u103d\u1032\" }, { \"from\": \"([\u102d\u102e])\u103b\", \"to\": \"\u103b$1\" }, { \"from\": \"\u103d\u103b\", \"to\": \"\u103b\u103d\" }, { \"from\": \"\u103a\u1037\", \"to\": \"\u1037\u103a\" }, { \"from\": \"\u102f(\u102d|\u102e|\u1036|\u1037)\u102f\", \"to\": \"\u102f$1\" }, { \"from\": \"(\u102f|\u1030)(\u102d|\u102e)\", \"to\": \"$2$1\" }, { \"from\": \"(\u103e)(\u103b|\u103c)\", \"to\": \"$2$1\" }, { \"from\": \"\u1025(?=[\u1037]?[\u103a\u102c])\", \"to\": \"\u1009\" }, { \"from\": \"\u1025\u102e\", \"to\": \"\u1026\" }, { \"from\": \"\u1005\u103b\", \"to\": \"\u1008\" }, { \"from\": \"\u1036(\u102f|\u1030)\", \"to\": \"$1\u1036\" }, { \"from\": \"\u1031\u1037\u103e\", \"to\": \"\u103e\u1031\u1037\" }, { \"from\": \"\u1031\u103e\u102c\", \"to\": \"\u103e\u1031\u102c\" }, { \"from\": \"\u105a\", \"to\": \"\u102b\u103a\" }, { \"from\": \"\u1031\u103b\u103e\", \"to\": \"\u103b\u103e\u1031\" }, { \"from\": \"(\u102d|\u102e)(\u103d|\u103e)\", \"to\": \"$2$1\" }, { \"from\": \"\u102c\u1039([\u1000-\u1021])\", \"to\": \"\u1039$1\u102c\" }, { \"from\": \"\u103c\u1004\u103a\u1039([\u1000-\u1021])\", \"to\": \"\u1004\u103a\u1039$1\u103c\" }, { \"from\": \"\u1039\u103c\u103a\u1039([\u1000-\u1021])\", \"to\": \"\u103a\u1039$1\u103c\" }, { \"from\": \"\u103c\u1039([\u1000-\u1021])\", \"to\": \"\u1039$1\u103c\" }, { \"from\": \"\u1036\u1039([\u1000-\u1021])\", \"to\": \"\u1039$1\u1036\" }, { \"from\": \"\u1092\", \"to\": \"\u100b\u1039\u100c\" }, { \"from\": \"\u104e\", \"to\": \"\u104e\u1004\u103a\u1038\" }, { \"from\": \"\u1040(\u102b|\u102c|\u1036)\", \"to\": \"\u101d$1\" }, { \"from\": \"\u1025\u1039\", \"to\": \"\u1009\u1039\" }, { \"from\": \"([\u1000-\u1021])\u103c\u1031\u103d\", \"to\": \"$1\u103c\u103d\u1031\" }, { \"from\": \"([\u1000-\u1021])\u103b\u1031\u103d(\u103e)?\", \"to\": \"$1\u103b\u103d$2\u1031\" }, { \"from\": \"([\u1000-\u1021])\u103d\u1031\u103b\", \"to\": \"$1\u103b\u103d\u1031\" }, { \"from\": \"([\u1000-\u1021])\u1031(\u1039[\u1000-\u1021])\", \"to\": \"$1$2\u1031\" }, { \"from\": \"\u1038\u103a\", \"to\": \"\u103a\u1038\" }, { \"from\": \"\u102d\u103a|\u103a\u102d\", \"to\": \"\u102d\" }, { \"from\": \"\u102d\u102f\u103a\", \"to\": \"\u102d\u102f\" }, { \"from\": \"\u0020\u1037\", \"to\": \"\u1037\" }, { \"from\": \"\u1037\u1036\", \"to\": \"\u1036\u1037\" }, { \"from\": \" \u1037\", \"to\": \"\u1037\" }, { \"from\": \"[\u102d]+\", \"to\": \"\u102d\" }, { \"from\": \"[\u103a]+\", \"to\": \"\u103a\" }, { \"from\": \"[\u103d]+\", \"to\": \"\u103d\" }, { \"from\": \"[\u1037]+\", \"to\": \"\u1037\" }, { \"from\": \"[\u102e]+\", \"to\": \"\u102e\" }, { \"from\": \"\u102d\u102e|\u102e\u102d\", \"to\": \"\u102e\" }, { \"from\": \"\u102f\u102d\", \"to\": \"\u102d\u102f\" }, { \"from\": \"\u1037\u1037\", \"to\": \"\u1037\" }, { \"from\": \"\u1032\u1032\", \"to\": \"\u1032\" }, { \"from\": \"\u1044\u1004\u103a\u1038\", \"to\": \"\u104E\u1004\u103a\u1038\" }, { \"from\": \"([\u102d\u102e])\u1039([\u1000-\u1021])\", \"to\": \"\u1039$2$1\" }, { \"from\": \"\u1036\u103d\", \"to\": \"\u103d\u1036\" }]";
21 | return replace_with_rule(rule, input);
22 | }
23 |
24 | private static String replace_with_rule(String rule, String output) {
25 |
26 | try {
27 | JSONArray rule_array = new JSONArray(rule);
28 | int max_loop = rule_array.length();
29 |
30 | //because of JDK 7 bugs in Android
31 | output = output.replace("null", "\uFFFF\uFFFF");
32 |
33 | for (int i = 0; i < max_loop; i++) {
34 |
35 | JSONObject obj = rule_array.getJSONObject(i);
36 | String from = obj.getString("from");
37 | String to = obj.getString("to");
38 |
39 | output = output.replaceAll(from, to);
40 | output = output.replace("null", "");
41 |
42 | }
43 | } catch (JSONException e) {
44 | e.printStackTrace();
45 | }
46 |
47 | output = output.replace("\uFFFF\uFFFF", "null");
48 | return output;
49 |
50 | }
51 | }
--------------------------------------------------------------------------------