diff --git a/app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java b/app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java index 6f795d77b..4f87f4e64 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java @@ -1,8 +1,12 @@ package com.topjohnwu.magisk; +import android.app.Activity; +import android.content.Intent; +import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.support.annotation.Nullable; +import android.support.design.widget.FloatingActionButton; import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; @@ -17,8 +21,11 @@ import android.view.ViewGroup; import android.widget.ProgressBar; import com.topjohnwu.magisk.module.Module; +import com.topjohnwu.magisk.utils.Shell; import com.topjohnwu.magisk.utils.Utils; +import java.io.File; +import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutionException; @@ -30,8 +37,11 @@ public class ModulesFragment extends Fragment { public static List listModules = new ArrayList<>(); public static List listModulesCache = new ArrayList<>(); + private static final int FILE_SELECT_CODE = 0; + private File input; @BindView(R.id.progressBar) ProgressBar progressBar; + @BindView(R.id.fab) FloatingActionButton fabio; @BindView(R.id.pager) ViewPager viewPager; @BindView(R.id.tab_layout) TabLayout tabLayout; @@ -51,8 +61,32 @@ public class ModulesFragment extends Fragment { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.menu_module, menu); + fabio.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + Intent intent = new Intent(); + intent.setType("*/zip"); + intent.setAction(Intent.ACTION_GET_CONTENT); + startActivityForResult(intent,FILE_SELECT_CODE); + } + }); } + public void onActivityResult(int requestCode, int resultCode, Intent data) { + switch (requestCode) { + case FILE_SELECT_CODE: + if (resultCode == Activity.RESULT_OK) { + // Get the Uri of the selected file + Uri uri = data.getData(); + String path = uri.getPath(); + String fileName = uri.getLastPathSegment(); + new Utils.FlashZIP(getActivity(), fileName, path).execute(); + + } + break; + }} + @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { diff --git a/app/src/main/res/drawable/ic_add.xml b/app/src/main/res/drawable/ic_add.xml new file mode 100644 index 000000000..0258249cc --- /dev/null +++ b/app/src/main/res/drawable/ic_add.xml @@ -0,0 +1,9 @@ + + +