mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-13 06:39:54 -04:00
Use DocumentProvider instead of FileProvider
This commit is contained in:
parent
6896e7f737
commit
eb0f834fcc
@ -94,7 +94,6 @@ android {
|
|||||||
// multiDexEnabled = true
|
// multiDexEnabled = true
|
||||||
// debuggable = true
|
// debuggable = true
|
||||||
resValue 'string', 'storageProviderAuthorities', 'net.kdt.pojavlaunch.scoped.gamefolder'
|
resValue 'string', 'storageProviderAuthorities', 'net.kdt.pojavlaunch.scoped.gamefolder'
|
||||||
resValue 'string', 'shareProviderAuthority', 'net.kdt.pojavlaunch.scoped.controlfolder'
|
|
||||||
}
|
}
|
||||||
gplay {
|
gplay {
|
||||||
initWith release
|
initWith release
|
||||||
|
@ -96,22 +96,6 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</provider>
|
</provider>
|
||||||
|
|
||||||
<provider
|
|
||||||
android:name="androidx.core.content.FileProvider"
|
|
||||||
android:authorities="@string/shareProviderAuthority"
|
|
||||||
android:exported="false"
|
|
||||||
android:grantUriPermissions="true"
|
|
||||||
android:permission="android.permission.MANAGE_DOCUMENTS">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.content.action.DOCUMENTS_PROVIDER" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data
|
|
||||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
|
||||||
android:resource="@xml/provider"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</provider>
|
|
||||||
|
|
||||||
<service android:name=".services.ProgressService"/>
|
<service android:name=".services.ProgressService"/>
|
||||||
<service android:name=".services.GameService" android:process=":game"/>
|
<service android:name=".services.GameService" android:process=":game"/>
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import android.os.*;
|
|||||||
|
|
||||||
import androidx.appcompat.app.*;
|
import androidx.appcompat.app.*;
|
||||||
|
|
||||||
|
import android.provider.DocumentsContract;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
|
|
||||||
@ -54,19 +55,21 @@ public class CustomControlsActivity extends BaseActivity {
|
|||||||
case 3: save(false, mControlLayout); break;
|
case 3: save(false, mControlLayout); break;
|
||||||
case 4: dialogSelectDefaultCtrl(mControlLayout); break;
|
case 4: dialogSelectDefaultCtrl(mControlLayout); break;
|
||||||
case 5: // Saving the currently shown control
|
case 5: // Saving the currently shown control
|
||||||
mControlLayout.save(Tools.DIR_DATA + "/files/" + sSelectedName + ".json");
|
try {
|
||||||
|
Uri contentUri = DocumentsContract.buildDocumentUri(getString(R.string.storageProviderAuthorities), doSaveCtrl(sSelectedName, mControlLayout));
|
||||||
|
|
||||||
Uri contentUri = getUriForFile(getBaseContext(), getString(R.string.shareProviderAuthority), new File(Tools.DIR_DATA, "/files/" + sSelectedName + ".json"));
|
Intent shareIntent = new Intent();
|
||||||
|
shareIntent.setAction(Intent.ACTION_SEND);
|
||||||
|
shareIntent.putExtra(Intent.EXTRA_STREAM, contentUri);
|
||||||
|
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
shareIntent.setType("application/json");
|
||||||
|
startActivity(shareIntent);
|
||||||
|
|
||||||
Intent shareIntent = new Intent();
|
Intent sendIntent = Intent.createChooser(shareIntent, sSelectedName);
|
||||||
shareIntent.setAction(Intent.ACTION_SEND);
|
startActivity(sendIntent);
|
||||||
shareIntent.putExtra(Intent.EXTRA_STREAM, contentUri);
|
}catch (Exception e) {
|
||||||
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
Tools.showError(this, e);
|
||||||
shareIntent.setType("application/json");
|
}
|
||||||
startActivity(shareIntent);
|
|
||||||
|
|
||||||
Intent sendIntent = Intent.createChooser(shareIntent, sSelectedName);
|
|
||||||
startActivity(sendIntent);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mDrawerLayout.closeDrawers();
|
mDrawerLayout.closeDrawers();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user