Skip to content

Commit c1b5916

Browse files
authored
Fix status bar crash and add more signal labels (#34)
* add more signal type labels * cleanup redundant function
1 parent 065e863 commit c1b5916

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

app/src/main/java/com/vandam/luma/helper/ActionService.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2226,7 +2226,6 @@ class ActionService : AccessibilityService() {
22262226
batteryIcon.visibility = if (prefs.batteryIcon) View.VISIBLE else View.GONE
22272227
batteryIcon.setImageResource(iconRes)
22282228
batteryIcon.setColorFilter(textColor)
2229-
LumaStatusBarUi.updateSectionBaseline(batteryLayout)
22302229
}
22312230

22322231
private fun updateSecureLockMaskConnectivityStatus(
@@ -2298,7 +2297,6 @@ class ActionService : AccessibilityService() {
22982297
wifiIcon.visibility == View.VISIBLE ||
22992298
bluetoothIcon.visibility == View.VISIBLE
23002299
connectivityLayout.visibility = if (anyVisible) View.VISIBLE else View.INVISIBLE
2301-
LumaStatusBarUi.updateSectionBaseline(connectivityLayout)
23022300
}
23032301

23042302
private fun shouldShowUnlockGateStatusBar(): Boolean =

app/src/main/java/com/vandam/luma/helper/LumaStatusBarUi.kt

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import android.os.BatteryManager
55
import android.telephony.TelephonyManager
66
import android.view.View
77
import android.widget.ImageView
8-
import android.widget.LinearLayout
98
import android.widget.TextView
109
import com.vandam.luma.R
1110
import com.vandam.luma.data.Prefs
@@ -21,15 +20,6 @@ object LumaStatusBarUi {
2120
imageView.setColorFilter(tintColor)
2221
}
2322

24-
fun updateSectionBaseline(layout: LinearLayout) {
25-
for (index in 0 until layout.childCount) {
26-
if (layout.getChildAt(index).visibility != View.GONE) {
27-
layout.baselineAlignedChildIndex = index
28-
return
29-
}
30-
}
31-
}
32-
3323
fun clockPlaceholder(prefs: Prefs): String {
3424
val is24Hour = prefs.timeFormat == Prefs.TimeFormat.TwentyFourHour
3525
val hour = if (is24Hour || prefs.leadingZero) "00" else "12"
@@ -58,15 +48,33 @@ object LumaStatusBarUi {
5848
fun networkLabelForType(type: Int?): String =
5949
when (type) {
6050
TelephonyManager.NETWORK_TYPE_NR -> "5G"
51+
6152
TelephonyManager.NETWORK_TYPE_LTE -> "LTE"
53+
6254
TelephonyManager.NETWORK_TYPE_HSPAP,
6355
TelephonyManager.NETWORK_TYPE_HSPA,
6456
TelephonyManager.NETWORK_TYPE_HSDPA,
6557
TelephonyManager.NETWORK_TYPE_HSUPA,
6658
TelephonyManager.NETWORK_TYPE_UMTS,
59+
TelephonyManager.NETWORK_TYPE_EVDO_0,
60+
TelephonyManager.NETWORK_TYPE_EVDO_A,
61+
TelephonyManager.NETWORK_TYPE_EVDO_B,
62+
TelephonyManager.NETWORK_TYPE_EHRPD,
63+
TelephonyManager.NETWORK_TYPE_TD_SCDMA,
6764
-> "3G"
65+
66+
TelephonyManager.NETWORK_TYPE_GSM -> "2G"
67+
68+
TelephonyManager.NETWORK_TYPE_CDMA -> "CDMA"
69+
70+
TelephonyManager.NETWORK_TYPE_1xRTT -> "1x"
71+
6872
TelephonyManager.NETWORK_TYPE_EDGE -> "E"
73+
6974
TelephonyManager.NETWORK_TYPE_GPRS -> "G"
75+
76+
TelephonyManager.NETWORK_TYPE_IWLAN -> "IWLAN"
77+
7078
else -> ""
7179
}
7280

app/src/main/java/com/vandam/luma/ui/HomeFragment.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,6 @@ class HomeFragment :
756756
if (!prefs.showsLumaStatusBarAnywhere() || (!prefs.batteryPercentage && !prefs.batteryIcon)) {
757757
binding.statusBatteryText.visibility = View.GONE
758758
binding.statusBattery.visibility = View.GONE
759-
updateSectionBaseline(binding.statusBatteryLayout)
760759
binding.statusBatteryLayout.visibility = View.INVISIBLE
761760
return
762761
}
@@ -771,7 +770,6 @@ class HomeFragment :
771770
if (!prefs.showsLumaStatusBarAnywhere() || (!prefs.batteryPercentage && !prefs.batteryIcon)) {
772771
binding.statusBatteryText.visibility = View.GONE
773772
binding.statusBattery.visibility = View.GONE
774-
updateSectionBaseline(binding.statusBatteryLayout)
775773
binding.statusBatteryLayout.visibility = View.INVISIBLE
776774
return
777775
}
@@ -808,7 +806,6 @@ class HomeFragment :
808806
binding.statusBatteryText.visibility = if (prefs.batteryPercentage) View.VISIBLE else View.GONE
809807
binding.statusBatteryText.text = "$pct%"
810808
binding.statusBattery.visibility = if (prefs.batteryIcon) View.VISIBLE else View.GONE
811-
updateSectionBaseline(binding.statusBatteryLayout)
812809
binding.statusBattery.setImageResource(icon)
813810
binding.statusBattery.setColorFilter(binding.statusBatteryText.currentTextColor)
814811
}
@@ -821,7 +818,6 @@ class HomeFragment :
821818
if (prefs.cellularEnabled) startCellularMonitor() else hideCellular()
822819
if (prefs.wifiEnabled) startWifiMonitor() else hideWifi()
823820
if (prefs.bluetoothEnabled) startBluetoothMonitor() else hideBluetooth()
824-
updateSectionBaseline(binding.statusConnectivityLayout)
825821
}
826822

827823
private fun stopConnectivityMonitors() {
@@ -855,7 +851,6 @@ class HomeFragment :
855851
} else {
856852
hideBluetooth()
857853
}
858-
updateSectionBaseline(binding.statusConnectivityLayout)
859854
}
860855

861856
private fun primeCellularState() {
@@ -956,10 +951,6 @@ class HomeFragment :
956951
binding.statusNetworkType.text = label
957952
}
958953

959-
private fun updateSectionBaseline(layout: LinearLayout) {
960-
LumaStatusBarUi.updateSectionBaseline(layout)
961-
}
962-
963954
private fun hideCellular() {
964955
binding.statusSignal.visibility = View.GONE
965956
binding.statusNetworkType.visibility = View.GONE

app/src/main/res/layout/luma_status_bar_content.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
android:layout_width="0dp"
1010
android:layout_height="match_parent"
1111
android:layout_weight="1"
12+
android:baselineAligned="false"
1213
android:gravity="center_vertical"
1314
android:orientation="horizontal"
1415
android:clipToPadding="false"
@@ -58,6 +59,7 @@
5859
android:layout_width="0dp"
5960
android:layout_height="match_parent"
6061
android:layout_weight="1"
62+
android:baselineAligned="false"
6163
android:gravity="center_vertical|end"
6264
android:orientation="horizontal"
6365
android:clipToPadding="false"

0 commit comments

Comments
 (0)