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 app/release
*.hprof *.hprof
.externalNativeBuild/ .externalNativeBuild/
src/main/assets/*.sh src/main/assets
public.certificate.x509.pem public.certificate.x509.pem
private.key.pk8 private.key.pk8
*.apk *.apk

View File

@ -14,8 +14,6 @@ import com.topjohnwu.magisk.components.AboutCardRow;
import com.topjohnwu.magisk.components.Activity; import com.topjohnwu.magisk.components.Activity;
import com.topjohnwu.magisk.utils.Const; import com.topjohnwu.magisk.utils.Const;
import java.io.IOException;
import java.io.InputStream;
import java.util.Locale; import java.util.Locale;
import butterknife.BindView; import butterknife.BindView;
@ -56,12 +54,8 @@ public class AboutActivity extends Activity {
appChangelog.removeSummary(); appChangelog.removeSummary();
appChangelog.setOnClickListener(v -> { appChangelog.setOnClickListener(v -> {
try { new MarkDownWindow(this, getString(R.string.app_changelog),
InputStream is = getAssets().open("changelog.md"); getResources().openRawResource(R.raw.changelog)).exec();
new MarkDownWindow(this, getString(R.string.app_changelog), is).exec();
} catch (IOException e) {
e.printStackTrace();
}
}); });
String translators = getString(R.string.translators); 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.magisk.utils.Utils;
import com.topjohnwu.superuser.Shell; import com.topjohnwu.superuser.Shell;
import java.io.IOException;
import java.io.InputStream;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
@ -99,12 +96,8 @@ public class MainActivity extends Activity
if (mm.prefs.getInt(Const.Key.APP_VER, -1) < BuildConfig.VERSION_CODE) { if (mm.prefs.getInt(Const.Key.APP_VER, -1) < BuildConfig.VERSION_CODE) {
prefs.edit().putInt(Const.Key.APP_VER, BuildConfig.VERSION_CODE).apply(); prefs.edit().putInt(Const.Key.APP_VER, BuildConfig.VERSION_CODE).apply();
try { new MarkDownWindow(this, getString(R.string.app_changelog),
InputStream is = getAssets().open("changelog.md"); getResources().openRawResource(R.raw.changelog)).exec();
new MarkDownWindow(this, getString(R.string.app_changelog), is).exec();
} catch (IOException e) {
e.printStackTrace();
}
} }
} }

View File

@ -54,11 +54,13 @@ public class MarkDownWindow extends ParallelTask<Void, Void, String> {
} }
String css; String css;
try ( 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() ByteArrayOutputStream out = new ByteArrayOutputStream()
) { ) {
ShellUtils.pump(in, out); ShellUtils.pump(in, out);
css = out.toString(); css = out.toString();
in.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
return ""; return "";