summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Dryomov <artur.dryomov@gmail.com>2013-09-05 11:59:27 +0300
committerArtur Dryomov <artur.dryomov@gmail.com>2013-09-05 19:38:03 +0300
commit3c1c51020c07c748248d0c6e4ae33f3f37ce1390 (patch)
tree32ffc6d6d472cb3cd80dd2eb41b4407900628402
parent36baf31d2baa30c34c05b042283845ed348be888 (diff)
Add the settings screen.
It contains options that can confuse user: * changing transitions using volume keys; * keeping screenon while presenting. Change-Id: I1a9cb9afdf1409fc78e713b899d68ae045db5cb7
-rw-r--r--android/sdremote/AndroidManifest.xml5
-rw-r--r--android/sdremote/res/menu/menu_action_bar_computers.xml5
-rw-r--r--android/sdremote/res/values/strings.xml7
-rw-r--r--android/sdremote/res/xml/preferences.xml14
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/activity/ComputersActivity.java9
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/activity/SettingsActivity.java54
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java63
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java1
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/util/Intents.java5
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/util/Preferences.java28
10 files changed, 185 insertions, 6 deletions
diff --git a/android/sdremote/AndroidManifest.xml b/android/sdremote/AndroidManifest.xml
index 109c1c27d962..7b80b6644d74 100644
--- a/android/sdremote/AndroidManifest.xml
+++ b/android/sdremote/AndroidManifest.xml
@@ -54,6 +54,11 @@
</activity>
<activity
+ android:name=".activity.SettingsActivity"
+ android:label="@string/title_settings">
+ </activity>
+
+ <activity
android:name=".activity.LicensesActivity"
android:label="@string/title_licenses">
</activity>
diff --git a/android/sdremote/res/menu/menu_action_bar_computers.xml b/android/sdremote/res/menu/menu_action_bar_computers.xml
index 7835fa986feb..f99df2122f70 100644
--- a/android/sdremote/res/menu/menu_action_bar_computers.xml
+++ b/android/sdremote/res/menu/menu_action_bar_computers.xml
@@ -8,6 +8,11 @@
android:showAsAction="always"/>
<item
+ android:id="@+id/menu_settings"
+ android:title="@string/title_settings"
+ android:showAsAction="never"/>
+
+ <item
android:id="@+id/menu_licenses"
android:title="@string/menu_licenses"
android:showAsAction="never"/>
diff --git a/android/sdremote/res/values/strings.xml b/android/sdremote/res/values/strings.xml
index 0aaa46fc5106..f810f0ece5d1 100644
--- a/android/sdremote/res/values/strings.xml
+++ b/android/sdremote/res/values/strings.xml
@@ -7,12 +7,14 @@
<string name="title_bluetooth" translatable="false">Bluetooth</string>
<string name="title_wifi" translatable="false">WiFi</string>
<string name="title_licenses">Open source licenses</string>
+ <string name="title_settings">Settings</string>
<string name="title_connection">Connection</string>
<string name="title_creation">Creation</string>
<string name="title_slide_show">Slide Show</string>
<string name="title_timer">Timer</string>
<string name="menu_licenses">Open source licenses</string>
+ <string name="menu_settings">Settings</string>
<string name="menu_reconnect">Reconnect</string>
<string name="menu_add_computer">Add computer</string>
<string name="menu_remove_computer">Remove</string>
@@ -48,4 +50,9 @@
<string name="description_pager_slide">Slide preview</string>
<string name="description_grid_slide">Slide preview</string>
+ <string name="preferences_volume_keys_actions_title">Volume keys actions</string>
+ <string name="preferences_volume_keys_actions_summary">Switch slides and activate animations using volume keys</string>
+ <string name="preferences_keep_screen_on_title">Screen on</string>
+ <string name="preferences_keep_screen_on_summary">Keep screen on while presenting</string>
+
</resources>
diff --git a/android/sdremote/res/xml/preferences.xml b/android/sdremote/res/xml/preferences.xml
new file mode 100644
index 000000000000..87b8450739de
--- /dev/null
+++ b/android/sdremote/res/xml/preferences.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <CheckBoxPreference
+ android:key="volume_keys_actions"
+ android:title="@string/preferences_volume_keys_actions_title"
+ android:summary="@string/preferences_volume_keys_actions_summary"/>
+
+ <CheckBoxPreference
+ android:key="keep_screen_on"
+ android:title="@string/preferences_keep_screen_on_title"
+ android:summary="@string/preferences_keep_screen_on_summary"/>
+
+</PreferenceScreen> \ No newline at end of file
diff --git a/android/sdremote/src/org/libreoffice/impressremote/activity/ComputersActivity.java b/android/sdremote/src/org/libreoffice/impressremote/activity/ComputersActivity.java
index 90003ef26383..da4652a9317a 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/activity/ComputersActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/activity/ComputersActivity.java
@@ -187,6 +187,10 @@ public class ComputersActivity extends SherlockFragmentActivity implements Actio
@Override
public boolean onOptionsItemSelected(MenuItem aMenuItem) {
switch (aMenuItem.getItemId()) {
+ case R.id.menu_settings:
+ callSettingsActivity();
+ return true;
+
case R.id.menu_licenses:
callLicensesActivity();
return true;
@@ -196,6 +200,11 @@ public class ComputersActivity extends SherlockFragmentActivity implements Actio
}
}
+ private void callSettingsActivity() {
+ Intent aIntent = Intents.buildSettingsIntent(this);
+ startActivity(aIntent);
+ }
+
private void callLicensesActivity() {
Intent aIntent = Intents.buildLicensesIntent(this);
startActivity(aIntent);
diff --git a/android/sdremote/src/org/libreoffice/impressremote/activity/SettingsActivity.java b/android/sdremote/src/org/libreoffice/impressremote/activity/SettingsActivity.java
new file mode 100644
index 000000000000..4309e8eccf47
--- /dev/null
+++ b/android/sdremote/src/org/libreoffice/impressremote/activity/SettingsActivity.java
@@ -0,0 +1,54 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+package org.libreoffice.impressremote.activity;
+
+import android.os.Bundle;
+
+import com.actionbarsherlock.app.SherlockPreferenceActivity;
+import com.actionbarsherlock.view.MenuItem;
+import org.libreoffice.impressremote.R;
+
+public class SettingsActivity extends SherlockPreferenceActivity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setUpHomeButton();
+ setUpPreferences();
+ }
+
+ private void setUpHomeButton() {
+ getSupportActionBar().setHomeButtonEnabled(true);
+ }
+
+ private void setUpPreferences() {
+ // This action is deprecated
+ // but we still need to target pre-Honeycomb devices
+
+ addPreferencesFromResource(R.xml.preferences);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem aMenuItem) {
+ switch (aMenuItem.getItemId()) {
+ case android.R.id.home:
+ navigateUp();
+ return true;
+
+ default:
+ return super.onOptionsItemSelected(aMenuItem);
+ }
+ }
+
+ private void navigateUp() {
+ finish();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java b/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java
index 791861cfaab5..18f169135f12 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java
@@ -19,6 +19,7 @@ import android.os.IBinder;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.content.LocalBroadcastManager;
+import android.view.KeyEvent;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity;
@@ -34,6 +35,7 @@ import org.libreoffice.impressremote.fragment.TimerEditingDialog;
import org.libreoffice.impressremote.fragment.TimerSettingDialog;
import org.libreoffice.impressremote.util.FragmentOperator;
import org.libreoffice.impressremote.util.Intents;
+import org.libreoffice.impressremote.util.Preferences;
public class SlideShowActivity extends SherlockFragmentActivity implements ServiceConnection {
private static enum Mode {
@@ -53,6 +55,7 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi
setUpHomeButton();
setUpFragment();
+ setUpKeepingScreenOn();
bindService();
}
@@ -86,6 +89,16 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi
}
}
+ private void setUpKeepingScreenOn() {
+ findViewById(android.R.id.content).setKeepScreenOn(isKeepingScreenOnRequired());
+ }
+
+ private boolean isKeepingScreenOnRequired() {
+ Preferences preferences = Preferences.getSettingsInstance(this);
+
+ return preferences.getBoolean(Preferences.Keys.KEEP_SCREEN_ON);
+ }
+
private void bindService() {
Intent aIntent = Intents.buildCommunicationServiceIntent(this);
bindService(aIntent, this, Context.BIND_AUTO_CREATE);
@@ -237,6 +250,50 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi
}
@Override
+ public boolean onKeyDown(int aKeyCode, KeyEvent aKeyEvent) {
+ if (!areVolumeKeysActionsRequired()) {
+ return super.onKeyDown(aKeyCode, aKeyEvent);
+ }
+
+ switch (aKeyCode) {
+ case KeyEvent.KEYCODE_VOLUME_UP:
+ mCommunicationService.getTransmitter().performNextTransition();
+ return true;
+
+ case KeyEvent.KEYCODE_VOLUME_DOWN:
+ mCommunicationService.getTransmitter().performPreviousTransition();
+ return true;
+
+ default:
+ return super.onKeyDown(aKeyCode, aKeyEvent);
+ }
+ }
+
+ private boolean areVolumeKeysActionsRequired() {
+ Preferences preferences = Preferences.getSettingsInstance(this);
+
+ return preferences.getBoolean(Preferences.Keys.VOLUME_KEYS_ACTIONS);
+ }
+
+ @Override
+ public boolean onKeyUp(int aKeyCode, KeyEvent aKeyEvent) {
+ if (!areVolumeKeysActionsRequired()) {
+ return super.onKeyUp(aKeyCode, aKeyEvent);
+ }
+
+ // Suppress sound of volume changing
+
+ switch (aKeyCode) {
+ case KeyEvent.KEYCODE_VOLUME_UP:
+ case KeyEvent.KEYCODE_VOLUME_DOWN:
+ return true;
+
+ default:
+ return super.onKeyUp(aKeyCode, aKeyEvent);
+ }
+ }
+
+ @Override
public boolean onCreateOptionsMenu(Menu aMenu) {
getSupportMenuInflater().inflate(R.menu.menu_action_bar_slide_show, aMenu);
@@ -318,8 +375,7 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi
if (aTimer.isSet()) {
callEditingTimer(aTimer);
- }
- else {
+ } else {
callSettingTimer();
}
}
@@ -334,8 +390,7 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi
private DialogFragment buildTimerEditingDialog(Timer aTimer) {
if (aTimer.isTimeUp()) {
return TimerEditingDialog.newInstance(aTimer.getMinutesLength());
- }
- else {
+ } else {
return TimerEditingDialog.newInstance(aTimer.getMinutesLeft());
}
}
diff --git a/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java b/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java
index 0c2280102afc..08b5cc214832 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java
@@ -21,6 +21,7 @@ import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.text.Html;
import android.text.TextUtils;
+import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
diff --git a/android/sdremote/src/org/libreoffice/impressremote/util/Intents.java b/android/sdremote/src/org/libreoffice/impressremote/util/Intents.java
index eb85418ea14d..cdcec9ae5c66 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/util/Intents.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/util/Intents.java
@@ -14,6 +14,7 @@ import android.content.Intent;
import org.libreoffice.impressremote.activity.ComputerConnectionActivity;
import org.libreoffice.impressremote.activity.ComputerCreationActivity;
import org.libreoffice.impressremote.activity.LicensesActivity;
+import org.libreoffice.impressremote.activity.SettingsActivity;
import org.libreoffice.impressremote.activity.SlideShowActivity;
import org.libreoffice.impressremote.communication.CommunicationService;
import org.libreoffice.impressremote.communication.Server;
@@ -139,6 +140,10 @@ public final class Intents {
return new Intent(aContext, SlideShowActivity.class);
}
+ public static Intent buildSettingsIntent(Context aContext) {
+ return new Intent(aContext, SettingsActivity.class);
+ }
+
public static Intent buildLicensesIntent(Context aContext) {
return new Intent(aContext, LicensesActivity.class);
}
diff --git a/android/sdremote/src/org/libreoffice/impressremote/util/Preferences.java b/android/sdremote/src/org/libreoffice/impressremote/util/Preferences.java
index 4b22c29e024b..4ad2490f8712 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/util/Preferences.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/util/Preferences.java
@@ -12,6 +12,7 @@ import java.util.Map;
import android.content.Context;
import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
public final class Preferences {
private static final class Locations {
@@ -28,6 +29,17 @@ public final class Preferences {
}
public static final String SELECTED_COMPUTERS_TAB_INDEX = "selected_computers_tab_index";
+ public static final String VOLUME_KEYS_ACTIONS = "volume_keys_actions";
+ public static final String KEEP_SCREEN_ON = "keep_screen_on";
+ }
+
+ private static final class Defaults {
+ private Defaults() {
+ }
+
+ public static final String STRING = null;
+ public static final int INT = 0;
+ public static final boolean BOOLEAN = false;
}
private final SharedPreferences mPreferences;
@@ -52,22 +64,34 @@ public final class Preferences {
return new Preferences(aContext, Locations.APPLICATION_STATES);
}
+ public static Preferences getSettingsInstance(Context context) {
+ return new Preferences(context);
+ }
+
+ private Preferences(Context context) {
+ mPreferences = PreferenceManager.getDefaultSharedPreferences(context);
+ }
+
public Map<String, ?> getAll() {
return mPreferences.getAll();
}
public String getString(String aKey) {
- return mPreferences.getString(aKey, null);
+ return mPreferences.getString(aKey, Defaults.STRING);
}
public int getInt(String aKey) {
- return mPreferences.getInt(aKey, 0);
+ return mPreferences.getInt(aKey, Defaults.INT);
}
public void setString(String aKey, String aValue) {
mPreferences.edit().putString(aKey, aValue).commit();
}
+ public boolean getBoolean(String aKey) {
+ return mPreferences.getBoolean(aKey, Defaults.BOOLEAN);
+ }
+
public void setInt(String aKey, int aValue) {
mPreferences.edit().putInt(aKey, aValue).commit();
}