About activity improvements

This commit is contained in:
tehcneko 2021-01-30 14:57:56 +08:00
parent 9e16ce5ede
commit 9379ffbca5
2 changed files with 33 additions and 47 deletions

View File

@ -1,19 +1,14 @@
package io.github.lsposed.manager.util; package io.github.lsposed.manager.util;
import android.content.Context;
import android.net.Uri; import android.net.Uri;
import android.text.Spannable; import android.text.Spannable;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.style.URLSpan; import android.text.style.URLSpan;
import android.text.util.Linkify; import android.text.util.Linkify;
import androidx.annotation.AnyThread; import androidx.browser.customtabs.CustomTabColorSchemeParams;
import androidx.annotation.NonNull;
import androidx.browser.customtabs.CustomTabsIntent; import androidx.browser.customtabs.CustomTabsIntent;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import io.github.lsposed.manager.App;
import io.github.lsposed.manager.R; import io.github.lsposed.manager.R;
import io.github.lsposed.manager.ui.activity.BaseActivity; import io.github.lsposed.manager.ui.activity.BaseActivity;
@ -33,20 +28,18 @@ public final class NavUtil {
public static void startURL(BaseActivity activity, Uri uri) { public static void startURL(BaseActivity activity, Uri uri) {
CustomTabsIntent.Builder customTabsIntent = new CustomTabsIntent.Builder(); CustomTabsIntent.Builder customTabsIntent = new CustomTabsIntent.Builder();
customTabsIntent.setShowTitle(true); customTabsIntent.setShowTitle(true);
customTabsIntent.setToolbarColor(activity.getThemedColor(R.attr.colorActionBar)); CustomTabColorSchemeParams params = new CustomTabColorSchemeParams.Builder()
.setToolbarColor(activity.getThemedColor(R.attr.colorActionBar))
.setNavigationBarColor(activity.getThemedColor(android.R.attr.navigationBarColor))
.setNavigationBarDividerColor(0)
.build();
customTabsIntent.setDefaultColorSchemeParams(params);
boolean night = BaseActivity.isNightMode(activity.getResources().getConfiguration());
customTabsIntent.setColorScheme(night ? CustomTabsIntent.COLOR_SCHEME_DARK : CustomTabsIntent.COLOR_SCHEME_LIGHT);
customTabsIntent.build().launchUrl(activity, uri); customTabsIntent.build().launchUrl(activity, uri);
} }
public static void startURL(BaseActivity activity, String url) { public static void startURL(BaseActivity activity, String url) {
startURL(activity, parseURL(url)); startURL(activity, parseURL(url));
} }
@AnyThread
public static void showMessage(final @NonNull Context context, final CharSequence message) {
App.runOnUiThread(() -> new MaterialAlertDialogBuilder(context)
.setMessage(message)
.setPositiveButton(android.R.string.ok, null)
.show());
}
} }

View File

@ -34,12 +34,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="#000"
app:cardCornerRadius="0dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -72,7 +66,6 @@
android:text="Posed" /> android:text="Posed" />
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>
</com.google.android.material.card.MaterialCardView>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"