Add Fit Screen option to resolution settings
authorTodd McKinney <tmckinney@vbridges.com>
Tue, 20 Aug 2013 20:21:25 +0000 (15:21 -0500)
committerTodd McKinney <tmckinney@vbridges.com>
Tue, 20 Aug 2013 20:52:31 +0000 (15:52 -0500)
There may be times where users want to have the desktop resolution match the device resolution
on a small screen. The change adds the option without changing existing functionality of the
automatic resolution setting.

Also included localized text strings for the new option and addressed some issues with string
comparison in non en-US locales.

client/Android/FreeRDPCore/res/values-es/strings.xml
client/Android/FreeRDPCore/res/values-fr/strings.xml
client/Android/FreeRDPCore/res/values-nl/strings.xml
client/Android/FreeRDPCore/res/values/strings.xml
client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/application/GlobalSettings.java
client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/BookmarkBase.java
client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/BookmarkActivity.java
client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/SessionActivity.java

index cf9b933..620823c 100644 (file)
     </string-array>\r
     <string name="settings_resolution">Resolucion</string>\r
     <string name="resolution_automatic">Automatico</string>\r
+    <string name="resolution_fit">Pantalla</string>\r
     <string name="resolution_custom">Manual</string>\r
     <string-array name="resolutions_array">\r
         <item>Automatico</item>\r
+        <item>Ajuste a la pantalla</item>\r
         <item>Manual</item>\r
         <item>640x480</item>\r
         <item>720x480</item>\r
@@ -79,6 +81,7 @@
     </string-array>\r
     <string-array name="resolutions_values_array">\r
         <item>automatico</item>\r
+        <item>pantalla</item>\r
         <item>manual</item>\r
         <item>640x480</item>\r
         <item>720x480</item>\r
index 3e0f171..7c1ff6d 100644 (file)
     </string-array>
     <string name="settings_resolution">"Résolution"</string>
     <string name="resolution_automatic">"Automatique"</string>
+    <string name="resolution_fit">"Agrandir la fenêtre"</string>
     <string name="resolution_custom">"Personalisé"</string>
     <string-array name="resolutions_array">
         <item>"Automatique"</item>
+        <item>"Agrandir la fenêtre"</item>
         <item>"Personalisé"</item>
         <item>"640x480"</item>
         <item>"720x480"</item>
@@ -78,6 +80,7 @@
     </string-array>
     <string-array name="resolutions_values_array">
         <item>"Automatique"</item>
+        <item>"fenêtre"</item>
         <item>"Personalisé"</item>
         <item>"640x480"</item>
         <item>"720x480"</item>
index 4bff58d..0ddc536 100644 (file)
     </string-array>
     <string name="settings_resolution">Resolutie</string>
     <string name="resolution_automatic">Automatisch</string>
+    <string name="resolution_fit">Schermvullend</string>
     <string name="resolution_custom">Aangepast</string>
     <string-array name="resolutions_array">
         <item>Automatisch</item>
+        <item>Schermvullend</item>
         <item>Aangepast</item>
         <item>640x480</item>
         <item>720x480</item>
@@ -79,6 +81,7 @@
     </string-array>
     <string-array name="resolutions_values_array">
         <item>Automatisch</item>
+        <item>Schermvullend</item>
         <item>Aangepast</item>
         <item>640x480</item>
         <item>720x480</item>
index 6110afd..0f6aacd 100644 (file)
     </string-array>
     <string name="settings_resolution">Resolution</string>
     <string name="resolution_automatic">Automatic</string>
+    <string name="resolution_fit">Fitscreen</string>
     <string name="resolution_custom">Custom</string>
     <string-array name="resolutions_array">
         <item>Automatic</item>
+        <item>Fit Screen</item>
         <item>Custom</item>
         <item>640x480</item>
         <item>720x480</item>
@@ -79,6 +81,7 @@
     </string-array>
     <string-array name="resolutions_values_array">
         <item>automatic</item>
+        <item>fitscreen</item>
         <item>custom</item>
         <item>640x480</item>
         <item>720x480</item>
index 5b876dd..e44a3e7 100644 (file)
@@ -27,9 +27,11 @@ public class GlobalSettings {
        private static final String PREF_SECURITY_ACCEPTALLCERTIFICATES = "security.accept_certificates";
 
        private static SharedPreferences settings;
+       public static Context initialContext;
        
        public static void init(Context context)
        {               
+               initialContext = context;
                settings = PreferenceManager.getDefaultSharedPreferences(context);
                initValues();
        }
index 981386b..7c7c363 100644 (file)
@@ -10,6 +10,8 @@
 package com.freerdp.freerdpcore.domain;
 
 import com.freerdp.freerdpcore.application.GlobalApp;
+import com.freerdp.freerdpcore.application.GlobalSettings;
+import com.freerdp.freerdpcore.R;
 
 import android.content.SharedPreferences;
 import android.os.Parcel;
@@ -143,6 +145,7 @@ public class BookmarkBase implements Parcelable, Cloneable
        // Screen Settings class
        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;
@@ -174,7 +177,7 @@ public class BookmarkBase implements Parcelable, Cloneable
                {
                        this.resolution = resolution;
                        
-                       if (resolution == AUTOMATIC) {
+                       if (resolution == AUTOMATIC || resolution == FITSCREEN) {
                                width = 0;
                                height = 0;
                        }
@@ -188,15 +191,20 @@ public class BookmarkBase implements Parcelable, Cloneable
                                this.height = Integer.valueOf(dimensions[1]);
                                this.resolution = PREDEFINED;
                        }
-                       else if (resolution.equalsIgnoreCase("custom"))
+                       else if (resolution.equalsIgnoreCase(GlobalSettings.initialContext.getResources().getString(R.string.resolution_custom)))
                        {
                                this.width = width;                             
                                this.height = height;                           
                                this.resolution = CUSTOM;
                        }
+                       else if (resolution.equalsIgnoreCase(GlobalSettings.initialContext.getResources().getString(R.string.resolution_fit)))
+                       {
+                               this.width = this.height = 0;
+                               this.resolution = FITSCREEN;
+                       }
                        else
                        {
-                               this.width = this.height = 0;                           
+                               this.width = this.height = 0;
                                this.resolution = AUTOMATIC;
                        }
                }
@@ -210,8 +218,10 @@ public class BookmarkBase implements Parcelable, Cloneable
                {       
                        if (isPredefined())
                                return (width + "x" + height);
-                       
-                       return (isAutomatic() ? "automatic" : "custom");
+
+                       return (isFitScreen() ? GlobalSettings.initialContext.getResources().getString(R.string.resolution_fit) :
+                               isAutomatic() ? GlobalSettings.initialContext.getResources().getString(R.string.resolution_automatic) : 
+                                       GlobalSettings.initialContext.getResources().getString(R.string.resolution_custom));
                }
 
                public boolean isPredefined() {
@@ -221,7 +231,11 @@ public class BookmarkBase implements Parcelable, Cloneable
                public boolean isAutomatic() {
                        return (resolution == AUTOMATIC);
                }
-               
+
+               public boolean isFitScreen() {
+                       return (resolution == FITSCREEN);
+               }
+
                public boolean isCustom() {
                        return (resolution == CUSTOM);
                }
index 004a716..33e6a33 100644 (file)
@@ -451,7 +451,7 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref
                        ListPreference listPreference = (ListPreference)findPreference(key);
                        listPreference.setSummary(listPreference.getEntry());           
                        
-                       boolean enabled = listPreference.getValue().equals("custom");
+                       boolean enabled = listPreference.getValue().equalsIgnoreCase(getResources().getString(R.string.resolution_custom));
                        if (key.equals("bookmark.resolution"))
                        {
                                findPreference("bookmark.width").setEnabled(enabled);                           
index defaf92..c69b5ff 100644 (file)
@@ -624,6 +624,10 @@ public class SessionActivity extends Activity
                                screenSettings.setWidth((int)((float)screenMax * 1.6f));
                        }                       
                }
+               if (screenSettings.isFitScreen()) {
+                       screenSettings.setHeight(screen_height);                                
+                       screenSettings.setWidth(screen_width);                  
+               }
                
                progressDialog = new ProgressDialog(this);
                progressDialog.setTitle(bookmark.getLabel());