Fix MainActivity lighting
This commit is contained in:
parent
4849337ecd
commit
a2f40cf27a
|
|
@ -43,7 +43,6 @@
|
|||
android:label="@string/menu_scope"/>
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:theme="@style/AppTheme.ActivityMain"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTop">
|
||||
<intent-filter>
|
||||
|
|
@ -83,9 +82,6 @@
|
|||
<receiver
|
||||
android:name=".util.NotificationUtil$RebootReceiver"
|
||||
android:exported="false" />
|
||||
<receiver
|
||||
android:name=".util.NotificationUtil$ApkReceiver"
|
||||
android:exported="false" />
|
||||
<receiver
|
||||
android:name=".receivers.BootReceiver"
|
||||
android:enabled="true"
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package org.meowcat.edxposed.manager;
|
|||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
|
|
@ -13,6 +14,7 @@ import org.meowcat.edxposed.manager.adapters.BlackListAdapter;
|
|||
import org.meowcat.edxposed.manager.databinding.ActivityMainBinding;
|
||||
import org.meowcat.edxposed.manager.util.ModuleUtil;
|
||||
import org.meowcat.edxposed.manager.util.RepoLoader;
|
||||
import org.meowcat.edxposed.manager.util.light.Light;
|
||||
|
||||
public class MainActivity extends BaseActivity implements RepoLoader.RepoListener, ModuleUtil.ModuleListener {
|
||||
ActivityMainBinding binding;
|
||||
|
|
@ -24,6 +26,13 @@ public class MainActivity extends BaseActivity implements RepoLoader.RepoListene
|
|||
super.onCreate(savedInstanceState);
|
||||
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
getWindow().getDecorView().post(() -> {
|
||||
if (Light.setLightSourceAlpha(getWindow().getDecorView(), 0.01f, 0.029f)) {
|
||||
binding.status.setElevation(24);
|
||||
binding.modules.setElevation(12);
|
||||
binding.downloads.setElevation(12);
|
||||
}
|
||||
});
|
||||
setupWindowInsets(binding.snackbar, binding.nestedScrollView);
|
||||
repoLoader = RepoLoader.getInstance();
|
||||
ModuleUtil.getInstance().addListener(this);
|
||||
|
|
@ -84,23 +93,23 @@ public class MainActivity extends BaseActivity implements RepoLoader.RepoListene
|
|||
binding.statusTitle.setText(R.string.Activated);
|
||||
binding.statusSummary.setText(installedXposedVersion.replace(installedXposedVersionStr + "-", ""));
|
||||
binding.status.setCardBackgroundColor(ContextCompat.getColor(this, R.color.download_status_update_available));
|
||||
binding.statusIcon.setImageDrawable(getDrawable(R.drawable.ic_check_circle));
|
||||
binding.statusIcon.setImageResource(R.drawable.ic_check_circle);
|
||||
} else {
|
||||
binding.statusTitle.setText(R.string.Inactivate);
|
||||
binding.statusSummary.setText(R.string.installed_lollipop_inactive);
|
||||
binding.status.setCardBackgroundColor(ContextCompat.getColor(this, R.color.amber_500));
|
||||
binding.statusIcon.setImageDrawable(getDrawable(R.drawable.ic_warning));
|
||||
binding.statusIcon.setImageResource(R.drawable.ic_warning);
|
||||
}
|
||||
} else if (XposedApp.getXposedVersion() > 0) {
|
||||
binding.statusTitle.setText(R.string.Activated);
|
||||
binding.statusSummary.setText(getString(R.string.version_x, XposedApp.getXposedVersion()));
|
||||
binding.status.setCardBackgroundColor(ContextCompat.getColor(this, R.color.download_status_update_available));
|
||||
binding.statusIcon.setImageDrawable(getDrawable(R.drawable.ic_check_circle));
|
||||
binding.statusIcon.setImageResource(R.drawable.ic_check_circle);
|
||||
} else {
|
||||
binding.statusTitle.setText(R.string.Install);
|
||||
binding.statusSummary.setText(R.string.InstallDetail);
|
||||
binding.status.setCardBackgroundColor(ContextCompat.getColor(this, R.color.colorPrimary));
|
||||
binding.statusIcon.setImageDrawable(getDrawable(R.drawable.ic_error));
|
||||
binding.statusIcon.setImageResource(R.drawable.ic_error);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
new Thread(() -> new BlackListAdapter(getApplicationContext(), AppHelper.isWhiteListMode()).generateCheckedList());
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,47 @@
|
|||
package org.meowcat.edxposed.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@
|
|||
android:foreground="?attr/selectableItemBackground"
|
||||
app:cardBackgroundColor="#4CAF50"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="8dp"
|
||||
app:cardElevation="4dp"
|
||||
app:cardPreventCornerOverlap="false">
|
||||
|
||||
<RelativeLayout
|
||||
|
|
@ -131,7 +131,7 @@
|
|||
android:focusable="true"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="8dp"
|
||||
app:cardElevation="4dp"
|
||||
app:cardPreventCornerOverlap="false">
|
||||
|
||||
<RelativeLayout
|
||||
|
|
@ -182,7 +182,7 @@
|
|||
android:focusable="true"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="8dp"
|
||||
app:cardElevation="4dp"
|
||||
app:cardPreventCornerOverlap="false">
|
||||
|
||||
<RelativeLayout
|
||||
|
|
|
|||
|
|
@ -54,11 +54,6 @@
|
|||
<item name="tabLayoutTheme">@style/Widget.MaterialComponents.TabLayout.Colored</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.ActivityMain" parent="AppTheme">
|
||||
<item name="android:ambientShadowAlpha">0.01</item>
|
||||
<item name="android:spotShadowAlpha">0.01</item>
|
||||
</style>
|
||||
|
||||
<style name="ThemeOverlay.ActivityMain">
|
||||
<item name="android:windowLightStatusBar">@bool/lightSystemUI</item>
|
||||
<item name="colorPrimaryDark">?android:colorBackground</item>
|
||||
|
|
|
|||
Loading…
Reference in New Issue