From da9fe0b815bfaecf37cd9a7919b666dd4e371512 Mon Sep 17 00:00:00 2001 From: justcontributor <130456670+justcontributor@users.noreply.github.com> Date: Tue, 19 Sep 2023 01:06:51 +0900 Subject: [PATCH 01/14] Update strings.xml --- app/src/main/res/values-ko/strings.xml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 771d2a7..d31ecd7 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -372,15 +372,29 @@ F0000 사용자 영역 보충 A 100000 사용자 영역 보충 B + 다음 + 건너뛰기 + 완료 + 문자판 + Unicode의 모든 문자를 탐색할 수 있습니다. 짧게 눌러 문자를 입력하고 길게 눌러 문자 정보를 확인합니다. + 복사 / 공유 / 완료 + 편집이 끝났다면, Unicode 문자열을 복사하거나 공유할 수 있습니다. + + 이모지, 검색, 즐겨찾기 등 여러 문자판을 이용할 수 있습니다. + 글꼴 선택기 + 글리프(렌더링한 문자)가 누락된 경우 적절한 글꼴을 내려받고 선택합니다. + 설정 + 앱의 동작과 모양을 사용자 지정할 수 있습니다. 또 설정에서 이 안내를 다시 확인할 수 있습니다. + 일반 표시 기능 편집 상자의 글자 크기 열 개수 열 개수 (가로모드) - Unicode 버전 - 최근 (15.1.0) + + 최신 (15.1.0) EmojiCompat으로 이모지 표시 꺼짐 @@ -406,6 +420,7 @@ 스크롤 위치 현재 데이터와 합치기 광고 숨기기 + 안내 건너뛰기 탭 설정… 보이는 탭 숨긴 탭 @@ -436,7 +451,8 @@ 항상 IME 비활성화 - 초기화 버튼 보이기 + 초기화 버튼 표시 + 버튼 줄 표시 ZIP 파일 이름이 잘못됨 라이선스 This application includes a modified version of Unicode Data File. From d80464d73a4d9c3499b41b60ac37221c7ba2acf6 Mon Sep 17 00:00:00 2001 From: kjh9348 Date: Tue, 10 Oct 2023 01:09:31 +0900 Subject: [PATCH 02/14] Improve theme setting - Recreate activity instead of restarting the app - Add "System default" setting to follow the system dark mode setting --- .../jp/ddo/hotmist/unicodepad/BaseActivity.kt | 32 +++++++++++++++++++ .../jp/ddo/hotmist/unicodepad/ListAdapter.kt | 12 +++---- .../ddo/hotmist/unicodepad/SettingActivity.kt | 32 ++++++------------- .../jp/ddo/hotmist/unicodepad/TabsActivity.kt | 12 +------ .../ddo/hotmist/unicodepad/UnicodeActivity.kt | 8 +---- app/src/main/res/values-ko/strings.xml | 1 + app/src/main/res/values-night/style.xml | 5 +++ app/src/main/res/values/setting.xml | 2 ++ app/src/main/res/values/strings.xml | 1 + app/src/main/res/values/style.xml | 2 ++ app/src/main/res/xml/setting.xml | 1 - 11 files changed, 60 insertions(+), 48 deletions(-) create mode 100644 app/src/main/java/jp/ddo/hotmist/unicodepad/BaseActivity.kt create mode 100644 app/src/main/res/values-night/style.xml diff --git a/app/src/main/java/jp/ddo/hotmist/unicodepad/BaseActivity.kt b/app/src/main/java/jp/ddo/hotmist/unicodepad/BaseActivity.kt new file mode 100644 index 0000000..e0e9d96 --- /dev/null +++ b/app/src/main/java/jp/ddo/hotmist/unicodepad/BaseActivity.kt @@ -0,0 +1,32 @@ +package jp.ddo.hotmist.unicodepad + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import androidx.preference.PreferenceManager + +private val THEME = intArrayOf( + R.style.Theme, + R.style.Theme_Light, + R.style.Theme_Light_DarkActionBar, + R.style.Theme_DayNight +) + +abstract class BaseActivity : AppCompatActivity() { + private var currentTheme = -1 + private fun getThemeFromPref(): Int { + val pref = PreferenceManager.getDefaultSharedPreferences(this) + return THEME[(pref.getString("theme", null)?.toIntOrNull() ?: 2131492983) - 2131492983] + } + + override fun onCreate(savedInstanceState: Bundle?) { + setTheme(getThemeFromPref().also { currentTheme = it }) + super.onCreate(savedInstanceState) + } + + override fun onResume() { + super.onResume() + if (currentTheme != getThemeFromPref()) { + recreate() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/jp/ddo/hotmist/unicodepad/ListAdapter.kt b/app/src/main/java/jp/ddo/hotmist/unicodepad/ListAdapter.kt index fbf0e54..d6d78e7 100644 --- a/app/src/main/java/jp/ddo/hotmist/unicodepad/ListAdapter.kt +++ b/app/src/main/java/jp/ddo/hotmist/unicodepad/ListAdapter.kt @@ -21,10 +21,9 @@ import android.app.AlertDialog import android.content.Context import android.content.DialogInterface import android.content.SharedPreferences -import android.content.res.Resources +import android.content.res.Configuration import android.database.DataSetObserver import android.graphics.* -import android.os.Build import android.text.Editable import android.text.InputType import android.text.TextWatcher @@ -540,11 +539,10 @@ internal class ListAdapter(activity: Activity, pref: SharedPreferences, db: Name val jmap = jump.context.resources.getStringArray(R.array.codes).associate { Integer.valueOf(it.substring(0, it.indexOf(' ')), 16) to it.substring(it.indexOf(' ') + 1) } - val jdef = jump.context.resources.let { - jump.context.createConfigurationContext(jump.context.resources.configuration.apply { setLocale(Locale.US) }).resources - }.getStringArray(R.array.codes).associate { - Integer.valueOf(it.substring(0, it.indexOf(' ')), 16) to it.substring(it.indexOf(' ') + 1) - } + val jdef = jump.context.createConfigurationContext(Configuration().apply { setLocale(Locale.US) }).resources + .getStringArray(R.array.codes).associate { + Integer.valueOf(it.substring(0, it.indexOf(' ')), 16) to it.substring(it.indexOf(' ') + 1) + } val jstr = fromCodePoint.keys.map { JumpItem(it, jmap.getValue(it), jdef.getValue(it)) }.toTypedArray() val adp = ArrayAdapter(jump.context, android.R.layout.simple_spinner_item, jstr) adp.setDropDownViewResource(R.layout.spinner_drop_down_item) diff --git a/app/src/main/java/jp/ddo/hotmist/unicodepad/SettingActivity.kt b/app/src/main/java/jp/ddo/hotmist/unicodepad/SettingActivity.kt index 734a5b1..9c0696c 100644 --- a/app/src/main/java/jp/ddo/hotmist/unicodepad/SettingActivity.kt +++ b/app/src/main/java/jp/ddo/hotmist/unicodepad/SettingActivity.kt @@ -18,32 +18,31 @@ package jp.ddo.hotmist.unicodepad import android.app.AlertDialog -import android.content.Context import android.content.DialogInterface import android.content.Intent import android.net.Uri import android.os.Build import android.os.Bundle -import android.os.LocaleList import android.text.ClipboardManager import android.view.ViewGroup import android.widget.CheckBox import android.widget.CompoundButton import android.widget.LinearLayout import android.widget.Toast -import androidx.appcompat.app.AppCompatActivity import androidx.preference.* import org.json.JSONException import org.json.JSONObject import java.io.IOException import java.util.* -class SettingActivity : AppCompatActivity() { +class SettingActivity : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { - val pref = PreferenceManager.getDefaultSharedPreferences(this) - setTheme(THEME[(pref.getString("theme", null)?.toIntOrNull() ?: 2131492983) - 2131492983]) super.onCreate(savedInstanceState) - fragmentManager.beginTransaction().replace(android.R.id.content, MyPreferenceFragment()).commit() + if (savedInstanceState == null) { + fragmentManager.beginTransaction() + .replace(android.R.id.content, MyPreferenceFragment()) + .commit() + } } override fun onSupportNavigateUp(): Boolean { @@ -51,16 +50,6 @@ class SettingActivity : AppCompatActivity() { return true } - override fun attachBaseContext(newBase: Context?) { - applyOverrideConfiguration(newBase?.resources?.configuration?.also { - it.setLocale(Locale.getDefault()) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - it.setLocales(LocaleList.getDefault()) - } - }) - super.attachBaseContext(newBase) - } - class MyPreferenceFragment : PreferenceFragment(), Preference.OnPreferenceChangeListener { private val adCompat: AdCompat = AdCompatImpl() @@ -168,7 +157,10 @@ class SettingActivity : AppCompatActivity() { } catch (e: NumberFormatException) { return false } - if (key == "theme" || key == "emojicompat") { + if (key == "theme") { + activity.recreate() + } + if (key == "emojicompat") { Toast.makeText(activity, R.string.theme_title, Toast.LENGTH_SHORT).show() activity.setResult(RESULT_FIRST_USER) } @@ -430,10 +422,6 @@ class SettingActivity : AppCompatActivity() { } companion object { - private val THEME = intArrayOf( - androidx.appcompat.R.style.Theme_AppCompat, - androidx.appcompat.R.style.Theme_AppCompat_Light, - androidx.appcompat.R.style.Theme_AppCompat_Light_DarkActionBar) private const val SETTING_EXPORT_CODE = 43 private const val SETTING_IMPORT_CODE = 44 } diff --git a/app/src/main/java/jp/ddo/hotmist/unicodepad/TabsActivity.kt b/app/src/main/java/jp/ddo/hotmist/unicodepad/TabsActivity.kt index 0c126b9..ab306f3 100644 --- a/app/src/main/java/jp/ddo/hotmist/unicodepad/TabsActivity.kt +++ b/app/src/main/java/jp/ddo/hotmist/unicodepad/TabsActivity.kt @@ -18,15 +18,12 @@ package jp.ddo.hotmist.unicodepad import android.annotation.SuppressLint import android.os.Bundle import android.util.TypedValue -import androidx.appcompat.app.AppCompatActivity -import androidx.preference.PreferenceManager import com.mobeta.android.dslv.DragSortController import com.mobeta.android.dslv.DragSortListView -class TabsActivity : AppCompatActivity() { +class TabsActivity : BaseActivity() { @SuppressLint("ClickableViewAccessibility") override fun onCreate(savedInstanceState: Bundle?) { - setTheme(THEME[(PreferenceManager.getDefaultSharedPreferences(this).getString("theme", null)?.toIntOrNull() ?: 2131492983) - 2131492983]) super.onCreate(savedInstanceState) val view = DragSortListView(this, null) val controller = DragSortController(view, R.id.HANDLE_ID, DragSortController.ON_DRAG, DragSortController.FLING_REMOVE) @@ -44,11 +41,4 @@ class TabsActivity : AppCompatActivity() { finish() return true } - - companion object { - private val THEME = intArrayOf( - R.style.Theme, - R.style.Theme_Light, - R.style.Theme_Light_DarkActionBar) - } } \ No newline at end of file diff --git a/app/src/main/java/jp/ddo/hotmist/unicodepad/UnicodeActivity.kt b/app/src/main/java/jp/ddo/hotmist/unicodepad/UnicodeActivity.kt index 1d94aaa..c85b40e 100644 --- a/app/src/main/java/jp/ddo/hotmist/unicodepad/UnicodeActivity.kt +++ b/app/src/main/java/jp/ddo/hotmist/unicodepad/UnicodeActivity.kt @@ -31,7 +31,6 @@ import android.view.* import android.view.inputmethod.EditorInfo import android.view.inputmethod.InputMethodManager import android.widget.* -import androidx.appcompat.app.AppCompatActivity import androidx.core.content.res.getResourceIdOrThrow import androidx.core.provider.FontRequest import androidx.core.view.doOnLayout @@ -53,7 +52,7 @@ import kotlin.math.min @Suppress("DEPRECATION") -class UnicodeActivity : AppCompatActivity() { +class UnicodeActivity : BaseActivity() { private lateinit var editText: EditText private lateinit var btnClear: ImageButton private lateinit var btnRow: LinearLayout @@ -98,7 +97,6 @@ class UnicodeActivity : AppCompatActivity() { } })) } - setTheme(THEME[(pref.getString("theme", null)?.toIntOrNull() ?: 2131492983) - 2131492983]) super.onCreate(savedInstanceState) window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN) setContentView(if (useEmoji == "null") R.layout.main else R.layout.main_emojicompat) @@ -616,10 +614,6 @@ class UnicodeActivity : AppCompatActivity() { private const val MENU_ID_SHARE = 36 private const val MENU_ID_SEND = 37 private const val MAX_HISTORY = 256 - private val THEME = intArrayOf( - R.style.Theme, - R.style.Theme_Light, - R.style.Theme_Light_DarkActionBar) private var fontsize = 24.0f internal var univer = 1000 } diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 771d2a7..f953347 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -426,6 +426,7 @@ 어둡게 밝게 밝게 + 제목 표시줄 어둡게 + 시스템 기본값 재시작 후 적용됨 목록 탭은 숨길 수 없음 diff --git a/app/src/main/res/values-night/style.xml b/app/src/main/res/values-night/style.xml new file mode 100644 index 0000000..29cee98 --- /dev/null +++ b/app/src/main/res/values-night/style.xml @@ -0,0 +1,5 @@ + + + + + +