44import android .content .Context ;
55import android .graphics .PixelFormat ;
66import android .graphics .Point ;
7+ import android .graphics .Typeface ;
8+ import android .os .Build ;
79import android .util .AttributeSet ;
10+ import android .util .Log ;
811import android .view .Gravity ;
912import android .view .MotionEvent ;
1013import android .view .ScaleGestureDetector ;
1417import android .widget .LinearLayout ;
1518import android .widget .Toast ;
1619
20+ import com .termux .terminal .EmulatorDebug ;
1721import com .termux .view .TerminalView ;
1822
23+ import java .io .File ;
24+
1925public class TermuxFloatView extends LinearLayout {
2026
2127 public static final float ALPHA_FOCUS = 0.9f ;
@@ -94,7 +100,17 @@ protected void onAttachedToWindow() {
94100 DISPLAY_WIDTH = displaySize .x ;
95101 DISPLAY_HEIGHT = displaySize .y ;
96102
97- // mTerminalView.checkForFontAndColors();
103+ checkForFont ();
104+ }
105+
106+ void checkForFont () {
107+ try {
108+ @ SuppressLint ("SdCardPath" ) File fontFile = new File ("/data/data/com.termux/files/home/.termux/font.ttf" );
109+ final Typeface newTypeface = (fontFile .exists () && fontFile .length () > 0 ) ? Typeface .createFromFile (fontFile ) : Typeface .MONOSPACE ;
110+ mTerminalView .setTypeface (newTypeface );
111+ } catch (Exception e ) {
112+ Log .e (EmulatorDebug .LOG_TAG , "Error in checkForFont()" , e );
113+ }
98114 }
99115
100116 @ SuppressLint ("RtlHardcoded" )
@@ -103,7 +119,11 @@ public void launchFloatingWindow() {
103119 layoutParams .flags = computeLayoutFlags (true );
104120 layoutParams .width = widthAndHeight ;
105121 layoutParams .height = widthAndHeight ;
106- layoutParams .type = WindowManager .LayoutParams .TYPE_PHONE ;
122+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
123+ layoutParams .type = WindowManager .LayoutParams .TYPE_APPLICATION_OVERLAY ;
124+ } else {
125+ layoutParams .type = WindowManager .LayoutParams .TYPE_PHONE ;
126+ }
107127 layoutParams .format = PixelFormat .RGBA_8888 ;
108128
109129 layoutParams .gravity = Gravity .TOP | Gravity .LEFT ;
0 commit comments