[app] Remove light hack
This commit is contained in:
parent
1e22764695
commit
bd8dd70969
|
|
@ -31,12 +31,12 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.bumptech.glide.request.target.CustomTarget;
|
import com.bumptech.glide.request.target.CustomTarget;
|
||||||
import com.bumptech.glide.request.transition.Transition;
|
import com.bumptech.glide.request.transition.Transition;
|
||||||
import com.google.android.material.checkbox.MaterialCheckBox;
|
import com.google.android.material.checkbox.MaterialCheckBox;
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -201,7 +201,7 @@ public class ScopeAdapter extends RecyclerView.Adapter<ScopeAdapter.ViewHolder>
|
||||||
int itemId = item.getItemId();
|
int itemId = item.getItemId();
|
||||||
if (itemId == R.id.use_recommended) {
|
if (itemId == R.id.use_recommended) {
|
||||||
if (!checkedList.isEmpty()) {
|
if (!checkedList.isEmpty()) {
|
||||||
new MaterialAlertDialogBuilder(activity)
|
new AlertDialog.Builder(activity)
|
||||||
.setTitle(R.string.use_recommended)
|
.setTitle(R.string.use_recommended)
|
||||||
.setMessage(R.string.use_recommended_message)
|
.setMessage(R.string.use_recommended_message)
|
||||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> checkRecommended())
|
.setPositiveButton(android.R.string.ok, (dialog, which) -> checkRecommended())
|
||||||
|
|
@ -468,7 +468,7 @@ public class ScopeAdapter extends RecyclerView.Adapter<ScopeAdapter.ViewHolder>
|
||||||
|
|
||||||
public boolean onBackPressed() {
|
public boolean onBackPressed() {
|
||||||
if (masterSwitch.isChecked() && checkedList.isEmpty()) {
|
if (masterSwitch.isChecked() && checkedList.isEmpty()) {
|
||||||
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(activity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
builder.setTitle(R.string.use_recommended);
|
builder.setTitle(R.string.use_recommended);
|
||||||
builder.setMessage(hasRecommended() ? R.string.no_scope_selected_has_recommended : R.string.no_scope_selected);
|
builder.setMessage(hasRecommended() ? R.string.no_scope_selected_has_recommended : R.string.no_scope_selected);
|
||||||
if (hasRecommended()) {
|
if (hasRecommended()) {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.widget.SearchView;
|
import androidx.appcompat.widget.SearchView;
|
||||||
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
import io.github.lsposed.manager.BuildConfig;
|
import io.github.lsposed.manager.BuildConfig;
|
||||||
|
|
@ -84,7 +83,7 @@ public class AppListActivity extends BaseActivity {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
AlertDialog alertDialog = new MaterialAlertDialogBuilder(this)
|
AlertDialog alertDialog = new AlertDialog.Builder(this)
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setMessage(R.string.settings_backuping)
|
.setMessage(R.string.settings_backuping)
|
||||||
.show();
|
.show();
|
||||||
|
|
@ -110,7 +109,7 @@ public class AppListActivity extends BaseActivity {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
AlertDialog alertDialog = new MaterialAlertDialogBuilder(this)
|
AlertDialog alertDialog = new AlertDialog.Builder(this)
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setMessage(R.string.settings_restoring)
|
.setMessage(R.string.settings_restoring)
|
||||||
.show();
|
.show();
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,9 @@ import android.view.Window;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.StyleRes;
|
import androidx.annotation.StyleRes;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import io.github.lsposed.manager.App;
|
import io.github.lsposed.manager.App;
|
||||||
|
|
@ -101,7 +100,7 @@ public class BaseActivity extends MaterialActivity {
|
||||||
Version managerVersion = new Version(BuildConfig.VERSION_NAME);
|
Version managerVersion = new Version(BuildConfig.VERSION_NAME);
|
||||||
Version coreVersion = new Version(coreVersionStr);
|
Version coreVersion = new Version(coreVersionStr);
|
||||||
if (!managerVersion.equals(coreVersion)) {
|
if (!managerVersion.equals(coreVersion)) {
|
||||||
new MaterialAlertDialogBuilder(this)
|
new AlertDialog.Builder(this)
|
||||||
.setMessage(R.string.outdated_manager)
|
.setMessage(R.string.outdated_manager)
|
||||||
.setPositiveButton(R.string.ok, (dialog, id) -> {
|
.setPositiveButton(R.string.ok, (dialog, id) -> {
|
||||||
NavUtil.startURL(this, getString(R.string.about_source));
|
NavUtil.startURL(this, getString(R.string.about_source));
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.core.content.FileProvider;
|
import androidx.core.content.FileProvider;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
import com.google.android.material.tabs.TabLayout;
|
import com.google.android.material.tabs.TabLayout;
|
||||||
|
|
||||||
|
|
@ -79,7 +78,7 @@ public class LogsActivity extends BaseActivity {
|
||||||
}
|
}
|
||||||
if (!preferences.getBoolean("hide_logcat_warning", false)) {
|
if (!preferences.getBoolean("hide_logcat_warning", false)) {
|
||||||
DialogInstallWarningBinding binding = DialogInstallWarningBinding.inflate(getLayoutInflater());
|
DialogInstallWarningBinding binding = DialogInstallWarningBinding.inflate(getLayoutInflater());
|
||||||
new MaterialAlertDialogBuilder(this)
|
new AlertDialog.Builder(this)
|
||||||
.setTitle(R.string.install_warning_title)
|
.setTitle(R.string.install_warning_title)
|
||||||
.setMessage(R.string.not_logcat)
|
.setMessage(R.string.not_logcat)
|
||||||
.setView(binding.getRoot())
|
.setView(binding.getRoot())
|
||||||
|
|
@ -251,7 +250,7 @@ public class LogsActivity extends BaseActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
mProgressDialog = new MaterialAlertDialogBuilder(LogsActivity.this).create();
|
mProgressDialog = new AlertDialog.Builder(LogsActivity.this).create();
|
||||||
mProgressDialog.setMessage(getString(R.string.loading));
|
mProgressDialog.setMessage(getString(R.string.loading));
|
||||||
mProgressDialog.setCancelable(false);
|
mProgressDialog.setCancelable(false);
|
||||||
handler.postDelayed(mRunnable, 300);
|
handler.postDelayed(mRunnable, 300);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package io.github.lsposed.manager.ui.activity;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
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.GlideHelper;
|
||||||
import io.github.lsposed.manager.util.ModuleUtil;
|
import io.github.lsposed.manager.util.ModuleUtil;
|
||||||
import io.github.lsposed.manager.util.NavUtil;
|
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.holidays.HolidayHelper;
|
||||||
import name.mikanoshi.customiuizer.utils.Helpers;
|
import name.mikanoshi.customiuizer.utils.Helpers;
|
||||||
|
|
||||||
|
|
@ -52,28 +52,35 @@ public class MainActivity extends BaseActivity {
|
||||||
.load(GlideHelper.wrapApplicationInfoForIconLoader(getApplicationInfo()))
|
.load(GlideHelper.wrapApplicationInfoForIconLoader(getApplicationInfo()))
|
||||||
.into(binding.appIcon);
|
.into(binding.appIcon);
|
||||||
String installedXposedVersion = Constants.getXposedVersion();
|
String installedXposedVersion = Constants.getXposedVersion();
|
||||||
|
int cardBackgroundColor;
|
||||||
if (installedXposedVersion != null) {
|
if (installedXposedVersion != null) {
|
||||||
binding.statusTitle.setText(String.format(Locale.US, "%s %s", getString(R.string.Activated), Constants.getXposedVariant()));
|
binding.statusTitle.setText(String.format(Locale.US, "%s %s", getString(R.string.Activated), Constants.getXposedVariant()));
|
||||||
if (!Constants.isPermissive()) {
|
if (!Constants.isPermissive()) {
|
||||||
if (Helpers.currentHoliday == Helpers.Holidays.LUNARNEWYEAR) {
|
if (Helpers.currentHoliday == Helpers.Holidays.LUNARNEWYEAR) {
|
||||||
binding.status.setCardBackgroundColor(0xfff05654);
|
cardBackgroundColor = 0xfff05654;
|
||||||
|
|
||||||
} else {
|
} 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.statusIcon.setImageResource(R.drawable.ic_check_circle);
|
||||||
binding.statusSummary.setText(String.format(Locale.US, "%s (%d)", installedXposedVersion, Constants.getXposedVersionCode()));
|
binding.statusSummary.setText(String.format(Locale.US, "%s (%d)", installedXposedVersion, Constants.getXposedVersionCode()));
|
||||||
} else {
|
} 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.statusIcon.setImageResource(R.drawable.ic_warning);
|
||||||
binding.statusSummary.setText(R.string.selinux_permissive_summary);
|
binding.statusSummary.setText(R.string.selinux_permissive_summary);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
cardBackgroundColor = ContextCompat.getColor(this, R.color.colorInstall);
|
||||||
binding.statusTitle.setText(R.string.Install);
|
binding.statusTitle.setText(R.string.Install);
|
||||||
binding.statusSummary.setText(R.string.InstallDetail);
|
binding.statusSummary.setText(R.string.InstallDetail);
|
||||||
binding.status.setCardBackgroundColor(ContextCompat.getColor(this, R.color.colorInstall));
|
|
||||||
binding.statusIcon.setImageResource(R.drawable.ic_error);
|
binding.statusIcon.setImageResource(R.drawable.ic_error);
|
||||||
Snackbar.make(binding.snackbar, R.string.lsposed_not_active, Snackbar.LENGTH_LONG).show();
|
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 {
|
private class StartActivityListener implements View.OnClickListener {
|
||||||
|
|
@ -99,12 +106,7 @@ public class MainActivity extends BaseActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
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();
|
super.onResume();
|
||||||
binding.modulesSummary.setText(String.format(getString(R.string.ModulesDetail), ModuleUtil.getInstance().getEnabledModules().size()));
|
binding.modulesSummary.setText(String.format(getString(R.string.ModulesDetail), ModuleUtil.getInstance().getEnabledModules().size()));
|
||||||
HolidayHelper.onResume();
|
HolidayHelper.onResume();
|
||||||
|
|
|
||||||
|
|
@ -35,10 +35,10 @@ import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.viewpager2.widget.ViewPager2;
|
import androidx.viewpager2.widget.ViewPager2;
|
||||||
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|
||||||
import com.google.android.material.tabs.TabLayoutMediator;
|
import com.google.android.material.tabs.TabLayoutMediator;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -254,7 +254,7 @@ public class RepoItemActivity extends BaseActivity {
|
||||||
holder.viewAssets.setOnClickListener(v -> {
|
holder.viewAssets.setOnClickListener(v -> {
|
||||||
ArrayList<String> names = new ArrayList<>();
|
ArrayList<String> names = new ArrayList<>();
|
||||||
assets.forEach(releaseAsset -> names.add(releaseAsset.getName()));
|
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()))
|
.setItems(names.toArray(new String[0]), (dialog, which) -> NavUtil.startURL(RepoItemActivity.this, assets.get(which).getDownloadUrl()))
|
||||||
.show();
|
.show();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ import androidx.preference.Preference;
|
||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
import com.takisoft.preferencex.PreferenceFragmentCompat;
|
import com.takisoft.preferencex.PreferenceFragmentCompat;
|
||||||
import com.takisoft.preferencex.SimpleMenuPreference;
|
import com.takisoft.preferencex.SimpleMenuPreference;
|
||||||
|
|
@ -133,7 +132,7 @@ public class SettingsActivity extends BaseActivity {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
AlertDialog alertDialog = new MaterialAlertDialogBuilder(requireActivity())
|
AlertDialog alertDialog = new AlertDialog.Builder(requireActivity())
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setMessage(R.string.settings_backuping)
|
.setMessage(R.string.settings_backuping)
|
||||||
.show();
|
.show();
|
||||||
|
|
@ -160,7 +159,7 @@ public class SettingsActivity extends BaseActivity {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
AlertDialog alertDialog = new MaterialAlertDialogBuilder(requireActivity())
|
AlertDialog alertDialog = new AlertDialog.Builder(requireActivity())
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setMessage(R.string.settings_restoring)
|
.setMessage(R.string.settings_restoring)
|
||||||
.show();
|
.show();
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,11 @@ import android.view.LayoutInflater;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatDialogFragment;
|
import androidx.appcompat.app.AppCompatDialogFragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.lifecycle.Lifecycle;
|
import androidx.lifecycle.Lifecycle;
|
||||||
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
|
@ -58,7 +58,7 @@ public class CompileDialogFragment extends AppCompatDialogFragment {
|
||||||
|
|
||||||
FragmentCompileDialogBinding binding = FragmentCompileDialogBinding.inflate(LayoutInflater.from(requireActivity()), null, false);
|
FragmentCompileDialogBinding binding = FragmentCompileDialogBinding.inflate(LayoutInflater.from(requireActivity()), null, false);
|
||||||
final PackageManager pm = requireContext().getPackageManager();
|
final PackageManager pm = requireContext().getPackageManager();
|
||||||
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireActivity())
|
AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity())
|
||||||
.setIcon(appInfo.loadIcon(pm))
|
.setIcon(appInfo.loadIcon(pm))
|
||||||
.setTitle(appInfo.loadLabel(pm))
|
.setTitle(appInfo.loadLabel(pm))
|
||||||
.setView(binding.getRoot());
|
.setView(binding.getRoot());
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package io.github.lsposed.manager.ui.fragment;
|
package io.github.lsposed.manager.ui.fragment;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
|
@ -9,8 +10,6 @@ import android.view.View;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.text.HtmlCompat;
|
import androidx.core.text.HtmlCompat;
|
||||||
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
|
|
@ -24,7 +23,7 @@ import io.github.lsposed.manager.R;
|
||||||
import io.github.lsposed.manager.databinding.StatusInstallerBinding;
|
import io.github.lsposed.manager.databinding.StatusInstallerBinding;
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
public class StatusDialogBuilder extends MaterialAlertDialogBuilder {
|
public class StatusDialogBuilder extends AlertDialog.Builder {
|
||||||
private static final String CPU_ABI;
|
private static final String CPU_ABI;
|
||||||
private static final String CPU_ABI2;
|
private static final String CPU_ABI2;
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -132,6 +132,8 @@
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:foreground="?attr/selectableItemBackground"
|
android:foreground="?attr/selectableItemBackground"
|
||||||
|
android:outlineAmbientShadowColor="#3A000000"
|
||||||
|
android:outlineSpotShadowColor="#3A000000"
|
||||||
app:cardCornerRadius="8dp"
|
app:cardCornerRadius="8dp"
|
||||||
app:cardElevation="4dp"
|
app:cardElevation="4dp"
|
||||||
app:cardPreventCornerOverlap="false">
|
app:cardPreventCornerOverlap="false">
|
||||||
|
|
@ -183,6 +185,8 @@
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:foreground="?attr/selectableItemBackground"
|
android:foreground="?attr/selectableItemBackground"
|
||||||
|
android:outlineAmbientShadowColor="#3A000000"
|
||||||
|
android:outlineSpotShadowColor="#3A000000"
|
||||||
app:cardCornerRadius="8dp"
|
app:cardCornerRadius="8dp"
|
||||||
app:cardElevation="4dp"
|
app:cardElevation="4dp"
|
||||||
app:cardPreventCornerOverlap="false">
|
app:cardPreventCornerOverlap="false">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue