Mercurial > 510Connectbot
comparison app/src/main/java/com/five_ten_sg/connectbot/service/TerminalBridge.java @ 457:105815cce146 stable-1.9.3-3
minimum version android 5, target and compile version api 28
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Tue, 29 Jan 2019 11:21:57 -0800 |
parents | d29cce60f393 |
children |
comparison
equal
deleted
inserted
replaced
456:b00031b2d6ac | 457:105815cce146 |
---|---|
53 import android.os.Binder; | 53 import android.os.Binder; |
54 import android.os.Environment; | 54 import android.os.Environment; |
55 import android.text.ClipboardManager; | 55 import android.text.ClipboardManager; |
56 import android.text.Editable; | 56 import android.text.Editable; |
57 import android.text.method.CharacterPickerDialog; | 57 import android.text.method.CharacterPickerDialog; |
58 import android.util.FloatMath; | |
59 import android.util.Log; | 58 import android.util.Log; |
60 import android.view.KeyEvent; | 59 import android.view.KeyEvent; |
61 import android.view.View; | 60 import android.view.View; |
62 import android.widget.AdapterView; | 61 import android.widget.AdapterView; |
63 import android.widget.Button; | 62 import android.widget.Button; |
448 size = (float)(int)((size * 10.0f) + 0.5f) / 10.0f; | 447 size = (float)(int)((size * 10.0f) + 0.5f) / 10.0f; |
449 defaultPaint.setTextSize(size); | 448 defaultPaint.setTextSize(size); |
450 fontSize = size; | 449 fontSize = size; |
451 // read new metrics to get exact pixel dimensions | 450 // read new metrics to get exact pixel dimensions |
452 FontMetrics fm = defaultPaint.getFontMetrics(); | 451 FontMetrics fm = defaultPaint.getFontMetrics(); |
453 charTop = (int)FloatMath.ceil(fm.top); | 452 charTop = (int)Math.ceil(fm.top); |
454 float[] widths = new float[1]; | 453 float[] widths = new float[1]; |
455 defaultPaint.getTextWidths("X", widths); | 454 defaultPaint.getTextWidths("X", widths); |
456 charWidth = (int)FloatMath.ceil(widths[0]); | 455 charWidth = (int)Math.ceil(widths[0]); |
457 charHeight = (int)FloatMath.ceil(fm.descent - fm.top); | 456 charHeight = (int)Math.ceil(fm.descent - fm.top); |
458 | 457 |
459 // refresh any bitmap with new font size | 458 // refresh any bitmap with new font size |
460 if (parent != null) parentChanged(parent); | 459 if (parent != null) parentChanged(parent); |
461 | 460 |
462 synchronized(fontSizeChangedListeners) { | 461 synchronized(fontSizeChangedListeners) { |
689 addr++; | 688 addr++; |
690 } | 689 } |
691 } | 690 } |
692 | 691 |
693 // Save the current clip region | 692 // Save the current clip region |
694 canvas.save(Canvas.CLIP_SAVE_FLAG); | 693 canvas.save(); |
695 // clear this dirty area with background color | 694 // clear this dirty area with background color |
696 defaultPaint.setColor(bg); | 695 defaultPaint.setColor(bg); |
697 | 696 |
698 if (isWideCharacter) { | 697 if (isWideCharacter) { |
699 canvas.clipRect(c * charWidth, | 698 canvas.clipRect(c * charWidth, |
798 defaultPaint.setTextSize(size); | 797 defaultPaint.setTextSize(size); |
799 FontMetrics fm = defaultPaint.getFontMetrics(); | 798 FontMetrics fm = defaultPaint.getFontMetrics(); |
800 float[] widths = new float[1]; | 799 float[] widths = new float[1]; |
801 defaultPaint.getTextWidths("X", widths); | 800 defaultPaint.getTextWidths("X", widths); |
802 int termWidth = (int)widths[0] * cols; | 801 int termWidth = (int)widths[0] * cols; |
803 int termHeight = (int)FloatMath.ceil(fm.descent - fm.top) * rows; | 802 int termHeight = (int)Math.ceil(fm.descent - fm.top) * rows; |
804 Log.d("fontsize", String.format("font size %f resulted in %d x %d", size, termWidth, termHeight)); | 803 Log.d("fontsize", String.format("font size %f resulted in %d x %d", size, termWidth, termHeight)); |
805 | 804 |
806 // Check to see if it fits in resolution specified. | 805 // Check to see if it fits in resolution specified. |
807 if (termWidth > width || termHeight > height) | 806 if (termWidth > width || termHeight > height) |
808 return 1; | 807 return 1; |