Merge pull request #1524 from akallabeth/android_debug_settings

Add debug settings menu for android

Menu needs to be activated with cmake with -DWITH_ANDROID_DEBUG_MENU=ON
This commit is contained in:
Bernhard Miklautz 2013-10-03 05:36:42 -07:00
commit 5c61ac97cb
12 changed files with 874 additions and 642 deletions

View File

@ -28,6 +28,14 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/project.properties.cmake
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/ant.properties.cmake CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/ant.properties.cmake
${CMAKE_CURRENT_BINARY_DIR}/ant.properties @ONLY) ${CMAKE_CURRENT_BINARY_DIR}/ant.properties @ONLY)
# Generate a Java class with static members set to the CMake
# configuration properties.
set(JAVA_CFG "src/com/freerdp/freerdpcore/utils/BuildConfiguration.java")
set(JAVA_CFG_OUT "${CMAKE_CURRENT_BINARY_DIR}/${JAVA_CFG}")
set(JAVA_CFG_IN "${CMAKE_CURRENT_SOURCE_DIR}/${JAVA_CFG}.in")
CONFIGURE_FILE(${JAVA_CFG_IN} ${JAVA_CFG_OUT})
file(COPY res DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY res DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
if (ANDROID_SDK) if (ANDROID_SDK)

View File

@ -22,6 +22,7 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<ImageView android:id="@+id/bookmark_icon1" <ImageView android:id="@+id/bookmark_icon1"
android:contentDescription="@+id/bookmark_icon1"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
@ -46,6 +47,7 @@
/> />
<ImageView android:id="@+id/bookmark_icon2" <ImageView android:id="@+id/bookmark_icon2"
android:contentDescription="@+id/bookmark_icon2"
android:layout_marginTop="9dip" android:layout_marginTop="9dip"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@ -23,6 +23,7 @@
<ImageView <ImageView
android:id="@+id/session_screenshot" android:id="@+id/session_screenshot"
android:contentDescription="@+id/session_screenshot"
android:layout_width="64dp" android:layout_width="64dp"
android:layout_height="48dp" android:layout_height="48dp"
android:scaleType="fitXY" android:scaleType="fitXY"
@ -51,6 +52,7 @@
<ImageButton <ImageButton
android:id="@+id/session_disconnect" android:id="@+id/session_disconnect"
android:contentDescription="@+id/session_disconnect"
android:focusable="false" android:focusable="false"
android:focusableInTouchMode="false" android:focusableInTouchMode="false"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -32,8 +32,8 @@
<!-- List placeholder labels --> <!-- List placeholder labels -->
<string name="list_placeholder_login">Login</string> <string name="list_placeholder_login">Login</string>
<string name="list_placeholder_no_servers">No Servers</string> <string name="list_placeholder_no_servers">No Servers</string>
<string name="list_placeholder_connecting">Connecting ...</string> <string name="list_placeholder_connecting">Connecting &#8230;</string>
<string name="list_placeholder_disconnecting">Disconnecting ...</string> <string name="list_placeholder_disconnecting">Disconnecting &#8230;</string>
<string name="list_placeholder_connection_error">Connection Lost</string> <string name="list_placeholder_connection_error">Connection Lost</string>
<string name="list_placeholder_wrong_password">Wrong Password</string> <string name="list_placeholder_wrong_password">Wrong Password</string>
<string name="list_placeholder_invalid_username">Invalid Username</string> <string name="list_placeholder_invalid_username">Invalid Username</string>
@ -178,8 +178,8 @@
<string name="dlg_title_credentials">Please enter your credentials</string> <string name="dlg_title_credentials">Please enter your credentials</string>
<string name="dlg_title_create_shortcut">Create Shortcut</string> <string name="dlg_title_create_shortcut">Create Shortcut</string>
<string name="dlg_msg_create_shortcut">Shortcut name:</string> <string name="dlg_msg_create_shortcut">Shortcut name:</string>
<string name="dlg_msg_connecting">Connecting ...</string> <string name="dlg_msg_connecting">Connecting &#8230;</string>
<string name="dlg_msg_logging_in">Logging in ...</string> <string name="dlg_msg_logging_in">Logging in &#8230;</string>
<string name="dlg_title_about">About aFreeRDP</string> <string name="dlg_title_about">About aFreeRDP</string>
<string name="dlg_msg_about">Version: %1$s\n\u00A9 2012 Thinstuff Technologies GmbH</string> <string name="dlg_msg_about">Version: %1$s\n\u00A9 2012 Thinstuff Technologies GmbH</string>
<string name="dlg_title_create_bookmark_after_qc">Save Connection Settings?</string> <string name="dlg_title_create_bookmark_after_qc">Save Connection Settings?</string>
@ -191,4 +191,6 @@
<string name="dlg_msg_exit">Are you sure you want to exit the application?</string> <string name="dlg_msg_exit">Are you sure you want to exit the application?</string>
<string name="dlg_title_clear_cert_cache">Delete Certificates?</string> <string name="dlg_title_clear_cert_cache">Delete Certificates?</string>
<string name="dlg_msg_clear_cert_cache">Are you sure you want to delete all your cached Certificates?</string> <string name="dlg_msg_clear_cert_cache">Are you sure you want to delete all your cached Certificates?</string>
<string name="debug_level">Debug Level</string>
<string name="settings_debug">Debug Settings</string>
</resources> </resources>

View File

@ -26,7 +26,9 @@
</PreferenceScreen> </PreferenceScreen>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/settings_cat_settings"> <PreferenceCategory
android:key="category.settings"
android:title="@string/settings_cat_settings">
<PreferenceScreen android:key="bookmark.screen" android:title="@string/settings_screen"> <PreferenceScreen android:key="bookmark.screen" android:title="@string/settings_screen">
<intent android:action="android.intent.action.VIEW" <intent android:action="android.intent.action.VIEW"
@ -49,6 +51,13 @@
android:data="preferences://advanced_settings" /> android:data="preferences://advanced_settings" />
</PreferenceScreen> </PreferenceScreen>
</PreferenceCategory> <PreferenceScreen android:key="bookmark.debug" android:title="@string/settings_debug">
<intent android:action="android.intent.action.VIEW"
android:targetPackage="*"
android:targetClass="com.freerdp.freerdpcore.presentation.BookmarkActivity"
android:data="preferences://debug_settings" />
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
Debug Settings Layout
Copyright 2013 Thinstuff Technologies GmbH
Copyright 2013 Armin Novak <anovak@thinstuff.at>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:freerdp="http://schemas.android.com/apk/res-auto">
<PreferenceCategory android:title="@string/settings_debug">
<com.freerdp.freerdpcore.utils.IntEditTextPreference
android:key="bookmark.debug_level"
android:title="@string/debug_level"
android:summary="Debug level, 0 to disable."
android:numeric="integer"
android:inputType="number"
freerdp:bounds_min="0"
freerdp:bounds_max="10"
freerdp:bounds_default="0" />
</PreferenceCategory>
</PreferenceScreen>

View File

@ -5,18 +5,19 @@
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. 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/. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
package com.freerdp.freerdpcore.domain; package com.freerdp.freerdpcore.domain;
import java.util.Locale;
import com.freerdp.freerdpcore.application.GlobalApp; import com.freerdp.freerdpcore.application.GlobalApp;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
public class BookmarkBase implements Parcelable, Cloneable public class BookmarkBase implements Parcelable, Cloneable {
{
public static final int TYPE_INVALID = -1; public static final int TYPE_INVALID = -1;
public static final int TYPE_MANUAL = 1; public static final int TYPE_MANUAL = 1;
public static final int TYPE_QUICKCONNECT = 2; public static final int TYPE_QUICKCONNECT = 2;
@ -24,8 +25,7 @@ public class BookmarkBase implements Parcelable, Cloneable
public static final int TYPE_CUSTOM_BASE = 1000; public static final int TYPE_CUSTOM_BASE = 1000;
// performance flags // performance flags
public static class PerformanceFlags implements Parcelable public static class PerformanceFlags implements Parcelable {
{
private boolean remotefx; private boolean remotefx;
private boolean wallpaper; private boolean wallpaper;
private boolean theming; private boolean theming;
@ -110,8 +110,7 @@ public class BookmarkBase implements Parcelable, Cloneable
this.desktopComposition = desktopComposition; this.desktopComposition = desktopComposition;
} }
public static final Parcelable.Creator<PerformanceFlags> CREATOR = new Parcelable.Creator<PerformanceFlags>() public static final Parcelable.Creator<PerformanceFlags> CREATOR = new Parcelable.Creator<PerformanceFlags>() {
{
public PerformanceFlags createFromParcel(Parcel in) { public PerformanceFlags createFromParcel(Parcel in) {
return new PerformanceFlags(in); return new PerformanceFlags(in);
} }
@ -128,8 +127,7 @@ public class BookmarkBase implements Parcelable, Cloneable
} }
@Override @Override
public void writeToParcel(Parcel out, int flags) public void writeToParcel(Parcel out, int flags) {
{
out.writeInt(remotefx ? 1 : 0); out.writeInt(remotefx ? 1 : 0);
out.writeInt(wallpaper ? 1 : 0); out.writeInt(wallpaper ? 1 : 0);
out.writeInt(theming ? 1 : 0); out.writeInt(theming ? 1 : 0);
@ -141,8 +139,7 @@ public class BookmarkBase implements Parcelable, Cloneable
} }
// Screen Settings class // Screen Settings class
public static class ScreenSettings implements Parcelable public static class ScreenSettings implements Parcelable {
{
public static final int FITSCREEN = -2; public static final int FITSCREEN = -2;
public static final int AUTOMATIC = -1; public static final int AUTOMATIC = -1;
public static final int CUSTOM = 0; public static final int CUSTOM = 0;
@ -171,8 +168,7 @@ public class BookmarkBase implements Parcelable, Cloneable
height = 0; height = 0;
} }
public void setResolution(int resolution) public void setResolution(int resolution) {
{
this.resolution = resolution; this.resolution = resolution;
if (resolution == AUTOMATIC || resolution == FITSCREEN) { if (resolution == AUTOMATIC || resolution == FITSCREEN) {
@ -181,43 +177,35 @@ public class BookmarkBase implements Parcelable, Cloneable
} }
} }
public void setResolution(String resolution, int width, int height) public void setResolution(String resolution, int width, int height) {
{
if (resolution.contains("x")) { if (resolution.contains("x")) {
String[] dimensions = resolution.split("x"); String[] dimensions = resolution.split("x");
this.width = Integer.valueOf(dimensions[0]); this.width = Integer.valueOf(dimensions[0]);
this.height = Integer.valueOf(dimensions[1]); this.height = Integer.valueOf(dimensions[1]);
this.resolution = PREDEFINED; this.resolution = PREDEFINED;
} } else if (resolution.equalsIgnoreCase("custom")) {
else if (resolution.equalsIgnoreCase("custom"))
{
this.width = width; this.width = width;
this.height = height; this.height = height;
this.resolution = CUSTOM; this.resolution = CUSTOM;
} } else if (resolution.equalsIgnoreCase("fitscreen")) {
else if (resolution.equalsIgnoreCase("fitscreen"))
{
this.width = this.height = 0; this.width = this.height = 0;
this.resolution = FITSCREEN; this.resolution = FITSCREEN;
} } else {
else
{
this.width = this.height = 0; this.width = this.height = 0;
this.resolution = AUTOMATIC; this.resolution = AUTOMATIC;
} }
} }
public int getResolution() public int getResolution() {
{
return resolution; return resolution;
} }
public String getResolutionString() public String getResolutionString() {
{
if (isPredefined()) if (isPredefined())
return (width + "x" + height); return (width + "x" + height);
return (isFitScreen() ? "fitscreen" : isAutomatic() ? "automatic" : "custom"); return (isFitScreen() ? "fitscreen" : isAutomatic() ? "automatic"
: "custom");
} }
public boolean isPredefined() { public boolean isPredefined() {
@ -260,8 +248,7 @@ public class BookmarkBase implements Parcelable, Cloneable
return colors; return colors;
} }
public static final Parcelable.Creator<ScreenSettings> CREATOR = new Parcelable.Creator<ScreenSettings>() public static final Parcelable.Creator<ScreenSettings> CREATOR = new Parcelable.Creator<ScreenSettings>() {
{
public ScreenSettings createFromParcel(Parcel in) { public ScreenSettings createFromParcel(Parcel in) {
return new ScreenSettings(in); return new ScreenSettings(in);
} }
@ -278,8 +265,7 @@ public class BookmarkBase implements Parcelable, Cloneable
} }
@Override @Override
public void writeToParcel(Parcel out, int flags) public void writeToParcel(Parcel out, int flags) {
{
out.writeInt(resolution); out.writeInt(resolution);
out.writeInt(colors); out.writeInt(colors);
out.writeInt(width); out.writeInt(width);
@ -287,10 +273,53 @@ public class BookmarkBase implements Parcelable, Cloneable
} }
} }
public static class DebugSettings implements Parcelable {
private int debug;
public DebugSettings() {
init();
}
public DebugSettings(Parcel parcel) {
debug = parcel.readInt();
}
private void init() {
debug = 0;
}
public int getDebugLevel() {
return debug;
}
public void setDebugLevel(int debug) {
this.debug = debug;
}
public static final Parcelable.Creator<DebugSettings> CREATOR = new Parcelable.Creator<DebugSettings>() {
public DebugSettings createFromParcel(Parcel in) {
return new DebugSettings(in);
}
@Override
public DebugSettings[] newArray(int size) {
return new DebugSettings[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeInt(debug);
}
}
// Session Settings // Session Settings
public static class AdvancedSettings implements Parcelable public static class AdvancedSettings implements Parcelable {
{
private boolean enable3GSettings; private boolean enable3GSettings;
private ScreenSettings screen3G; private ScreenSettings screen3G;
private PerformanceFlags performance3G; private PerformanceFlags performance3G;
@ -308,8 +337,10 @@ public class BookmarkBase implements Parcelable, Cloneable
public AdvancedSettings(Parcel parcel) { public AdvancedSettings(Parcel parcel) {
enable3GSettings = (parcel.readInt() == 1) ? true : false; enable3GSettings = (parcel.readInt() == 1) ? true : false;
screen3G = parcel.readParcelable(ScreenSettings.class.getClassLoader()); screen3G = parcel.readParcelable(ScreenSettings.class
performance3G = parcel.readParcelable(PerformanceFlags.class.getClassLoader()); .getClassLoader());
performance3G = parcel.readParcelable(PerformanceFlags.class
.getClassLoader());
redirectSDCard = (parcel.readInt() == 1) ? true : false; redirectSDCard = (parcel.readInt() == 1) ? true : false;
redirectSound = parcel.readInt(); redirectSound = parcel.readInt();
redirectMicrophone = (parcel.readInt() == 1) ? true : false; redirectMicrophone = (parcel.readInt() == 1) ? true : false;
@ -396,28 +427,23 @@ public class BookmarkBase implements Parcelable, Cloneable
return consoleMode; return consoleMode;
} }
public void setRemoteProgram(String remoteProgram) public void setRemoteProgram(String remoteProgram) {
{
this.remoteProgram = remoteProgram; this.remoteProgram = remoteProgram;
} }
public String getRemoteProgram() public String getRemoteProgram() {
{
return remoteProgram; return remoteProgram;
} }
public void setWorkDir(String workDir) public void setWorkDir(String workDir) {
{
this.workDir = workDir; this.workDir = workDir;
} }
public String getWorkDir() public String getWorkDir() {
{
return workDir; return workDir;
} }
public static final Parcelable.Creator<AdvancedSettings> CREATOR = new Parcelable.Creator<AdvancedSettings>() public static final Parcelable.Creator<AdvancedSettings> CREATOR = new Parcelable.Creator<AdvancedSettings>() {
{
public AdvancedSettings createFromParcel(Parcel in) { public AdvancedSettings createFromParcel(Parcel in) {
return new AdvancedSettings(in); return new AdvancedSettings(in);
} }
@ -434,8 +460,7 @@ public class BookmarkBase implements Parcelable, Cloneable
} }
@Override @Override
public void writeToParcel(Parcel out, int flags) public void writeToParcel(Parcel out, int flags) {
{
out.writeInt(enable3GSettings ? 1 : 0); out.writeInt(enable3GSettings ? 1 : 0);
out.writeParcelable(screen3G, flags); out.writeParcelable(screen3G, flags);
out.writeParcelable(performance3G, flags); out.writeParcelable(performance3G, flags);
@ -449,8 +474,8 @@ public class BookmarkBase implements Parcelable, Cloneable
} }
} }
protected int type; protected int type;
private long id; private long id;
private String label; private String label;
private String username; private String username;
private String password; private String password;
@ -459,23 +484,23 @@ public class BookmarkBase implements Parcelable, Cloneable
private ScreenSettings screenSettings; private ScreenSettings screenSettings;
private PerformanceFlags performanceFlags; private PerformanceFlags performanceFlags;
private AdvancedSettings advancedSettings; private AdvancedSettings advancedSettings;
private DebugSettings debugSettings;
private void init() private void init() {
{
type = TYPE_INVALID; type = TYPE_INVALID;
id = -1; id = -1;
label = ""; label = "";
username = ""; username = "";
password = ""; password = "";
domain = ""; domain = "";
screenSettings = new ScreenSettings(); screenSettings = new ScreenSettings();
performanceFlags = new PerformanceFlags(); performanceFlags = new PerformanceFlags();
advancedSettings = new AdvancedSettings(); advancedSettings = new AdvancedSettings();
debugSettings = new DebugSettings();
} }
public BookmarkBase(Parcel parcel) public BookmarkBase(Parcel parcel) {
{
type = parcel.readInt(); type = parcel.readInt();
id = parcel.readLong(); id = parcel.readLong();
label = parcel.readString(); label = parcel.readString();
@ -483,9 +508,14 @@ public class BookmarkBase implements Parcelable, Cloneable
password = parcel.readString(); password = parcel.readString();
domain = parcel.readString(); domain = parcel.readString();
screenSettings = parcel.readParcelable(ScreenSettings.class.getClassLoader()); screenSettings = parcel.readParcelable(ScreenSettings.class
performanceFlags = parcel.readParcelable(PerformanceFlags.class.getClassLoader()); .getClassLoader());
advancedSettings = parcel.readParcelable(AdvancedSettings.class.getClassLoader()); performanceFlags = parcel.readParcelable(PerformanceFlags.class
.getClassLoader());
advancedSettings = parcel.readParcelable(AdvancedSettings.class
.getClassLoader());
debugSettings = parcel.readParcelable(DebugSettings.class
.getClassLoader());
} }
public BookmarkBase() { public BookmarkBase() {
@ -493,7 +523,9 @@ public class BookmarkBase implements Parcelable, Cloneable
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends BookmarkBase> T get() { return (T)this; } public <T extends BookmarkBase> T get() {
return (T) this;
}
public int getType() { public int getType() {
return type; return type;
@ -563,18 +595,27 @@ public class BookmarkBase implements Parcelable, Cloneable
return advancedSettings; return advancedSettings;
} }
public ScreenSettings getActiveScreenSettings() public void setDebugSettings(DebugSettings debugSettings) {
{ this.debugSettings = debugSettings;
return (GlobalApp.ConnectedTo3G && advancedSettings.getEnable3GSettings()) ? advancedSettings.getScreen3G() : screenSettings;
} }
public PerformanceFlags getActivePerformanceFlags() public DebugSettings getDebugSettings() {
{ return debugSettings;
return (GlobalApp.ConnectedTo3G && advancedSettings.getEnable3GSettings()) ? advancedSettings.getPerformance3G() : performanceFlags;
} }
public static final Parcelable.Creator<BookmarkBase> CREATOR = new Parcelable.Creator<BookmarkBase>() public ScreenSettings getActiveScreenSettings() {
{ return (GlobalApp.ConnectedTo3G && advancedSettings
.getEnable3GSettings()) ? advancedSettings.getScreen3G()
: screenSettings;
}
public PerformanceFlags getActivePerformanceFlags() {
return (GlobalApp.ConnectedTo3G && advancedSettings
.getEnable3GSettings()) ? advancedSettings.getPerformance3G()
: performanceFlags;
}
public static final Parcelable.Creator<BookmarkBase> CREATOR = new Parcelable.Creator<BookmarkBase>() {
public BookmarkBase createFromParcel(Parcel in) { public BookmarkBase createFromParcel(Parcel in) {
return new BookmarkBase(in); return new BookmarkBase(in);
} }
@ -591,8 +632,7 @@ public class BookmarkBase implements Parcelable, Cloneable
} }
@Override @Override
public void writeToParcel(Parcel out, int flags) public void writeToParcel(Parcel out, int flags) {
{
out.writeInt(type); out.writeInt(type);
out.writeLong(id); out.writeLong(id);
out.writeString(label); out.writeString(label);
@ -603,11 +643,14 @@ public class BookmarkBase implements Parcelable, Cloneable
out.writeParcelable(screenSettings, flags); out.writeParcelable(screenSettings, flags);
out.writeParcelable(performanceFlags, flags); out.writeParcelable(performanceFlags, flags);
out.writeParcelable(advancedSettings, flags); out.writeParcelable(advancedSettings, flags);
out.writeParcelable(debugSettings, flags);
} }
// write to shared preferences // write to shared preferences
public void writeToSharedPreferences(SharedPreferences sharedPrefs) public void writeToSharedPreferences(SharedPreferences sharedPrefs) {
{
Locale locale = Locale.ENGLISH;
SharedPreferences.Editor editor = sharedPrefs.edit(); SharedPreferences.Editor editor = sharedPrefs.edit();
editor.clear(); editor.clear();
editor.putString("bookmark.label", label); editor.putString("bookmark.label", label);
@ -616,95 +659,151 @@ public class BookmarkBase implements Parcelable, Cloneable
editor.putString("bookmark.domain", domain); editor.putString("bookmark.domain", domain);
editor.putInt("bookmark.colors", screenSettings.getColors()); editor.putInt("bookmark.colors", screenSettings.getColors());
editor.putString("bookmark.resolution", screenSettings.getResolutionString().toLowerCase()); editor.putString("bookmark.resolution", screenSettings
.getResolutionString().toLowerCase(locale));
editor.putInt("bookmark.width", screenSettings.getWidth()); editor.putInt("bookmark.width", screenSettings.getWidth());
editor.putInt("bookmark.height", screenSettings.getHeight()); editor.putInt("bookmark.height", screenSettings.getHeight());
editor.putBoolean("bookmark.perf_remotefx", performanceFlags.getRemoteFX()); editor.putBoolean("bookmark.perf_remotefx",
editor.putBoolean("bookmark.perf_wallpaper", performanceFlags.getWallpaper()); performanceFlags.getRemoteFX());
editor.putBoolean("bookmark.perf_font_smoothing", performanceFlags.getFontSmoothing()); editor.putBoolean("bookmark.perf_wallpaper",
editor.putBoolean("bookmark.perf_desktop_composition", performanceFlags.getDesktopComposition()); performanceFlags.getWallpaper());
editor.putBoolean("bookmark.perf_window_dragging", performanceFlags.getFullWindowDrag()); editor.putBoolean("bookmark.perf_font_smoothing",
editor.putBoolean("bookmark.perf_menu_animation", performanceFlags.getMenuAnimations()); performanceFlags.getFontSmoothing());
editor.putBoolean("bookmark.perf_desktop_composition",
performanceFlags.getDesktopComposition());
editor.putBoolean("bookmark.perf_window_dragging",
performanceFlags.getFullWindowDrag());
editor.putBoolean("bookmark.perf_menu_animation",
performanceFlags.getMenuAnimations());
editor.putBoolean("bookmark.perf_themes", performanceFlags.getTheming()); editor.putBoolean("bookmark.perf_themes", performanceFlags.getTheming());
editor.putBoolean("bookmark.enable_3g_settings", advancedSettings.getEnable3GSettings()); editor.putBoolean("bookmark.enable_3g_settings",
advancedSettings.getEnable3GSettings());
editor.putInt("bookmark.colors_3g", advancedSettings.getScreen3G().getColors()); editor.putInt("bookmark.colors_3g", advancedSettings.getScreen3G()
editor.putString("bookmark.resolution_3g", advancedSettings.getScreen3G().getResolutionString().toLowerCase()); .getColors());
editor.putInt("bookmark.width_3g", advancedSettings.getScreen3G().getWidth()); editor.putString("bookmark.resolution_3g", advancedSettings
editor.putInt("bookmark.height_3g", advancedSettings.getScreen3G().getHeight()); .getScreen3G().getResolutionString().toLowerCase(locale));
editor.putInt("bookmark.width_3g", advancedSettings.getScreen3G()
.getWidth());
editor.putInt("bookmark.height_3g", advancedSettings.getScreen3G()
.getHeight());
editor.putBoolean("bookmark.perf_remotefx_3g", advancedSettings.getPerformance3G().getRemoteFX()); editor.putBoolean("bookmark.perf_remotefx_3g", advancedSettings
editor.putBoolean("bookmark.perf_wallpaper_3g", advancedSettings.getPerformance3G().getWallpaper()); .getPerformance3G().getRemoteFX());
editor.putBoolean("bookmark.perf_font_smoothing_3g", advancedSettings.getPerformance3G().getFontSmoothing()); editor.putBoolean("bookmark.perf_wallpaper_3g", advancedSettings
editor.putBoolean("bookmark.perf_desktop_composition_3g", advancedSettings.getPerformance3G().getDesktopComposition()); .getPerformance3G().getWallpaper());
editor.putBoolean("bookmark.perf_window_dragging_3g", advancedSettings.getPerformance3G().getFullWindowDrag()); editor.putBoolean("bookmark.perf_font_smoothing_3g", advancedSettings
editor.putBoolean("bookmark.perf_menu_animation_3g", advancedSettings.getPerformance3G().getMenuAnimations()); .getPerformance3G().getFontSmoothing());
editor.putBoolean("bookmark.perf_themes_3g", advancedSettings.getPerformance3G().getTheming()); editor.putBoolean("bookmark.perf_desktop_composition_3g",
advancedSettings.getPerformance3G().getDesktopComposition());
editor.putBoolean("bookmark.perf_window_dragging_3g", advancedSettings
.getPerformance3G().getFullWindowDrag());
editor.putBoolean("bookmark.perf_menu_animation_3g", advancedSettings
.getPerformance3G().getMenuAnimations());
editor.putBoolean("bookmark.perf_themes_3g", advancedSettings
.getPerformance3G().getTheming());
editor.putBoolean("bookmark.redirect_sdcard", advancedSettings.getRedirectSDCard()); editor.putBoolean("bookmark.redirect_sdcard",
editor.putInt("bookmark.redirect_sound", advancedSettings.getRedirectSound()); advancedSettings.getRedirectSDCard());
editor.putBoolean("bookmark.redirect_microphone", advancedSettings.getRedirectMicrophone()); editor.putInt("bookmark.redirect_sound",
advancedSettings.getRedirectSound());
editor.putBoolean("bookmark.redirect_microphone",
advancedSettings.getRedirectMicrophone());
editor.putInt("bookmark.security", advancedSettings.getSecurity()); editor.putInt("bookmark.security", advancedSettings.getSecurity());
editor.putString("bookmark.remote_program", advancedSettings.getRemoteProgram()); editor.putString("bookmark.remote_program",
advancedSettings.getRemoteProgram());
editor.putString("bookmark.work_dir", advancedSettings.getWorkDir()); editor.putString("bookmark.work_dir", advancedSettings.getWorkDir());
editor.putBoolean("bookmark.console_mode", advancedSettings.getConsoleMode()); editor.putBoolean("bookmark.console_mode",
advancedSettings.getConsoleMode());
editor.putInt("bookmark.debug_level",
debugSettings.getDebugLevel());
editor.commit(); editor.commit();
} }
// read from shared preferences // read from shared preferences
public void readFromSharedPreferences(SharedPreferences sharedPrefs) public void readFromSharedPreferences(SharedPreferences sharedPrefs) {
{
label = sharedPrefs.getString("bookmark.label", ""); label = sharedPrefs.getString("bookmark.label", "");
username = sharedPrefs.getString("bookmark.username", ""); username = sharedPrefs.getString("bookmark.username", "");
password = sharedPrefs.getString("bookmark.password", ""); password = sharedPrefs.getString("bookmark.password", "");
domain = sharedPrefs.getString("bookmark.domain", ""); domain = sharedPrefs.getString("bookmark.domain", "");
screenSettings.setColors(sharedPrefs.getInt("bookmark.colors", 16)); screenSettings.setColors(sharedPrefs.getInt("bookmark.colors", 16));
screenSettings.setResolution(sharedPrefs.getString("bookmark.resolution", "automatic"), sharedPrefs.getInt("bookmark.width", 800), sharedPrefs.getInt("bookmark.height", 600)); screenSettings.setResolution(
sharedPrefs.getString("bookmark.resolution", "automatic"),
sharedPrefs.getInt("bookmark.width", 800),
sharedPrefs.getInt("bookmark.height", 600));
performanceFlags.setRemoteFX(sharedPrefs.getBoolean("bookmark.perf_remotefx", false)); performanceFlags.setRemoteFX(sharedPrefs.getBoolean(
performanceFlags.setWallpaper(sharedPrefs.getBoolean("bookmark.perf_wallpaper", false)); "bookmark.perf_remotefx", false));
performanceFlags.setFontSmoothing(sharedPrefs.getBoolean("bookmark.perf_font_smoothing", false)); performanceFlags.setWallpaper(sharedPrefs.getBoolean(
performanceFlags.setDesktopComposition(sharedPrefs.getBoolean("bookmark.perf_desktop_composition", false)); "bookmark.perf_wallpaper", false));
performanceFlags.setFullWindowDrag(sharedPrefs.getBoolean("bookmark.perf_window_dragging", false)); performanceFlags.setFontSmoothing(sharedPrefs.getBoolean(
performanceFlags.setMenuAnimations(sharedPrefs.getBoolean("bookmark.perf_menu_animation", false)); "bookmark.perf_font_smoothing", false));
performanceFlags.setTheming(sharedPrefs.getBoolean("bookmark.perf_themes", false)); performanceFlags.setDesktopComposition(sharedPrefs.getBoolean(
"bookmark.perf_desktop_composition", false));
performanceFlags.setFullWindowDrag(sharedPrefs.getBoolean(
"bookmark.perf_window_dragging", false));
performanceFlags.setMenuAnimations(sharedPrefs.getBoolean(
"bookmark.perf_menu_animation", false));
performanceFlags.setTheming(sharedPrefs.getBoolean(
"bookmark.perf_themes", false));
advancedSettings.setEnable3GSettings(sharedPrefs.getBoolean("bookmark.enable_3g_settings", false)); advancedSettings.setEnable3GSettings(sharedPrefs.getBoolean(
"bookmark.enable_3g_settings", false));
advancedSettings.getScreen3G().setColors(sharedPrefs.getInt("bookmark.colors_3g", 16)); advancedSettings.getScreen3G().setColors(
advancedSettings.getScreen3G().setResolution(sharedPrefs.getString("bookmark.resolution_3g", "automatic"), sharedPrefs.getInt("bookmark.colors_3g", 16));
sharedPrefs.getInt("bookmark.width_3g", 800), sharedPrefs.getInt("bookmark.height_3g", 600)); advancedSettings.getScreen3G().setResolution(
sharedPrefs.getString("bookmark.resolution_3g", "automatic"),
sharedPrefs.getInt("bookmark.width_3g", 800),
sharedPrefs.getInt("bookmark.height_3g", 600));
advancedSettings.getPerformance3G().setRemoteFX(sharedPrefs.getBoolean("bookmark.perf_remotefx_3g", false)); advancedSettings.getPerformance3G().setRemoteFX(
advancedSettings.getPerformance3G().setWallpaper(sharedPrefs.getBoolean("bookmark.perf_wallpaper_3g", false)); sharedPrefs.getBoolean("bookmark.perf_remotefx_3g", false));
advancedSettings.getPerformance3G().setFontSmoothing(sharedPrefs.getBoolean("bookmark.perf_font_smoothing_3g", false)); advancedSettings.getPerformance3G().setWallpaper(
advancedSettings.getPerformance3G().setDesktopComposition(sharedPrefs.getBoolean("bookmark.perf_desktop_composition_3g", false)); sharedPrefs.getBoolean("bookmark.perf_wallpaper_3g", false));
advancedSettings.getPerformance3G().setFullWindowDrag(sharedPrefs.getBoolean("bookmark.perf_window_dragging_3g", false)); advancedSettings.getPerformance3G().setFontSmoothing(
advancedSettings.getPerformance3G().setMenuAnimations(sharedPrefs.getBoolean("bookmark.perf_menu_animation_3g", false)); sharedPrefs
advancedSettings.getPerformance3G().setTheming(sharedPrefs.getBoolean("bookmark.perf_themes_3g", false)); .getBoolean("bookmark.perf_font_smoothing_3g", false));
advancedSettings.getPerformance3G().setDesktopComposition(
sharedPrefs.getBoolean("bookmark.perf_desktop_composition_3g",
false));
advancedSettings.getPerformance3G().setFullWindowDrag(
sharedPrefs.getBoolean("bookmark.perf_window_dragging_3g",
false));
advancedSettings.getPerformance3G().setMenuAnimations(
sharedPrefs
.getBoolean("bookmark.perf_menu_animation_3g", false));
advancedSettings.getPerformance3G().setTheming(
sharedPrefs.getBoolean("bookmark.perf_themes_3g", false));
advancedSettings.setRedirectSDCard(sharedPrefs.getBoolean("bookmark.redirect_sdcard", false)); advancedSettings.setRedirectSDCard(sharedPrefs.getBoolean(
advancedSettings.setRedirectSound(sharedPrefs.getInt("bookmark.redirect_sound", 0)); "bookmark.redirect_sdcard", false));
advancedSettings.setRedirectMicrophone(sharedPrefs.getBoolean("bookmark.redirect_microphone", false)); advancedSettings.setRedirectSound(sharedPrefs.getInt(
advancedSettings.setSecurity(sharedPrefs.getInt("bookmark.security", 0)); "bookmark.redirect_sound", 0));
advancedSettings.setRemoteProgram(sharedPrefs.getString("bookmark.remote_program", "")); advancedSettings.setRedirectMicrophone(sharedPrefs.getBoolean(
advancedSettings.setWorkDir(sharedPrefs.getString("bookmark.work_dir", "")); "bookmark.redirect_microphone", false));
advancedSettings.setConsoleMode(sharedPrefs.getBoolean("bookmark.console_mode", false)); advancedSettings
.setSecurity(sharedPrefs.getInt("bookmark.security", 0));
advancedSettings.setRemoteProgram(sharedPrefs.getString(
"bookmark.remote_program", ""));
advancedSettings.setWorkDir(sharedPrefs.getString("bookmark.work_dir",
""));
advancedSettings.setConsoleMode(sharedPrefs.getBoolean(
"bookmark.console_mode", false));
debugSettings.setDebugLevel(sharedPrefs.getInt("bookmark.debug_level", 0));
} }
// Cloneable // Cloneable
public Object clone() public Object clone() {
{ try {
try
{
return super.clone(); return super.clone();
} } catch (CloneNotSupportedException e) {
catch(CloneNotSupportedException e)
{
return null; return null;
} }
} }

View File

@ -5,12 +5,13 @@
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. 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/. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
package com.freerdp.freerdpcore.presentation; package com.freerdp.freerdpcore.presentation;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import com.freerdp.freerdpcore.R; import com.freerdp.freerdpcore.R;
import com.freerdp.freerdpcore.application.GlobalApp; import com.freerdp.freerdpcore.application.GlobalApp;
@ -19,6 +20,7 @@ import com.freerdp.freerdpcore.domain.ConnectionReference;
import com.freerdp.freerdpcore.domain.ManualBookmark; import com.freerdp.freerdpcore.domain.ManualBookmark;
import com.freerdp.freerdpcore.services.BookmarkBaseGateway; import com.freerdp.freerdpcore.services.BookmarkBaseGateway;
import com.freerdp.freerdpcore.utils.RDPFileParser; import com.freerdp.freerdpcore.utils.RDPFileParser;
import com.freerdp.freerdpcore.utils.BuildConfiguration;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.ComponentName; import android.content.ComponentName;
@ -29,10 +31,11 @@ import android.os.Bundle;
import android.preference.ListPreference; import android.preference.ListPreference;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
import android.util.Log; import android.util.Log;
public class BookmarkActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener public class BookmarkActivity extends PreferenceActivity implements
{ OnSharedPreferenceChangeListener {
public static final String PARAM_CONNECTION_REFERENCE = "conRef"; public static final String PARAM_CONNECTION_REFERENCE = "conRef";
private static final String TAG = "BookmarkActivity"; private static final String TAG = "BookmarkActivity";
@ -46,9 +49,12 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref
private static final int PREFERENCES_SCREEN3G = 6; private static final int PREFERENCES_SCREEN3G = 6;
private static final int PREFERENCES_PERFORMANCE3G = 7; private static final int PREFERENCES_PERFORMANCE3G = 7;
private static final int PREFERENCES_GATEWAY = 8; private static final int PREFERENCES_GATEWAY = 8;
private static final int PREFERENCES_DEBUG = 9;
// bookmark needs to be static because the activity is started for each subview // bookmark needs to be static because the activity is started for each
// (we have to do this because Android has a bug where the style for Preferences // subview
// (we have to do this because Android has a bug where the style for
// Preferences
// is only applied to the first PreferenceScreen but not to subsequent ones) // is only applied to the first PreferenceScreen but not to subsequent ones)
private static BookmarkBase bookmark = null; private static BookmarkBase bookmark = null;
@ -56,53 +62,48 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref
private static boolean new_bookmark = false; private static boolean new_bookmark = false;
@Override @Override
public void onCreate(Bundle savedInstanceState) public void onCreate(Bundle savedInstanceState) {
{
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// init shared preferences for activity // init shared preferences for activity
getPreferenceManager().setSharedPreferencesName("TEMP"); getPreferenceManager().setSharedPreferencesName("TEMP");
getPreferenceManager().setSharedPreferencesMode(MODE_PRIVATE); getPreferenceManager().setSharedPreferencesMode(MODE_PRIVATE);
if (bookmark == null) if (bookmark == null) {
{
// if we have a bookmark id set in the extras we are in edit mode // if we have a bookmark id set in the extras we are in edit mode
Bundle bundle = getIntent().getExtras(); Bundle bundle = getIntent().getExtras();
if(bundle != null) if (bundle != null) {
{
// See if we got a connection reference to a bookmark // See if we got a connection reference to a bookmark
if(bundle.containsKey(PARAM_CONNECTION_REFERENCE)) if (bundle.containsKey(PARAM_CONNECTION_REFERENCE)) {
{ String refStr = bundle
String refStr = bundle.getString(PARAM_CONNECTION_REFERENCE); .getString(PARAM_CONNECTION_REFERENCE);
if(ConnectionReference.isManualBookmarkReference(refStr)) if (ConnectionReference.isManualBookmarkReference(refStr)) {
{ bookmark = GlobalApp.getManualBookmarkGateway()
bookmark = GlobalApp.getManualBookmarkGateway().findById(ConnectionReference.getManualBookmarkId(refStr)); .findById(
ConnectionReference
.getManualBookmarkId(refStr));
new_bookmark = false; new_bookmark = false;
} } else if (ConnectionReference.isHostnameReference(refStr)) {
else if(ConnectionReference.isHostnameReference(refStr))
{
bookmark = new ManualBookmark(); bookmark = new ManualBookmark();
bookmark.<ManualBookmark>get().setLabel(ConnectionReference.getHostname(refStr)); bookmark.<ManualBookmark> get().setLabel(
bookmark.<ManualBookmark>get().setHostname(ConnectionReference.getHostname(refStr)); ConnectionReference.getHostname(refStr));
bookmark.<ManualBookmark> get().setHostname(
ConnectionReference.getHostname(refStr));
new_bookmark = true; new_bookmark = true;
} } else if (ConnectionReference.isFileReference(refStr)) {
else if (ConnectionReference.isFileReference(refStr))
{
String file = ConnectionReference.getFile(refStr); String file = ConnectionReference.getFile(refStr);
bookmark = new ManualBookmark(); bookmark = new ManualBookmark();
bookmark.setLabel(file); bookmark.setLabel(file);
try try {
{
RDPFileParser rdpFile = new RDPFileParser(file); RDPFileParser rdpFile = new RDPFileParser(file);
updateBookmarkFromFile((ManualBookmark)bookmark, rdpFile); updateBookmarkFromFile((ManualBookmark) bookmark,
rdpFile);
bookmark.setLabel(new File(file).getName()); bookmark.setLabel(new File(file).getName());
new_bookmark = true; new_bookmark = true;
} } catch (IOException e) {
catch (IOException e)
{
Log.e(TAG, "Failed reading RDP file", e); Log.e(TAG, "Failed reading RDP file", e);
} }
} }
@ -110,98 +111,102 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref
} }
// last chance - ensure we really have a valid bookmark // last chance - ensure we really have a valid bookmark
if(bookmark == null) if (bookmark == null)
bookmark = new ManualBookmark(); bookmark = new ManualBookmark();
// hide gateway settings if we edit a non-manual bookmark // hide gateway settings if we edit a non-manual bookmark
if (current_preferences == PREFERENCES_ADVANCED && bookmark.getType() != ManualBookmark.TYPE_MANUAL) if (current_preferences == PREFERENCES_ADVANCED
{ && bookmark.getType() != ManualBookmark.TYPE_MANUAL) {
getPreferenceScreen().removePreference(findPreference("bookmark.enable_gateway")); getPreferenceScreen().removePreference(
getPreferenceScreen().removePreference(findPreference("bookmark.gateway")); findPreference("bookmark.enable_gateway"));
getPreferenceScreen().removePreference(
findPreference("bookmark.gateway"));
} }
// update preferences from bookmark // update preferences from bookmark
bookmark.writeToSharedPreferences(getPreferenceManager().getSharedPreferences()); bookmark.writeToSharedPreferences(getPreferenceManager()
.getSharedPreferences());
// no settings changed yet // no settings changed yet
settings_changed = false; settings_changed = false;
} }
// load the requested settings resource // load the requested settings resource
if (getIntent() == null || getIntent().getData() == null) if (getIntent() == null || getIntent().getData() == null) {
{
addPreferencesFromResource(R.xml.bookmark_settings); addPreferencesFromResource(R.xml.bookmark_settings);
current_preferences = PREFERENCES_BOOKMARK; current_preferences = PREFERENCES_BOOKMARK;
} } else if (getIntent().getData().toString()
else if (getIntent().getData().toString().equals("preferences://screen_settings")) .equals("preferences://screen_settings")) {
{
addPreferencesFromResource(R.xml.screen_settings); addPreferencesFromResource(R.xml.screen_settings);
current_preferences = PREFERENCES_SCREEN; current_preferences = PREFERENCES_SCREEN;
} } else if (getIntent().getData().toString()
else if (getIntent().getData().toString().equals("preferences://performance_flags")) .equals("preferences://performance_flags")) {
{
addPreferencesFromResource(R.xml.performance_flags); addPreferencesFromResource(R.xml.performance_flags);
current_preferences = PREFERENCES_PERFORMANCE; current_preferences = PREFERENCES_PERFORMANCE;
} } else if (getIntent().getData().toString()
else if (getIntent().getData().toString().equals("preferences://screen_settings_3g")) .equals("preferences://screen_settings_3g")) {
{
addPreferencesFromResource(R.xml.screen_settings_3g); addPreferencesFromResource(R.xml.screen_settings_3g);
current_preferences = PREFERENCES_SCREEN3G; current_preferences = PREFERENCES_SCREEN3G;
} } else if (getIntent().getData().toString()
else if (getIntent().getData().toString().equals("preferences://performance_flags_3g")) .equals("preferences://performance_flags_3g")) {
{
addPreferencesFromResource(R.xml.performance_flags_3g); addPreferencesFromResource(R.xml.performance_flags_3g);
current_preferences = PREFERENCES_PERFORMANCE3G; current_preferences = PREFERENCES_PERFORMANCE3G;
} } else if (getIntent().getData().toString()
else if (getIntent().getData().toString().equals("preferences://advanced_settings")) .equals("preferences://advanced_settings")) {
{
addPreferencesFromResource(R.xml.advanced_settings); addPreferencesFromResource(R.xml.advanced_settings);
current_preferences = PREFERENCES_ADVANCED; current_preferences = PREFERENCES_ADVANCED;
} } else if (getIntent().getData().toString()
else if (getIntent().getData().toString().equals("preferences://credentials_settings")) .equals("preferences://credentials_settings")) {
{
addPreferencesFromResource(R.xml.credentials_settings); addPreferencesFromResource(R.xml.credentials_settings);
current_preferences = PREFERENCES_CREDENTIALS; current_preferences = PREFERENCES_CREDENTIALS;
} } else if (getIntent().getData().toString()
else if (getIntent().getData().toString().equals("preferences://gateway_settings")) .equals("preferences://gateway_settings")) {
{
addPreferencesFromResource(R.xml.gateway_settings); addPreferencesFromResource(R.xml.gateway_settings);
current_preferences = PREFERENCES_GATEWAY; current_preferences = PREFERENCES_GATEWAY;
} } else if (getIntent().getData().toString()
else .equals("preferences://debug_settings")) {
{ addPreferencesFromResource(R.xml.debug_settings);
current_preferences = PREFERENCES_DEBUG;
} else {
addPreferencesFromResource(R.xml.bookmark_settings); addPreferencesFromResource(R.xml.bookmark_settings);
current_preferences = PREFERENCES_BOOKMARK; current_preferences = PREFERENCES_BOOKMARK;
} }
// Hide debug settings, if not activated.
if (!BuildConfiguration.WITH_ANDROID_DEBUG_MENU
.equalsIgnoreCase("ON")) {
Preference pref = findPreference("bookmark.debug");
PreferenceCategory cat = (PreferenceCategory)findPreference("category.settings");
if (pref != null) {
cat.removePreference(pref);
}
}
// update UI with bookmark data // update UI with bookmark data
initSettings(getPreferenceManager().getSharedPreferences()); SharedPreferences spref = getPreferenceManager().getSharedPreferences();
initSettings(spref);
// register for preferences changed notification // register for preferences changed notification
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); getPreferenceManager().getSharedPreferences()
.registerOnSharedPreferenceChangeListener(this);
// set the correct component names in our preferencescreen settings // set the correct component names in our preferencescreen settings
setIntentComponentNames(); setIntentComponentNames();
} }
private void updateBookmarkFromFile(ManualBookmark bookmark, RDPFileParser rdpFile) private void updateBookmarkFromFile(ManualBookmark bookmark,
{ RDPFileParser rdpFile) {
String s; String s;
Integer i; Integer i;
s = rdpFile.getString("full address"); s = rdpFile.getString("full address");
if (s != null) if (s != null) {
{
// this gets complicated as it can include port // this gets complicated as it can include port
if (s.lastIndexOf(":") > s.lastIndexOf("]")) if (s.lastIndexOf(":") > s.lastIndexOf("]")) {
{ try {
try
{
String port = s.substring(s.lastIndexOf(":") + 1); String port = s.substring(s.lastIndexOf(":") + 1);
bookmark.setPort(Integer.parseInt(port)); bookmark.setPort(Integer.parseInt(port));
} } catch (NumberFormatException e) {
catch (NumberFormatException e)
{
Log.e(TAG, "Malformed address"); Log.e(TAG, "Malformed address");
} }
@ -232,92 +237,102 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref
bookmark.getAdvancedSettings().setConsoleMode(i == 1); bookmark.getAdvancedSettings().setConsoleMode(i == 1);
} }
private void setIntentComponentNames() private void setIntentComponentNames() {
{ // we set the component name for our sub-activity calls here because we
// we set the component name for our sub-activity calls here because we don't know the package // don't know the package
// name of the main app in our library project. // name of the main app in our library project.
ComponentName compName = new ComponentName(getPackageName(), BookmarkActivity.class.getName()); ComponentName compName = new ComponentName(getPackageName(),
String[] prefKeys = { BookmarkActivity.class.getName());
"bookmark.credentials", ArrayList<String> prefKeys = new ArrayList<String>();
"bookmark.screen",
"bookmark.performance",
"bookmark.advanced",
"bookmark.screen_3g",
"bookmark.performance_3g",
"bookmark.gateway_settings"
};
for (int i = 0; i < prefKeys.length; ++i) prefKeys.add("bookmark.credentials");
{ prefKeys.add("bookmark.screen");
Preference pref = findPreference(prefKeys[i]); prefKeys.add("bookmark.performance");
prefKeys.add("bookmark.advanced");
prefKeys.add("bookmark.screen_3g");
prefKeys.add("bookmark.performance_3g");
prefKeys.add("bookmark.gateway_settings");
prefKeys.add("bookmark.debug");
for (String p : prefKeys) {
Preference pref = findPreference(p);
if (pref != null) if (pref != null)
pref.getIntent().setComponent(compName); pref.getIntent().setComponent(compName);
} }
} }
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
settings_changed = true; settings_changed = true;
switch (current_preferences) switch (current_preferences) {
{ case PREFERENCES_DEBUG:
case PREFERENCES_BOOKMARK: debugSettingsChanged(sharedPreferences, key);
bookmarkSettingsChanged(sharedPreferences, key); break;
break;
case PREFERENCES_ADVANCED: case PREFERENCES_BOOKMARK:
advancedSettingsChanged(sharedPreferences, key); bookmarkSettingsChanged(sharedPreferences, key);
break; break;
case PREFERENCES_CREDENTIALS: case PREFERENCES_ADVANCED:
credentialsSettingsChanged(sharedPreferences, key); advancedSettingsChanged(sharedPreferences, key);
break; break;
case PREFERENCES_SCREEN: case PREFERENCES_CREDENTIALS:
case PREFERENCES_SCREEN3G: credentialsSettingsChanged(sharedPreferences, key);
screenSettingsChanged(sharedPreferences, key); break;
break;
case PREFERENCES_GATEWAY: case PREFERENCES_SCREEN:
gatewaySettingsChanged(sharedPreferences, key); case PREFERENCES_SCREEN3G:
break; screenSettingsChanged(sharedPreferences, key);
break;
case PREFERENCES_GATEWAY:
gatewaySettingsChanged(sharedPreferences, key);
break;
default:
break;
} }
} }
private void initSettings(SharedPreferences sharedPreferences) private void initSettings(SharedPreferences sharedPreferences) {
{ switch (current_preferences) {
switch (current_preferences) case PREFERENCES_BOOKMARK:
{ initBookmarkSettings(sharedPreferences);
case PREFERENCES_BOOKMARK: break;
initBookmarkSettings(sharedPreferences);
break;
case PREFERENCES_ADVANCED: case PREFERENCES_ADVANCED:
initAdvancedSettings(sharedPreferences); initAdvancedSettings(sharedPreferences);
break; break;
case PREFERENCES_CREDENTIALS: case PREFERENCES_CREDENTIALS:
initCredentialsSettings(sharedPreferences); initCredentialsSettings(sharedPreferences);
break; break;
case PREFERENCES_SCREEN: case PREFERENCES_SCREEN:
initScreenSettings(sharedPreferences); initScreenSettings(sharedPreferences);
break; break;
case PREFERENCES_SCREEN3G: case PREFERENCES_SCREEN3G:
initScreenSettings3G(sharedPreferences); initScreenSettings3G(sharedPreferences);
break; break;
case PREFERENCES_GATEWAY: case PREFERENCES_GATEWAY:
initGatewaySettings(sharedPreferences); initGatewaySettings(sharedPreferences);
break; break;
case PREFERENCES_DEBUG:
initDebugSettings(sharedPreferences);
break;
default:
break;
} }
} }
private void initBookmarkSettings(SharedPreferences sharedPreferences) private void initBookmarkSettings(SharedPreferences sharedPreferences) {
{
bookmarkSettingsChanged(sharedPreferences, "bookmark.label"); bookmarkSettingsChanged(sharedPreferences, "bookmark.label");
bookmarkSettingsChanged(sharedPreferences, "bookmark.hostname"); bookmarkSettingsChanged(sharedPreferences, "bookmark.hostname");
bookmarkSettingsChanged(sharedPreferences, "bookmark.port"); bookmarkSettingsChanged(sharedPreferences, "bookmark.port");
@ -325,31 +340,38 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref
bookmarkSettingsChanged(sharedPreferences, "bookmark.resolution"); bookmarkSettingsChanged(sharedPreferences, "bookmark.resolution");
} }
private void bookmarkSettingsChanged(SharedPreferences sharedPreferences, String key) private void bookmarkSettingsChanged(SharedPreferences sharedPreferences,
{ String key) {
if (key.equals("bookmark.label") && findPreference(key) != null) if (key.equals("bookmark.label") && findPreference(key) != null)
findPreference(key).setSummary(sharedPreferences.getString(key, "")); findPreference(key)
.setSummary(sharedPreferences.getString(key, ""));
else if (key.equals("bookmark.hostname") && findPreference(key) != null) else if (key.equals("bookmark.hostname") && findPreference(key) != null)
findPreference(key).setSummary(sharedPreferences.getString(key, "")); findPreference(key)
.setSummary(sharedPreferences.getString(key, ""));
else if (key.equals("bookmark.port") && findPreference(key) != null) else if (key.equals("bookmark.port") && findPreference(key) != null)
findPreference(key).setSummary(String.valueOf(sharedPreferences.getInt(key, -1))); findPreference(key).setSummary(
else if (key.equals("bookmark.username")) String.valueOf(sharedPreferences.getInt(key, -1)));
{ else if (key.equals("bookmark.username")) {
String username = sharedPreferences.getString(key, "<none>"); String username = sharedPreferences.getString(key, "<none>");
if (username.length() == 0) if (username.length() == 0)
username = "<none>"; username = "<none>";
findPreference("bookmark.credentials").setSummary(username); findPreference("bookmark.credentials").setSummary(username);
} } else if (key.equals("bookmark.resolution")
else if (key.equals("bookmark.resolution") || key.equals("bookmark.colors") || key.equals("bookmark.width") || key.equals("bookmark.height")) || key.equals("bookmark.colors")
{ || key.equals("bookmark.width")
String resolution = sharedPreferences.getString("bookmark.resolution", "800x600"); || key.equals("bookmark.height")) {
//compare english string from resolutions_values_array array, decode to localized String resolution = sharedPreferences.getString(
//text for display "bookmark.resolution", "800x600");
// compare english string from resolutions_values_array array,
// decode to localized
// text for display
if (resolution.equals("automatic")) { if (resolution.equals("automatic")) {
resolution = getResources().getString(R.string.resolution_automatic); resolution = getResources().getString(
R.string.resolution_automatic);
} }
if (resolution.equals("custom")) { if (resolution.equals("custom")) {
resolution = getResources().getString(R.string.resolution_custom); resolution = getResources().getString(
R.string.resolution_custom);
} }
if (resolution.equals("fitscreen")) { if (resolution.equals("fitscreen")) {
resolution = getResources().getString(R.string.resolution_fit); resolution = getResources().getString(R.string.resolution_fit);
@ -359,170 +381,188 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref
} }
} }
private void initAdvancedSettings(SharedPreferences sharedPreferences) private void initAdvancedSettings(SharedPreferences sharedPreferences) {
{ advancedSettingsChanged(sharedPreferences,
advancedSettingsChanged(sharedPreferences, "bookmark.enable_gateway_settings"); "bookmark.enable_gateway_settings");
advancedSettingsChanged(sharedPreferences, "bookmark.enable_3g_settings"); advancedSettingsChanged(sharedPreferences,
"bookmark.enable_3g_settings");
advancedSettingsChanged(sharedPreferences, "bookmark.security"); advancedSettingsChanged(sharedPreferences, "bookmark.security");
advancedSettingsChanged(sharedPreferences, "bookmark.resolution_3g"); advancedSettingsChanged(sharedPreferences, "bookmark.resolution_3g");
advancedSettingsChanged(sharedPreferences, "bookmark.remote_program"); advancedSettingsChanged(sharedPreferences, "bookmark.remote_program");
advancedSettingsChanged(sharedPreferences, "bookmark.work_dir"); advancedSettingsChanged(sharedPreferences, "bookmark.work_dir");
} }
private void advancedSettingsChanged(SharedPreferences sharedPreferences, String key) private void advancedSettingsChanged(SharedPreferences sharedPreferences,
{ String key) {
if (key.equals("bookmark.enable_gateway_settings")) if (key.equals("bookmark.enable_gateway_settings")) {
{ boolean enabled = sharedPreferences.getBoolean(key, false);
boolean enabled = sharedPreferences.getBoolean(key, false); findPreference("bookmark.gateway_settings").setEnabled(enabled);
findPreference("bookmark.gateway_settings").setEnabled(enabled); } else if (key.equals("bookmark.enable_3g_settings")) {
}
else if (key.equals("bookmark.enable_3g_settings"))
{
boolean enabled = sharedPreferences.getBoolean(key, false); boolean enabled = sharedPreferences.getBoolean(key, false);
findPreference("bookmark.screen_3g").setEnabled(enabled); findPreference("bookmark.screen_3g").setEnabled(enabled);
findPreference("bookmark.performance_3g").setEnabled(enabled); findPreference("bookmark.performance_3g").setEnabled(enabled);
} } else if (key.equals("bookmark.security")) {
else if (key.equals("bookmark.security")) ListPreference listPreference = (ListPreference) findPreference(key);
{ CharSequence security = listPreference.getEntries()[sharedPreferences
ListPreference listPreference = (ListPreference)findPreference(key); .getInt(key, 0)];
CharSequence security = listPreference.getEntries()[sharedPreferences.getInt(key, 0)];
listPreference.setSummary(security); listPreference.setSummary(security);
} } else if (key.equals("bookmark.resolution_3g")
else if (key.equals("bookmark.resolution_3g") || key.equals("bookmark.colors_3g") || key.equals("bookmark.width_3g") || key.equals("bookmark.height_3g")) || key.equals("bookmark.colors_3g")
{ || key.equals("bookmark.width_3g")
String resolution = sharedPreferences.getString("bookmark.resolution_3g", "800x600"); || key.equals("bookmark.height_3g")) {
String resolution = sharedPreferences.getString(
"bookmark.resolution_3g", "800x600");
if (resolution.equals("automatic")) if (resolution.equals("automatic"))
resolution = getResources().getString(R.string.resolution_automatic); resolution = getResources().getString(
R.string.resolution_automatic);
else if (resolution.equals("custom")) else if (resolution.equals("custom"))
resolution = getResources().getString(R.string.resolution_custom); resolution = getResources().getString(
resolution += "@" + sharedPreferences.getInt("bookmark.colors_3g", 16); R.string.resolution_custom);
resolution += "@"
+ sharedPreferences.getInt("bookmark.colors_3g", 16);
findPreference("bookmark.screen_3g").setSummary(resolution); findPreference("bookmark.screen_3g").setSummary(resolution);
} } else if (key.equals("bookmark.remote_program"))
else if (key.equals("bookmark.remote_program")) findPreference(key)
findPreference(key).setSummary(sharedPreferences.getString(key, "")); .setSummary(sharedPreferences.getString(key, ""));
else if (key.equals("bookmark.work_dir")) else if (key.equals("bookmark.work_dir"))
findPreference(key).setSummary(sharedPreferences.getString(key, "")); findPreference(key)
.setSummary(sharedPreferences.getString(key, ""));
} }
private void initCredentialsSettings(SharedPreferences sharedPreferences) private void initCredentialsSettings(SharedPreferences sharedPreferences) {
{
credentialsSettingsChanged(sharedPreferences, "bookmark.username"); credentialsSettingsChanged(sharedPreferences, "bookmark.username");
credentialsSettingsChanged(sharedPreferences, "bookmark.password"); credentialsSettingsChanged(sharedPreferences, "bookmark.password");
credentialsSettingsChanged(sharedPreferences, "bookmark.domain"); credentialsSettingsChanged(sharedPreferences, "bookmark.domain");
} }
private void credentialsSettingsChanged(SharedPreferences sharedPreferences, String key) private void credentialsSettingsChanged(
{ SharedPreferences sharedPreferences, String key) {
if (key.equals("bookmark.username")) if (key.equals("bookmark.username"))
findPreference(key).setSummary(sharedPreferences.getString(key, "")); findPreference(key)
else if (key.equals("bookmark.password")) .setSummary(sharedPreferences.getString(key, ""));
{ else if (key.equals("bookmark.password")) {
if (sharedPreferences.getString(key, "").length() == 0) if (sharedPreferences.getString(key, "").length() == 0)
findPreference(key).setSummary(getResources().getString(R.string.settings_password_empty)); findPreference(key).setSummary(
getResources().getString(
R.string.settings_password_empty));
else else
findPreference(key).setSummary(getResources().getString(R.string.settings_password_present)); findPreference(key).setSummary(
} getResources().getString(
else if (key.equals("bookmark.domain")) R.string.settings_password_present));
findPreference(key).setSummary(sharedPreferences.getString(key, "")); } else if (key.equals("bookmark.domain"))
findPreference(key)
.setSummary(sharedPreferences.getString(key, ""));
} }
private void initScreenSettings(SharedPreferences sharedPreferences) private void initScreenSettings(SharedPreferences sharedPreferences) {
{
screenSettingsChanged(sharedPreferences, "bookmark.colors"); screenSettingsChanged(sharedPreferences, "bookmark.colors");
screenSettingsChanged(sharedPreferences, "bookmark.resolution"); screenSettingsChanged(sharedPreferences, "bookmark.resolution");
screenSettingsChanged(sharedPreferences, "bookmark.width"); screenSettingsChanged(sharedPreferences, "bookmark.width");
screenSettingsChanged(sharedPreferences, "bookmark.height"); screenSettingsChanged(sharedPreferences, "bookmark.height");
} }
private void initScreenSettings3G(SharedPreferences sharedPreferences) private void initScreenSettings3G(SharedPreferences sharedPreferences) {
{
screenSettingsChanged(sharedPreferences, "bookmark.colors_3g"); screenSettingsChanged(sharedPreferences, "bookmark.colors_3g");
screenSettingsChanged(sharedPreferences, "bookmark.resolution_3g"); screenSettingsChanged(sharedPreferences, "bookmark.resolution_3g");
screenSettingsChanged(sharedPreferences, "bookmark.width_3g"); screenSettingsChanged(sharedPreferences, "bookmark.width_3g");
screenSettingsChanged(sharedPreferences, "bookmark.height_3g"); screenSettingsChanged(sharedPreferences, "bookmark.height_3g");
} }
private void screenSettingsChanged(SharedPreferences sharedPreferences, String key) private void screenSettingsChanged(SharedPreferences sharedPreferences,
{ String key) {
// could happen during initialization because 3g and non-3g settings share this routine - just skip // could happen during initialization because 3g and non-3g settings
// share this routine - just skip
if (findPreference(key) == null) if (findPreference(key) == null)
return; return;
if (key.equals("bookmark.colors") || key.equals("bookmark.colors_3g")) if (key.equals("bookmark.colors") || key.equals("bookmark.colors_3g")) {
{ ListPreference listPreference = (ListPreference) findPreference(key);
ListPreference listPreference = (ListPreference)findPreference(key);
listPreference.setSummary(listPreference.getEntry()); listPreference.setSummary(listPreference.getEntry());
} } else if (key.equals("bookmark.resolution")
else if (key.equals("bookmark.resolution") || key.equals("bookmark.resolution_3g")) || key.equals("bookmark.resolution_3g")) {
{ ListPreference listPreference = (ListPreference) findPreference(key);
ListPreference listPreference = (ListPreference)findPreference(key);
listPreference.setSummary(listPreference.getEntry()); listPreference.setSummary(listPreference.getEntry());
boolean enabled = listPreference.getValue().equalsIgnoreCase(getResources().getString(R.string.resolution_custom)); boolean enabled = listPreference.getValue().equalsIgnoreCase(
if (key.equals("bookmark.resolution")) getResources().getString(R.string.resolution_custom));
{ if (key.equals("bookmark.resolution")) {
findPreference("bookmark.width").setEnabled(enabled); findPreference("bookmark.width").setEnabled(enabled);
findPreference("bookmark.height").setEnabled(enabled); findPreference("bookmark.height").setEnabled(enabled);
} } else {
else
{
findPreference("bookmark.width_3g").setEnabled(enabled); findPreference("bookmark.width_3g").setEnabled(enabled);
findPreference("bookmark.height_3g").setEnabled(enabled); findPreference("bookmark.height_3g").setEnabled(enabled);
} }
} } else if (key.equals("bookmark.width")
else if (key.equals("bookmark.width") || key.equals("bookmark.width_3g")) || key.equals("bookmark.width_3g"))
findPreference(key).setSummary(String.valueOf(sharedPreferences.getInt(key, 800))); findPreference(key).setSummary(
else if (key.equals("bookmark.height") || key.equals("bookmark.height_3g")) String.valueOf(sharedPreferences.getInt(key, 800)));
findPreference(key).setSummary(String.valueOf(sharedPreferences.getInt(key, 600))); else if (key.equals("bookmark.height")
|| key.equals("bookmark.height_3g"))
findPreference(key).setSummary(
String.valueOf(sharedPreferences.getInt(key, 600)));
} }
private void initGatewaySettings(SharedPreferences sharedPreferences) private void initDebugSettings(SharedPreferences sharedPreferences) {
{ debugSettingsChanged(sharedPreferences, "bookmark.debug_level");
gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_hostname"); }
gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_port");
gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_username");
gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_password");
gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_domain");
}
private void gatewaySettingsChanged(SharedPreferences sharedPreferences, String key) private void initGatewaySettings(SharedPreferences sharedPreferences) {
{ gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_hostname");
if (key.equals("bookmark.gateway_hostname")) gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_port");
{ gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_username");
findPreference(key).setSummary(sharedPreferences.getString(key, "")); gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_password");
} gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_domain");
else if (key.equals("bookmark.gateway_port")) }
{
findPreference(key).setSummary(String.valueOf(sharedPreferences.getInt(key, 443))); private void debugSettingsChanged(SharedPreferences sharedPreferences,
} String key) {
else if (key.equals("bookmark.gateway_username")) if (key.equals("bookmark.debug_level")) {
{ int level = sharedPreferences.getInt(key, 0);
findPreference(key).setSummary(sharedPreferences.getString(key, "")); Preference pref = findPreference("bookmark.debug_level");
} pref.setDefaultValue(level);
else if (key.equals("bookmark.gateway_password")) }
{ }
if (sharedPreferences.getString(key, "").length() == 0)
findPreference(key).setSummary(getResources().getString(R.string.settings_password_empty)); private void gatewaySettingsChanged(SharedPreferences sharedPreferences,
else String key) {
findPreference(key).setSummary(getResources().getString(R.string.settings_password_present)); if (key.equals("bookmark.gateway_hostname")) {
} findPreference(key)
else if (key.equals("bookmark.gateway_domain")) .setSummary(sharedPreferences.getString(key, ""));
findPreference(key).setSummary(sharedPreferences.getString(key, "")); } else if (key.equals("bookmark.gateway_port")) {
} findPreference(key).setSummary(
String.valueOf(sharedPreferences.getInt(key, 443)));
} else if (key.equals("bookmark.gateway_username")) {
findPreference(key)
.setSummary(sharedPreferences.getString(key, ""));
} else if (key.equals("bookmark.gateway_password")) {
if (sharedPreferences.getString(key, "").length() == 0)
findPreference(key).setSummary(
getResources().getString(
R.string.settings_password_empty));
else
findPreference(key).setSummary(
getResources().getString(
R.string.settings_password_present));
} else if (key.equals("bookmark.gateway_domain"))
findPreference(key)
.setSummary(sharedPreferences.getString(key, ""));
}
private boolean verifySettings(SharedPreferences sharedPreferences) { private boolean verifySettings(SharedPreferences sharedPreferences) {
boolean verifyFailed = false; boolean verifyFailed = false;
// perform sanity checks on settings // perform sanity checks on settings
// Label set // Label set
if (sharedPreferences.getString("bookmark.label", "").length() == 0) if (sharedPreferences.getString("bookmark.label", "").length() == 0)
verifyFailed = true; verifyFailed = true;
// Server and port specified // Server and port specified
if (!verifyFailed && sharedPreferences.getString("bookmark.hostname", "").length() == 0) if (!verifyFailed
&& sharedPreferences.getString("bookmark.hostname", "")
.length() == 0)
verifyFailed = true; verifyFailed = true;
// Server and port specified // Server and port specified
if (!verifyFailed && sharedPreferences.getInt("bookmark.port", -1) <= 0) if (!verifyFailed && sharedPreferences.getInt("bookmark.port", -1) <= 0)
verifyFailed = true; verifyFailed = true;
@ -530,93 +570,99 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref
return (!verifyFailed); return (!verifyFailed);
} }
private void finishAndResetBookmark() private void finishAndResetBookmark() {
{
bookmark = null; bookmark = null;
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this); getPreferenceManager().getSharedPreferences()
.unregisterOnSharedPreferenceChangeListener(this);
finish(); finish();
} }
@Override @Override
public void onBackPressed() public void onBackPressed() {
{
// only proceed if we are in the main preferences screen // only proceed if we are in the main preferences screen
if (current_preferences != PREFERENCES_BOOKMARK) if (current_preferences != PREFERENCES_BOOKMARK) {
{
super.onBackPressed(); super.onBackPressed();
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this); getPreferenceManager().getSharedPreferences()
.unregisterOnSharedPreferenceChangeListener(this);
return; return;
} }
SharedPreferences sharedPreferences = getPreferenceManager().getSharedPreferences(); SharedPreferences sharedPreferences = getPreferenceManager()
if(!verifySettings(sharedPreferences)) .getSharedPreferences();
{ if (!verifySettings(sharedPreferences)) {
// ask the user if he wants to cancel or continue editing // ask the user if he wants to cancel or continue editing
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.error_bookmark_incomplete_title) builder.setTitle(R.string.error_bookmark_incomplete_title)
.setMessage(R.string.error_bookmark_incomplete) .setMessage(R.string.error_bookmark_incomplete)
.setPositiveButton(R.string.cancel, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.cancel,
@Override new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { @Override
finishAndResetBookmark(); public void onClick(DialogInterface dialog,
} int which) {
}) finishAndResetBookmark();
.setNegativeButton(R.string.cont, new DialogInterface.OnClickListener() { }
@Override })
public void onClick(DialogInterface dialog, int which) { .setNegativeButton(R.string.cont,
dialog.cancel(); new DialogInterface.OnClickListener() {
} @Override
}) public void onClick(DialogInterface dialog,
.show(); int which) {
dialog.cancel();
}
}).show();
return; return;
} } else {
else // ask the user if he wants to save or cancel editing if a setting
{ // has changed
// ask the user if he wants to save or cancel editing if a setting has changed if (new_bookmark || settings_changed) {
if (new_bookmark || settings_changed)
{
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.dlg_title_save_bookmark) builder.setTitle(R.string.dlg_title_save_bookmark)
.setMessage(R.string.dlg_save_bookmark) .setMessage(R.string.dlg_save_bookmark)
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.yes,
@Override new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { @Override
// read shared prefs back to bookmark public void onClick(DialogInterface dialog,
bookmark.readFromSharedPreferences(getPreferenceManager().getSharedPreferences()); int which) {
// read shared prefs back to bookmark
bookmark.readFromSharedPreferences(getPreferenceManager()
.getSharedPreferences());
BookmarkBaseGateway bookmarkGateway; BookmarkBaseGateway bookmarkGateway;
if(bookmark.getType() == BookmarkBase.TYPE_MANUAL) if (bookmark.getType() == BookmarkBase.TYPE_MANUAL) {
{ bookmarkGateway = GlobalApp
bookmarkGateway = GlobalApp.getManualBookmarkGateway(); .getManualBookmarkGateway();
// remove any history entry for this bookmark // remove any history entry for this
GlobalApp.getQuickConnectHistoryGateway().removeHistoryItem(bookmark.<ManualBookmark>get().getHostname()); // bookmark
} GlobalApp
else .getQuickConnectHistoryGateway()
{ .removeHistoryItem(
assert false; bookmark.<ManualBookmark> get()
return; .getHostname());
} } else {
assert false;
return;
}
// insert or update bookmark and leave activity // insert or update bookmark and leave
if(bookmark.getId() > 0) // activity
bookmarkGateway.update(bookmark); if (bookmark.getId() > 0)
else bookmarkGateway.update(bookmark);
bookmarkGateway.insert(bookmark); else
bookmarkGateway.insert(bookmark);
finishAndResetBookmark(); finishAndResetBookmark();
} }
}) })
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { .setNegativeButton(R.string.no,
@Override new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { @Override
finishAndResetBookmark(); public void onClick(DialogInterface dialog,
} int which) {
}) finishAndResetBookmark();
.show(); }
} }).show();
else } else {
{
finishAndResetBookmark(); finishAndResetBookmark();
} }
} }

View File

@ -71,6 +71,8 @@ public abstract class BookmarkBaseGateway
values.put("remote_program", bookmark.getAdvancedSettings().getRemoteProgram()); values.put("remote_program", bookmark.getAdvancedSettings().getRemoteProgram());
values.put("work_dir", bookmark.getAdvancedSettings().getWorkDir()); values.put("work_dir", bookmark.getAdvancedSettings().getWorkDir());
values.put("debug_level", bookmark.getDebugSettings().getDebugLevel());
// add any special columns // add any special columns
addBookmarkSpecificColumns(bookmark, values); addBookmarkSpecificColumns(bookmark, values);
@ -109,6 +111,8 @@ public abstract class BookmarkBaseGateway
values.put("remote_program", bookmark.getAdvancedSettings().getRemoteProgram()); values.put("remote_program", bookmark.getAdvancedSettings().getRemoteProgram());
values.put("work_dir", bookmark.getAdvancedSettings().getWorkDir()); values.put("work_dir", bookmark.getAdvancedSettings().getWorkDir());
values.put("debug_level", bookmark.getDebugSettings().getDebugLevel());
addBookmarkSpecificColumns(bookmark, values); addBookmarkSpecificColumns(bookmark, values);
// update bookmark // update bookmark
@ -230,6 +234,9 @@ public abstract class BookmarkBaseGateway
columns.add("remote_program"); columns.add("remote_program");
columns.add("work_dir"); columns.add("work_dir");
// debug settings
columns.add("debug_level");
addBookmarkSpecificColumns(columns); addBookmarkSpecificColumns(columns);
} }
@ -290,6 +297,8 @@ public abstract class BookmarkBaseGateway
bookmark.getAdvancedSettings().setRemoteProgram(cursor.getString(cursor.getColumnIndex("remote_program"))); bookmark.getAdvancedSettings().setRemoteProgram(cursor.getString(cursor.getColumnIndex("remote_program")));
bookmark.getAdvancedSettings().setWorkDir(cursor.getString(cursor.getColumnIndex("work_dir"))); bookmark.getAdvancedSettings().setWorkDir(cursor.getString(cursor.getColumnIndex("work_dir")));
bookmark.getDebugSettings().setDebugLevel(cursor.getInt(cursor.getColumnIndex("debug_level")));
readBookmarkSpecificColumns(bookmark, cursor); readBookmarkSpecificColumns(bookmark, cursor);
return bookmark; return bookmark;

View File

@ -22,7 +22,7 @@ import android.database.sqlite.SQLiteOpenHelper;
public class BookmarkDB extends SQLiteOpenHelper public class BookmarkDB extends SQLiteOpenHelper
{ {
private static final int DB_VERSION = 4; private static final int DB_VERSION = 6;
private static final String DB_NAME = "bookmarks.db"; private static final String DB_NAME = "bookmarks.db";
public static final String ID = BaseColumns._ID; public static final String ID = BaseColumns._ID;
@ -106,7 +106,8 @@ public class BookmarkDB extends SQLiteOpenHelper
+ "security, " + "security, "
+ "remote_program, " + "remote_program, "
+ "work_dir, " + "work_dir, "
+ "console_mode) " + "console_mode, "
+ "debug_level ) "
+ "VALUES ( " + "VALUES ( "
+ "'Test Server', " + "'Test Server', "
+ "'testservice.afreerdp.com', " + "'testservice.afreerdp.com', "
@ -114,7 +115,7 @@ public class BookmarkDB extends SQLiteOpenHelper
+ "'', " + "'', "
+ "'', " + "'', "
+ "3389, " + "3389, "
+ "1, 1, 2, 2, 0, 0, 0, 0, '', '', 0);"; + "1, 1, 2, 2, 0, 0, 0, 0, '', '', 0, 0);";
db.execSQL(sqlInsertDefaultSessionEntry); db.execSQL(sqlInsertDefaultSessionEntry);
} }
@ -149,6 +150,7 @@ public class BookmarkDB extends SQLiteOpenHelper
+ "remote_program TEXT, " + "remote_program TEXT, "
+ "work_dir TEXT, " + "work_dir TEXT, "
+ "console_mode INTEGER, " + "console_mode INTEGER, "
+ "debug_level INTEGER DEFAULT 0, "
+ "FOREIGN KEY(screen_settings) REFERENCES tbl_screen_settings(" + ID + "), " + "FOREIGN KEY(screen_settings) REFERENCES tbl_screen_settings(" + ID + "), "
+ "FOREIGN KEY(performance_flags) REFERENCES tbl_performance_flags(" + ID + "), " + "FOREIGN KEY(performance_flags) REFERENCES tbl_performance_flags(" + ID + "), "

View File

@ -0,0 +1,15 @@
package com.freerdp.freerdpcore.utils;
public class BuildConfiguration {
public static final String WITH_ANDROID_DEBUG_MENU = "@WITH_ANDROID_DEBUG_MENU@";
public static final int FREERDP_VERSION_MAJOR = @FREERDP_VERSION_MAJOR@;
public static final int FREERDP_VERSION_MINOR = @FREERDP_VERSION_MINOR@;
public static final int FREERDP_VERSION_REVISION = @FREERDP_VERSION_REVISION@;
public static final String FREERDP_VERSION_SUFFIX = "@FREERDP_VERSION_SUFFIX@";
public static final String FREERDP_API_VERSION = "@FREERDP_API_VERSION@";
public static final String FREERDP_VERSION = "@FREERDP_VERSION@";
public static final String FREERDP_VERSION_FULL = "@FREERDP_VERSION_FULL@";
public static final String GIT_REVISION = "@GIT_REVISION@";
}

View File

@ -21,9 +21,12 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
endif() endif()
option(WITH_DEBUG_ANDROID_JNI "Enable debug output for android jni bindings" ${DEFAULT_DEBUG_OPTION}) option(WITH_DEBUG_ANDROID_JNI "Enable debug output for android jni bindings" ${DEFAULT_DEBUG_OPTION})
option(WITH_ANDROID_DEBUG_MENU "Enable debug output for android jni bindings" ${DEFAULT_DEBUG_OPTION})
option(WITH_OPENSLES "Enable sound and microphone redirection using OpenSLES" ON)
option(ANDROID_BUILD_JAVA "Automatically android java code - build type depends on CMAKE_BUILD_TYPE" ON) option(ANDROID_BUILD_JAVA "Automatically android java code - build type depends on CMAKE_BUILD_TYPE" ON)
option(ANDROID_BUILD_JAVA_DEBUG "Create a android debug package" ${JAVA_DEBUG_DEFAULT}) option(ANDROID_BUILD_JAVA_DEBUG "Create a android debug package" ${JAVA_DEBUG_DEFAULT})
set(ANDROID_APP_TARGET_SDK 11 CACHE STRING "Application target android SDK") set(ANDROID_APP_TARGET_SDK 11 CACHE STRING "Application target android SDK")
set(ANDROID_APP_MIN_SDK 9 CACHE STRING "Application minimum android SDK requirement") set(ANDROID_APP_MIN_SDK 9 CACHE STRING "Application minimum android SDK requirement")
set(ANDROID_APP_GOOGLE_TARGET_SDK "16" CACHE STRING "Application target google SDK") set(ANDROID_APP_GOOGLE_TARGET_SDK "16" CACHE STRING "Application target google SDK")