Holy tapdancing god, it works now!

This commit is contained in:
d8ahazard 2016-09-15 12:52:58 -05:00
parent 8f973661f4
commit 0b02e8116c
3 changed files with 58 additions and 11 deletions

View File

@ -24,7 +24,32 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name="com.ipaulpro.afilechooser.FileChooserActivity"
android:icon="@drawable/ic_chooser"
android:enabled="@bool/use_activity"
android:exported="true"
android:label="@string/choose_file" >
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
<provider
android:name="com.ianhanniballake.localstorage.LocalStorageProvider"
android:authorities="com.topjohnwu.magisk.documents"
android:enabled="@bool/use_provider"
android:exported="true"
android:grantUriPermissions="true"
android:permission="android.permission.MANAGE_DOCUMENTS" >
<intent-filter>
<action android:name="android.content.action.DOCUMENTS_PROVIDER" />
</intent-filter>
</provider>
<activity
android:name=".AboutActivity"
android:theme="@style/AppTheme.Transparent"/>

View File

@ -2,9 +2,12 @@ package com.topjohnwu.magisk;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.TabLayout;
@ -12,13 +15,17 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.ipaulpro.afilechooser.FileInfo;
import com.ipaulpro.afilechooser.utils.FileUtils;
import com.topjohnwu.magisk.module.Module;
import com.topjohnwu.magisk.module.RepoHelper;
import com.topjohnwu.magisk.utils.Utils;
@ -54,9 +61,10 @@ public class ModulesFragment extends Fragment {
ButterKnife.bind(this, view);
fabio.setOnClickListener(v -> {
Intent fileIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
fileIntent.setType("application/zip");
fileIntent.addCategory(Intent.CATEGORY_OPENABLE);
Intent getContentIntent = FileUtils.createGetContentIntent(null);
getContentIntent.setType("application/zip");
Intent fileIntent = Intent.createChooser(getContentIntent, "Select a file");
startActivityForResult(fileIntent, FETCH_ZIP_CODE);
});
@ -75,13 +83,27 @@ public class ModulesFragment extends Fragment {
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Uri mUri = data.getData();
final int takeFlags = data.getFlags()
& (Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
if (resultCode == Activity.RESULT_OK && requestCode == FETCH_ZIP_CODE) {
new Utils.FlashZIP(getActivity(), mUri, takeFlags).execute();
if (data != null) {
// Get the URI of the selected file
final Uri uri = data.getData();
Log.i("Magisk", "ModulesFragment: Uri = " + uri.toString() + " or ");
new Utils.FlashZIP(getActivity(),uri).execute();
try {
// Get the file path from the URI
FileInfo fileInfo = FileUtils.getFileInfo(getActivity(), uri);
Toast.makeText(getActivity(),
"File Selected: " + fileInfo.getDisplayName() + " size: " + fileInfo.getSize(), Toast.LENGTH_LONG).show();
if (!fileInfo.isExternal()) {
} else {
}
} catch (Exception e) {
Log.e("FileSelectorTestAc...", "File select error", e);
}
}
}
@Override

View File

@ -506,7 +506,7 @@ public class Utils {
deleteFileAfter = false;
}
public FlashZIP(Context context, Uri uRi, int flags) {
public FlashZIP(Context context, Uri uRi) {
mContext = context;
mUri = uRi;
deleteFileAfter = true;
@ -527,7 +527,7 @@ public class Utils {
this.cancel(true);
}
ContentResolver contentResolver = mContext.getContentResolver();
contentResolver.takePersistableUriPermission(mUri, flags);
//contentResolver.takePersistableUriPermission(mUri, flags);
try {
InputStream in = contentResolver.openInputStream(mUri);
Log.d("Magisk", "Firing inputStream");