Skip to content

Commit

Permalink
Merge pull request #113 from Ryosuke839/develop
Browse files Browse the repository at this point in the history
Release 2.12.1
  • Loading branch information
Ryosuke839 committed Jan 24, 2023
2 parents 0026b68 + f356243 commit 1493aef
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 8 deletions.
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 32
compileSdkVersion 33

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

compileOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ class SettingActivity : PreferenceActivity(), OnPreferenceChangeListener {
it.put("shrink", if (pref.contains("shrink")) pref.getBoolean("shrink", true) else null)
it.put("ime", if (pref.contains("ime")) pref.getBoolean("ime", true) else null)
it.put("clear", if (pref.contains("clear")) pref.getBoolean("clear", true) else null)
it.put("buttons", if (pref.contains("buttons")) pref.getBoolean("buttons", true) else null)
it.put("scroll", pref.getString("scroll", null))
it.put("recentsize", pref.getString("recentsize", null))
})
Expand Down Expand Up @@ -334,6 +335,7 @@ class SettingActivity : PreferenceActivity(), OnPreferenceChangeListener {
(it.opt("shrink") as? Boolean)?.let { bool -> edit.putBoolean("shrink", bool) }
(it.opt("ime") as? Boolean)?.let { bool -> edit.putBoolean("ime", bool) }
(it.opt("clear") as? Boolean)?.let { bool -> edit.putBoolean("clear", bool) }
(it.opt("buttons") as? Boolean)?.let { bool -> edit.putBoolean("buttons", bool) }
(it.opt("scroll") as? String)?.let { str -> edit.putString("scroll", str) }
(it.opt("recentsize") as? String)?.let { str -> edit.putString("recentsize", str) }
}
Expand Down
60 changes: 57 additions & 3 deletions app/src/main/java/jp/ddo/hotmist/unicodepad/UnicodeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ import kotlin.math.min
class UnicodeActivity : AppCompatActivity() {
private lateinit var editText: EditText
private lateinit var btnClear: ImageButton
private lateinit var btnFinish: MenuItem
private lateinit var btnRow: LinearLayout
private lateinit var btnFinish: Button
private lateinit var chooser: FontChooser
private lateinit var locale: LocaleChooser
private lateinit var scroll: LockableScrollView
Expand Down Expand Up @@ -107,7 +108,7 @@ class UnicodeActivity : AppCompatActivity() {
it.textSize = fontsize
it.setOnEditorActionListener { _, actionId, keyEvent ->
if (keyEvent?.keyCode == KeyEvent.KEYCODE_ENTER && keyEvent.action == KeyEvent.ACTION_DOWN || actionId == EditorInfo.IME_ACTION_DONE) {
onOptionsItemSelected(btnFinish)
btnFinish.performClick()
true
} else
false
Expand Down Expand Up @@ -140,12 +141,62 @@ class UnicodeActivity : AppCompatActivity() {
}
})
}
findViewById<Button>(R.id.copy).also {
it.setOnClickListener {
cm.text = editText.text.toString()
Toast.makeText(this, R.string.copied, Toast.LENGTH_SHORT).show()
}
}
findViewById<Button>(R.id.find).also {
it.setOnClickListener {
val str = editText.editableText.toString()
if (str.isEmpty()) return@setOnClickListener
val start = editText.selectionStart
if (start == -1) return@setOnClickListener
val end = editText.selectionEnd
adpPage.adapterEdit.updateString()
adpPage.showDesc(null, str.codePointCount(0, if (start == end) if (start == 0) 0 else start - 1 else min(start, end)), adpPage.adapterEdit)
}
}
findViewById<Button>(R.id.paste).also {
it.setOnClickListener {
editText.setText(cm.text)
}
}
btnFinish = findViewById<Button>(R.id.finish).also {
it.setOnClickListener {
when {
action == ACTION_INTERCEPT -> {
setResult(RESULT_OK, Intent().apply {
putExtra(REPLACE_KEY, editText.text.toString())
})
finish()
}
Build.VERSION.SDK_INT >= 23 && action == Intent.ACTION_PROCESS_TEXT -> {
setResult(RESULT_OK, Intent().apply {
putExtra(Intent.EXTRA_PROCESS_TEXT, editText.text)
})
finish()
}
else -> {
startActivity(Intent().apply {
action = Intent.ACTION_SEND
type = "text/plain"
putExtra(Intent.EXTRA_TEXT, editText.text.toString())
})
}
}
}
}
btnClear = findViewById<ImageButton>(R.id.clear).also {
it.setOnClickListener {
editText.setText("")
}
it.visibility = if (pref.getBoolean("clear", false)) View.VISIBLE else View.GONE
}
btnRow = findViewById<LinearLayout>(R.id.buttonBar).also {
it.visibility = if (pref.getBoolean("buttons", true)) View.VISIBLE else View.GONE
}
findViewById<ImageButton>(R.id.delete).also {
it.setOnTouchListener { view: View, motionEvent: MotionEvent ->
view.onTouchEvent(motionEvent)
Expand Down Expand Up @@ -218,8 +269,10 @@ class UnicodeActivity : AppCompatActivity() {
}
if (action == ACTION_INTERCEPT || (Build.VERSION.SDK_INT >= 23 && action == Intent.ACTION_PROCESS_TEXT && !it.getBooleanExtra(Intent.EXTRA_PROCESS_TEXT_READONLY, false))) {
editText.imeOptions = EditorInfo.IME_ACTION_DONE
btnFinish.setText(R.string.finish)
} else {
editText.imeOptions = EditorInfo.IME_ACTION_SEND
btnFinish.setText(R.string.share)
action = null
}
adCompat.renderAdToContainer(this, pref)
Expand All @@ -243,7 +296,7 @@ class UnicodeActivity : AppCompatActivity() {
menu.add(1, MENU_ID_CONVERT, MENU_ID_CONVERT, R.string.convert_).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_NEVER).setIcon(android.R.drawable.ic_menu_sort_alphabetically)
menu.add(2, MENU_ID_DESC, MENU_ID_DESC, R.string.desc).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM).setIcon(android.R.drawable.ic_menu_info_details)
menu.add(3, MENU_ID_COPY, MENU_ID_COPY, android.R.string.copy).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_NEVER)
btnFinish = if (action == ACTION_INTERCEPT || (Build.VERSION.SDK_INT >= 23 && action == Intent.ACTION_PROCESS_TEXT)) {
if (action == ACTION_INTERCEPT || (Build.VERSION.SDK_INT >= 23 && action == Intent.ACTION_PROCESS_TEXT)) {
menu.add(3, MENU_ID_SHARE, MENU_ID_SHARE, R.string.share).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_NEVER).setIcon(android.R.drawable.ic_menu_share)
menu.add(3, MENU_ID_SEND, MENU_ID_SEND, R.string.finish).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS).setIcon(android.R.drawable.ic_menu_send)
} else {
Expand Down Expand Up @@ -444,6 +497,7 @@ class UnicodeActivity : AppCompatActivity() {
disableime = pref.getBoolean("ime", true)
if (created) {
btnClear.visibility = if (pref.getBoolean("clear", false)) View.VISIBLE else View.GONE
btnRow.visibility = if (pref.getBoolean("buttons", true)) View.VISIBLE else View.GONE
editText.textSize = fontsize
adpPage.notifyDataSetChanged()
scroll.setLockView(pager, (pref.getString("scroll", null)?.toIntOrNull()
Expand Down
43 changes: 43 additions & 0 deletions app/src/main/res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,49 @@
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
android:id="@+id/buttonBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?android:attr/buttonBarStyle">

<Button
android:id="@+id/paste"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:text="@android:string/paste"
style="?android:attr/buttonBarButtonStyle" />

<Button
android:id="@+id/find"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:text="@string/desc"
style="?android:attr/buttonBarButtonStyle" />

<Button
android:id="@+id/copy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:text="@android:string/copy"
style="?android:attr/buttonBarButtonStyle" />

<Button
android:id="@+id/finish"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:text="@string/finish"
style="?android:attr/buttonBarButtonStyle" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
Expand Down
43 changes: 43 additions & 0 deletions app/src/main/res/layout/main_emojicompat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,49 @@
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
android:id="@+id/buttonBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?android:attr/buttonBarStyle">

<Button
android:id="@+id/paste"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:text="@android:string/paste"
style="?android:attr/buttonBarButtonStyle" />

<Button
android:id="@+id/find"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:text="@string/desc"
style="?android:attr/buttonBarButtonStyle" />

<Button
android:id="@+id/copy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:text="@android:string/copy"
style="?android:attr/buttonBarButtonStyle" />

<Button
android:id="@+id/finish"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:text="@string/finish"
style="?android:attr/buttonBarButtonStyle" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@

<string name="ime_desc">IMEを無効化</string>
<string name="clear_desc">全削除ボタンを表示</string>
<string name="buttons_desc">ボタン行を表示</string>
<string name="malformed">ZIP内のファイル名が破損</string>
<string name="legal">法的表記</string>
<string name="legal_uni2">本アプリケーションはUnicode Data Fileの改変された版を含んでいます。
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@

<string name="ime_desc">Disable IME</string>
<string name="clear_desc">Show clear button</string>
<string name="buttons_desc">Show button row</string>
<string name="clear" translatable="false">⌧</string>
<string name="erase" translatable="false">⌫</string>
<string name="notacharacter" translatable="false">&lt;not a character&gt;</string>
Expand All @@ -470,7 +471,7 @@
Copyright © 1991-2022 Unicode, Inc. All rights reserved.
Distributed under the Terms of Use in
http://www.unicode.org/copyright.html.</string>
<string name="legal_app" translatable="false">UnicodePad 2.12.0</string>
<string name="legal_app" translatable="false">UnicodePad 2.12.1</string>
<string name="legal_app2" translatable="false">UnicodePad is licensed under the Apache License, Version2.0
https://github.com/Ryosuke839/UnicodePad</string>
</resources>
4 changes: 4 additions & 0 deletions app/src/main/res/xml/setting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@
android:defaultValue="false"
android:key="clear"
android:title="@string/clear_desc" />
<CheckBoxPreference
android:defaultValue="true"
android:key="buttons"
android:title="@string/buttons_desc" />
<ListPreference
android:defaultValue="1"
android:dialogTitle="@string/scroll_desc"
Expand Down

0 comments on commit 1493aef

Please sign in to comment.