This commit is contained in:
dgis 2019-02-03 22:36:41 +00:00
parent 737096a0e0
commit a765895abb
6 changed files with 53 additions and 32 deletions

View file

@ -57,10 +57,24 @@
<!--android:mimeType="*/*"--> <!--android:mimeType="*/*"-->
<!--android:pathPattern=".*\\.e48"--> <!--android:pathPattern=".*\\.e48"-->
<!--android:host="*"/>--> <!--android:host="*"/>-->
<!--<data android:scheme="file"--> </intent-filter>
<!--android:mimeType="*/*"--> <intent-filter>
<!--android:pathPattern=".*\\.e49"--> <action android:name="android.intent.action.VIEW" />
<!--android:host="*"/>--> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.kml" />
<data android:host="*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="content" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.kml" />
<data android:host="*" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity

View file

@ -360,6 +360,19 @@ JNIEXPORT jint JNICALL Java_org_emulator_forty_eight_NativeLib_onFileNew(JNIEnv
_tcscpy(szChosenCurrentKml, filenameUTF8); _tcscpy(szChosenCurrentKml, filenameUTF8);
(*env)->ReleaseStringUTFChars(env, kmlFilename, filenameUTF8); (*env)->ReleaseStringUTFChars(env, kmlFilename, filenameUTF8);
TCHAR * urlContentSchemeFound = _tcsstr(szChosenCurrentKml, _T("content://"));
if(urlContentSchemeFound) {
_tcscpy(szEmuDirectory, szChosenCurrentKml);
TCHAR * filename = _tcsrchr(szChosenCurrentKml, _T('/'));
if(filename) {
*filename = _T('\0');
}
_tcscpy(szRomDirectory, szEmuDirectory);
} else {
_tcscpy(szEmuDirectory, "assets/calculators/");
_tcscpy(szRomDirectory, "assets/calculators/");
}
BOOL result = NewDocument(); BOOL result = NewDocument();
chooseCurrentKmlMode = ChooseKmlMode_UNKNOWN; chooseCurrentKmlMode = ChooseKmlMode_UNKNOWN;

View file

@ -1049,7 +1049,15 @@ BOOL InsertMenu(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, L
BOOL SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags) { return 0; } BOOL SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags) { return 0; }
BOOL IsRectEmpty(CONST RECT *lprc) { return 0; } BOOL IsRectEmpty(CONST RECT *lprc) { return 0; }
BOOL WINAPI SetWindowOrgEx(HDC hdc, int x, int y, LPPOINT lppt) { return 0; } BOOL WINAPI SetWindowOrgEx(HDC hdc, int x, int y, LPPOINT lppt) {
if(lppt) {
lppt->x = hdc->windowOrigineX;
lppt->y = hdc->windowOrigineY;
}
hdc->windowOrigineX = x;
hdc->windowOrigineY = y;
return TRUE;
}
// GDI // GDI
HGDIOBJ SelectObject(HDC hdc, HGDIOBJ h) { HGDIOBJ SelectObject(HDC hdc, HGDIOBJ h) {
@ -1345,6 +1353,8 @@ BOOL StretchBlt(HDC hdcDest, int xDest, int yDest, int wDest, int hDest, HDC hdc
destinationStride = (float)(destinationBytes * ((destinationWidth * hBitmapDestination->bitmapInfoHeader->biBitCount + 31) / 32)); destinationStride = (float)(destinationBytes * ((destinationWidth * hBitmapDestination->bitmapInfoHeader->biBitCount + 31) / 32));
} }
xDest -= hdcDest->windowOrigineX;
yDest -= hdcDest->windowOrigineY;
//https://softwareengineering.stackexchange.com/questions/148123/what-is-the-algorithm-to-copy-a-region-of-one-bitmap-into-a-region-in-another //https://softwareengineering.stackexchange.com/questions/148123/what-is-the-algorithm-to-copy-a-region-of-one-bitmap-into-a-region-in-another
float src_dx = (float)wSrc / (float)wDest; float src_dx = (float)wSrc / (float)wDest;

View file

@ -634,6 +634,8 @@ struct _HDC{
HBITMAP selectedBitmap; HBITMAP selectedBitmap;
HPALETTE selectedPalette; HPALETTE selectedPalette;
HPALETTE realizedPalette; HPALETTE realizedPalette;
int windowOrigineX;
int windowOrigineY;
}; };
//typedef HANDLE HDC; //typedef HANDLE HDC;
@ -1070,6 +1072,8 @@ extern int lstrcmpi(LPCWSTR lpString1, LPCWSTR lpString2);
#define _tcsncpy wcsncpy #define _tcsncpy wcsncpy
#define _tcscat wcscat #define _tcscat wcscat
#define _tcsstr wcsstr #define _tcsstr wcsstr
#define _tcsrchr wcsrchr
#else #else
@ -1093,6 +1097,7 @@ extern int lstrcmpi(LPCSTR lpString1, LPCSTR lpString2);
#define _tcsncpy strncpy #define _tcsncpy strncpy
#define _tcscat strcat #define _tcscat strcat
#define _tcsstr strstr #define _tcsstr strstr
#define _tcsrchr strrchr
#endif // !UNICODE #endif // !UNICODE

View file

@ -557,7 +557,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
if(which == lastIndex) { if(which == lastIndex) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT); Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*"); //intent.setType("file/*");
intent.setType("*/*");
startActivityForResult(intent, INTENT_PICK_KML_FILE); startActivityForResult(intent, INTENT_PICK_KML_FILE);
} else { } else {
String kmlScriptFilename = kmlScripts.get(which).filename; String kmlScriptFilename = kmlScripts.get(which).filename;
@ -819,7 +820,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
break; break;
case INTENT_PICK_KML_FILE: case INTENT_PICK_KML_FILE:
Log.d(TAG, "onActivityResult INTENT_OBJECT_SAVE " + url); Log.d(TAG, "onActivityResult INTENT_OBJECT_SAVE " + url);
newFileFromKML(url); String filePath = Utils.getFilePath(this, url);
newFileFromKML(filePath);
break; break;
default: default:
break; break;
@ -864,7 +866,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private String getFilenameFromURL(String url) { private String getFilenameFromURL(String url) {
String displayName = ""; String displayName = "";
try { try {
displayName = SettingsActivity.getFileName(this, url); displayName = Utils.getFileName(this, url);
} catch(Exception e) { } catch(Exception e) {
// Do nothing // Do nothing
} }

View file

@ -334,7 +334,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
String stringValue = value.toString(); String stringValue = value.toString();
String displayName = stringValue; String displayName = stringValue;
try { try {
displayName = getFileName(getActivity(), stringValue); displayName = Utils.getFileName(getActivity(), stringValue);
} catch(Exception e) { } catch(Exception e) {
} }
preference.setSummary(displayName); preference.setSummary(displayName);
@ -389,27 +389,4 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
getContentResolver().takePersistableUriPermission(uri, takeFlags); getContentResolver().takePersistableUriPermission(uri, takeFlags);
} }
public static String getFileName(Context context, String url) {
Uri uri = Uri.parse(url);
String result = null;
if (uri.getScheme().equals("content")) {
Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
try {
if (cursor != null && cursor.moveToFirst()) {
result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
}
} finally {
cursor.close();
}
}
if (result == null) {
result = uri.getPath();
int cut = result.lastIndexOf('/');
if (cut != -1) {
result = result.substring(cut + 1);
}
}
return result;
}
} }