| 
					
				 | 
			
			
				@@ -3963,16 +3963,15 @@ void laDestroySinglePanel(laPanel *p, int immediate){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 int laEnclosePanelContent(laPanel *p, laUiList *uil){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    laBoxedTheme *bt = _LA_THEME_FLOATING_PANEL; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     int MinW,MinWt=0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     int TitleReserve=p->Mode==LA_PANEL_FLOATING_TOP?LA_RH:0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(!MAIN.CurrentWindow){ MAIN.CurrentWindow=MAIN.Windows.pFirst; if(!MAIN.CurrentWindow) return 0; } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     int CW = MAIN.CurrentWindow->CW; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if(p->SL && p->SR){return 0;} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     la_SetPropMathcerContext(p); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    int em=bt->BoxStyle==-1?LA_M:0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    la_UpdateUiListRecursive(&p->TitleBar, LA_M+em, LA_M+em, p->TW - LA_M*2, p->TH, 0, p); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    la_UpdateUiListRecursive(uil, LA_M+p->TitleBar.B, em, 1000, 0, 0, p); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    la_UpdateUiListRecursive(&p->TitleBar, LA_M, LA_M, p->TW - LA_M*2, p->TH, 0, p); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    la_UpdateUiListRecursive(uil, LA_M+p->TitleBar.B, 0, 1000, 0, 0, p); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     MinWt = la_TestUiListMinumWidth(&p->TitleBar); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     MinW = la_TestUiListMinumWidth(uil); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if (MinW<MinWt){MinW=MinWt;} 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -3983,8 +3982,8 @@ int laEnclosePanelContent(laPanel *p, laUiList *uil){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     la_PanelValidateWidth(p,uil); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     laEnsurePanelInBound(p,uil); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if(p->TW>CW){ p->TW=CW; } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    la_UpdateUiListRecursive(&p->TitleBar, LA_M+em, LA_M+em, p->TW-LA_M*2, p->TH, 0, p); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    la_UpdateUiListRecursive(uil, LA_M+p->TitleBar.B, LA_M+em, p->TW-LA_M-ScrollerW, 0, 0, p); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    la_UpdateUiListRecursive(&p->TitleBar, LA_M, LA_M, p->TW-LA_M*2, p->TH, 0, p); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    la_UpdateUiListRecursive(uil, LA_M+p->TitleBar.B, LA_M, p->TW-LA_M-ScrollerW, 0, 0, p); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     laRedrawPanel(p); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -6513,7 +6512,7 @@ void la_DrawUiListScrollerH(laUiList *uil, int DisplayOffset, int TotalW, int Di 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 void la_DrawInstanceBkg(laUiList *uil, real* color, int LP, int RP){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     tnsUseNoTexture(); tnsColor4dv(color); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    la_DrawBox(uil->L-LP+1,uil->R+RP-1,uil->U+1,uil->B-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    la_DrawBox(uil->L-LP,uil->R+RP,uil->U,uil->B); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 void la_InitSocketRecord(laUiListDraw* uild, laUiList* container){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     laSocketRecord* sr; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -8956,40 +8955,30 @@ static int android_close(void *cookie){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // Ref: https://developer.android.com/ndk/reference/group/asset 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 FILE *android_fopen(const char *fileName, const char *mode) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    char buf[1024]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if (mode[0] == 'w') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    MAIN.AndroidLastPath=0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (mode[0] == 'w'){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // fopen() is mapped to android_fopen() that only grants read access to 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // assets directory through AAssetManager but we want to also be able to 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // write data when required using the standard stdio FILE access functions 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // Ref: https://stackoverflow.com/questions/11294487/android-writing-saving-files-from-native-code-only 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         #undef fopen 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        FILE* result=fopen(fileName, mode); if(result){ return result; } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        sprintf(buf,"%s/%s", MAIN.InternalDataPath, fileName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        result=fopen(buf, mode); if(result) return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        sprintf(buf,"%s/%s", MAIN.ExternalDataPath, fileName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return fopen(buf, mode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        char* valid_path=laAndroidEnsureValidFilePath(fileName,W_OK); if(!valid_path){ return 0; } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FILE* result=fopen(valid_path, mode); if(result){ MAIN.AndroidLastPath=valid_path; return result; } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         #define fopen(name, mode) android_fopen(name, mode) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // NOTE: AAsset provides access to read-only asset 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         AAsset *asset = AAssetManager_open(MAIN.AssetManager, fileName, AASSET_MODE_UNKNOWN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (asset != NULL) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (asset != NULL){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // Get pointer to file in the assets 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return funopen(asset, android_read, android_write, android_seek, android_close); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             #undef fopen 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            FILE* result=fopen(fileName, mode); if(result){ return result; } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // Just do a regular open if file is not found in the assets 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            sprintf(buf,"%s/%s", MAIN.InternalDataPath, fileName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            result=fopen(buf, mode); if(result){ return result; } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            sprintf(buf,"%s/%s", MAIN.ExternalDataPath, fileName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return fopen(buf, mode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            char* valid_path=laAndroidEnsureValidFilePath(fileName,R_OK); if(!valid_path){ return 0; } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            FILE* result=fopen(valid_path, mode); if(result){ MAIN.AndroidLastPath=valid_path; return result; } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             #define fopen(name, mode) android_fopen(name, mode) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 |