2016-08-23 15:02:32 +00:00
|
|
|
package com.topjohnwu.magisk;
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.support.annotation.Nullable;
|
|
|
|
import android.support.v7.app.ActionBar;
|
2017-02-12 11:49:46 +00:00
|
|
|
import android.support.v7.app.AlertDialog;
|
2016-08-23 15:02:32 +00:00
|
|
|
import android.support.v7.widget.Toolbar;
|
|
|
|
import android.text.Html;
|
2016-09-25 15:11:57 +00:00
|
|
|
import android.text.Spanned;
|
2016-08-23 15:02:32 +00:00
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.method.LinkMovementMethod;
|
|
|
|
import android.view.View;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
2017-02-12 19:12:10 +00:00
|
|
|
import com.topjohnwu.magisk.components.AboutCardRow;
|
2017-02-06 18:01:32 +00:00
|
|
|
import com.topjohnwu.magisk.components.Activity;
|
2017-02-14 21:24:02 +00:00
|
|
|
import com.topjohnwu.magisk.components.AlertDialogBuilder;
|
2017-11-05 20:41:23 +00:00
|
|
|
import com.topjohnwu.magisk.utils.Const;
|
2016-08-23 15:02:32 +00:00
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
2017-10-14 19:12:13 +00:00
|
|
|
import java.util.Locale;
|
2016-08-23 15:02:32 +00:00
|
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
|
import butterknife.ButterKnife;
|
|
|
|
|
2017-02-06 18:01:32 +00:00
|
|
|
public class AboutActivity extends Activity {
|
2016-08-23 15:02:32 +00:00
|
|
|
|
|
|
|
@BindView(R.id.toolbar) Toolbar toolbar;
|
2016-11-07 13:06:18 +00:00
|
|
|
@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;
|
|
|
|
@BindView(R.id.donation) AboutCardRow donation;
|
2016-08-23 15:02:32 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
2017-09-03 07:35:14 +00:00
|
|
|
if (getMagiskManager().isDarkTheme) {
|
2017-05-26 10:20:53 +00:00
|
|
|
setTheme(R.style.AppTheme_Transparent_Dark);
|
2016-09-25 15:11:57 +00:00
|
|
|
}
|
2016-08-23 15:02:32 +00:00
|
|
|
setContentView(R.layout.activity_about);
|
|
|
|
ButterKnife.bind(this);
|
|
|
|
|
|
|
|
setSupportActionBar(toolbar);
|
2016-08-28 22:35:07 +00:00
|
|
|
toolbar.setNavigationOnClickListener(view -> finish());
|
2016-08-23 15:02:32 +00:00
|
|
|
|
|
|
|
ActionBar ab = getSupportActionBar();
|
|
|
|
if (ab != null) {
|
|
|
|
ab.setTitle(R.string.about);
|
|
|
|
ab.setDisplayHomeAsUpEnabled(true);
|
|
|
|
}
|
|
|
|
|
2017-10-14 19:12:13 +00:00
|
|
|
appVersionInfo.setSummary(String.format(Locale.US, "%s (%d)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE));
|
2016-08-23 15:02:32 +00:00
|
|
|
|
|
|
|
String changes = null;
|
2017-01-12 01:02:52 +00:00
|
|
|
try (InputStream is = getAssets().open("changelog.html")) {
|
2016-08-23 15:02:32 +00:00
|
|
|
int size = is.available();
|
|
|
|
|
|
|
|
byte[] buffer = new byte[size];
|
|
|
|
is.read(buffer);
|
|
|
|
|
|
|
|
changes = new String(buffer);
|
|
|
|
} catch (IOException ignored) {
|
|
|
|
}
|
|
|
|
|
|
|
|
appChangelog.removeSummary();
|
|
|
|
if (changes == null) {
|
|
|
|
appChangelog.setVisibility(View.GONE);
|
|
|
|
} else {
|
2016-09-25 15:11:57 +00:00
|
|
|
Spanned result;
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
2016-09-29 20:18:41 +00:00
|
|
|
result = Html.fromHtml(changes, Html.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE);
|
2016-09-25 15:11:57 +00:00
|
|
|
} else {
|
|
|
|
result = Html.fromHtml(changes);
|
|
|
|
}
|
2016-08-28 22:35:07 +00:00
|
|
|
appChangelog.setOnClickListener(v -> {
|
2017-02-14 21:24:02 +00:00
|
|
|
AlertDialog d = new AlertDialogBuilder(this)
|
2016-08-28 22:35:07 +00:00
|
|
|
.setTitle(R.string.app_changelog)
|
2016-09-25 15:11:57 +00:00
|
|
|
.setMessage(result)
|
2016-08-23 15:02:32 +00:00
|
|
|
.setPositiveButton(android.R.string.ok, null)
|
2017-01-10 14:30:05 +00:00
|
|
|
.show();
|
2016-08-28 22:35:07 +00:00
|
|
|
|
2016-08-23 15:02:32 +00:00
|
|
|
//noinspection ConstantConditions
|
|
|
|
((TextView) d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
|
2016-08-28 22:35:07 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
appDevelopers.removeSummary();
|
|
|
|
appDevelopers.setOnClickListener(view -> {
|
2016-09-25 15:11:57 +00:00
|
|
|
Spanned result;
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
2016-09-29 20:18:41 +00:00
|
|
|
result = Html.fromHtml(getString(R.string.app_developers_), Html.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE);
|
2016-09-25 15:11:57 +00:00
|
|
|
} else {
|
|
|
|
result = Html.fromHtml(getString(R.string.app_developers_));
|
|
|
|
}
|
2017-02-14 21:24:02 +00:00
|
|
|
AlertDialog d = new AlertDialogBuilder(this)
|
2016-08-28 22:35:07 +00:00
|
|
|
.setTitle(R.string.app_developers)
|
2016-09-25 15:11:57 +00:00
|
|
|
.setMessage(result)
|
2016-08-28 22:35:07 +00:00
|
|
|
.setPositiveButton(android.R.string.ok, null)
|
|
|
|
.create();
|
|
|
|
|
|
|
|
d.show();
|
|
|
|
//noinspection ConstantConditions
|
|
|
|
((TextView) d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
|
2016-08-23 15:02:32 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
String translators = getString(R.string.translators);
|
|
|
|
if (TextUtils.isEmpty(translators)) {
|
|
|
|
appTranslators.setVisibility(View.GONE);
|
|
|
|
} else {
|
|
|
|
appTranslators.setSummary(translators);
|
|
|
|
}
|
|
|
|
|
|
|
|
appSourceCode.removeSummary();
|
2017-11-05 20:41:23 +00:00
|
|
|
appSourceCode.setOnClickListener(view -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Const.Url.SOURCE_CODE_URL))));
|
2016-08-23 15:02:32 +00:00
|
|
|
|
|
|
|
supportThread.removeSummary();
|
2017-11-05 20:41:23 +00:00
|
|
|
supportThread.setOnClickListener(view -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Const.Url.XDA_THREAD))));
|
2016-08-26 11:01:12 +00:00
|
|
|
|
2016-09-29 15:24:31 +00:00
|
|
|
donation.removeSummary();
|
2017-11-05 20:41:23 +00:00
|
|
|
donation.setOnClickListener(view -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Const.Url.DONATION_URL))));
|
2016-09-29 15:24:31 +00:00
|
|
|
|
2016-08-26 11:01:12 +00:00
|
|
|
setFloating();
|
|
|
|
}
|
|
|
|
|
2016-08-23 15:02:32 +00:00
|
|
|
}
|