Move to raw resources

This commit is contained in:
topjohnwu 2018-02-20 05:07:18 +08:00
parent 25b67017e4
commit df9c40c035
7 changed files with 8 additions and 19 deletions

2
.gitignore vendored
View File

@ -6,7 +6,7 @@
app/release
*.hprof
.externalNativeBuild/
src/main/assets/*.sh
src/main/assets
public.certificate.x509.pem
private.key.pk8
*.apk

View File

@ -14,8 +14,6 @@ import com.topjohnwu.magisk.components.AboutCardRow;
import com.topjohnwu.magisk.components.Activity;
import com.topjohnwu.magisk.utils.Const;
import java.io.IOException;
import java.io.InputStream;
import java.util.Locale;
import butterknife.BindView;
@ -56,12 +54,8 @@ public class AboutActivity extends Activity {
appChangelog.removeSummary();
appChangelog.setOnClickListener(v -> {
try {
InputStream is = getAssets().open("changelog.md");
new MarkDownWindow(this, getString(R.string.app_changelog), is).exec();
} catch (IOException e) {
e.printStackTrace();
}
new MarkDownWindow(this, getString(R.string.app_changelog),
getResources().openRawResource(R.raw.changelog)).exec();
});
String translators = getString(R.string.translators);

View File

@ -23,9 +23,6 @@ import com.topjohnwu.magisk.utils.Topic;
import com.topjohnwu.magisk.utils.Utils;
import com.topjohnwu.superuser.Shell;
import java.io.IOException;
import java.io.InputStream;
import butterknife.BindView;
import butterknife.ButterKnife;
@ -99,12 +96,8 @@ public class MainActivity extends Activity
if (mm.prefs.getInt(Const.Key.APP_VER, -1) < BuildConfig.VERSION_CODE) {
prefs.edit().putInt(Const.Key.APP_VER, BuildConfig.VERSION_CODE).apply();
try {
InputStream is = getAssets().open("changelog.md");
new MarkDownWindow(this, getString(R.string.app_changelog), is).exec();
} catch (IOException e) {
e.printStackTrace();
}
new MarkDownWindow(this, getString(R.string.app_changelog),
getResources().openRawResource(R.raw.changelog)).exec();
}
}

View File

@ -54,11 +54,13 @@ public class MarkDownWindow extends ParallelTask<Void, Void, String> {
}
String css;
try (
InputStream in = mm.getAssets().open(mm.isDarkTheme ? "dark.css" : "light.css");
InputStream in = mm.getResources().openRawResource(
mm.isDarkTheme ? R.raw.dark : R.raw.light);
ByteArrayOutputStream out = new ByteArrayOutputStream()
) {
ShellUtils.pump(in, out);
css = out.toString();
in.close();
} catch (IOException e) {
e.printStackTrace();
return "";