Holy tapdancing god, it works now!
This commit is contained in:
parent
8f973661f4
commit
0b02e8116c
@ -24,7 +24,32 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</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
|
<activity
|
||||||
android:name=".AboutActivity"
|
android:name=".AboutActivity"
|
||||||
android:theme="@style/AppTheme.Transparent"/>
|
android:theme="@style/AppTheme.Transparent"/>
|
||||||
|
@ -2,9 +2,12 @@ package com.topjohnwu.magisk;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.provider.MediaStore;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
import android.support.design.widget.TabLayout;
|
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.FragmentManager;
|
||||||
import android.support.v4.app.FragmentPagerAdapter;
|
import android.support.v4.app.FragmentPagerAdapter;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ProgressBar;
|
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.Module;
|
||||||
import com.topjohnwu.magisk.module.RepoHelper;
|
import com.topjohnwu.magisk.module.RepoHelper;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
@ -54,9 +61,10 @@ public class ModulesFragment extends Fragment {
|
|||||||
|
|
||||||
ButterKnife.bind(this, view);
|
ButterKnife.bind(this, view);
|
||||||
fabio.setOnClickListener(v -> {
|
fabio.setOnClickListener(v -> {
|
||||||
Intent fileIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
Intent getContentIntent = FileUtils.createGetContentIntent(null);
|
||||||
fileIntent.setType("application/zip");
|
getContentIntent.setType("application/zip");
|
||||||
fileIntent.addCategory(Intent.CATEGORY_OPENABLE);
|
Intent fileIntent = Intent.createChooser(getContentIntent, "Select a file");
|
||||||
|
|
||||||
startActivityForResult(fileIntent, FETCH_ZIP_CODE);
|
startActivityForResult(fileIntent, FETCH_ZIP_CODE);
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -75,13 +83,27 @@ public class ModulesFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
Uri mUri = data.getData();
|
if (data != null) {
|
||||||
final int takeFlags = data.getFlags()
|
// Get the URI of the selected file
|
||||||
& (Intent.FLAG_GRANT_READ_URI_PERMISSION
|
final Uri uri = data.getData();
|
||||||
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
Log.i("Magisk", "ModulesFragment: Uri = " + uri.toString() + " or ");
|
||||||
if (resultCode == Activity.RESULT_OK && requestCode == FETCH_ZIP_CODE) {
|
new Utils.FlashZIP(getActivity(),uri).execute();
|
||||||
new Utils.FlashZIP(getActivity(), mUri, takeFlags).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
|
@Override
|
||||||
|
@ -506,7 +506,7 @@ public class Utils {
|
|||||||
deleteFileAfter = false;
|
deleteFileAfter = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlashZIP(Context context, Uri uRi, int flags) {
|
public FlashZIP(Context context, Uri uRi) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mUri = uRi;
|
mUri = uRi;
|
||||||
deleteFileAfter = true;
|
deleteFileAfter = true;
|
||||||
@ -527,7 +527,7 @@ public class Utils {
|
|||||||
this.cancel(true);
|
this.cancel(true);
|
||||||
}
|
}
|
||||||
ContentResolver contentResolver = mContext.getContentResolver();
|
ContentResolver contentResolver = mContext.getContentResolver();
|
||||||
contentResolver.takePersistableUriPermission(mUri, flags);
|
//contentResolver.takePersistableUriPermission(mUri, flags);
|
||||||
try {
|
try {
|
||||||
InputStream in = contentResolver.openInputStream(mUri);
|
InputStream in = contentResolver.openInputStream(mUri);
|
||||||
Log.d("Magisk", "Firing inputStream");
|
Log.d("Magisk", "Firing inputStream");
|
||||||
|
Loading…
Reference in New Issue
Block a user