Skip to content
Snippets Groups Projects
Unverified Commit e1afa8a9 authored by mueller-ma's avatar mueller-ma Committed by GitHub
Browse files

Add "Turn off" action to demo mode snackbar (#1258)

parent 1255f284
Branches
No related tags found
No related merge requests found
...@@ -277,7 +277,7 @@ public class MainActivity extends AppCompatActivity implements ...@@ -277,7 +277,7 @@ public class MainActivity extends AppCompatActivity implements
private void handleConnectionChange() { private void handleConnectionChange() {
if (mConnection instanceof DemoConnection) { if (mConnection instanceof DemoConnection) {
showSnackbar(R.string.info_demo_mode_short); showDemoModeHintSnackbar();
} else { } else {
boolean hasLocalAndRemote = boolean hasLocalAndRemote =
ConnectionFactory.getConnection(Connection.TYPE_LOCAL) != null ConnectionFactory.getConnection(Connection.TYPE_LOCAL) != null
...@@ -1033,6 +1033,18 @@ public class MainActivity extends AppCompatActivity implements ...@@ -1033,6 +1033,18 @@ public class MainActivity extends AppCompatActivity implements
mLastSnackbar.show(); mLastSnackbar.show();
} }
public void showDemoModeHintSnackbar() {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
mLastSnackbar = Snackbar.make(findViewById(android.R.id.content),
R.string.info_demo_mode_short, Snackbar.LENGTH_LONG);
mLastSnackbar.setAction(R.string.turn_off, v -> {
prefs.edit()
.putBoolean(Constants.PREFERENCE_DEMOMODE, false)
.apply();
});
mLastSnackbar.show();
}
private void showSnackbar(@StringRes int messageResId) { private void showSnackbar(@StringRes int messageResId) {
mLastSnackbar = Snackbar.make(findViewById(android.R.id.content), mLastSnackbar = Snackbar.make(findViewById(android.R.id.content),
messageResId, Snackbar.LENGTH_LONG); messageResId, Snackbar.LENGTH_LONG);
......
...@@ -79,6 +79,8 @@ ...@@ -79,6 +79,8 @@
<string name="info_voice_input">openHAB, at your command!</string> <string name="info_voice_input">openHAB, at your command!</string>
<string name="info_voice_recognized_text">Recognized command: %1$s</string> <string name="info_voice_recognized_text">Recognized command: %1$s</string>
<string name="info_demo_mode_short">Running in demo mode</string> <string name="info_demo_mode_short">Running in demo mode</string>
<!-- Please try to keep the string as short as possible -->
<string name="turn_off">Turn off</string>
<string name="info_conn_url">Connecting to local URL</string> <string name="info_conn_url">Connecting to local URL</string>
<string name="info_conn_rem_url">Connecting to remote URL</string> <string name="info_conn_rem_url">Connecting to remote URL</string>
<string name="app_shortcut_diabled_habpanel">Your server doesn\'t have HABPanel installed</string> <string name="app_shortcut_diabled_habpanel">Your server doesn\'t have HABPanel installed</string>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment