8000 Write physical display size in Device Info · JUST-INTJ/fcitx5-android@58a6335 · GitHub
[go: up one dir, main page]

Skip to content

Commit 58a6335

Browse files
committed
Write physical display size in Device Info
1 parent c4a07bb commit 58a6335

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

app/src/main/java/org/fcitx/fcitx5/android/ui/main/settings/PinyinDictionaryFragment.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class PinyinDictionaryFragment : Fragment(), OnItemChangedListener<PinyinDiction
117117
getText(R.string.pinyin_dict),
118118
NotificationManager.IMPORTANCE_HIGH
119119
).apply { description = CHANNEL_ID }
120-
notificationManager.createNotificationChannel(channel)
120+
requireContext().notificationManager.createNotificationChannel(channel)
121121
}
122122
}
123123

@@ -172,7 +172,7 @@ class PinyinDictionaryFragment : Fragment(), OnItemChangedListener<PinyinDiction
172172
// Save the reference to NotificationManager, because reloadDict() could be called
173173
// right before the Fragment detached from Activity, and at the time reload completes,
174174
// Fragment is no longer attached to a Context, thus unable to cancel the notification.
175-
val nm = notificationManager
175+
val nm = requireContext().notificationManager
176176
lifecycleScope.launch(NonCancellable + Dispatchers.IO) {
177177
if (busy.compareAndSet(false, true)) {
178178
val id = RELOAD_ID++

app/src/main/java/org/fcitx/fcitx5/android/ui/main/settings/QuickPhraseListFragment.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class QuickPhraseListFragment : Fragment(), OnItemChangedListener<QuickPhrase> {
214214
getText(R.string.quickphrase_editor),
215215
NotificationManager.IMPORTANCE_HIGH
216216
).apply { description = CHANNEL_ID }
217-
notificationManager.createNotificationChannel(channel)
217+
requireContext().notificationManager.createNotificationChannel(channel)
218218
}
219219
}
220220

@@ -269,7 +269,7 @@ class QuickPhraseListFragment : Fragment(), OnItemChangedListener<QuickPhrase> {
269269
resetDustman()
270270
// save the reference to NotificationManager, in case we need to cancel notification
271271
// after Fragment detached
272-
val nm = notificationManager
272+
val nm = requireContext().notificationManager
273273
lifecycleScope.launch(NonCancellable + Dispatchers.IO) {
274274
if (busy.compareAndSet(false, true)) {
275275
val id = RELOAD_ID++

app/src/main/java/org/fcitx/fcitx5/android/ui/main/settings/TableInputMethodFragment.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class TableInputMethodFragment : Fragment(), OnItemChangedListener<TableBasedInp
135135
getText(R.string.table_im),
136136
NotificationManager.IMPORTANCE_HIGH
137137
).apply { description = CHANNEL_ID }
138-
notificationManager.createNotificationChannel(channel)
138+
requireContext().notificationManager.createNotificationChannel(channel)
139139
}
140140
}
141141

app/src/main/java/org/fcitx/fcitx5/android/utils/DeviceInfo.kt

+10-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package org.fcitx.fcitx5.android.utils
66

77
import android.content.Context
88
import android.content.res.Configuration
9+
import android.graphics.Point
910
import android.os.Build
1011
import org.fcitx.fcitx5.android.BuildConfig
1112

@@ -20,8 +21,16 @@ object DeviceInfo {
2021
appendLine("Model (product): ${Build.MODEL} (${Build.PRODUCT})")
2122
appendLine("Manufacturer: ${Build.MANUFACTURER}")
2223
appendLine("Tags: ${Build.TAGS}")
24+
@Suppress("DEPRECATION") // we really want the physical display size
25+
val size = Point().also {
26+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
27+
context.display!!
28+
} else {
29+
context.windowManager.defaultDisplay
30+
}.getRealSize(it)
31+
}
32+
appendLine("Screen Size: ${size.x} x ${size.y}")
2333
val metrics = context.resources.displayMetrics
24-
appendLine("Screen Size: ${metrics.widthPixels} x ${metrics.heightPixels}")
2534
appendLine("Screen Density: ${metrics.density}")
2635
appendLine(
2736
"Screen orientation: ${

app/src/main/java/org/fcitx/fcitx5/android/utils/SystemService.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import android.media.AudioManager
1111
import android.os.UserManager
1212
import android.os.Vibrator
1313
import android.os.storage.StorageManager
14+
import android.view.WindowManager
1415
import android.view.inputmethod.InputMethodManager
1516
import androidx.core.content.getSystemService
16-
import androidx.fragment.app.Fragment
1717

1818
val Context.audioManager
1919
get() = getSystemService<AudioManager>()!!
@@ -27,14 +27,14 @@ val Context.inputMethodManager
2727
val Context.notificationManager
2828
get() = getSystemService<NotificationManager>()!!
2929

30-
val Fragment.notificationManager
31-
get() = requireContext().notificationManager
32-
3330
val Context.storageManager
3431
get() = getSystemService<StorageManager>()!!
3532

3633
val Context.vibrator
3734
get() = getSystemService<Vibrator>()!!
3835

36+
val Context.windowManager
37+
get() = getSystemService<WindowManager>()!!
38+
3939
val Context.userManager
4040
get() = getSystemService<UserManager>()!!

0 commit comments

Comments
 (0)
0