Revert FileProvider to Keyman app

Starts to address #2039

Move FileProvider back to Keyman manifest and revert authority.

Added Toast notification if 3rd party app doesn't define FileProvider. (info pages fail to properly load)
This commit is contained in:
Darcy Wong 2019-09-04 11:13:27 +07:00
parent 0e855dbfcf
commit a36207ed79
6 changed files with 29 additions and 22 deletions

View file

@ -192,6 +192,16 @@
android:launchMode="singleTask"
android:theme="@style/AppTheme.Base" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>
</manifest>

View file

@ -68,17 +68,6 @@
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light.Dialog" >
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.tavultesoft.kmea.fileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>
</manifest>

View file

@ -24,6 +24,7 @@ import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;
import com.tavultesoft.kmea.util.FileUtils;
@ -100,10 +101,12 @@ public final class KeyboardInfoActivity extends AppCompatActivity {
// Starting with Android N, you can't pass file:// to intents, so we use FileProvider
try {
Uri contentUri = FileProvider.getUriForFile(
context, "com.tavultesoft.kmea.fileProvider", customHelp);
context, getApplication().getPackageName() + ".fileProvider", customHelp);
i.setDataAndType(contentUri, "text/html");
} catch (Exception e) {
Log.e("KeyboardInfoActivity", "Failed to access " + customHelp.toString());
} catch (NullPointerException e) {
String message = "FileProvider undefined in app to load" + customHelp.toString();
Toast.makeText(context, message, Toast.LENGTH_LONG).show();
Log.e("KeyboardInfoActivity", message);
}
}
else {

View file

@ -25,6 +25,7 @@ import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;
import com.tavultesoft.kmea.util.FileUtils;
import com.tavultesoft.kmea.util.MapCompat;
@ -143,10 +144,12 @@ public final class KeyboardSettingsActivity extends AppCompatActivity {
// Starting with Android N, you can't pass file:// to intents, so we use FileProvider
try {
Uri contentUri = FileProvider.getUriForFile(
context, "com.tavultesoft.kmea.fileProvider", customHelp);
context, getApplication().getPackageName() + ".fileProvider", customHelp);
i.setDataAndType(contentUri, "text/html");
} catch (Exception e) {
Log.e("KeyboardInfoActivity", "Failed to access " + customHelp.toString());
} catch (NullPointerException e) {
String message = "FileProvider undefined in app to load" + customHelp.toString();
Toast.makeText(context, message, Toast.LENGTH_LONG).show();
Log.e("KeyboardInfoActivity", message);
}
}
else {

View file

@ -143,10 +143,12 @@ public final class ModelInfoActivity extends AppCompatActivity {
// Starting with Android N, you can't pass file:// to intents, so we use FileProvider
try {
Uri contentUri = FileProvider.getUriForFile(
context, "com.tavultesoft.kmea.fileProvider", customHelp);
context, getApplication().getPackageName() + ".fileProvider", customHelp);
i.setDataAndType(contentUri, "text/html");
} catch (Exception e) {
Log.e("ModelInfoActivity", "Failed to access " + customHelp.toString());
} catch (NullPointerException e) {
String message = "FileProvider undefined in app to load" + customHelp.toString();
Toast.makeText(context, message, Toast.LENGTH_LONG).show();
Log.e("ModelInfoActivity", message);
}
}
else {