From 348d47076aefe4d843daf11bafcd36809b34d5e8 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Fri, 1 Feb 2019 04:39:54 -0500 Subject: [PATCH] Finish Magisk Fragment UI Remove AboutActivity at the same time --- app/src/full/AndroidManifest.xml | 3 - app/src/full/java/a/d.java | 7 - app/src/full/java/a/l.java | 22 -- .../com/topjohnwu/magisk/AboutActivity.java | 76 ----- .../java/com/topjohnwu/magisk/ClassMap.java | 3 - .../com/topjohnwu/magisk/MainActivity.java | 8 - .../magisk/fragments/MagiskFragment.java | 40 ++- .../magisk/uicomponents/AboutCardRow.java | 75 ----- .../magisk/uicomponents/UpdateCardHolder.java | 6 + app/src/full/res/layout/activity_about.xml | 143 -------- app/src/full/res/layout/fragment_magisk.xml | 314 ++++++++++++++---- app/src/full/res/layout/update_card.xml | 1 + app/src/full/res/menu/drawer.xml | 12 - app/src/full/res/values/attrs.xml | 33 +- app/src/full/res/values/styles.xml | 2 +- 15 files changed, 303 insertions(+), 442 deletions(-) delete mode 100644 app/src/full/java/a/d.java delete mode 100644 app/src/full/java/a/l.java delete mode 100644 app/src/full/java/com/topjohnwu/magisk/AboutActivity.java delete mode 100644 app/src/full/java/com/topjohnwu/magisk/uicomponents/AboutCardRow.java delete mode 100644 app/src/full/res/layout/activity_about.xml diff --git a/app/src/full/AndroidManifest.xml b/app/src/full/AndroidManifest.xml index 734174e3e..3b61d54e9 100644 --- a/app/src/full/AndroidManifest.xml +++ b/app/src/full/AndroidManifest.xml @@ -29,9 +29,6 @@ - finish()); - - ActionBar ab = getSupportActionBar(); - if (ab != null) { - ab.setTitle(R.string.about); - ab.setDisplayHomeAsUpEnabled(true); - } - - appVersionInfo.setSummary(String.format(Locale.US, "%s (%d) (%s)", - BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, getPackageName())); - - appChangelog.setOnClickListener(v -> { - MarkDownWindow.show(this, getString(R.string.app_changelog), - getResources().openRawResource(R.raw.changelog)); - }); - - String translators = getString(R.string.translators); - if (TextUtils.isEmpty(translators)) { - appTranslators.setVisibility(View.GONE); - } else { - appTranslators.setSummary(translators); - } - - appSourceCode.setOnClickListener(v -> AppUtils.openLink(this, Uri.parse(Const.Url.SOURCE_CODE_URL))); - supportThread.setOnClickListener(v -> AppUtils.openLink(this, Uri.parse(Const.Url.XDA_THREAD))); - twitter.setOnClickListener(v -> AppUtils.openLink(this, Uri.parse(Const.Url.TWITTER_URL))); - paypal.setOnClickListener(v -> AppUtils.openLink(this, Uri.parse(Const.Url.PAYPAL_URL))); - patreon.setOnClickListener(v -> AppUtils.openLink(this, Uri.parse(Const.Url.PATREON_URL))); - - setFloating(); - } - -} diff --git a/app/src/full/java/com/topjohnwu/magisk/ClassMap.java b/app/src/full/java/com/topjohnwu/magisk/ClassMap.java index 1e7090097..5bd8ace31 100644 --- a/app/src/full/java/com/topjohnwu/magisk/ClassMap.java +++ b/app/src/full/java/com/topjohnwu/magisk/ClassMap.java @@ -3,7 +3,6 @@ package com.topjohnwu.magisk; import com.topjohnwu.magisk.components.DownloadModuleService; import com.topjohnwu.magisk.components.GeneralReceiver; import com.topjohnwu.magisk.components.UpdateCheckService; -import com.topjohnwu.magisk.uicomponents.AboutCardRow; import java.util.HashMap; import java.util.Map; @@ -15,12 +14,10 @@ public class ClassMap { classMap.put(App.class, a.e.class); classMap.put(MainActivity.class, a.b.class); classMap.put(SplashActivity.class, a.c.class); - classMap.put(AboutActivity.class, a.d.class); classMap.put(FlashActivity.class, a.f.class); classMap.put(UpdateCheckService.class, a.g.class); classMap.put(GeneralReceiver.class, a.h.class); classMap.put(DownloadModuleService.class, a.j.class); - classMap.put(AboutCardRow.class, a.l.class); classMap.put(SuRequestActivity.class, a.m.class); } diff --git a/app/src/full/java/com/topjohnwu/magisk/MainActivity.java b/app/src/full/java/com/topjohnwu/magisk/MainActivity.java index 132fbf2cb..c76b1f678 100644 --- a/app/src/full/java/com/topjohnwu/magisk/MainActivity.java +++ b/app/src/full/java/com/topjohnwu/magisk/MainActivity.java @@ -153,16 +153,12 @@ public class MainActivity extends BaseActivity case "settings": itemId = R.id.settings; break; - case "about": - itemId = R.id.app_about; - break; } } navigate(itemId); } public void navigate(int itemId) { - int bak = mDrawerItem; mDrawerItem = itemId; navigationView.setCheckedItem(itemId); switch (itemId) { @@ -188,10 +184,6 @@ public class MainActivity extends BaseActivity case R.id.settings: displayFragment(new SettingsFragment(), true); break; - case R.id.app_about: - startActivity(new Intent(this, ClassMap.get(AboutActivity.class))); - mDrawerItem = bak; - break; } } diff --git a/app/src/full/java/com/topjohnwu/magisk/fragments/MagiskFragment.java b/app/src/full/java/com/topjohnwu/magisk/fragments/MagiskFragment.java index dd98d32ac..b853f1f8c 100644 --- a/app/src/full/java/com/topjohnwu/magisk/fragments/MagiskFragment.java +++ b/app/src/full/java/com/topjohnwu/magisk/fragments/MagiskFragment.java @@ -1,5 +1,6 @@ package com.topjohnwu.magisk.fragments; +import android.net.Uri; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -10,6 +11,7 @@ import android.widget.LinearLayout; import com.topjohnwu.magisk.BuildConfig; import com.topjohnwu.magisk.Config; +import com.topjohnwu.magisk.Const; import com.topjohnwu.magisk.MainActivity; import com.topjohnwu.magisk.R; import com.topjohnwu.magisk.components.BaseActivity; @@ -21,8 +23,10 @@ import com.topjohnwu.magisk.dialogs.UninstallDialog; import com.topjohnwu.magisk.tasks.CheckUpdates; import com.topjohnwu.magisk.uicomponents.ArrowExpandedViewHolder; import com.topjohnwu.magisk.uicomponents.ExpandableViewHolder; +import com.topjohnwu.magisk.uicomponents.MarkDownWindow; import com.topjohnwu.magisk.uicomponents.SafetyNet; import com.topjohnwu.magisk.uicomponents.UpdateCardHolder; +import com.topjohnwu.magisk.utils.AppUtils; import com.topjohnwu.magisk.utils.Topic; import com.topjohnwu.net.Networking; import com.topjohnwu.superuser.Shell; @@ -84,6 +88,35 @@ public class MagiskFragment extends BaseFragment new ManagerInstallDialog(requireActivity()).show(); } + private void openLink(String url) { + AppUtils.openLink(requireActivity(), Uri.parse(url)); + } + + @OnClick(R.id.paypal) + void paypal() { + openLink(Const.Url.PAYPAL_URL); + } + + @OnClick(R.id.patreon) + void patreon() { + openLink(Const.Url.PATREON_URL); + } + + @OnClick(R.id.twitter) + void twitter() { + openLink(Const.Url.TWITTER_URL); + } + + @OnClick(R.id.github) + void github() { + openLink(Const.Url.SOURCE_CODE_URL); + } + + @OnClick(R.id.xda) + void xda() { + openLink(Const.Url.XDA_THREAD); + } + @OnClick(R.id.uninstall_button) void uninstall() { new UninstallDialog(requireActivity()).show(); @@ -108,8 +141,11 @@ public class MagiskFragment extends BaseFragment safetyNet = new SafetyNet(v); magisk = new UpdateCardHolder(inflater, root); manager = new UpdateCardHolder(inflater, root); - root.addView(magisk.itemView, 0); - root.addView(manager.itemView, 1); + manager.setClickable(vv -> + MarkDownWindow.show(requireActivity(), null, + getResources().openRawResource(R.raw.changelog))); + root.addView(magisk.itemView, 1); + root.addView(manager.itemView, 2); keepVerityChkbox.setChecked(Config.keepVerity); keepVerityChkbox.setOnCheckedChangeListener((view, checked) -> Config.keepVerity = checked); diff --git a/app/src/full/java/com/topjohnwu/magisk/uicomponents/AboutCardRow.java b/app/src/full/java/com/topjohnwu/magisk/uicomponents/AboutCardRow.java deleted file mode 100644 index 474cf9f94..000000000 --- a/app/src/full/java/com/topjohnwu/magisk/uicomponents/AboutCardRow.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2016 dvdandroid - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.topjohnwu.magisk.uicomponents; - -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.drawable.Drawable; -import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; - -import com.topjohnwu.magisk.R; - -import androidx.appcompat.content.res.AppCompatResources; -import butterknife.BindView; - -/** - * @author dvdandroid - */ -public class AboutCardRow extends LinearLayout { - - @BindView(android.R.id.title) TextView mTitle; - @BindView(android.R.id.summary) TextView mSummary; - @BindView(android.R.id.icon) ImageView mIcon; - @BindView(R.id.container) View mView; - - public AboutCardRow(Context context) { - this(context, null); - } - - public AboutCardRow(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - public AboutCardRow(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - LayoutInflater.from(context).inflate(R.layout.info_item_row, this); - new AboutCardRow_ViewBinding(this, this); - - TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.AboutCardRow, 0, 0); - String title = a.getString(R.styleable.AboutCardRow_text); - Drawable icon = AppCompatResources.getDrawable(context, - a.getResourceId(R.styleable.AboutCardRow_icon, R.drawable.ic_magisk)); - a.recycle(); - mTitle.setText(title); - mIcon.setImageDrawable(icon); - } - - @Override - public void setOnClickListener(OnClickListener l) { - mView.setOnClickListener(l); - } - - public void setSummary(String s) { - mSummary.setVisibility(VISIBLE); - mSummary.setText(s); - } -} \ No newline at end of file diff --git a/app/src/full/java/com/topjohnwu/magisk/uicomponents/UpdateCardHolder.java b/app/src/full/java/com/topjohnwu/magisk/uicomponents/UpdateCardHolder.java index 66422909c..03486deee 100644 --- a/app/src/full/java/com/topjohnwu/magisk/uicomponents/UpdateCardHolder.java +++ b/app/src/full/java/com/topjohnwu/magisk/uicomponents/UpdateCardHolder.java @@ -31,6 +31,12 @@ public class UpdateCardHolder { unbinder = new UpdateCardHolder_ViewBinding(this, itemView); } + public void setClickable(View.OnClickListener listener) { + itemView.setClickable(true); + itemView.setFocusable(true); + itemView.setOnClickListener(listener); + } + public void setValid(boolean valid) { progress.setVisibility(View.GONE); statusIcon.setVisibility(View.VISIBLE); diff --git a/app/src/full/res/layout/activity_about.xml b/app/src/full/res/layout/activity_about.xml deleted file mode 100644 index a1f3e0222..000000000 --- a/app/src/full/res/layout/activity_about.xml +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/full/res/layout/fragment_magisk.xml b/app/src/full/res/layout/fragment_magisk.xml index e3d738bb8..e3b0c919a 100644 --- a/app/src/full/res/layout/fragment_magisk.xml +++ b/app/src/full/res/layout/fragment_magisk.xml @@ -19,11 +19,138 @@ android:layout_height="wrap_content" android:orientation="vertical"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + android:layout_height="wrap_content"> - + + + - - - - - - - - - - - + android:layout_margin="5dp" + android:text="PayPal" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textStyle="bold" /> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + app:cardElevation="@dimen/card_elevation"> diff --git a/app/src/full/res/menu/drawer.xml b/app/src/full/res/menu/drawer.xml index 9378af312..db37e41fc 100644 --- a/app/src/full/res/menu/drawer.xml +++ b/app/src/full/res/menu/drawer.xml @@ -54,16 +54,4 @@ - - - - - - diff --git a/app/src/full/res/values/attrs.xml b/app/src/full/res/values/attrs.xml index 4b67ac85d..fee7783ab 100644 --- a/app/src/full/res/values/attrs.xml +++ b/app/src/full/res/values/attrs.xml @@ -1,35 +1,6 @@ - - - - - - - - - - - - - - + - - \ No newline at end of file + diff --git a/app/src/full/res/values/styles.xml b/app/src/full/res/values/styles.xml index 34afe62aa..162718e9b 100644 --- a/app/src/full/res/values/styles.xml +++ b/app/src/full/res/values/styles.xml @@ -9,7 +9,7 @@ @style/CardViewStyle.Light false true - @android:color/secondary_text_light + @android:color/tertiary_text_light