use of de.robv.android.xposed.installer.repo.ModuleVersion in project XposedInstaller by rovo89.
the class DownloadDetailsVersionsFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
module = mActivity.getModule();
if (module == null)
return;
if (module.versions.isEmpty()) {
setEmptyText(getString(R.string.download_no_versions));
setListShown(true);
} else {
RepoLoader repoLoader = RepoLoader.getInstance();
if (!repoLoader.isVersionShown(module.versions.get(0))) {
TextView txtHeader = new TextView(getActivity());
txtHeader.setText(R.string.download_test_version_not_shown);
txtHeader.setTextColor(getResources().getColor(R.color.warning));
txtHeader.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mActivity.gotoPage(DownloadDetailsActivity.DOWNLOAD_SETTINGS);
}
});
getListView().addHeaderView(txtHeader);
}
sAdapter = new VersionsAdapter(mActivity, mActivity.getInstalledModule());
for (ModuleVersion version : module.versions) {
if (repoLoader.isVersionShown(version))
sAdapter.add(version);
}
setListAdapter(sAdapter);
}
DisplayMetrics metrics = getResources().getDisplayMetrics();
int sixDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6, metrics);
int eightDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, metrics);
getListView().setDivider(null);
getListView().setDividerHeight(sixDp);
getListView().setPadding(eightDp, eightDp, eightDp, eightDp);
getListView().setClipToPadding(false);
}
use of de.robv.android.xposed.installer.repo.ModuleVersion in project XposedInstaller by rovo89.
the class ModulesFragment method importModules.
private boolean importModules(File path) {
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
Toast.makeText(getActivity(), R.string.sdcard_not_writable, Toast.LENGTH_LONG).show();
return false;
}
InputStream ips = null;
RepoLoader repoLoader = RepoLoader.getInstance();
List<Module> list = new ArrayList<>();
if (!path.exists()) {
Toast.makeText(getActivity(), getString(R.string.no_backup_found), Toast.LENGTH_LONG).show();
return false;
}
try {
ips = new FileInputStream(path);
} catch (FileNotFoundException e) {
Log.e(XposedApp.TAG, "Could not open " + path, e);
}
if (path.length() == 0) {
Toast.makeText(getActivity(), R.string.file_is_empty, Toast.LENGTH_LONG).show();
return false;
}
try {
assert ips != null;
InputStreamReader ipsr = new InputStreamReader(ips);
BufferedReader br = new BufferedReader(ipsr);
String line;
while ((line = br.readLine()) != null) {
Module m = repoLoader.getModule(line);
if (m == null) {
Toast.makeText(getActivity(), getString(R.string.download_details_not_found, line), Toast.LENGTH_SHORT).show();
} else {
list.add(m);
}
}
br.close();
} catch (ActivityNotFoundException | IOException e) {
Toast.makeText(getActivity(), e.toString(), Toast.LENGTH_SHORT).show();
}
for (Module m : list) {
ModuleVersion mv = null;
for (int i = 0; i < m.versions.size(); i++) {
ModuleVersion mvTemp = m.versions.get(i);
if (mvTemp.relType == ReleaseType.STABLE) {
mv = mvTemp;
break;
}
}
if (mv != null) {
DownloadsUtil.add(getActivity(), m.name, mv.downloadLink, new DownloadsUtil.DownloadFinishedCallback() {
@Override
public void onDownloadFinished(Context context, DownloadsUtil.DownloadInfo info) {
XposedApp.installApk(context, info);
}
}, DownloadsUtil.MIME_TYPES.APK);
}
}
return true;
}
Aggregations