Improve About and Donation page

This commit is contained in:
topjohnwu 2018-08-30 05:05:29 -04:00
parent adfffe6121
commit 7ae8c26e50
14 changed files with 187 additions and 54 deletions

View File

@ -28,6 +28,9 @@
<activity <activity
android:name=".AboutActivity" android:name=".AboutActivity"
android:theme="@style/AppTheme.StatusBar" /> android:theme="@style/AppTheme.StatusBar" />
<activity
android:name=".DonationActivity"
android:theme="@style/AppTheme.StatusBar"/>
<activity <activity
android:name=".FlashActivity" android:name=".FlashActivity"
android:configChanges="keyboardHidden|orientation|screenSize" android:configChanges="keyboardHidden|orientation|screenSize"

View File

@ -26,7 +26,7 @@ public class AboutActivity extends BaseActivity {
@BindView(R.id.app_translators) AboutCardRow appTranslators; @BindView(R.id.app_translators) AboutCardRow appTranslators;
@BindView(R.id.app_source_code) AboutCardRow appSourceCode; @BindView(R.id.app_source_code) AboutCardRow appSourceCode;
@BindView(R.id.support_thread) AboutCardRow supportThread; @BindView(R.id.support_thread) AboutCardRow supportThread;
@BindView(R.id.donation) AboutCardRow donation; @BindView(R.id.follow_twitter) AboutCardRow twitter;
@Override @Override
public int getDarkTheme() { public int getDarkTheme() {
@ -51,7 +51,6 @@ public class AboutActivity extends BaseActivity {
appVersionInfo.setSummary(String.format(Locale.US, "%s (%d) (%s)", appVersionInfo.setSummary(String.format(Locale.US, "%s (%d) (%s)",
BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, getPackageName())); BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, getPackageName()));
appChangelog.removeSummary();
appChangelog.setOnClickListener(v -> { appChangelog.setOnClickListener(v -> {
new MarkDownWindow(this, getString(R.string.app_changelog), new MarkDownWindow(this, getString(R.string.app_changelog),
getResources().openRawResource(R.raw.changelog)).exec(); getResources().openRawResource(R.raw.changelog)).exec();
@ -64,14 +63,9 @@ public class AboutActivity extends BaseActivity {
appTranslators.setSummary(translators); appTranslators.setSummary(translators);
} }
appSourceCode.removeSummary(); appSourceCode.setOnClickListener(v -> Utils.openLink(this, Uri.parse(Const.Url.SOURCE_CODE_URL)));
appSourceCode.setOnClickListener(view -> Utils.openLink(this, Uri.parse(Const.Url.SOURCE_CODE_URL))); supportThread.setOnClickListener(v -> Utils.openLink(this, Uri.parse(Const.Url.XDA_THREAD)));
twitter.setOnClickListener(v -> Utils.openLink(this, Uri.parse(Const.Url.TWITTER_URL)));
supportThread.removeSummary();
supportThread.setOnClickListener(view -> Utils.openLink(this, Uri.parse(Const.Url.XDA_THREAD)));
donation.removeSummary();
donation.setOnClickListener(view -> Utils.openLink(this, Uri.parse(Const.Url.DONATION_URL)));
setFloating(); setFloating();
} }

View File

@ -78,7 +78,9 @@ public class Const {
public static final String REPO_URL = "https://api.github.com/users/Magisk-Modules-Repo/repos?per_page=100&sort=pushed&page=%d"; public static final String REPO_URL = "https://api.github.com/users/Magisk-Modules-Repo/repos?per_page=100&sort=pushed&page=%d";
public static final String FILE_URL = "https://raw.githubusercontent.com/Magisk-Modules-Repo/%s/master/%s"; public static final String FILE_URL = "https://raw.githubusercontent.com/Magisk-Modules-Repo/%s/master/%s";
public static final String ZIP_URL = "https://github.com/Magisk-Modules-Repo/%s/archive/master.zip"; public static final String ZIP_URL = "https://github.com/Magisk-Modules-Repo/%s/archive/master.zip";
public static final String DONATION_URL = "https://www.paypal.me/topjohnwu"; public static final String PAYPAL_URL = "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=CC7FZ7526MNGG";
public static final String PATREON_URL = "https://www.patreon.com/topjohnwu";
public static final String TWITTER_URL = "https://twitter.com/topjohnwu";
public static final String XDA_THREAD = "http://forum.xda-developers.com/showthread.php?t=3432382"; public static final String XDA_THREAD = "http://forum.xda-developers.com/showthread.php?t=3432382";
public static final String SOURCE_CODE_URL = "https://github.com/topjohnwu/Magisk"; public static final String SOURCE_CODE_URL = "https://github.com/topjohnwu/Magisk";
} }

View File

@ -0,0 +1,45 @@
package com.topjohnwu.magisk;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import com.topjohnwu.magisk.components.AboutCardRow;
import com.topjohnwu.magisk.components.BaseActivity;
import com.topjohnwu.magisk.utils.Utils;
import butterknife.BindView;
import butterknife.ButterKnife;
public class DonationActivity extends BaseActivity {
@BindView(R.id.toolbar) Toolbar toolbar;
@BindView(R.id.paypal) AboutCardRow paypal;
@BindView(R.id.patreon) AboutCardRow patreon;
@Override
public int getDarkTheme() {
return R.style.AppTheme_StatusBar_Dark;
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_donation);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(view -> finish());
ActionBar ab = getSupportActionBar();
if (ab != null) {
ab.setTitle(R.string.donation);
ab.setDisplayHomeAsUpEnabled(true);
}
paypal.setOnClickListener(v -> Utils.openLink(this, Uri.parse(Const.Url.PAYPAL_URL)));
patreon.setOnClickListener(v -> Utils.openLink(this, Uri.parse(Const.Url.PATREON_URL)));
}
}

View File

@ -160,6 +160,9 @@ public class MainActivity extends BaseActivity
case "about": case "about":
itemId = R.id.app_about; itemId = R.id.app_about;
break; break;
case "donation":
itemId = R.id.donation;
break;
} }
} }
navigate(itemId); navigate(itemId);
@ -196,6 +199,10 @@ public class MainActivity extends BaseActivity
startActivity(new Intent(this, AboutActivity.class)); startActivity(new Intent(this, AboutActivity.class));
mDrawerItem = bak; mDrawerItem = bak;
break; break;
case R.id.donation:
startActivity(new Intent(this, DonationActivity.class));
mDrawerItem = bak;
break;
} }
} }

View File

@ -28,19 +28,18 @@ import android.widget.TextView;
import com.topjohnwu.magisk.R; import com.topjohnwu.magisk.R;
import butterknife.BindView;
import butterknife.ButterKnife;
/** /**
* @author dvdandroid * @author dvdandroid
*/ */
public class AboutCardRow extends LinearLayout { public class AboutCardRow extends LinearLayout {
private final String title; @BindView(android.R.id.title) TextView mTitle;
private final Drawable icon; @BindView(android.R.id.summary) TextView mSummary;
@BindView(android.R.id.icon) ImageView mIcon;
private final TextView mTitle; @BindView(R.id.container) View mView;
private final TextView mSummary;
private final ImageView mIcon;
private final View mView;
public AboutCardRow(Context context) { public AboutCardRow(Context context) {
this(context, null); this(context, null);
@ -53,21 +52,17 @@ public class AboutCardRow extends LinearLayout {
public AboutCardRow(Context context, AttributeSet attrs, int defStyleAttr) { public AboutCardRow(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr); super(context, attrs, defStyleAttr);
LayoutInflater.from(context).inflate(R.layout.info_item_row, this); LayoutInflater.from(context).inflate(R.layout.info_item_row, this);
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.AboutCardRow, 0, 0); ButterKnife.bind(this, this);
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.AboutCardRow, 0, 0);
String title;
Drawable icon;
try { try {
title = a.getString(R.styleable.AboutCardRow_text); title = a.getString(R.styleable.AboutCardRow_text);
icon = a.getDrawable(R.styleable.AboutCardRow_icon); icon = a.getDrawable(R.styleable.AboutCardRow_icon);
} finally { } finally {
a.recycle(); a.recycle();
} }
mView = findViewById(R.id.container);
mTitle = (TextView) findViewById(android.R.id.title);
mSummary = (TextView) findViewById(android.R.id.summary);
mIcon = (ImageView) findViewById(android.R.id.icon);
mTitle.setText(title); mTitle.setText(title);
mIcon.setImageDrawable(icon); mIcon.setImageDrawable(icon);
} }
@ -80,10 +75,7 @@ public class AboutCardRow extends LinearLayout {
} }
public void setSummary(String s) { public void setSummary(String s) {
mSummary.setVisibility(VISIBLE);
mSummary.setText(s); mSummary.setText(s);
} }
public void removeSummary() {
mSummary.setVisibility(GONE);
}
} }

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M15.386,0.524c-4.764,0 -8.64,3.876 -8.64,8.64 0,4.75 3.876,8.613 8.64,8.613 4.75,0 8.614,-3.864 8.614,-8.613C24,4.4 20.136,0.524 15.386,0.524M0.003,23.537h4.22V0.524H0.003"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M6.908,24L3.804,24c-0.664,0 -1.086,-0.529 -0.936,-1.18l0.149,-0.674h2.071c0.666,0 1.336,-0.533 1.482,-1.182l1.064,-4.592c0.15,-0.648 0.816,-1.18 1.48,-1.18h0.883c3.789,0 6.734,-0.779 8.84,-2.34s3.16,-3.6 3.16,-6.135c0,-1.125 -0.195,-2.055 -0.588,-2.789 0,-0.016 -0.016,-0.031 -0.016,-0.046l0.135,0.075c0.75,0.465 1.32,1.064 1.711,1.814 0.404,0.75 0.598,1.68 0.598,2.791 0,2.535 -1.049,4.574 -3.164,6.135 -2.1,1.545 -5.055,2.324 -8.834,2.324h-0.9c-0.66,0 -1.334,0.525 -1.484,1.186L8.39,22.812c-0.149,0.645 -0.81,1.17 -1.47,1.17L6.908,24zM4.231,21.305L1.126,21.305c-0.663,0 -1.084,-0.529 -0.936,-1.18L4.563,1.182C4.714,0.529 5.378,0 6.044,0h6.465c1.395,0 2.609,0.098 3.648,0.289 1.035,0.189 1.92,0.519 2.684,0.99 0.736,0.465 1.322,1.072 1.697,1.818 0.389,0.748 0.584,1.68 0.584,2.797 0,2.535 -1.051,4.574 -3.164,6.119 -2.1,1.561 -5.056,2.326 -8.836,2.326h-0.883c-0.66,0 -1.328,0.524 -1.478,1.169L5.7,20.097c-0.149,0.646 -0.817,1.172 -1.485,1.172l0.016,0.036zM11.677,3.936h-1.014c-0.666,0 -1.332,0.529 -1.48,1.178l-0.93,4.02c-0.15,0.648 0.27,1.179 0.93,1.179h0.766c1.664,0 2.97,-0.343 3.9,-1.021 0.929,-0.686 1.395,-1.654 1.395,-2.912 0,-0.83 -0.301,-1.445 -0.9,-1.84 -0.6,-0.404 -1.5,-0.605 -2.686,-0.605l0.019,0.001z"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M23.954,4.569c-0.885,0.389 -1.83,0.654 -2.825,0.775 1.014,-0.611 1.794,-1.574 2.163,-2.723 -0.951,0.555 -2.005,0.959 -3.127,1.184 -0.896,-0.959 -2.173,-1.559 -3.591,-1.559 -2.717,0 -4.92,2.203 -4.92,4.917 0,0.39 0.045,0.765 0.127,1.124C7.691,8.094 4.066,6.13 1.64,3.161c-0.427,0.722 -0.666,1.561 -0.666,2.475 0,1.71 0.87,3.213 2.188,4.096 -0.807,-0.026 -1.566,-0.248 -2.228,-0.616v0.061c0,2.385 1.693,4.374 3.946,4.827 -0.413,0.111 -0.849,0.171 -1.296,0.171 -0.314,0 -0.615,-0.03 -0.916,-0.086 0.631,1.953 2.445,3.377 4.604,3.417 -1.68,1.319 -3.809,2.105 -6.102,2.105 -0.39,0 -0.779,-0.023 -1.17,-0.067 2.189,1.394 4.768,2.209 7.557,2.209 9.054,0 13.999,-7.496 13.999,-13.986 0,-0.209 0,-0.42 -0.015,-0.63 0.961,-0.689 1.8,-1.56 2.46,-2.548l-0.047,-0.02z"/>
</vector>

View File

@ -75,6 +75,13 @@
app:icon="@drawable/ic_language" app:icon="@drawable/ic_language"
app:text="@string/app_translators"/> app:text="@string/app_translators"/>
<com.topjohnwu.magisk.components.AboutCardRow
android:id="@+id/follow_twitter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:icon="@drawable/ic_twitter"
app:text="@string/follow_twitter"/>
<com.topjohnwu.magisk.components.AboutCardRow <com.topjohnwu.magisk.components.AboutCardRow
android:id="@+id/app_source_code" android:id="@+id/app_source_code"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -82,22 +89,6 @@
app:icon="@drawable/ic_github" app:icon="@drawable/ic_github"
app:text="@string/app_source_code"/> app:text="@string/app_source_code"/>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
style="?attr/cardStyle"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.topjohnwu.magisk.components.AboutCardRow <com.topjohnwu.magisk.components.AboutCardRow
android:id="@+id/support_thread" android:id="@+id/support_thread"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -105,13 +96,6 @@
app:icon="@drawable/ic_xda" app:icon="@drawable/ic_xda"
app:text="@string/support_thread"/> app:text="@string/support_thread"/>
<com.topjohnwu.magisk.components.AboutCardRow
android:id="@+id/donation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:icon="@drawable/ic_attach_money"
app:text="@string/donation"/>
</LinearLayout> </LinearLayout>
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>

View File

@ -49,6 +49,7 @@
<TextView <TextView
android:id="@android:id/summary" android:id="@android:id/summary"
android:visibility="gone"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"/> android:textAppearance="@style/TextAppearance.AppCompat.Caption"/>

View File

@ -52,12 +52,24 @@
android:icon="@drawable/ic_settings" android:icon="@drawable/ic_settings"
android:title="@string/settings"/> android:title="@string/settings"/>
</group>
<group
android:checkableBehavior="single"
android:id="@+id/forth_group">
<item <item
android:checkable="false" android:checkable="false"
android:id="@+id/app_about" android:id="@+id/app_about"
android:icon="@drawable/ic_info_outline" android:icon="@drawable/ic_info_outline"
android:title="@string/about"/> android:title="@string/about"/>
<item
android:checkable="false"
android:id="@+id/donation"
android:icon="@drawable/ic_attach_money"
android:title="@string/donation"/>
</group> </group>
</menu> </menu>

View File

@ -68,6 +68,7 @@
<string name="donation">Donation</string> <string name="donation">Donation</string>
<string name="app_translators">Translators</string> <string name="app_translators">Translators</string>
<string name="support_thread">Support thread</string> <string name="support_thread">Support thread</string>
<string name="follow_twitter">Follow me on Twitter</string>
<!--Toasts, Dialogs--> <!--Toasts, Dialogs-->
<string name="close">Close</string> <string name="close">Close</string>

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar"/>
<ScrollView
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="8dp"
tools:ignore="UseCompoundDrawables,ContentDescription">
<LinearLayout
android:id="@android:id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
style="?attr/cardStyle"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="16dp"
android:text="@string/donation"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"/>
<com.topjohnwu.magisk.components.AboutCardRow
android:id="@+id/paypal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:icon="@drawable/ic_paypal"
app:text="PayPal"/>
<com.topjohnwu.magisk.components.AboutCardRow
android:id="@+id/patreon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:icon="@drawable/ic_patreon"
app:text="Patreon"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>
</LinearLayout>