From 16936dc061bf22f8f95d5e73925900a0b7495b9b Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 2 Oct 2013 10:24:44 +0200 Subject: [PATCH 1/2] Added CMake generated BuildConfiguration java class. --- client/Android/FreeRDPCore/CMakeLists.txt | 8 ++++++++ .../freerdpcore/utils/BuildConfiguration.java.in | 15 +++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/utils/BuildConfiguration.java.in diff --git a/client/Android/FreeRDPCore/CMakeLists.txt b/client/Android/FreeRDPCore/CMakeLists.txt index 7c90dc965..a77e2cfdd 100644 --- a/client/Android/FreeRDPCore/CMakeLists.txt +++ b/client/Android/FreeRDPCore/CMakeLists.txt @@ -28,6 +28,14 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/project.properties.cmake CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/ant.properties.cmake ${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}) if (ANDROID_SDK) diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/utils/BuildConfiguration.java.in b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/utils/BuildConfiguration.java.in new file mode 100644 index 000000000..e0a72c95a --- /dev/null +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/utils/BuildConfiguration.java.in @@ -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@"; + } From 38323a456854d72c3a5a355c86a041b964cc7b14 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 2 Oct 2013 14:29:08 +0200 Subject: [PATCH 2/2] Implemented debug menu hidden in relase builds. --- .../res/layout/bookmark_list_item.xml | 2 + .../res/layout/session_list_item.xml | 2 + .../FreeRDPCore/res/values/strings.xml | 10 +- .../FreeRDPCore/res/xml/bookmark_settings.xml | 13 +- .../FreeRDPCore/res/xml/debug_settings.xml | 35 + .../freerdpcore/domain/BookmarkBase.java | 547 ++++++----- .../presentation/BookmarkActivity.java | 864 +++++++++--------- .../services/BookmarkBaseGateway.java | 9 + .../freerdpcore/services/BookmarkDB.java | 8 +- cmake/ConfigOptionsAndroid.cmake | 1 + 10 files changed, 849 insertions(+), 642 deletions(-) create mode 100644 client/Android/FreeRDPCore/res/xml/debug_settings.xml diff --git a/client/Android/FreeRDPCore/res/layout/bookmark_list_item.xml b/client/Android/FreeRDPCore/res/layout/bookmark_list_item.xml index 8903355aa..c4baa8c84 100644 --- a/client/Android/FreeRDPCore/res/layout/bookmark_list_item.xml +++ b/client/Android/FreeRDPCore/res/layout/bookmark_list_item.xml @@ -22,6 +22,7 @@ android:layout_height="wrap_content"> Login No Servers - Connecting ... - Disconnecting ... + Connecting … + Disconnecting … Connection Lost Wrong Password Invalid Username @@ -178,8 +178,8 @@ Please enter your credentials Create Shortcut Shortcut name: - Connecting ... - Logging in ... + Connecting … + Logging in … About aFreeRDP Version: %1$s\n\u00A9 2012 Thinstuff Technologies GmbH Save Connection Settings? @@ -191,4 +191,6 @@ Are you sure you want to exit the application? Delete Certificates? Are you sure you want to delete all your cached Certificates? + Debug Level + Debug Settings diff --git a/client/Android/FreeRDPCore/res/xml/bookmark_settings.xml b/client/Android/FreeRDPCore/res/xml/bookmark_settings.xml index 0564537d7..4ecc2da77 100644 --- a/client/Android/FreeRDPCore/res/xml/bookmark_settings.xml +++ b/client/Android/FreeRDPCore/res/xml/bookmark_settings.xml @@ -26,7 +26,9 @@ - + - + + + + + diff --git a/client/Android/FreeRDPCore/res/xml/debug_settings.xml b/client/Android/FreeRDPCore/res/xml/debug_settings.xml new file mode 100644 index 000000000..5689bd259 --- /dev/null +++ b/client/Android/FreeRDPCore/res/xml/debug_settings.xml @@ -0,0 +1,35 @@ + + + + + + + diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/BookmarkBase.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/BookmarkBase.java index 9a9f54a0d..f902dab12 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/BookmarkBase.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/BookmarkBase.java @@ -5,27 +5,27 @@ 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 com.freerdp.freerdpcore.domain; +import java.util.Locale; + import com.freerdp.freerdpcore.application.GlobalApp; import android.content.SharedPreferences; import android.os.Parcel; 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_MANUAL = 1; public static final int TYPE_QUICKCONNECT = 2; public static final int TYPE_PLACEHOLDER = 3; public static final int TYPE_CUSTOM_BASE = 1000; - + // performance flags - public static class PerformanceFlags implements Parcelable - { + public static class PerformanceFlags implements Parcelable { private boolean remotefx; private boolean wallpaper; private boolean theming; @@ -33,7 +33,7 @@ public class BookmarkBase implements Parcelable, Cloneable private boolean menuAnimations; private boolean fontSmoothing; private boolean desktopComposition; - + public PerformanceFlags() { remotefx = false; wallpaper = false; @@ -43,13 +43,13 @@ public class BookmarkBase implements Parcelable, Cloneable fontSmoothing = false; desktopComposition = false; } - + public PerformanceFlags(Parcel parcel) { remotefx = (parcel.readInt() == 1) ? true : false; - wallpaper = (parcel.readInt() == 1) ? true : false; - theming = (parcel.readInt() == 1) ? true : false; - fullWindowDrag = (parcel.readInt() == 1) ? true : false; - menuAnimations = (parcel.readInt() == 1) ? true : false; + wallpaper = (parcel.readInt() == 1) ? true : false; + theming = (parcel.readInt() == 1) ? true : false; + fullWindowDrag = (parcel.readInt() == 1) ? true : false; + menuAnimations = (parcel.readInt() == 1) ? true : false; fontSmoothing = (parcel.readInt() == 1) ? true : false; desktopComposition = (parcel.readInt() == 1) ? true : false; } @@ -57,7 +57,7 @@ public class BookmarkBase implements Parcelable, Cloneable public boolean getRemoteFX() { return remotefx; } - + public void setRemoteFX(boolean remotefx) { this.remotefx = remotefx; } @@ -65,15 +65,15 @@ public class BookmarkBase implements Parcelable, Cloneable public boolean getWallpaper() { return wallpaper; } - + public void setWallpaper(boolean wallpaper) { this.wallpaper = wallpaper; } - + public boolean getTheming() { return theming; } - + public void setTheming(boolean theming) { this.theming = theming; } @@ -81,7 +81,7 @@ public class BookmarkBase implements Parcelable, Cloneable public boolean getFullWindowDrag() { return fullWindowDrag; } - + public void setFullWindowDrag(boolean fullWindowDrag) { this.fullWindowDrag = fullWindowDrag; } @@ -89,7 +89,7 @@ public class BookmarkBase implements Parcelable, Cloneable public boolean getMenuAnimations() { return menuAnimations; } - + public void setMenuAnimations(boolean menuAnimations) { this.menuAnimations = menuAnimations; } @@ -97,21 +97,20 @@ public class BookmarkBase implements Parcelable, Cloneable public boolean getFontSmoothing() { return fontSmoothing; } - + public void setFontSmoothing(boolean fontSmoothing) { this.fontSmoothing = fontSmoothing; } - + public boolean getDesktopComposition() { return desktopComposition; } - + public void setDesktopComposition(boolean desktopComposition) { this.desktopComposition = desktopComposition; } - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() - { + public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { public PerformanceFlags createFromParcel(Parcel in) { return new PerformanceFlags(in); } @@ -128,26 +127,24 @@ public class BookmarkBase implements Parcelable, Cloneable } @Override - public void writeToParcel(Parcel out, int flags) - { + public void writeToParcel(Parcel out, int flags) { out.writeInt(remotefx ? 1 : 0); - out.writeInt(wallpaper ? 1 : 0); - out.writeInt(theming ? 1 : 0); - out.writeInt(fullWindowDrag ? 1 : 0); - out.writeInt(menuAnimations ? 1 : 0); + out.writeInt(wallpaper ? 1 : 0); + out.writeInt(theming ? 1 : 0); + out.writeInt(fullWindowDrag ? 1 : 0); + out.writeInt(menuAnimations ? 1 : 0); out.writeInt(fontSmoothing ? 1 : 0); out.writeInt(desktopComposition ? 1 : 0); - } + } } // 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 AUTOMATIC = -1; public static final int CUSTOM = 0; public static final int PREDEFINED = 1; - + private int resolution; private int colors; private int width; @@ -163,67 +160,58 @@ public class BookmarkBase implements Parcelable, Cloneable width = parcel.readInt(); height = parcel.readInt(); } - + private void init() { resolution = AUTOMATIC; colors = 16; width = 0; height = 0; } - - public void setResolution(int resolution) - { + + public void setResolution(int resolution) { this.resolution = resolution; - + if (resolution == AUTOMATIC || resolution == FITSCREEN) { width = 0; height = 0; } } - - public void setResolution(String resolution, int width, int height) - { + + public void setResolution(String resolution, int width, int height) { if (resolution.contains("x")) { String[] dimensions = resolution.split("x"); this.width = Integer.valueOf(dimensions[0]); this.height = Integer.valueOf(dimensions[1]); this.resolution = PREDEFINED; - } - else if (resolution.equalsIgnoreCase("custom")) - { - this.width = width; - this.height = height; + } else if (resolution.equalsIgnoreCase("custom")) { + this.width = width; + this.height = height; this.resolution = CUSTOM; - } - else if (resolution.equalsIgnoreCase("fitscreen")) - { + } else if (resolution.equalsIgnoreCase("fitscreen")) { this.width = this.height = 0; this.resolution = FITSCREEN; - } - else - { + } else { this.width = this.height = 0; this.resolution = AUTOMATIC; } } - public int getResolution() - { + public int getResolution() { return resolution; } - - public String getResolutionString() - { + + public String getResolutionString() { if (isPredefined()) return (width + "x" + height); - return (isFitScreen() ? "fitscreen" : isAutomatic() ? "automatic" : "custom"); + return (isFitScreen() ? "fitscreen" : isAutomatic() ? "automatic" + : "custom"); } public boolean isPredefined() { - return (resolution == PREDEFINED); + return (resolution == PREDEFINED); } - + public boolean isAutomatic() { return (resolution == AUTOMATIC); } @@ -239,29 +227,28 @@ public class BookmarkBase implements Parcelable, Cloneable public void setWidth(int width) { this.width = width; } - + public int getWidth() { return width; } - + public int getHeight() { return height; } - + public void setHeight(int height) { this.height = height; } - + public void setColors(int colors) { this.colors = colors; } - + public int getColors() { return colors; } - - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() - { + + public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { public ScreenSettings createFromParcel(Parcel in) { return new ScreenSettings(in); } @@ -278,19 +265,61 @@ public class BookmarkBase implements Parcelable, Cloneable } @Override - public void writeToParcel(Parcel out, int flags) - { + public void writeToParcel(Parcel out, int flags) { out.writeInt(resolution); out.writeInt(colors); out.writeInt(width); out.writeInt(height); - } + } } - - + + 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 CREATOR = new Parcelable.Creator() { + 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 - public static class AdvancedSettings implements Parcelable - { + public static class AdvancedSettings implements Parcelable { private boolean enable3GSettings; private ScreenSettings screen3G; private PerformanceFlags performance3G; @@ -308,17 +337,19 @@ public class BookmarkBase implements Parcelable, Cloneable public AdvancedSettings(Parcel parcel) { enable3GSettings = (parcel.readInt() == 1) ? true : false; - screen3G = parcel.readParcelable(ScreenSettings.class.getClassLoader()); - performance3G = parcel.readParcelable(PerformanceFlags.class.getClassLoader()); + screen3G = parcel.readParcelable(ScreenSettings.class + .getClassLoader()); + performance3G = parcel.readParcelable(PerformanceFlags.class + .getClassLoader()); redirectSDCard = (parcel.readInt() == 1) ? true : false; redirectSound = parcel.readInt(); redirectMicrophone = (parcel.readInt() == 1) ? true : false; security = parcel.readInt(); consoleMode = (parcel.readInt() == 1) ? true : false; remoteProgram = parcel.readString(); - workDir = parcel.readString(); + workDir = parcel.readString(); } - + private void init() { enable3GSettings = false; screen3G = new ScreenSettings(); @@ -331,11 +362,11 @@ public class BookmarkBase implements Parcelable, Cloneable remoteProgram = ""; workDir = ""; } - + public void setEnable3GSettings(boolean enable3GSettings) { this.enable3GSettings = enable3GSettings; } - + public boolean getEnable3GSettings() { return enable3GSettings; } @@ -343,81 +374,76 @@ public class BookmarkBase implements Parcelable, Cloneable public ScreenSettings getScreen3G() { return screen3G; } - + public void setScreen3G(ScreenSettings screen3G) { - this.screen3G = screen3G; + this.screen3G = screen3G; } public PerformanceFlags getPerformance3G() { return performance3G; } - + public void setPerformance3G(PerformanceFlags performance3G) { - this.performance3G = performance3G; + this.performance3G = performance3G; } public void setRedirectSDCard(boolean redirectSDCard) { this.redirectSDCard = redirectSDCard; } - + public boolean getRedirectSDCard() { return redirectSDCard; } - + public void setRedirectSound(int redirect) { this.redirectSound = redirect; } - + public int getRedirectSound() { return redirectSound; } - + public void setRedirectMicrophone(boolean redirect) { this.redirectMicrophone = redirect; } - + public boolean getRedirectMicrophone() { return redirectMicrophone; } - + public void setSecurity(int security) { this.security = security; } - + public int getSecurity() { return security; } - + public void setConsoleMode(boolean consoleMode) { this.consoleMode = consoleMode; } - + public boolean getConsoleMode() { return consoleMode; } - - public void setRemoteProgram(String remoteProgram) - { + + public void setRemoteProgram(String remoteProgram) { this.remoteProgram = remoteProgram; } - - public String getRemoteProgram() - { + + public String getRemoteProgram() { return remoteProgram; } - - public void setWorkDir(String workDir) - { + + public void setWorkDir(String workDir) { this.workDir = workDir; } - - public String getWorkDir() - { + + public String getWorkDir() { return workDir; - } - - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() - { + } + + public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { public AdvancedSettings createFromParcel(Parcel in) { return new AdvancedSettings(in); } @@ -434,23 +460,22 @@ public class BookmarkBase implements Parcelable, Cloneable } @Override - public void writeToParcel(Parcel out, int flags) - { + public void writeToParcel(Parcel out, int flags) { out.writeInt(enable3GSettings ? 1 : 0); out.writeParcelable(screen3G, flags); out.writeParcelable(performance3G, flags); out.writeInt(redirectSDCard ? 1 : 0); out.writeInt(redirectSound); out.writeInt(redirectMicrophone ? 1 : 0); - out.writeInt(security); - out.writeInt(consoleMode ? 1 : 0); + out.writeInt(security); + out.writeInt(consoleMode ? 1 : 0); out.writeString(remoteProgram); out.writeString(workDir); - } + } } - - protected int type; - private long id; + + protected int type; + private long id; private String label; private String username; private String password; @@ -459,23 +484,23 @@ public class BookmarkBase implements Parcelable, Cloneable private ScreenSettings screenSettings; private PerformanceFlags performanceFlags; private AdvancedSettings advancedSettings; - - private void init() - { + private DebugSettings debugSettings; + + private void init() { type = TYPE_INVALID; id = -1; label = ""; username = ""; password = ""; - domain = ""; - + domain = ""; + screenSettings = new ScreenSettings(); performanceFlags = new PerformanceFlags(); advancedSettings = new AdvancedSettings(); + debugSettings = new DebugSettings(); } - - public BookmarkBase(Parcel parcel) - { + + public BookmarkBase(Parcel parcel) { type = parcel.readInt(); id = parcel.readLong(); label = parcel.readString(); @@ -483,62 +508,69 @@ public class BookmarkBase implements Parcelable, Cloneable password = parcel.readString(); domain = parcel.readString(); - screenSettings = parcel.readParcelable(ScreenSettings.class.getClassLoader()); - performanceFlags = parcel.readParcelable(PerformanceFlags.class.getClassLoader()); - advancedSettings = parcel.readParcelable(AdvancedSettings.class.getClassLoader()); + screenSettings = parcel.readParcelable(ScreenSettings.class + .getClassLoader()); + performanceFlags = parcel.readParcelable(PerformanceFlags.class + .getClassLoader()); + advancedSettings = parcel.readParcelable(AdvancedSettings.class + .getClassLoader()); + debugSettings = parcel.readParcelable(DebugSettings.class + .getClassLoader()); } - + public BookmarkBase() { init(); } @SuppressWarnings("unchecked") - public T get() { return (T)this; } + public T get() { + return (T) this; + } public int getType() { return type; } - + public void setId(long id) { this.id = id; } - + public long getId() { return id; } - + public void setLabel(String label) { this.label = label; } - + public String getLabel() { return label; } - + public void setUsername(String username) { this.username = username; } - + public String getUsername() { return username; } - + public void setPassword(String password) { this.password = password; } - + public String getPassword() { return password; } - + public void setDomain(String domain) { this.domain = domain; } - + public String getDomain() { return domain; } - + public void setScreenSettings(ScreenSettings screenSettings) { this.screenSettings = screenSettings; } @@ -550,11 +582,11 @@ public class BookmarkBase implements Parcelable, Cloneable public void setPerformanceFlags(PerformanceFlags performanceFlags) { this.performanceFlags = performanceFlags; } - + public PerformanceFlags getPerformanceFlags() { return performanceFlags; } - + public void setAdvancedSettings(AdvancedSettings advancedSettings) { this.advancedSettings = advancedSettings; } @@ -562,19 +594,28 @@ public class BookmarkBase implements Parcelable, Cloneable public AdvancedSettings getAdvancedSettings() { return advancedSettings; } - - public ScreenSettings getActiveScreenSettings() - { - return (GlobalApp.ConnectedTo3G && advancedSettings.getEnable3GSettings()) ? advancedSettings.getScreen3G() : screenSettings; - } - - public PerformanceFlags getActivePerformanceFlags() - { - return (GlobalApp.ConnectedTo3G && advancedSettings.getEnable3GSettings()) ? advancedSettings.getPerformance3G() : performanceFlags; + + public void setDebugSettings(DebugSettings debugSettings) { + this.debugSettings = debugSettings; } - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() - { + public DebugSettings getDebugSettings() { + return debugSettings; + } + + 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 CREATOR = new Parcelable.Creator() { public BookmarkBase createFromParcel(Parcel in) { return new BookmarkBase(in); } @@ -584,15 +625,14 @@ public class BookmarkBase implements Parcelable, Cloneable return new BookmarkBase[size]; } }; - + @Override public int describeContents() { return 0; } @Override - public void writeToParcel(Parcel out, int flags) - { + public void writeToParcel(Parcel out, int flags) { out.writeInt(type); out.writeLong(id); out.writeString(label); @@ -603,11 +643,14 @@ public class BookmarkBase implements Parcelable, Cloneable out.writeParcelable(screenSettings, flags); out.writeParcelable(performanceFlags, flags); out.writeParcelable(advancedSettings, flags); + out.writeParcelable(debugSettings, flags); } // write to shared preferences - public void writeToSharedPreferences(SharedPreferences sharedPrefs) - { + public void writeToSharedPreferences(SharedPreferences sharedPrefs) { + + Locale locale = Locale.ENGLISH; + SharedPreferences.Editor editor = sharedPrefs.edit(); editor.clear(); editor.putString("bookmark.label", label); @@ -616,95 +659,151 @@ public class BookmarkBase implements Parcelable, Cloneable editor.putString("bookmark.domain", domain); 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.height", screenSettings.getHeight()); - editor.putBoolean("bookmark.perf_remotefx", performanceFlags.getRemoteFX()); - editor.putBoolean("bookmark.perf_wallpaper", performanceFlags.getWallpaper()); - editor.putBoolean("bookmark.perf_font_smoothing", 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_remotefx", + performanceFlags.getRemoteFX()); + editor.putBoolean("bookmark.perf_wallpaper", + performanceFlags.getWallpaper()); + editor.putBoolean("bookmark.perf_font_smoothing", + 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.enable_3g_settings", advancedSettings.getEnable3GSettings()); - editor.putInt("bookmark.colors_3g", advancedSettings.getScreen3G().getColors()); - editor.putString("bookmark.resolution_3g", advancedSettings.getScreen3G().getResolutionString().toLowerCase()); - editor.putInt("bookmark.width_3g", advancedSettings.getScreen3G().getWidth()); - editor.putInt("bookmark.height_3g", advancedSettings.getScreen3G().getHeight()); + editor.putBoolean("bookmark.enable_3g_settings", + advancedSettings.getEnable3GSettings()); - editor.putBoolean("bookmark.perf_remotefx_3g", advancedSettings.getPerformance3G().getRemoteFX()); - editor.putBoolean("bookmark.perf_wallpaper_3g", advancedSettings.getPerformance3G().getWallpaper()); - editor.putBoolean("bookmark.perf_font_smoothing_3g", advancedSettings.getPerformance3G().getFontSmoothing()); - 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.putInt("bookmark.colors_3g", advancedSettings.getScreen3G() + .getColors()); + editor.putString("bookmark.resolution_3g", advancedSettings + .getScreen3G().getResolutionString().toLowerCase(locale)); + editor.putInt("bookmark.width_3g", advancedSettings.getScreen3G() + .getWidth()); + editor.putInt("bookmark.height_3g", advancedSettings.getScreen3G() + .getHeight()); - editor.putBoolean("bookmark.redirect_sdcard", advancedSettings.getRedirectSDCard()); - editor.putInt("bookmark.redirect_sound", advancedSettings.getRedirectSound()); - editor.putBoolean("bookmark.redirect_microphone", advancedSettings.getRedirectMicrophone()); + editor.putBoolean("bookmark.perf_remotefx_3g", advancedSettings + .getPerformance3G().getRemoteFX()); + editor.putBoolean("bookmark.perf_wallpaper_3g", advancedSettings + .getPerformance3G().getWallpaper()); + editor.putBoolean("bookmark.perf_font_smoothing_3g", advancedSettings + .getPerformance3G().getFontSmoothing()); + 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.putInt("bookmark.redirect_sound", + advancedSettings.getRedirectSound()); + editor.putBoolean("bookmark.redirect_microphone", + advancedSettings.getRedirectMicrophone()); 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.putBoolean("bookmark.console_mode", advancedSettings.getConsoleMode()); + editor.putBoolean("bookmark.console_mode", + advancedSettings.getConsoleMode()); + + editor.putInt("bookmark.debug_level", + debugSettings.getDebugLevel()); editor.commit(); } // read from shared preferences - public void readFromSharedPreferences(SharedPreferences sharedPrefs) - { + public void readFromSharedPreferences(SharedPreferences sharedPrefs) { label = sharedPrefs.getString("bookmark.label", ""); username = sharedPrefs.getString("bookmark.username", ""); password = sharedPrefs.getString("bookmark.password", ""); domain = sharedPrefs.getString("bookmark.domain", ""); 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.setWallpaper(sharedPrefs.getBoolean("bookmark.perf_wallpaper", false)); - performanceFlags.setFontSmoothing(sharedPrefs.getBoolean("bookmark.perf_font_smoothing", 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)); + performanceFlags.setRemoteFX(sharedPrefs.getBoolean( + "bookmark.perf_remotefx", false)); + performanceFlags.setWallpaper(sharedPrefs.getBoolean( + "bookmark.perf_wallpaper", false)); + performanceFlags.setFontSmoothing(sharedPrefs.getBoolean( + "bookmark.perf_font_smoothing", 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.getScreen3G().setColors( + sharedPrefs.getInt("bookmark.colors_3g", 16)); + 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().setWallpaper( + sharedPrefs.getBoolean("bookmark.perf_wallpaper_3g", false)); + advancedSettings.getPerformance3G().setFontSmoothing( + sharedPrefs + .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.setRedirectSound(sharedPrefs.getInt( + "bookmark.redirect_sound", 0)); + advancedSettings.setRedirectMicrophone(sharedPrefs.getBoolean( + "bookmark.redirect_microphone", 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)); - advancedSettings.setEnable3GSettings(sharedPrefs.getBoolean("bookmark.enable_3g_settings", false)); - - advancedSettings.getScreen3G().setColors(sharedPrefs.getInt("bookmark.colors_3g", 16)); - 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().setWallpaper(sharedPrefs.getBoolean("bookmark.perf_wallpaper_3g", false)); - advancedSettings.getPerformance3G().setFontSmoothing(sharedPrefs.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.setRedirectSound(sharedPrefs.getInt("bookmark.redirect_sound", 0)); - advancedSettings.setRedirectMicrophone(sharedPrefs.getBoolean("bookmark.redirect_microphone", 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 - public Object clone() - { - try - { - return super.clone(); - } - catch(CloneNotSupportedException e) - { + public Object clone() { + try { + return super.clone(); + } catch (CloneNotSupportedException e) { return null; } } diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/BookmarkActivity.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/BookmarkActivity.java index ca5b8f4ac..e3381f02b 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/BookmarkActivity.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/BookmarkActivity.java @@ -5,12 +5,13 @@ 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 com.freerdp.freerdpcore.presentation; import java.io.File; import java.io.IOException; +import java.util.ArrayList; import com.freerdp.freerdpcore.R; 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.services.BookmarkBaseGateway; import com.freerdp.freerdpcore.utils.RDPFileParser; +import com.freerdp.freerdpcore.utils.BuildConfiguration; import android.app.AlertDialog; import android.content.ComponentName; @@ -29,11 +31,12 @@ import android.os.Bundle; import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceActivity; +import android.preference.PreferenceCategory; import android.util.Log; -public class BookmarkActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener -{ - public static final String PARAM_CONNECTION_REFERENCE = "conRef"; +public class BookmarkActivity extends PreferenceActivity implements + OnSharedPreferenceChangeListener { + public static final String PARAM_CONNECTION_REFERENCE = "conRef"; private static final String TAG = "BookmarkActivity"; @@ -46,172 +49,174 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref private static final int PREFERENCES_SCREEN3G = 6; private static final int PREFERENCES_PERFORMANCE3G = 7; 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 - // (we have to do this because Android has a bug where the style for Preferences + // bookmark needs to be static because the activity is started for each + // 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) private static BookmarkBase bookmark = null; - + private static boolean settings_changed = false; private static boolean new_bookmark = false; - + @Override - public void onCreate(Bundle savedInstanceState) - { + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // init shared preferences for activity getPreferenceManager().setSharedPreferencesName("TEMP"); 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 - Bundle bundle = getIntent().getExtras(); - if(bundle != null) - { + Bundle bundle = getIntent().getExtras(); + if (bundle != null) { // See if we got a connection reference to a bookmark - if(bundle.containsKey(PARAM_CONNECTION_REFERENCE)) - { - String refStr = bundle.getString(PARAM_CONNECTION_REFERENCE); - if(ConnectionReference.isManualBookmarkReference(refStr)) - { - bookmark = GlobalApp.getManualBookmarkGateway().findById(ConnectionReference.getManualBookmarkId(refStr)); + if (bundle.containsKey(PARAM_CONNECTION_REFERENCE)) { + String refStr = bundle + .getString(PARAM_CONNECTION_REFERENCE); + if (ConnectionReference.isManualBookmarkReference(refStr)) { + bookmark = GlobalApp.getManualBookmarkGateway() + .findById( + ConnectionReference + .getManualBookmarkId(refStr)); new_bookmark = false; - } - else if(ConnectionReference.isHostnameReference(refStr)) - { + } else if (ConnectionReference.isHostnameReference(refStr)) { bookmark = new ManualBookmark(); - bookmark.get().setLabel(ConnectionReference.getHostname(refStr)); - bookmark.get().setHostname(ConnectionReference.getHostname(refStr)); + bookmark. get().setLabel( + ConnectionReference.getHostname(refStr)); + bookmark. get().setHostname( + ConnectionReference.getHostname(refStr)); new_bookmark = true; - } - else if (ConnectionReference.isFileReference(refStr)) - { + } else if (ConnectionReference.isFileReference(refStr)) { String file = ConnectionReference.getFile(refStr); bookmark = new ManualBookmark(); bookmark.setLabel(file); - try - { + try { RDPFileParser rdpFile = new RDPFileParser(file); - updateBookmarkFromFile((ManualBookmark)bookmark, rdpFile); - + updateBookmarkFromFile((ManualBookmark) bookmark, + rdpFile); + bookmark.setLabel(new File(file).getName()); new_bookmark = true; - } - catch (IOException e) - { + } catch (IOException e) { Log.e(TAG, "Failed reading RDP file", e); } } - } - } + } + } // last chance - ensure we really have a valid bookmark - if(bookmark == null) - bookmark = new ManualBookmark(); + if (bookmark == null) + bookmark = new ManualBookmark(); // hide gateway settings if we edit a non-manual bookmark - if (current_preferences == PREFERENCES_ADVANCED && bookmark.getType() != ManualBookmark.TYPE_MANUAL) - { - getPreferenceScreen().removePreference(findPreference("bookmark.enable_gateway")); - getPreferenceScreen().removePreference(findPreference("bookmark.gateway")); + if (current_preferences == PREFERENCES_ADVANCED + && bookmark.getType() != ManualBookmark.TYPE_MANUAL) { + getPreferenceScreen().removePreference( + findPreference("bookmark.enable_gateway")); + getPreferenceScreen().removePreference( + findPreference("bookmark.gateway")); } - + // update preferences from bookmark - bookmark.writeToSharedPreferences(getPreferenceManager().getSharedPreferences()); - + bookmark.writeToSharedPreferences(getPreferenceManager() + .getSharedPreferences()); + // no settings changed yet settings_changed = false; } - + // load the requested settings resource - if (getIntent() == null || getIntent().getData() == null) - { + if (getIntent() == null || getIntent().getData() == null) { addPreferencesFromResource(R.xml.bookmark_settings); - current_preferences = PREFERENCES_BOOKMARK; - } - else if (getIntent().getData().toString().equals("preferences://screen_settings")) - { + current_preferences = PREFERENCES_BOOKMARK; + } else if (getIntent().getData().toString() + .equals("preferences://screen_settings")) { addPreferencesFromResource(R.xml.screen_settings); current_preferences = PREFERENCES_SCREEN; - } - else if (getIntent().getData().toString().equals("preferences://performance_flags")) - { + } else if (getIntent().getData().toString() + .equals("preferences://performance_flags")) { addPreferencesFromResource(R.xml.performance_flags); current_preferences = PREFERENCES_PERFORMANCE; - } - else if (getIntent().getData().toString().equals("preferences://screen_settings_3g")) - { + } else if (getIntent().getData().toString() + .equals("preferences://screen_settings_3g")) { addPreferencesFromResource(R.xml.screen_settings_3g); current_preferences = PREFERENCES_SCREEN3G; - } - else if (getIntent().getData().toString().equals("preferences://performance_flags_3g")) - { + } else if (getIntent().getData().toString() + .equals("preferences://performance_flags_3g")) { addPreferencesFromResource(R.xml.performance_flags_3g); current_preferences = PREFERENCES_PERFORMANCE3G; - } - else if (getIntent().getData().toString().equals("preferences://advanced_settings")) - { + } else if (getIntent().getData().toString() + .equals("preferences://advanced_settings")) { addPreferencesFromResource(R.xml.advanced_settings); current_preferences = PREFERENCES_ADVANCED; - } - else if (getIntent().getData().toString().equals("preferences://credentials_settings")) - { + } else if (getIntent().getData().toString() + .equals("preferences://credentials_settings")) { addPreferencesFromResource(R.xml.credentials_settings); current_preferences = PREFERENCES_CREDENTIALS; - } - else if (getIntent().getData().toString().equals("preferences://gateway_settings")) - { + } else if (getIntent().getData().toString() + .equals("preferences://gateway_settings")) { addPreferencesFromResource(R.xml.gateway_settings); current_preferences = PREFERENCES_GATEWAY; - } - else - { + } else if (getIntent().getData().toString() + .equals("preferences://debug_settings")) { + addPreferencesFromResource(R.xml.debug_settings); + current_preferences = PREFERENCES_DEBUG; + } else { addPreferencesFromResource(R.xml.bookmark_settings); 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 - initSettings(getPreferenceManager().getSharedPreferences()); + SharedPreferences spref = getPreferenceManager().getSharedPreferences(); + initSettings(spref); // register for preferences changed notification - getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); - - // set the correct component names in our preferencescreen settings + getPreferenceManager().getSharedPreferences() + .registerOnSharedPreferenceChangeListener(this); + + // set the correct component names in our preferencescreen settings setIntentComponentNames(); } - private void updateBookmarkFromFile(ManualBookmark bookmark, RDPFileParser rdpFile) - { + private void updateBookmarkFromFile(ManualBookmark bookmark, + RDPFileParser rdpFile) { String s; Integer i; - + s = rdpFile.getString("full address"); - if (s != null) - { + if (s != null) { // this gets complicated as it can include port - if (s.lastIndexOf(":") > s.lastIndexOf("]")) - { - try - { + if (s.lastIndexOf(":") > s.lastIndexOf("]")) { + try { String port = s.substring(s.lastIndexOf(":") + 1); bookmark.setPort(Integer.parseInt(port)); - } - catch (NumberFormatException e) - { + } catch (NumberFormatException e) { Log.e(TAG, "Malformed address"); } - + s = s.substring(0, s.lastIndexOf(":")); } - + // or even be an ipv6 address if (s.startsWith("[") && s.endsWith("]")) s = s.substring(1, s.length() - 1); - + bookmark.setHostname(s); } @@ -226,400 +231,441 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref s = rdpFile.getString("domain"); if (s != null) bookmark.setDomain(s); - + i = rdpFile.getInteger("connect to console"); if (i != null) bookmark.getAdvancedSettings().setConsoleMode(i == 1); } - private void setIntentComponentNames() - { - // we set the component name for our sub-activity calls here because we don't know the package - // name of the main app in our library project. - ComponentName compName = new ComponentName(getPackageName(), BookmarkActivity.class.getName()); - String[] prefKeys = { - "bookmark.credentials", - "bookmark.screen", - "bookmark.performance", - "bookmark.advanced", - "bookmark.screen_3g", - "bookmark.performance_3g", - "bookmark.gateway_settings" - }; - - for (int i = 0; i < prefKeys.length; ++i) - { - Preference pref = findPreference(prefKeys[i]); + private void setIntentComponentNames() { + // we set the component name for our sub-activity calls here because we + // don't know the package + // name of the main app in our library project. + ComponentName compName = new ComponentName(getPackageName(), + BookmarkActivity.class.getName()); + ArrayList prefKeys = new ArrayList(); + + prefKeys.add("bookmark.credentials"); + prefKeys.add("bookmark.screen"); + 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) - pref.getIntent().setComponent(compName); + pref.getIntent().setComponent(compName); } - - } - + @Override - public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { + public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, + String key) { settings_changed = true; - switch (current_preferences) - { - case PREFERENCES_BOOKMARK: - bookmarkSettingsChanged(sharedPreferences, key); - break; - - case PREFERENCES_ADVANCED: - advancedSettingsChanged(sharedPreferences, key); - break; - - case PREFERENCES_CREDENTIALS: - credentialsSettingsChanged(sharedPreferences, key); - break; - - case PREFERENCES_SCREEN: - case PREFERENCES_SCREEN3G: - screenSettingsChanged(sharedPreferences, key); - break; + switch (current_preferences) { + case PREFERENCES_DEBUG: + debugSettingsChanged(sharedPreferences, key); + break; - case PREFERENCES_GATEWAY: - gatewaySettingsChanged(sharedPreferences, key); - break; + case PREFERENCES_BOOKMARK: + bookmarkSettingsChanged(sharedPreferences, key); + break; + + case PREFERENCES_ADVANCED: + advancedSettingsChanged(sharedPreferences, key); + break; + + case PREFERENCES_CREDENTIALS: + credentialsSettingsChanged(sharedPreferences, key); + break; + + case PREFERENCES_SCREEN: + case PREFERENCES_SCREEN3G: + screenSettingsChanged(sharedPreferences, key); + break; + + case PREFERENCES_GATEWAY: + gatewaySettingsChanged(sharedPreferences, key); + break; + + default: + break; } - + } - private void initSettings(SharedPreferences sharedPreferences) - { - switch (current_preferences) - { - case PREFERENCES_BOOKMARK: - initBookmarkSettings(sharedPreferences); - break; - - case PREFERENCES_ADVANCED: - initAdvancedSettings(sharedPreferences); - break; - - case PREFERENCES_CREDENTIALS: - initCredentialsSettings(sharedPreferences); - break; - - case PREFERENCES_SCREEN: - initScreenSettings(sharedPreferences); - break; + private void initSettings(SharedPreferences sharedPreferences) { + switch (current_preferences) { + case PREFERENCES_BOOKMARK: + initBookmarkSettings(sharedPreferences); + break; - case PREFERENCES_SCREEN3G: - initScreenSettings3G(sharedPreferences); - break; - - case PREFERENCES_GATEWAY: - initGatewaySettings(sharedPreferences); - break; - } + case PREFERENCES_ADVANCED: + initAdvancedSettings(sharedPreferences); + break; + + case PREFERENCES_CREDENTIALS: + initCredentialsSettings(sharedPreferences); + break; + + case PREFERENCES_SCREEN: + initScreenSettings(sharedPreferences); + break; + + case PREFERENCES_SCREEN3G: + initScreenSettings3G(sharedPreferences); + break; + + case PREFERENCES_GATEWAY: + initGatewaySettings(sharedPreferences); + break; + + case PREFERENCES_DEBUG: + initDebugSettings(sharedPreferences); + break; + + default: + break; + } } - - private void initBookmarkSettings(SharedPreferences sharedPreferences) - { - bookmarkSettingsChanged(sharedPreferences, "bookmark.label"); - bookmarkSettingsChanged(sharedPreferences, "bookmark.hostname"); - bookmarkSettingsChanged(sharedPreferences, "bookmark.port"); - bookmarkSettingsChanged(sharedPreferences, "bookmark.username"); + + private void initBookmarkSettings(SharedPreferences sharedPreferences) { + bookmarkSettingsChanged(sharedPreferences, "bookmark.label"); + bookmarkSettingsChanged(sharedPreferences, "bookmark.hostname"); + bookmarkSettingsChanged(sharedPreferences, "bookmark.port"); + bookmarkSettingsChanged(sharedPreferences, "bookmark.username"); 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) - findPreference(key).setSummary(sharedPreferences.getString(key, "")); + findPreference(key) + .setSummary(sharedPreferences.getString(key, "")); 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) - findPreference(key).setSummary(String.valueOf(sharedPreferences.getInt(key, -1))); - else if (key.equals("bookmark.username")) - { + findPreference(key).setSummary( + String.valueOf(sharedPreferences.getInt(key, -1))); + else if (key.equals("bookmark.username")) { String username = sharedPreferences.getString(key, ""); if (username.length() == 0) username = ""; - findPreference("bookmark.credentials").setSummary(username); - } - else if (key.equals("bookmark.resolution") || key.equals("bookmark.colors") || key.equals("bookmark.width") || key.equals("bookmark.height")) - { - String resolution = sharedPreferences.getString("bookmark.resolution", "800x600"); - //compare english string from resolutions_values_array array, decode to localized - //text for display + findPreference("bookmark.credentials").setSummary(username); + } else if (key.equals("bookmark.resolution") + || key.equals("bookmark.colors") + || key.equals("bookmark.width") + || key.equals("bookmark.height")) { + String resolution = sharedPreferences.getString( + "bookmark.resolution", "800x600"); + // compare english string from resolutions_values_array array, + // decode to localized + // text for display if (resolution.equals("automatic")) { - resolution = getResources().getString(R.string.resolution_automatic); + resolution = getResources().getString( + R.string.resolution_automatic); } if (resolution.equals("custom")) { - resolution = getResources().getString(R.string.resolution_custom); + resolution = getResources().getString( + R.string.resolution_custom); } if (resolution.equals("fitscreen")) { resolution = getResources().getString(R.string.resolution_fit); } resolution += "@" + sharedPreferences.getInt("bookmark.colors", 16); - findPreference("bookmark.screen").setSummary(resolution); + findPreference("bookmark.screen").setSummary(resolution); } } - private void initAdvancedSettings(SharedPreferences sharedPreferences) - { - advancedSettingsChanged(sharedPreferences, "bookmark.enable_gateway_settings"); - advancedSettingsChanged(sharedPreferences, "bookmark.enable_3g_settings"); - advancedSettingsChanged(sharedPreferences, "bookmark.security"); - advancedSettingsChanged(sharedPreferences, "bookmark.resolution_3g"); - advancedSettingsChanged(sharedPreferences, "bookmark.remote_program"); - advancedSettingsChanged(sharedPreferences, "bookmark.work_dir"); + private void initAdvancedSettings(SharedPreferences sharedPreferences) { + advancedSettingsChanged(sharedPreferences, + "bookmark.enable_gateway_settings"); + advancedSettingsChanged(sharedPreferences, + "bookmark.enable_3g_settings"); + advancedSettingsChanged(sharedPreferences, "bookmark.security"); + advancedSettingsChanged(sharedPreferences, "bookmark.resolution_3g"); + advancedSettingsChanged(sharedPreferences, "bookmark.remote_program"); + advancedSettingsChanged(sharedPreferences, "bookmark.work_dir"); } - private void advancedSettingsChanged(SharedPreferences sharedPreferences, String key) - { - if (key.equals("bookmark.enable_gateway_settings")) - { - boolean enabled = sharedPreferences.getBoolean(key, false); - findPreference("bookmark.gateway_settings").setEnabled(enabled); - } - else if (key.equals("bookmark.enable_3g_settings")) - { + private void advancedSettingsChanged(SharedPreferences sharedPreferences, + String key) { + if (key.equals("bookmark.enable_gateway_settings")) { + boolean enabled = sharedPreferences.getBoolean(key, false); + findPreference("bookmark.gateway_settings").setEnabled(enabled); + } else if (key.equals("bookmark.enable_3g_settings")) { boolean enabled = sharedPreferences.getBoolean(key, false); findPreference("bookmark.screen_3g").setEnabled(enabled); findPreference("bookmark.performance_3g").setEnabled(enabled); - } - else if (key.equals("bookmark.security")) - { - ListPreference listPreference = (ListPreference)findPreference(key); - CharSequence security = listPreference.getEntries()[sharedPreferences.getInt(key, 0)]; - listPreference.setSummary(security); - } - else if (key.equals("bookmark.resolution_3g") || key.equals("bookmark.colors_3g") || key.equals("bookmark.width_3g") || key.equals("bookmark.height_3g")) - { - String resolution = sharedPreferences.getString("bookmark.resolution_3g", "800x600"); + } else if (key.equals("bookmark.security")) { + ListPreference listPreference = (ListPreference) findPreference(key); + CharSequence security = listPreference.getEntries()[sharedPreferences + .getInt(key, 0)]; + listPreference.setSummary(security); + } else if (key.equals("bookmark.resolution_3g") + || key.equals("bookmark.colors_3g") + || key.equals("bookmark.width_3g") + || key.equals("bookmark.height_3g")) { + String resolution = sharedPreferences.getString( + "bookmark.resolution_3g", "800x600"); if (resolution.equals("automatic")) - resolution = getResources().getString(R.string.resolution_automatic); + resolution = getResources().getString( + R.string.resolution_automatic); else if (resolution.equals("custom")) - resolution = getResources().getString(R.string.resolution_custom); - resolution += "@" + sharedPreferences.getInt("bookmark.colors_3g", 16); - findPreference("bookmark.screen_3g").setSummary(resolution); - } - else if (key.equals("bookmark.remote_program")) - findPreference(key).setSummary(sharedPreferences.getString(key, "")); + resolution = getResources().getString( + R.string.resolution_custom); + resolution += "@" + + sharedPreferences.getInt("bookmark.colors_3g", 16); + findPreference("bookmark.screen_3g").setSummary(resolution); + } else if (key.equals("bookmark.remote_program")) + findPreference(key) + .setSummary(sharedPreferences.getString(key, "")); else if (key.equals("bookmark.work_dir")) - findPreference(key).setSummary(sharedPreferences.getString(key, "")); + findPreference(key) + .setSummary(sharedPreferences.getString(key, "")); } - private void initCredentialsSettings(SharedPreferences sharedPreferences) - { - credentialsSettingsChanged(sharedPreferences, "bookmark.username"); - credentialsSettingsChanged(sharedPreferences, "bookmark.password"); - credentialsSettingsChanged(sharedPreferences, "bookmark.domain"); + private void initCredentialsSettings(SharedPreferences sharedPreferences) { + credentialsSettingsChanged(sharedPreferences, "bookmark.username"); + credentialsSettingsChanged(sharedPreferences, "bookmark.password"); + credentialsSettingsChanged(sharedPreferences, "bookmark.domain"); } - private void credentialsSettingsChanged(SharedPreferences sharedPreferences, String key) - { + private void credentialsSettingsChanged( + SharedPreferences sharedPreferences, String key) { if (key.equals("bookmark.username")) - findPreference(key).setSummary(sharedPreferences.getString(key, "")); - else if (key.equals("bookmark.password")) - { + findPreference(key) + .setSummary(sharedPreferences.getString(key, "")); + else if (key.equals("bookmark.password")) { 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 - findPreference(key).setSummary(getResources().getString(R.string.settings_password_present)); - } - else if (key.equals("bookmark.domain")) - findPreference(key).setSummary(sharedPreferences.getString(key, "")); + findPreference(key).setSummary( + getResources().getString( + R.string.settings_password_present)); + } else if (key.equals("bookmark.domain")) + findPreference(key) + .setSummary(sharedPreferences.getString(key, "")); } - private void initScreenSettings(SharedPreferences sharedPreferences) - { - screenSettingsChanged(sharedPreferences, "bookmark.colors"); - screenSettingsChanged(sharedPreferences, "bookmark.resolution"); - screenSettingsChanged(sharedPreferences, "bookmark.width"); - screenSettingsChanged(sharedPreferences, "bookmark.height"); + private void initScreenSettings(SharedPreferences sharedPreferences) { + screenSettingsChanged(sharedPreferences, "bookmark.colors"); + screenSettingsChanged(sharedPreferences, "bookmark.resolution"); + screenSettingsChanged(sharedPreferences, "bookmark.width"); + screenSettingsChanged(sharedPreferences, "bookmark.height"); } - private void initScreenSettings3G(SharedPreferences sharedPreferences) - { - screenSettingsChanged(sharedPreferences, "bookmark.colors_3g"); - screenSettingsChanged(sharedPreferences, "bookmark.resolution_3g"); - screenSettingsChanged(sharedPreferences, "bookmark.width_3g"); - screenSettingsChanged(sharedPreferences, "bookmark.height_3g"); + private void initScreenSettings3G(SharedPreferences sharedPreferences) { + screenSettingsChanged(sharedPreferences, "bookmark.colors_3g"); + screenSettingsChanged(sharedPreferences, "bookmark.resolution_3g"); + screenSettingsChanged(sharedPreferences, "bookmark.width_3g"); + screenSettingsChanged(sharedPreferences, "bookmark.height_3g"); } - private void screenSettingsChanged(SharedPreferences sharedPreferences, String key) - { - // could happen during initialization because 3g and non-3g settings share this routine - just skip + private void screenSettingsChanged(SharedPreferences sharedPreferences, + String key) { + // could happen during initialization because 3g and non-3g settings + // share this routine - just skip if (findPreference(key) == null) return; - - if (key.equals("bookmark.colors") || key.equals("bookmark.colors_3g")) - { - ListPreference listPreference = (ListPreference)findPreference(key); - listPreference.setSummary(listPreference.getEntry()); - } - else if (key.equals("bookmark.resolution") || key.equals("bookmark.resolution_3g")) - { - ListPreference listPreference = (ListPreference)findPreference(key); - listPreference.setSummary(listPreference.getEntry()); - - boolean enabled = listPreference.getValue().equalsIgnoreCase(getResources().getString(R.string.resolution_custom)); - if (key.equals("bookmark.resolution")) - { - findPreference("bookmark.width").setEnabled(enabled); - findPreference("bookmark.height").setEnabled(enabled); + + if (key.equals("bookmark.colors") || key.equals("bookmark.colors_3g")) { + ListPreference listPreference = (ListPreference) findPreference(key); + listPreference.setSummary(listPreference.getEntry()); + } else if (key.equals("bookmark.resolution") + || key.equals("bookmark.resolution_3g")) { + ListPreference listPreference = (ListPreference) findPreference(key); + listPreference.setSummary(listPreference.getEntry()); + + boolean enabled = listPreference.getValue().equalsIgnoreCase( + getResources().getString(R.string.resolution_custom)); + if (key.equals("bookmark.resolution")) { + findPreference("bookmark.width").setEnabled(enabled); + findPreference("bookmark.height").setEnabled(enabled); + } else { + findPreference("bookmark.width_3g").setEnabled(enabled); + findPreference("bookmark.height_3g").setEnabled(enabled); } - else - { - findPreference("bookmark.width_3g").setEnabled(enabled); - findPreference("bookmark.height_3g").setEnabled(enabled); - } - } - else if (key.equals("bookmark.width") || key.equals("bookmark.width_3g")) - findPreference(key).setSummary(String.valueOf(sharedPreferences.getInt(key, 800))); - else if (key.equals("bookmark.height") || key.equals("bookmark.height_3g")) - findPreference(key).setSummary(String.valueOf(sharedPreferences.getInt(key, 600))); + } else if (key.equals("bookmark.width") + || key.equals("bookmark.width_3g")) + findPreference(key).setSummary( + String.valueOf(sharedPreferences.getInt(key, 800))); + else if (key.equals("bookmark.height") + || key.equals("bookmark.height_3g")) + findPreference(key).setSummary( + String.valueOf(sharedPreferences.getInt(key, 600))); + } + + private void initDebugSettings(SharedPreferences sharedPreferences) { + debugSettingsChanged(sharedPreferences, "bookmark.debug_level"); + } + + private void initGatewaySettings(SharedPreferences sharedPreferences) { + 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 debugSettingsChanged(SharedPreferences sharedPreferences, + String key) { + if (key.equals("bookmark.debug_level")) { + int level = sharedPreferences.getInt(key, 0); + Preference pref = findPreference("bookmark.debug_level"); + pref.setDefaultValue(level); + } + } + + private void gatewaySettingsChanged(SharedPreferences sharedPreferences, + String key) { + if (key.equals("bookmark.gateway_hostname")) { + 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 void initGatewaySettings(SharedPreferences sharedPreferences) - { - 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) - { - if (key.equals("bookmark.gateway_hostname")) - { - 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) { - + boolean verifyFailed = false; - // perform sanity checks on settings - // Label set + // perform sanity checks on settings + // Label set if (sharedPreferences.getString("bookmark.label", "").length() == 0) - verifyFailed = true; + verifyFailed = true; - // Server and port specified - if (!verifyFailed && sharedPreferences.getString("bookmark.hostname", "").length() == 0) - verifyFailed = true; + // Server and port specified + if (!verifyFailed + && sharedPreferences.getString("bookmark.hostname", "") + .length() == 0) + verifyFailed = true; - // Server and port specified + // Server and port specified if (!verifyFailed && sharedPreferences.getInt("bookmark.port", -1) <= 0) - verifyFailed = true; + verifyFailed = true; - // if an error occured - display toast and return false + // if an error occured - display toast and return false return (!verifyFailed); } - - private void finishAndResetBookmark() - { + + private void finishAndResetBookmark() { bookmark = null; - getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this); + getPreferenceManager().getSharedPreferences() + .unregisterOnSharedPreferenceChangeListener(this); finish(); } - - @Override - public void onBackPressed() - { - // only proceed if we are in the main preferences screen - if (current_preferences != PREFERENCES_BOOKMARK) - { - super.onBackPressed(); - getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this); - return; - } - - SharedPreferences sharedPreferences = getPreferenceManager().getSharedPreferences(); - if(!verifySettings(sharedPreferences)) - { - // ask the user if he wants to cancel or continue editing - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(R.string.error_bookmark_incomplete_title) - .setMessage(R.string.error_bookmark_incomplete) - .setPositiveButton(R.string.cancel, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - finishAndResetBookmark(); - } - }) - .setNegativeButton(R.string.cont, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.cancel(); - } - }) - .show(); + @Override + public void onBackPressed() { + // only proceed if we are in the main preferences screen + if (current_preferences != PREFERENCES_BOOKMARK) { + super.onBackPressed(); + getPreferenceManager().getSharedPreferences() + .unregisterOnSharedPreferenceChangeListener(this); return; } - else - { - // ask the user if he wants to save or cancel editing if a setting has changed - if (new_bookmark || settings_changed) - { + + SharedPreferences sharedPreferences = getPreferenceManager() + .getSharedPreferences(); + if (!verifySettings(sharedPreferences)) { + // ask the user if he wants to cancel or continue editing + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(R.string.error_bookmark_incomplete_title) + .setMessage(R.string.error_bookmark_incomplete) + .setPositiveButton(R.string.cancel, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, + int which) { + finishAndResetBookmark(); + } + }) + .setNegativeButton(R.string.cont, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, + int which) { + dialog.cancel(); + } + }).show(); + + return; + } else { + // ask the user if he wants to save or cancel editing if a setting + // has changed + if (new_bookmark || settings_changed) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.dlg_title_save_bookmark) - .setMessage(R.string.dlg_save_bookmark) - .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - // read shared prefs back to bookmark - bookmark.readFromSharedPreferences(getPreferenceManager().getSharedPreferences()); - - BookmarkBaseGateway bookmarkGateway; - if(bookmark.getType() == BookmarkBase.TYPE_MANUAL) - { - bookmarkGateway = GlobalApp.getManualBookmarkGateway(); - // remove any history entry for this bookmark - GlobalApp.getQuickConnectHistoryGateway().removeHistoryItem(bookmark.get().getHostname()); - } - else - { - assert false; - return; - } - - // insert or update bookmark and leave activity - if(bookmark.getId() > 0) - bookmarkGateway.update(bookmark); - else - bookmarkGateway.insert(bookmark); + .setMessage(R.string.dlg_save_bookmark) + .setPositiveButton(R.string.yes, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, + int which) { + // read shared prefs back to bookmark + bookmark.readFromSharedPreferences(getPreferenceManager() + .getSharedPreferences()); - finishAndResetBookmark(); - } - }) - .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - finishAndResetBookmark(); - } - }) - .show(); + BookmarkBaseGateway bookmarkGateway; + if (bookmark.getType() == BookmarkBase.TYPE_MANUAL) { + bookmarkGateway = GlobalApp + .getManualBookmarkGateway(); + // remove any history entry for this + // bookmark + GlobalApp + .getQuickConnectHistoryGateway() + .removeHistoryItem( + bookmark. get() + .getHostname()); + } else { + assert false; + return; + } + + // insert or update bookmark and leave + // activity + if (bookmark.getId() > 0) + bookmarkGateway.update(bookmark); + else + bookmarkGateway.insert(bookmark); + + finishAndResetBookmark(); + } + }) + .setNegativeButton(R.string.no, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, + int which) { + finishAndResetBookmark(); + } + }).show(); + } else { + finishAndResetBookmark(); } - else - { - finishAndResetBookmark(); - } - } + } } } diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkBaseGateway.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkBaseGateway.java index 593cecdf8..70f9d1717 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkBaseGateway.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkBaseGateway.java @@ -70,6 +70,8 @@ public abstract class BookmarkBaseGateway values.put("console_mode", bookmark.getAdvancedSettings().getConsoleMode()); values.put("remote_program", bookmark.getAdvancedSettings().getRemoteProgram()); values.put("work_dir", bookmark.getAdvancedSettings().getWorkDir()); + + values.put("debug_level", bookmark.getDebugSettings().getDebugLevel()); // add any special columns addBookmarkSpecificColumns(bookmark, values); @@ -109,6 +111,8 @@ public abstract class BookmarkBaseGateway values.put("remote_program", bookmark.getAdvancedSettings().getRemoteProgram()); values.put("work_dir", bookmark.getAdvancedSettings().getWorkDir()); + values.put("debug_level", bookmark.getDebugSettings().getDebugLevel()); + addBookmarkSpecificColumns(bookmark, values); // update bookmark @@ -229,6 +233,9 @@ public abstract class BookmarkBaseGateway columns.add("console_mode"); columns.add("remote_program"); columns.add("work_dir"); + + // debug settings + columns.add("debug_level"); addBookmarkSpecificColumns(columns); } @@ -290,6 +297,8 @@ public abstract class BookmarkBaseGateway bookmark.getAdvancedSettings().setRemoteProgram(cursor.getString(cursor.getColumnIndex("remote_program"))); bookmark.getAdvancedSettings().setWorkDir(cursor.getString(cursor.getColumnIndex("work_dir"))); + bookmark.getDebugSettings().setDebugLevel(cursor.getInt(cursor.getColumnIndex("debug_level"))); + readBookmarkSpecificColumns(bookmark, cursor); return bookmark; diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkDB.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkDB.java index 97bf6193b..fe42d0d48 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkDB.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkDB.java @@ -22,7 +22,7 @@ import android.database.sqlite.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"; public static final String ID = BaseColumns._ID; @@ -106,7 +106,8 @@ public class BookmarkDB extends SQLiteOpenHelper + "security, " + "remote_program, " + "work_dir, " - + "console_mode) " + + "console_mode, " + + "debug_level ) " + "VALUES ( " + "'Test Server', " + "'testservice.afreerdp.com', " @@ -114,7 +115,7 @@ public class BookmarkDB extends SQLiteOpenHelper + "'', " + "'', " + "3389, " - + "1, 1, 2, 2, 0, 0, 0, 0, '', '', 0);"; + + "1, 1, 2, 2, 0, 0, 0, 0, '', '', 0, 0);"; db.execSQL(sqlInsertDefaultSessionEntry); } @@ -149,6 +150,7 @@ public class BookmarkDB extends SQLiteOpenHelper + "remote_program TEXT, " + "work_dir TEXT, " + "console_mode INTEGER, " + + "debug_level INTEGER DEFAULT 0, " + "FOREIGN KEY(screen_settings) REFERENCES tbl_screen_settings(" + ID + "), " + "FOREIGN KEY(performance_flags) REFERENCES tbl_performance_flags(" + ID + "), " diff --git a/cmake/ConfigOptionsAndroid.cmake b/cmake/ConfigOptionsAndroid.cmake index 4ffec393d..49db7c756 100644 --- a/cmake/ConfigOptionsAndroid.cmake +++ b/cmake/ConfigOptionsAndroid.cmake @@ -21,6 +21,7 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") endif() 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_DEBUG "Create a android debug package" ${JAVA_DEBUG_DEFAULT})