mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-05-16 12:50:27 -04:00
Android release
This commit is contained in:
@@ -8,8 +8,8 @@ android {
|
||||
applicationId "com.compassconnections.app"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 34
|
||||
versionName "1.5.5"
|
||||
versionCode 36
|
||||
versionName "1.6.0"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
aaptOptions {
|
||||
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
android:supportsRtl="true"
|
||||
android:usesCleartextTraffic="true"
|
||||
android:fitsSystemWindows="true"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:theme="@style/AppTheme">
|
||||
|
||||
<activity
|
||||
@@ -65,6 +66,7 @@
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
|
||||
<uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove" />
|
||||
|
||||
|
||||
@@ -75,23 +75,20 @@ public class MainActivity extends BridgeActivity implements ModifiedMainActivity
|
||||
public void downloadFile(String filename, String content) {
|
||||
try {
|
||||
// Create file in app-specific external storage
|
||||
File file = new File(context.getExternalFilesDir(null), filename);
|
||||
File downloadsDir = android.os.Environment
|
||||
.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_DOWNLOADS);
|
||||
|
||||
File file = new File(downloadsDir, filename);
|
||||
|
||||
// Write content to file
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
fos.write(content.getBytes());
|
||||
fos.close();
|
||||
|
||||
// Get URI via FileProvider
|
||||
String authority = context.getPackageName() + ".provider";
|
||||
android.net.Uri uri = FileProvider.getUriForFile(context, authority, file);
|
||||
android.net.Uri uri = android.net.Uri.fromFile(file);
|
||||
|
||||
// Launch intent to view/share file
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(uri, "application/json");
|
||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
context.startActivity(intent);
|
||||
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
||||
intent.setData(uri);
|
||||
context.sendBroadcast(intent);
|
||||
|
||||
} catch (IOException e) {
|
||||
Log.i("CompassApp", "Failed to download file", e);
|
||||
|
||||
Reference in New Issue
Block a user