manifest: use different file provider authorities for the different package names

crowdin
Floens 7 years ago
parent eea9911c96
commit 5469528e4b
  1. 3
      Clover/app/build.gradle
  2. 33
      Clover/app/src/default/AndroidManifest.xml
  3. 33
      Clover/app/src/dev/AndroidManifest.xml
  4. 33
      Clover/app/src/fdroid/AndroidManifest.xml
  5. 13
      Clover/app/src/main/AndroidManifest.xml
  6. 12
      Clover/app/src/main/java/org/floens/chan/core/cache/FileCacheProvider.java

@ -72,6 +72,9 @@ android {
defaultPublishConfig "default"
flavorDimensions "default"
productFlavors {
// NOTE: the file provider authority names append to the package name.
// When changing this also update the authority in the manifest files.
// The app name refers to the name as displayed on the launcher.
// the flavor name is appended to the name in the settings.
"default" {

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?><!--
Clover - 4chan browser https://github.com/Floens/Clover/
Copyright (C) 2014 Floens
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<!-- Note: only difference is the authorities property -->
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="org.floens.chan.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?><!--
Clover - 4chan browser https://github.com/Floens/Clover/
Copyright (C) 2014 Floens
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<!-- Note: only difference is the authorities property -->
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="org.floens.chan.dev.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?><!--
Clover - 4chan browser https://github.com/Floens/Clover/
Copyright (C) 2014 Floens
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<!-- Note: only difference is the authorities property -->
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="org.floens.chan.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>

@ -95,17 +95,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</receiver>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="org.floens.chan.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<!-- providers are defined in the flavor specific directories -->
<!-- see src/<flavorname>/AndroidManifest.xml -->
</application>

@ -26,11 +26,15 @@ import org.floens.chan.utils.AndroidUtils;
import java.io.File;
public class FileCacheProvider {
// Same as the one defined in the manifest.
private static final String AUTHORITY = "org.floens.chan.fileprovider";
public static Uri getUriForFile(File file) {
Context applicationContext = AndroidUtils.getAppContext();
return FileProvider.getUriForFile(applicationContext, AUTHORITY, file);
String authority = getAuthority(applicationContext);
return FileProvider.getUriForFile(applicationContext, authority, file);
}
private static String getAuthority(Context applicationContext) {
// NOTE: keep this in line with the name defined in the different manifests for the
// different flavors.
return applicationContext.getPackageName() + ".fileprovider";
}
}

Loading…
Cancel
Save