[app] Nuke holiday theme

This commit is contained in:
tehcneko 2021-04-28 14:36:03 +08:00 committed by Wang Han
parent da5a01e1ae
commit 7d171bcfa0
7 changed files with 2 additions and 181 deletions

View File

@ -45,7 +45,6 @@ import org.lsposed.manager.util.GlideHelper;
import org.lsposed.manager.util.ModuleUtil;
import org.lsposed.manager.util.NavUtil;
import org.lsposed.manager.util.chrome.LinkTransformationMethod;
import org.lsposed.manager.util.holiday.HolidayHelper;
import java.util.Locale;
@ -59,7 +58,6 @@ public class MainActivity extends BaseActivity {
super.onCreate(savedInstanceState);
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
HolidayHelper.setup(this);
binding.status.setOnClickListener(v -> {
if (ConfigManager.getXposedApiVersion() != -1) {
new InfoDialogBuilder(this)
@ -102,17 +100,7 @@ public class MainActivity extends BaseActivity {
binding.statusSummary.setText(R.string.selinux_policy_not_loaded_summary);
} else {
binding.statusTitle.setText(R.string.activated);
HolidayHelper.CardColors cardColors = HolidayHelper.getHolidayColors();
if (cardColors.textColor != 0) {
binding.statusIcon.setImageTintList(ColorStateList.valueOf(cardColors.textColor));
binding.statusTitle.setTextColor(ColorStateList.valueOf(cardColors.textColor));
binding.statusSummary.setTextColor(ColorStateList.valueOf(cardColors.textColor));
}
if (cardColors.backgroundColor != 0) {
cardBackgroundColor = cardColors.backgroundColor;
} else {
cardBackgroundColor = ResourcesKt.resolveColor(getTheme(), R.attr.colorNormal);
}
cardBackgroundColor = ResourcesKt.resolveColor(getTheme(), R.attr.colorNormal);
binding.statusIcon.setImageResource(R.drawable.ic_check_circle);
binding.statusSummary.setText(String.format(Locale.US, "%s (%d)", installXposedVersion, ConfigManager.getXposedVersionCode()));
}

View File

@ -1,48 +0,0 @@
/*
* This file is part of LSPosed.
*
* LSPosed is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LSPosed is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LSPosed. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright (C) 2021 LSPosed Contributors
*/
package org.lsposed.manager.util.holiday;
import java.util.Calendar;
public class Helpers {
public static Holidays currentHoliday = Holidays.NONE;
public enum Holidays {
NONE, NEWYEAR, LUNARNEWYEAR, PRIDE
}
public static void detectHoliday() {
currentHoliday = Holidays.NONE;
Calendar cal = Calendar.getInstance();
int month = cal.get(Calendar.MONTH);
int monthDay = cal.get(Calendar.DAY_OF_MONTH);
//int year = cal.get(Calendar.YEAR);
// Lunar NY
if ((month == 0 && monthDay > 15) || month == 1) {
currentHoliday = Holidays.LUNARNEWYEAR;
} else if (month == 0 || month == 11) { // NY
currentHoliday = Holidays.NEWYEAR;
} else if (month == 5) { // Pride Month
currentHoliday = Holidays.PRIDE;
}
}
}

View File

@ -1,85 +0,0 @@
/*
* This file is part of LSPosed.
*
* LSPosed is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LSPosed is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LSPosed. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright (C) 2021 LSPosed Contributors
*/
package org.lsposed.manager.util.holiday;
import android.app.Activity;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import org.lsposed.manager.R;
public class HolidayHelper {
public static void setup(Activity activity) {
Helpers.detectHoliday();
ImageView header = activity.findViewById(R.id.holiday_header);
switch (Helpers.currentHoliday) {
case NEWYEAR:
header.setLayoutParams(
new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
header.setImageResource(R.drawable.newyear_header);
header.setVisibility(View.VISIBLE);
break;
case LUNARNEWYEAR:
header.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
header.setImageResource(R.drawable.lunar_newyear_header);
header.setVisibility(View.VISIBLE);
((FrameLayout) header.getParent()).requestLayout();
break;
case PRIDE:
header.setForeground(new ColorDrawable(0x15000000));
header.setImageResource(R.drawable.pride_flag);
header.setVisibility(View.VISIBLE);
break;
case NONE:
default:
((ViewGroup) header.getParent()).removeView(header);
}
}
public static CardColors getHolidayColors() {
switch (Helpers.currentHoliday) {
case LUNARNEWYEAR:
return new CardColors(0xfff05654, 0);
case NEWYEAR:
return new CardColors(0xff677a89, 0);
case PRIDE:
return new CardColors(0, 0xffffffff);
case NONE:
default:
return new CardColors(0, 0);
}
}
public static class CardColors {
public int backgroundColor;
public int textColor;
public CardColors(int background, int text) {
backgroundColor = background;
textColor = text;
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

View File

@ -1,24 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="777dp"
android:height="480dp"
android:viewportWidth="777"
android:viewportHeight="480">
<path
android:pathData="M0,0h777v480h-777z"
android:fillColor="#750787" />
<path
android:pathData="M0,0h777v400h-777z"
android:fillColor="#004dff" />
<path
android:pathData="M0,0h777v320h-777z"
android:fillColor="#008026" />
<path
android:pathData="M0,0h777v240h-777z"
android:fillColor="#ffed00" />
<path
android:pathData="M0,0h777v160h-777z"
android:fillColor="#ff8c00" />
<path
android:pathData="M0,0h777v80h-777z"
android:fillColor="#e40303" />
</vector>

View File

@ -82,7 +82,7 @@
<com.google.android.material.card.MaterialCardView
android:id="@+id/status"
android:layout_width="match_parent"
android:layout_height="86dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:clickable="true"
android:focusable="true"
@ -92,16 +92,6 @@
app:cardElevation="4dp"
app:cardPreventCornerOverlap="false">
<ImageView
android:id="@+id/holiday_header"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:focusable="false"
android:focusableInTouchMode="false"
android:visibility="gone"
tools:ignore="ContentDescription" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"