2016-08-23 15:02:32 +00:00
|
|
|
package com.topjohnwu.magisk;
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.os.Build;
|
|
|
|
import android.os.Bundle;
|
2016-09-25 15:11:57 +00:00
|
|
|
import android.preference.PreferenceManager;
|
2016-08-23 15:02:32 +00:00
|
|
|
import android.support.annotation.Nullable;
|
|
|
|
import android.support.v7.app.ActionBar;
|
|
|
|
import android.support.v7.app.AlertDialog;
|
|
|
|
import android.support.v7.app.AppCompatActivity;
|
|
|
|
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;
|
2016-08-26 11:01:12 +00:00
|
|
|
import android.view.WindowManager;
|
2016-08-23 15:02:32 +00:00
|
|
|
import android.widget.TextView;
|
|
|
|
|
2016-09-25 15:11:57 +00:00
|
|
|
import com.topjohnwu.magisk.utils.Logger;
|
2016-08-23 15:02:32 +00:00
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
|
import butterknife.ButterKnife;
|
|
|
|
|
2016-09-30 10:07:08 +00:00
|
|
|
public class AboutActivity extends AppCompatActivity {
|
2016-08-23 15:02:32 +00:00
|
|
|
|
|
|
|
private static final String SOURCE_CODE_URL = "https://github.com/topjohnwu/MagiskManager";
|
2016-09-29 15:24:31 +00:00
|
|
|
private static final String XDA_THREAD = "http://forum.xda-developers.com/showthread.php?t=3432382";
|
|
|
|
private static final String DONATION_URL = "http://topjohnwu.github.io/donate";
|
|
|
|
|
2016-09-25 15:11:57 +00:00
|
|
|
private AlertDialog.Builder builder;
|
2016-08-23 15:02:32 +00:00
|
|
|
@BindView(R.id.toolbar) Toolbar toolbar;
|
|
|
|
|
|
|
|
@BindView(R.id.app_version_info) RowItem appVersionInfo;
|
|
|
|
@BindView(R.id.app_changelog) RowItem appChangelog;
|
|
|
|
@BindView(R.id.app_developers) RowItem appDevelopers;
|
|
|
|
@BindView(R.id.app_translators) RowItem appTranslators;
|
|
|
|
@BindView(R.id.app_source_code) RowItem appSourceCode;
|
|
|
|
@BindView(R.id.support_thread) RowItem supportThread;
|
2016-09-29 15:24:31 +00:00
|
|
|
@BindView(R.id.donation) RowItem donation;
|
2016-08-23 15:02:32 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
2016-09-25 15:11:57 +00:00
|
|
|
String theme = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("theme", "");
|
2016-09-27 16:33:01 +00:00
|
|
|
Logger.dev("AboutActivity: Theme is " + theme);
|
2016-09-25 15:11:57 +00:00
|
|
|
if (theme.equals("Dark")) {
|
|
|
|
setTheme(R.style.AppTheme_dh);
|
|
|
|
}
|
2016-08-23 15:02:32 +00:00
|
|
|
setContentView(R.layout.activity_about);
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
|
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
appVersionInfo.setSummary(BuildConfig.VERSION_NAME);
|
|
|
|
|
|
|
|
String changes = null;
|
|
|
|
try {
|
|
|
|
InputStream is = getAssets().open("changelog.html");
|
|
|
|
int size = is.available();
|
|
|
|
|
|
|
|
byte[] buffer = new byte[size];
|
|
|
|
is.read(buffer);
|
|
|
|
is.close();
|
|
|
|
|
|
|
|
changes = new String(buffer);
|
|
|
|
} catch (IOException ignored) {
|
|
|
|
}
|
|
|
|
|
|
|
|
appChangelog.removeSummary();
|
2016-09-25 15:11:57 +00:00
|
|
|
if (theme.equals("Dark")) {
|
|
|
|
builder = new AlertDialog.Builder(this,R.style.AlertDialog_dh);
|
|
|
|
} else {
|
|
|
|
builder = new AlertDialog.Builder(this);
|
|
|
|
}
|
2016-08-23 15:02:32 +00:00
|
|
|
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) {
|
|
|
|
result = Html.fromHtml(changes,Html.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE);
|
|
|
|
} else {
|
|
|
|
result = Html.fromHtml(changes);
|
|
|
|
}
|
2016-08-28 22:35:07 +00:00
|
|
|
appChangelog.setOnClickListener(v -> {
|
2016-09-25 15:11:57 +00:00
|
|
|
AlertDialog d = builder
|
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)
|
|
|
|
.create();
|
|
|
|
|
|
|
|
d.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) {
|
|
|
|
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 = builder
|
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();
|
2016-08-28 22:35:07 +00:00
|
|
|
appSourceCode.setOnClickListener(view -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(SOURCE_CODE_URL))));
|
2016-08-23 15:02:32 +00:00
|
|
|
|
|
|
|
supportThread.removeSummary();
|
2016-08-28 22:35:07 +00:00
|
|
|
supportThread.setOnClickListener(view -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(XDA_THREAD))));
|
2016-08-26 11:01:12 +00:00
|
|
|
|
2016-09-29 15:24:31 +00:00
|
|
|
donation.removeSummary();
|
|
|
|
donation.setOnClickListener(view -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(DONATION_URL))));
|
|
|
|
|
2016-08-26 11:01:12 +00:00
|
|
|
setFloating();
|
|
|
|
}
|
|
|
|
|
2016-09-23 21:22:11 +00:00
|
|
|
|
|
|
|
|
2016-08-26 11:01:12 +00:00
|
|
|
public void setFloating() {
|
|
|
|
boolean isTablet = getResources().getBoolean(R.bool.isTablet);
|
|
|
|
if (isTablet) {
|
|
|
|
WindowManager.LayoutParams params = getWindow().getAttributes();
|
|
|
|
params.height = getResources().getDimensionPixelSize(R.dimen.floating_height);
|
|
|
|
params.width = getResources().getDimensionPixelSize(R.dimen.floating_width);
|
|
|
|
params.alpha = 1.0f;
|
|
|
|
params.dimAmount = 0.6f;
|
|
|
|
params.flags |= 2;
|
|
|
|
getWindow().setAttributes(params);
|
|
|
|
setFinishOnTouchOutside(true);
|
|
|
|
}
|
2016-08-23 15:02:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onResume() {
|
|
|
|
super.onResume();
|
|
|
|
|
2016-09-23 21:22:11 +00:00
|
|
|
setTitle("About");
|
|
|
|
|
|
|
|
|
2016-09-25 15:11:57 +00:00
|
|
|
}
|
2016-08-23 15:02:32 +00:00
|
|
|
}
|