mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-27 20:09:27 +03:00
Merge pull request #1382 from vector-im/feature/aiplane_mode
Better connectivity lost indicator when airplane mode is on
This commit is contained in:
commit
43b9e2cec9
5 changed files with 29 additions and 5 deletions
|
@ -5,7 +5,7 @@ Features ✨:
|
||||||
-
|
-
|
||||||
|
|
||||||
Improvements 🙌:
|
Improvements 🙌:
|
||||||
-
|
- Better connectivity lost indicator when airplane mode is on
|
||||||
|
|
||||||
Bugfix 🐛:
|
Bugfix 🐛:
|
||||||
-
|
-
|
||||||
|
|
|
@ -53,6 +53,10 @@ fun isIgnoringBatteryOptimizations(context: Context): Boolean {
|
||||||
|| (context.getSystemService(Context.POWER_SERVICE) as PowerManager?)?.isIgnoringBatteryOptimizations(context.packageName) == true
|
|| (context.getSystemService(Context.POWER_SERVICE) as PowerManager?)?.isIgnoringBatteryOptimizations(context.packageName) == true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isAirplaneModeOn(context: Context): Boolean {
|
||||||
|
return Settings.Global.getInt(context.contentResolver, Settings.Global.AIRPLANE_MODE_ON, 0) != 0
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* display the system dialog for granting this permission. If previously granted, the
|
* display the system dialog for granting this permission. If previously granted, the
|
||||||
* system will not show it (so you should call this method).
|
* system will not show it (so you should call this method).
|
||||||
|
|
|
@ -23,6 +23,7 @@ import android.widget.FrameLayout
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import im.vector.matrix.android.api.session.sync.SyncState
|
import im.vector.matrix.android.api.session.sync.SyncState
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
|
import im.vector.riotx.core.utils.isAirplaneModeOn
|
||||||
import kotlinx.android.synthetic.main.view_sync_state.view.*
|
import kotlinx.android.synthetic.main.view_sync_state.view.*
|
||||||
|
|
||||||
class SyncStateView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0)
|
class SyncStateView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0)
|
||||||
|
@ -33,10 +34,15 @@ class SyncStateView @JvmOverloads constructor(context: Context, attrs: Attribute
|
||||||
}
|
}
|
||||||
|
|
||||||
fun render(newState: SyncState) {
|
fun render(newState: SyncState) {
|
||||||
syncStateProgressBar.visibility = when (newState) {
|
syncStateProgressBar.isVisible = newState is SyncState.Running && newState.afterPause
|
||||||
is SyncState.Running -> if (newState.afterPause) View.VISIBLE else View.GONE
|
|
||||||
else -> View.GONE
|
if (newState == SyncState.NoNetwork) {
|
||||||
|
val isAirplaneModeOn = isAirplaneModeOn(context)
|
||||||
|
syncStateNoNetwork.isVisible = isAirplaneModeOn.not()
|
||||||
|
syncStateNoNetworkAirplane.isVisible = isAirplaneModeOn
|
||||||
|
} else {
|
||||||
|
syncStateNoNetwork.isVisible = false
|
||||||
|
syncStateNoNetworkAirplane.isVisible = false
|
||||||
}
|
}
|
||||||
syncStateNoNetwork.isVisible = newState == SyncState.NoNetwork
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,19 @@
|
||||||
android:text="@string/no_connectivity_to_the_server_indicator"
|
android:text="@string/no_connectivity_to_the_server_indicator"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
|
tools:layout_marginTop="10dp"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/syncStateNoNetworkAirplane"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/notification_accent_color"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/no_connectivity_to_the_server_indicator_airplane"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:layout_marginTop="10dp"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</merge>
|
</merge>
|
|
@ -2163,6 +2163,7 @@ Not all features in Riot are implemented in RiotX yet. Main missing (and coming
|
||||||
<string name="qr_code_scanned_by_other_no">No</string>
|
<string name="qr_code_scanned_by_other_no">No</string>
|
||||||
|
|
||||||
<string name="no_connectivity_to_the_server_indicator">Connectivity to the server has been lost</string>
|
<string name="no_connectivity_to_the_server_indicator">Connectivity to the server has been lost</string>
|
||||||
|
<string name="no_connectivity_to_the_server_indicator_airplane">Airplane mode is on</string>
|
||||||
|
|
||||||
<string name="settings_dev_tools">Dev Tools</string>
|
<string name="settings_dev_tools">Dev Tools</string>
|
||||||
<string name="settings_account_data">Account Data</string>
|
<string name="settings_account_data">Account Data</string>
|
||||||
|
|
Loading…
Reference in a new issue