Add changelogs

This commit is contained in:
topjohnwu 2017-12-03 02:48:21 +08:00
parent b2873dd44b
commit 1cd2c5e653
15 changed files with 79 additions and 110 deletions

View File

@ -0,0 +1,5 @@
### v5.4.3 (68)
- Fix dynamic resource loading, should prevent crashing when chacking SafetyNet
- Update SignAPK to use very little RAM, should expand old device support
- Support settings migration after hiding Magisk Manager
- Add changelog in app

View File

@ -4,7 +4,7 @@ body {
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: #303030;
background-color: #424242;
color: white;
padding: 15px; }

View File

@ -5,18 +5,13 @@ import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
import android.text.Html;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.widget.TextView;
import com.topjohnwu.magisk.asyncs.MarkDownWindow;
import com.topjohnwu.magisk.components.AboutCardRow;
import com.topjohnwu.magisk.components.Activity;
import com.topjohnwu.magisk.components.AlertDialogBuilder;
import com.topjohnwu.magisk.utils.Const;
import java.io.IOException;
@ -31,7 +26,6 @@ public class AboutActivity extends Activity {
@BindView(R.id.toolbar) Toolbar toolbar;
@BindView(R.id.app_version_info) AboutCardRow appVersionInfo;
@BindView(R.id.app_changelog) AboutCardRow appChangelog;
@BindView(R.id.app_developers) AboutCardRow appDevelopers;
@BindView(R.id.app_translators) AboutCardRow appTranslators;
@BindView(R.id.app_source_code) AboutCardRow appSourceCode;
@BindView(R.id.support_thread) AboutCardRow supportThread;
@ -40,9 +34,6 @@ public class AboutActivity extends Activity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getMagiskManager().isDarkTheme) {
setTheme(R.style.AppTheme_Transparent_Dark);
}
setContentView(R.layout.activity_about);
ButterKnife.bind(this);
@ -55,58 +46,17 @@ public class AboutActivity extends Activity {
ab.setDisplayHomeAsUpEnabled(true);
}
appVersionInfo.setSummary(String.format(Locale.US, "%s (%d)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE));
String changes = null;
try (InputStream is = getAssets().open("changelog.html")) {
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
changes = new String(buffer);
} catch (IOException ignored) {
}
appVersionInfo.setSummary(String.format(Locale.US, "%s (%d) (%s)",
BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, getPackageName()));
appChangelog.removeSummary();
if (changes == null) {
appChangelog.setVisibility(View.GONE);
} else {
Spanned result;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
result = Html.fromHtml(changes, Html.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE);
} else {
result = Html.fromHtml(changes);
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();
}
appChangelog.setOnClickListener(v -> {
AlertDialog d = new AlertDialogBuilder(this)
.setTitle(R.string.app_changelog)
.setMessage(result)
.setPositiveButton(android.R.string.ok, null)
.show();
//noinspection ConstantConditions
((TextView) d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
});
}
appDevelopers.removeSummary();
appDevelopers.setOnClickListener(view -> {
Spanned result;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
result = Html.fromHtml(getString(R.string.app_developers_), Html.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE);
} else {
result = Html.fromHtml(getString(R.string.app_developers_));
}
AlertDialog d = new AlertDialogBuilder(this)
.setTitle(R.string.app_developers)
.setMessage(result)
.setPositiveButton(android.R.string.ok, null)
.create();
d.show();
//noinspection ConstantConditions
((TextView) d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
});
String translators = getString(R.string.translators);

View File

@ -52,6 +52,7 @@ public class MagiskManager extends Application {
public String bootBlock = null;
public int snet_version;
public int updateServiceVersion;
public int appVersion;
// Data
public Map<String, Module> moduleMap;
@ -163,6 +164,7 @@ public class MagiskManager extends Application {
snet_version = prefs.getInt(Const.Key.SNET_VER, -1);
updateServiceVersion = prefs.getInt(Const.Key.UPDATE_SERVICE_VER, -1);
customChannelUrl = prefs.getString(Const.Key.CUSTOM_CHANNEL, "");
appVersion = prefs.getInt(Const.Key.APP_VER, 0);
}
public static void toast(String msg, int duration) {

View File

@ -16,12 +16,16 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import com.topjohnwu.magisk.asyncs.MarkDownWindow;
import com.topjohnwu.magisk.components.Activity;
import com.topjohnwu.magisk.utils.Const;
import com.topjohnwu.magisk.utils.Shell;
import com.topjohnwu.magisk.utils.Topic;
import com.topjohnwu.magisk.utils.Utils;
import java.io.IOException;
import java.io.InputStream;
import butterknife.BindView;
import butterknife.ButterKnife;
@ -42,6 +46,7 @@ public class MainActivity extends Activity
protected void onCreate(final Bundle savedInstanceState) {
MagiskManager mm = getMagiskManager();
prefs = mm.prefs;
if (!mm.hasInit) {
Intent intent = new Intent(this, SplashActivity.class);
@ -58,11 +63,6 @@ public class MainActivity extends Activity
ActivityCompat.requestPermissions(this, new String[] { perm }, 0);
}
prefs = mm.prefs;
if (mm.isDarkTheme) {
setTheme(R.style.AppTheme_Dark);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
@ -91,6 +91,17 @@ public class MainActivity extends Activity
navigate(getIntent().getStringExtra(Const.Key.OPEN_SECTION));
navigationView.setNavigationItemSelectedListener(this);
if (mm.appVersion < BuildConfig.VERSION_CODE) {
prefs.edit().putInt(Const.Key.APP_VER, BuildConfig.VERSION_CODE).apply();
mm.appVersion = BuildConfig.VERSION_CODE;
try {
InputStream is = getAssets().open("changelog.md");
new MarkDownWindow(this, getString(R.string.app_changelog), is).exec();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override

View File

@ -38,10 +38,6 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getMagiskManager().isDarkTheme) {
setTheme(R.style.AppTheme_Transparent_Dark);
}
setContentView(R.layout.activity_settings);
ButterKnife.bind(this);

View File

@ -6,15 +6,23 @@ import android.webkit.WebView;
import com.topjohnwu.magisk.MagiskManager;
import com.topjohnwu.magisk.R;
import com.topjohnwu.magisk.utils.Utils;
import com.topjohnwu.magisk.utils.WebService;
import org.commonmark.node.Node;
import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class MarkDownWindow extends ParallelTask<Void, Void, String> {
private String mTitle, mUrl;
private String mTitle;
private String mUrl;
private InputStream is;
public MarkDownWindow(Activity context, String title, String url) {
super(context);
@ -22,9 +30,28 @@ public class MarkDownWindow extends ParallelTask<Void, Void, String> {
mUrl = url;
}
public MarkDownWindow(Activity context, String title, InputStream in) {
super(context);
mTitle = title;
is = in;
}
@Override
protected String doInBackground(Void... voids) {
String md = WebService.getString(mUrl);
String md;
if (mUrl != null) {
md = WebService.getString(mUrl);
} else {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
Utils.inToOut(is, out);
md = out.toString();
is.close();
} catch (IOException e) {
e.printStackTrace();
return "";
}
}
Parser parser = Parser.builder().build();
HtmlRenderer renderer = HtmlRenderer.builder().build();
Node doc = parser.parse(md);

View File

@ -37,6 +37,9 @@ public class Activity extends AppCompatActivity {
if (this instanceof Topic.Subscriber) {
((Topic.Subscriber) this).subscribeTopics();
}
if (getMagiskManager().isDarkTheme) {
setTheme(R.style.AppTheme_Dark);
}
}
@Override

View File

@ -9,8 +9,6 @@ import android.support.annotation.StyleRes;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -29,7 +27,6 @@ public class AlertDialogBuilder extends AlertDialog.Builder {
@BindView(R.id.positive) Button positive;
@BindView(R.id.neutral) Button neutral;
@BindView(R.id.message) TextView messageView;
@BindView(R.id.custom_view) ViewStub custom;
private DialogInterface.OnClickListener positiveListener;
private DialogInterface.OnClickListener negativeListener;
@ -59,20 +56,15 @@ public class AlertDialogBuilder extends AlertDialog.Builder {
}
@Override
public AlertDialog.Builder setView(int layoutResId) {
custom.setLayoutResource(layoutResId);
custom.inflate();
return this;
public AlertDialog.Builder setTitle(int titleId) {
return super.setTitle(titleId);
}
@Override
public AlertDialog.Builder setView(View view) {
ViewGroup parent = (ViewGroup) custom.getParent();
int idx = parent.indexOfChild(custom);
parent.removeView(custom);
parent.addView(view, idx);
return this;
}
public AlertDialog.Builder setView(int layoutResId) { return this; }
@Override
public AlertDialog.Builder setView(View view) { return this; }
@Override
public AlertDialog.Builder setMessage(@Nullable CharSequence message) {

View File

@ -118,6 +118,7 @@ public class Const {
public static final String BOOT_FORMAT = "boot_format";
public static final String SNET_VER = "snet_version";
public static final String UPDATE_SERVICE_VER = "update_service_version";
public static final String APP_VER = "app_version";
public static final String MAGISKHIDE = "magiskhide";
public static final String HOSTS = "hosts";
public static final String DISABLE = "disable";

View File

@ -24,14 +24,12 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="8dp"
style="?attr/cardStyle"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:orientation="vertical">
<LinearLayout
@ -70,13 +68,6 @@
app:icon="@drawable/ic_history"
app:text="@string/app_changelog"/>
<com.topjohnwu.magisk.components.AboutCardRow
android:id="@+id/app_developers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:icon="@drawable/ic_person"
app:text="@string/app_developers"/>
<com.topjohnwu.magisk.components.AboutCardRow
android:id="@+id/app_translators"
android:layout_width="match_parent"
@ -99,14 +90,12 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="8dp"
style="?attr/cardStyle"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:orientation="vertical">
<com.topjohnwu.magisk.components.AboutCardRow

View File

@ -38,7 +38,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@color/button_panel_background_color"
android:orientation="horizontal"
android:visibility="gone">

View File

@ -8,7 +8,7 @@
<LinearLayout
android:id="@+id/message_panel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="12dip"
android:paddingEnd="20dip"
@ -25,11 +25,6 @@
</LinearLayout>
<ViewStub
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/custom_view"/>
<LinearLayout
style="?android:attr/buttonBarStyle"
android:id="@+id/button_panel"
@ -46,7 +41,7 @@
android:id="@+id/negative"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_weight="1"
android:maxLines="2" />
@ -55,7 +50,7 @@
android:id="@+id/neutral"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:maxLines="2" />
@ -64,7 +59,7 @@
android:id="@+id/positive"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:layout_weight="1"
android:maxLines="2" />

View File

@ -20,5 +20,4 @@
<!-- Flashing colors -->
<color name="flashing_background_color">@android:color/black</color>
<color name="button_panel_background_color">@android:color/darker_gray</color>
</resources>

View File

@ -66,12 +66,12 @@
<string name="about">About</string>
<string name="app_developers">Main developers</string>
<string name="app_developers_"><![CDATA[App created by <a href="https://github.com/topjohnwu">topjohnwu</a> in collaboration with <a href="https://github.com/d8ahazard">Digitalhigh</a> and <a href="https://github.com/dvdandroid">Dvdandroid</a>.]]></string>
<string name="app_changelog">App\'s changelog</string>
<string name="app_changelog">Changelog</string>
<string name="translators" />
<string name="app_version">App\'s version</string>
<string name="app_version">Version</string>
<string name="app_source_code">Source code</string>
<string name="donation">Donation</string>
<string name="app_translators">App\'s translators</string>
<string name="app_translators">Translators</string>
<string name="support_thread">Support thread</string>
<!--Toasts, Dialogs-->