changeset 188:cf677a6f586d

use floating point font size, change size by scaling factor rather than linear addition
author Carl Byington <carl@five-ten-sg.com>
date Wed, 02 Jul 2014 16:10:20 -0700
parents 81f9ba83c0e9
children ab6f64d1a24a
files src/com/five_ten_sg/connectbot/bean/HostBean.java src/com/five_ten_sg/connectbot/service/TerminalBridge.java
diffstat 2 files changed, 14 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/bean/HostBean.java	Wed Jul 02 15:40:18 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/bean/HostBean.java	Wed Jul 02 16:10:20 2014 -0700
@@ -45,7 +45,7 @@
     private long    pubkeyId = -1;
     private boolean wantSession = true;
     private String  delKey = HostDatabase.DELKEY_DEL;
-    private int     fontSize = -1;
+    private float   fontSize = -1;
     private boolean compression = false;
     private String  httpproxy = null;
     private String  encoding = HostDatabase.ENCODING_DEFAULT;
@@ -197,10 +197,10 @@
     public String getDelKey() {
         return delKey;
     }
-    public void setFontSize(int fontSize) {
+    public void setFontSize(float fontSize) {
         this.fontSize = fontSize;
     }
-    public int getFontSize() {
+    public float getFontSize() {
         return fontSize;
     }
     public void setCompression(boolean compression) {
--- a/src/com/five_ten_sg/connectbot/service/TerminalBridge.java	Wed Jul 02 15:40:18 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/service/TerminalBridge.java	Wed Jul 02 16:10:20 2014 -0700
@@ -78,8 +78,8 @@
 public class TerminalBridge implements VDUDisplay {
     public final static String TAG = "ConnectBot.TerminalBridge";
 
-    public  final static int    DEFAULT_FONT_SIZE = 10;
-    private final static int    FONT_SIZE_STEP    = 2;
+    public  final static float  DEFAULT_FONT_SIZE = 10.0;
+    private final static float  FONT_SIZE_FACTOR  = 1.1;
 
     public Integer[] color;
 
@@ -189,11 +189,12 @@
         defaultPaint.setFakeBoldText(true);  // more readable?
         localOutput = new LinkedList<String>();
         fontSizeChangedListeners = new LinkedList<FontSizeChangedListener>();
-        Integer defaultFontSize = Integer.parseInt(manager.prefs.getString(PreferenceConstants.DEFAULT_FONT_SIZE, "-1"));
+        float defaultFontSize = Float.parseFloat(manager.prefs.getString(PreferenceConstants.DEFAULT_FONT_SIZE, "-1"));
         Log.i(TAG, "fontSize: " + this.fontSize + ", defaultFontSize: " + defaultFontSize);
 
-        if (fontSize == -1) {
-            if (defaultFontSize > 0 && host.getFontSize() == -1)
+        float hostFontSize;
+        if (fontSize <= 0) {
+            if ((defaultFontSize > 0) && (host.getFontSize() <= 0))
                 hostFontSize = defaultFontSize;
             else
                 hostFontSize = host.getFontSize();
@@ -468,7 +469,7 @@
         for (FontSizeChangedListener ofscl : fontSizeChangedListeners)
             ofscl.onFontSizeChanged(size);
 
-        host.setFontSize((int) fontSize);
+        host.setFontSize(fontSize);
         manager.hostdb.updateFontSize(host);
     }
 
@@ -993,14 +994,14 @@
      *
      */
     public void increaseFontSize() {
-        setFontSize(fontSize + FONT_SIZE_STEP);
+        setFontSize(fontSize * FONT_SIZE_FACTOR);
     }
 
     /**
      *
      */
     public void decreaseFontSize() {
-        setFontSize(fontSize - FONT_SIZE_STEP);
+        setFontSize(fontSize / FONT_SIZE_FACTOR);
     }
 
     /**
@@ -1008,9 +1009,9 @@
      */
     public void resetSize(TerminalView parent) {
         this.forcedSize = false;
-        Integer defaultFontSize = Integer.parseInt(manager.prefs.getString(PreferenceConstants.DEFAULT_FONT_SIZE, "-1"));
+        float defaultFontSize = Float.parseFloat(manager.prefs.getString(PreferenceConstants.DEFAULT_FONT_SIZE, "-1"));
 
-        if (this.fontSize != -1 && defaultFontSize > 0)
+        if (defaultFontSize > 0)
             setFontSize(defaultFontSize);
         else
             setFontSize(DEFAULT_FONT_SIZE);