[app] Remove light hack

This commit is contained in:
tehcneko 2021-02-12 22:11:52 +08:00
parent 1e22764695
commit bd8dd70969
12 changed files with 34 additions and 1283 deletions

View File

@ -31,12 +31,12 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import com.google.android.material.checkbox.MaterialCheckBox;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
import java.util.ArrayList;
@ -201,7 +201,7 @@ public class ScopeAdapter extends RecyclerView.Adapter<ScopeAdapter.ViewHolder>
int itemId = item.getItemId();
if (itemId == R.id.use_recommended) {
if (!checkedList.isEmpty()) {
new MaterialAlertDialogBuilder(activity)
new AlertDialog.Builder(activity)
.setTitle(R.string.use_recommended)
.setMessage(R.string.use_recommended_message)
.setPositiveButton(android.R.string.ok, (dialog, which) -> checkRecommended())
@ -468,7 +468,7 @@ public class ScopeAdapter extends RecyclerView.Adapter<ScopeAdapter.ViewHolder>
public boolean onBackPressed() {
if (masterSwitch.isChecked() && checkedList.isEmpty()) {
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(activity);
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(R.string.use_recommended);
builder.setMessage(hasRecommended() ? R.string.no_scope_selected_has_recommended : R.string.no_scope_selected);
if (hasRecommended()) {

View File

@ -17,7 +17,6 @@ import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.SearchView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
import io.github.lsposed.manager.BuildConfig;
@ -84,7 +83,7 @@ public class AppListActivity extends BaseActivity {
} catch (Exception e) {
e.printStackTrace();
}
AlertDialog alertDialog = new MaterialAlertDialogBuilder(this)
AlertDialog alertDialog = new AlertDialog.Builder(this)
.setCancelable(false)
.setMessage(R.string.settings_backuping)
.show();
@ -110,7 +109,7 @@ public class AppListActivity extends BaseActivity {
} catch (Exception e) {
e.printStackTrace();
}
AlertDialog alertDialog = new MaterialAlertDialogBuilder(this)
AlertDialog alertDialog = new AlertDialog.Builder(this)
.setCancelable(false)
.setMessage(R.string.settings_restoring)
.show();

View File

@ -13,10 +13,9 @@ import android.view.Window;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import java.util.Objects;
import io.github.lsposed.manager.App;
@ -101,7 +100,7 @@ public class BaseActivity extends MaterialActivity {
Version managerVersion = new Version(BuildConfig.VERSION_NAME);
Version coreVersion = new Version(coreVersionStr);
if (!managerVersion.equals(coreVersion)) {
new MaterialAlertDialogBuilder(this)
new AlertDialog.Builder(this)
.setMessage(R.string.outdated_manager)
.setPositiveButton(R.string.ok, (dialog, id) -> {
NavUtil.startURL(this, getString(R.string.about_source));

View File

@ -22,7 +22,6 @@ import androidx.appcompat.app.AlertDialog;
import androidx.core.content.FileProvider;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.tabs.TabLayout;
@ -79,7 +78,7 @@ public class LogsActivity extends BaseActivity {
}
if (!preferences.getBoolean("hide_logcat_warning", false)) {
DialogInstallWarningBinding binding = DialogInstallWarningBinding.inflate(getLayoutInflater());
new MaterialAlertDialogBuilder(this)
new AlertDialog.Builder(this)
.setTitle(R.string.install_warning_title)
.setMessage(R.string.not_logcat)
.setView(binding.getRoot())
@ -251,7 +250,7 @@ public class LogsActivity extends BaseActivity {
@Override
protected void onPreExecute() {
mProgressDialog = new MaterialAlertDialogBuilder(LogsActivity.this).create();
mProgressDialog = new AlertDialog.Builder(LogsActivity.this).create();
mProgressDialog.setMessage(getString(R.string.loading));
mProgressDialog.setCancelable(false);
handler.postDelayed(mRunnable, 300);

View File

@ -2,6 +2,7 @@ package io.github.lsposed.manager.ui.activity;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
@ -19,7 +20,6 @@ import io.github.lsposed.manager.ui.fragment.StatusDialogBuilder;
import io.github.lsposed.manager.util.GlideHelper;
import io.github.lsposed.manager.util.ModuleUtil;
import io.github.lsposed.manager.util.NavUtil;
import io.github.lsposed.manager.util.light.Light;
import name.mikanoshi.customiuizer.holidays.HolidayHelper;
import name.mikanoshi.customiuizer.utils.Helpers;
@ -52,28 +52,35 @@ public class MainActivity extends BaseActivity {
.load(GlideHelper.wrapApplicationInfoForIconLoader(getApplicationInfo()))
.into(binding.appIcon);
String installedXposedVersion = Constants.getXposedVersion();
int cardBackgroundColor;
if (installedXposedVersion != null) {
binding.statusTitle.setText(String.format(Locale.US, "%s %s", getString(R.string.Activated), Constants.getXposedVariant()));
if (!Constants.isPermissive()) {
if (Helpers.currentHoliday == Helpers.Holidays.LUNARNEWYEAR) {
binding.status.setCardBackgroundColor(0xfff05654);
cardBackgroundColor = 0xfff05654;
} else {
binding.status.setCardBackgroundColor(ContextCompat.getColor(this, R.color.colorNormal));
cardBackgroundColor = ContextCompat.getColor(this, R.color.colorNormal);
}
binding.statusIcon.setImageResource(R.drawable.ic_check_circle);
binding.statusSummary.setText(String.format(Locale.US, "%s (%d)", installedXposedVersion, Constants.getXposedVersionCode()));
} else {
binding.status.setCardBackgroundColor(ContextCompat.getColor(this, R.color.colorError));
cardBackgroundColor = ContextCompat.getColor(this, R.color.colorError);
binding.statusIcon.setImageResource(R.drawable.ic_warning);
binding.statusSummary.setText(R.string.selinux_permissive_summary);
}
} else {
cardBackgroundColor = ContextCompat.getColor(this, R.color.colorInstall);
binding.statusTitle.setText(R.string.Install);
binding.statusSummary.setText(R.string.InstallDetail);
binding.status.setCardBackgroundColor(ContextCompat.getColor(this, R.color.colorInstall));
binding.statusIcon.setImageResource(R.drawable.ic_error);
Snackbar.make(binding.snackbar, R.string.lsposed_not_active, Snackbar.LENGTH_LONG).show();
}
binding.status.setCardBackgroundColor(cardBackgroundColor);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
binding.status.setOutlineSpotShadowColor(cardBackgroundColor);
binding.status.setOutlineAmbientShadowColor(cardBackgroundColor);
}
}
private class StartActivityListener implements View.OnClickListener {
@ -99,12 +106,7 @@ public class MainActivity extends BaseActivity {
@Override
protected void onResume() {
getWindow().getDecorView().post(() -> {
if (Light.setLightSourceAlpha(getWindow().getDecorView(), 0.01f, 0.029f)) {
binding.status.setElevation(24);
binding.modules.setElevation(12);
}
});
super.onResume();
binding.modulesSummary.setText(String.format(getString(R.string.ModulesDetail), ModuleUtil.getInstance().getEnabledModules().size()));
HolidayHelper.onResume();

View File

@ -35,10 +35,10 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager2.widget.ViewPager2;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.tabs.TabLayoutMediator;
import java.util.ArrayList;
@ -254,7 +254,7 @@ public class RepoItemActivity extends BaseActivity {
holder.viewAssets.setOnClickListener(v -> {
ArrayList<String> names = new ArrayList<>();
assets.forEach(releaseAsset -> names.add(releaseAsset.getName()));
new MaterialAlertDialogBuilder(RepoItemActivity.this)
new AlertDialog.Builder(RepoItemActivity.this)
.setItems(names.toArray(new String[0]), (dialog, which) -> NavUtil.startURL(RepoItemActivity.this, assets.get(which).getDownloadUrl()))
.show();
});

View File

@ -21,7 +21,6 @@ import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
import com.takisoft.preferencex.PreferenceFragmentCompat;
import com.takisoft.preferencex.SimpleMenuPreference;
@ -133,7 +132,7 @@ public class SettingsActivity extends BaseActivity {
} catch (Exception e) {
e.printStackTrace();
}
AlertDialog alertDialog = new MaterialAlertDialogBuilder(requireActivity())
AlertDialog alertDialog = new AlertDialog.Builder(requireActivity())
.setCancelable(false)
.setMessage(R.string.settings_backuping)
.show();
@ -160,7 +159,7 @@ public class SettingsActivity extends BaseActivity {
} catch (Exception e) {
e.printStackTrace();
}
AlertDialog alertDialog = new MaterialAlertDialogBuilder(requireActivity())
AlertDialog alertDialog = new AlertDialog.Builder(requireActivity())
.setCancelable(false)
.setMessage(R.string.settings_restoring)
.show();

View File

@ -11,11 +11,11 @@ import android.view.LayoutInflater;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatDialogFragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
import java.io.BufferedReader;
@ -58,7 +58,7 @@ public class CompileDialogFragment extends AppCompatDialogFragment {
FragmentCompileDialogBinding binding = FragmentCompileDialogBinding.inflate(LayoutInflater.from(requireActivity()), null, false);
final PackageManager pm = requireContext().getPackageManager();
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireActivity())
AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity())
.setIcon(appInfo.loadIcon(pm))
.setTitle(appInfo.loadLabel(pm))
.setView(binding.getRoot());

View File

@ -1,6 +1,7 @@
package io.github.lsposed.manager.ui.fragment;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Build;
import android.view.LayoutInflater;
@ -9,8 +10,6 @@ import android.view.View;
import androidx.annotation.NonNull;
import androidx.core.text.HtmlCompat;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
@ -24,7 +23,7 @@ import io.github.lsposed.manager.R;
import io.github.lsposed.manager.databinding.StatusInstallerBinding;
@SuppressLint("StaticFieldLeak")
public class StatusDialogBuilder extends MaterialAlertDialogBuilder {
public class StatusDialogBuilder extends AlertDialog.Builder {
private static final String CPU_ABI;
private static final String CPU_ABI2;

View File

@ -1,47 +0,0 @@
package io.github.lsposed.manager.util.light;
import android.annotation.SuppressLint;
import android.graphics.HardwareRenderer;
import android.os.Build;
import android.view.View;
@SuppressWarnings({"unchecked", "ConstantConditions"})
@SuppressLint("PrivateApi")
public class Light {
public static boolean setLightSourceAlpha(View view, float ambientShadowAlpha, float spotShadowAlpha) {
try {
@SuppressWarnings("rawtypes") Class threadedRendererClass = Class.forName("android.view.ThreadedRenderer");
Object threadedRenderer = Hack.into(View.class)
.method("getThreadedRenderer")
.returning(threadedRendererClass)
.withoutParams()
.invoke()
.on(view);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
((HardwareRenderer) threadedRenderer).setLightSourceAlpha(ambientShadowAlpha, spotShadowAlpha);
} else {
long mNativeProxy = (long) Hack.into(threadedRendererClass)
.field("mNativeProxy").ofType(long.class).get(threadedRenderer);
float mLightRadius = (float) Hack.into(threadedRendererClass)
.field("mLightRadius")
.ofType(float.class)
.get(threadedRenderer);
Hack.into(threadedRendererClass)
.staticMethod("nSetup")
.withParams(long.class, float.class, int.class, int.class)
.invoke(mNativeProxy, mLightRadius,
(int) (255 * ambientShadowAlpha + 0.5f), (int) (255 * spotShadowAlpha + 0.5f))
.statically();
}
return true;
} catch (Throwable tr) {
tr.printStackTrace();
return false;
}
}
}

View File

@ -132,6 +132,8 @@
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
android:outlineAmbientShadowColor="#3A000000"
android:outlineSpotShadowColor="#3A000000"
app:cardCornerRadius="8dp"
app:cardElevation="4dp"
app:cardPreventCornerOverlap="false">
@ -183,6 +185,8 @@
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
android:outlineAmbientShadowColor="#3A000000"
android:outlineSpotShadowColor="#3A000000"
app:cardCornerRadius="8dp"
app:cardElevation="4dp"
app:cardPreventCornerOverlap="false">