eastern egg and text and icon

This commit is contained in:
Riko Sakurauchi 2019-12-30 13:43:49 +08:00
parent fe48abb061
commit cd8b81ed11
No known key found for this signature in database
GPG Key ID: 25AC0345B92902AF
12 changed files with 87 additions and 11 deletions

View File

@ -196,7 +196,7 @@ public class ActionBar extends FrameLayout {
if (drawable != null) {
TextPaint textPaint = titleTextView.getTextPaint();
textPaint.getFontMetricsInt(fontMetricsInt);
textPaint.getTextBounds((String) titleTextView.getText(), 0, 1, rect);
textPaint.getTextBounds((String) titleTextView.getText(), 0, 2, rect);
int x = titleTextView.getTextStartX() + Theme.getCurrentHolidayDrawableXOffset() + (rect.width() - (drawable.getIntrinsicWidth() + Theme.getCurrentHolidayDrawableXOffset())) / 2;
int y = titleTextView.getTextStartY() + Theme.getCurrentHolidayDrawableYOffset() + (int) Math.ceil((titleTextView.getTextHeight() - rect.height()) / 2.0f);
drawable.setBounds(x, y - drawable.getIntrinsicHeight(), x + drawable.getIntrinsicWidth(), y);

View File

@ -88,6 +88,8 @@ import java.util.HashSet;
import androidx.annotation.UiThread;
import tw.nekomimi.nekogram.NekoConfig;
public class Theme {
public static class ThemeInfo implements NotificationCenter.NotificationCenterDelegate {
@ -2269,7 +2271,7 @@ public class Theme {
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int eventType = -1;
if (monthOfYear == 11 && dayOfMonth >= 24 && dayOfMonth <= 31 || monthOfYear == 0 && dayOfMonth == 1) {
if (NekoConfig.xmas || (monthOfYear == 11 && dayOfMonth >= 24 && dayOfMonth <= 31 || monthOfYear == 0 && dayOfMonth == 1)) {
eventType = 0;
}
return eventType;
@ -2284,16 +2286,16 @@ public class Theme {
int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
int minutes = calendar.get(Calendar.MINUTE);
int hour = calendar.get(Calendar.HOUR_OF_DAY);
if (monthOfYear == 0 && dayOfMonth == 1 && minutes <= 10 && hour == 0) {
if (NekoConfig.newYearEve || (monthOfYear == 0 && dayOfMonth == 1 && minutes <= 10 && hour == 0)) {
canStartHolidayAnimation = true;
} else {
canStartHolidayAnimation = false;
}
if (dialogs_holidayDrawable == null) {
if (monthOfYear == 11 && dayOfMonth >= (BuildVars.DEBUG_PRIVATE_VERSION ? 29 : 31) && dayOfMonth <= 31 || monthOfYear == 0 && dayOfMonth == 1) {
if (NekoConfig.newYear || (monthOfYear == 11 && dayOfMonth >= (BuildVars.DEBUG_PRIVATE_VERSION ? 29 : 31) && dayOfMonth <= 31 || monthOfYear == 0 && dayOfMonth == 1)) {
dialogs_holidayDrawable = ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.newyear);
dialogs_holidayDrawableOffsetX = -AndroidUtilities.dp(3);
dialogs_holidayDrawableOffsetY = -AndroidUtilities.dp(1);
dialogs_holidayDrawableOffsetY = +AndroidUtilities.dp(1);
}
}
}

View File

@ -29,6 +29,10 @@ public class NekoConfig {
public static boolean showAdminActions = true;
public static boolean showChangePermissions = true;
public static boolean xmas = false;
public static boolean newYear = false;
public static boolean newYearEve = false;
private static boolean configLoaded;
static {
@ -57,6 +61,9 @@ public class NekoConfig {
editor.putBoolean("showPrPr", showPrPr);
editor.putBoolean("showAdminActions", showAdminActions);
editor.putBoolean("showChangePermissions", showChangePermissions);
editor.putBoolean("xmas", xmas);
editor.putBoolean("newYear", newYear);
editor.putBoolean("newYearEve", newYearEve);
editor.commit();
} catch (Exception e) {
@ -88,6 +95,9 @@ public class NekoConfig {
showPrPr = preferences.getBoolean("showPrPr", true);
showAdminActions = preferences.getBoolean("showAdminActions", true);
showChangePermissions = preferences.getBoolean("showChangePermissions", true);
xmas = preferences.getBoolean("xmas", false);
newYear = preferences.getBoolean("newYear", false);
newYearEve = preferences.getBoolean("newYearEve", false);
configLoaded = true;
}
}
@ -166,7 +176,7 @@ public class NekoConfig {
editor.commit();
}
public static void toogleTypeface() {
public static void toggleTypeface() {
typeface = typeface == 0 ? 1 : 0;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
@ -228,4 +238,28 @@ public class NekoConfig {
}
}
public static void toggleXmas() {
xmas = !xmas;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("xmas", xmas);
editor.commit();
}
public static void toggleNewYear() {
newYear = !newYear;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("newYear", newYear);
editor.commit();
}
public static void toggleNewYearEve() {
newYearEve = !newYearEve;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("newYearEve", newYearEve);
editor.commit();
}
}

View File

@ -76,6 +76,9 @@ public class NekoSettingsActivity extends BaseFragment {
private int navigationBarTintRow;
private int navigationBarColorRow;
private int forceTabletRow;
private int xmasRow;
private int newYearRow;
private int newYearEveRow;
private int settings2Row;
@Override
@ -221,7 +224,7 @@ public class NekoSettingsActivity extends BaseFragment {
((TextCheckCell) view).setChecked(SharedConfig.useSystemEmoji);
}
} else if (position == typefaceRow) {
NekoConfig.toogleTypeface();
NekoConfig.toggleTypeface();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.typeface == 1);
}
@ -250,6 +253,21 @@ public class NekoSettingsActivity extends BaseFragment {
listAdapter.notifyItemChanged(nameOrderRow);
});
showDialog(builder.create());
} else if (position == xmasRow) {
NekoConfig.toggleXmas();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.xmas);
}
} else if (position == newYearRow) {
NekoConfig.toggleNewYear();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.newYear);
}
} else if (position == newYearEveRow) {
NekoConfig.toggleNewYearEve();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.newYearEve);
}
}
});
@ -290,6 +308,9 @@ public class NekoSettingsActivity extends BaseFragment {
navigationBarColorRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? rowCount++ : -1;
forceTabletRow = rowCount++;
nameOrderRow = rowCount++;
xmasRow = rowCount++;
newYearRow = rowCount++;
newYearEveRow = rowCount++;
settings2Row = rowCount++;
if (notify && listAdapter != null) {
listAdapter.notifyDataSetChanged();
@ -368,7 +389,7 @@ public class NekoSettingsActivity extends BaseFragment {
value = LocaleController.getString("FirstLast", R.string.FirstLast);
break;
}
textCell.setTextAndValue(LocaleController.getString("NameOrder", R.string.NameOrder), value, false);
textCell.setTextAndValue(LocaleController.getString("NameOrder", R.string.NameOrder), value, true);
} else if (position == navigationBarColorRow) {
String value;
switch (NekoConfig.navigationBarColor) {
@ -430,6 +451,12 @@ public class NekoSettingsActivity extends BaseFragment {
textCell.setTextAndCheck(LocaleController.getString("IgnoreBlocked", R.string.IgnoreBlocked), NekoConfig.ignoreBlocked, true);
} else if (position == forceTabletRow) {
textCell.setTextAndCheck(LocaleController.getString("ForceTabletMode", R.string.ForceTabletMode), NekoConfig.forceTablet, true);
} else if (position == xmasRow) {
textCell.setTextAndCheck(LocaleController.getString("ChristmasEveryday", R.string.ChristmasEveryday), NekoConfig.xmas, true);
} else if (position == newYearRow) {
textCell.setTextAndCheck(LocaleController.getString("NewYearEveryday", R.string.NewYearEveryday), NekoConfig.newYear, true);
} else if (position == newYearEveRow) {
textCell.setTextAndCheck(LocaleController.getString("HappyNewYearEveryday", R.string.HappyNewYearEveryday), NekoConfig.newYearEve, false);
}
break;
}
@ -457,6 +484,7 @@ public class NekoSettingsActivity extends BaseFragment {
position == showChangePermissionsRow || position == showAdminActionsRow || position == showReportRow ||
position == showPrPrRow || position == showAddToSavedMessagesRow ||
position == nameOrderRow || position == forceTabletRow || position == mapPreviewRow ||
position == xmasRow || position == newYearRow || position == newYearEveRow ||
(position == transparentStatusBarRow && (NekoConfig.navigationBarTint || Build.VERSION.SDK_INT < Build.VERSION_CODES.O)) ||
(position == navigationBarColorRow && NekoConfig.navigationBarTint);
}
@ -504,7 +532,7 @@ public class NekoSettingsActivity extends BaseFragment {
position == showAdminActionsRow || position == showChangePermissionsRow ||
position == transparentStatusBarRow || position == navigationBarTintRow ||
position == ignoreBlockedRow || position == useSystemEmojiRow || position == typefaceRow ||
position == forceTabletRow) {
position == forceTabletRow || position == xmasRow || position == newYearRow || position == newYearEveRow) {
return 3;
} else if (position == settingsRow || position == connectionRow || position == messageMenuRow || position == chatRow) {
return 4;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 519 B

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 341 B

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 619 B

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 881 B

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -40,4 +40,7 @@
<string name="EnableResidentNotification">常駐通知を表示する</string>
<string name="DisableResidentNotification">常駐通知を無効にする</string>
<string name="NekogramRunning">Nekogram ランニング</string>
<string name="ChristmasEveryday">毎日がXmas</string>
<string name="NewYearEveryday">毎日が新年</string>
<string name="HappyNewYearEveryday">毎日がHappy New Year</string>
</resources>

View File

@ -40,4 +40,7 @@
<string name="EnableResidentNotification">请让猫咪住在通知栏里吧</string>
<string name="DisableResidentNotification">果然通知栏还是太挤了</string>
<string name="NekogramRunning">Nekogram 正在运行</string>
<string name="ChristmasEveryday">天天是圣诞(需要重启)</string>
<string name="NewYearEveryday">天天是新年(需要重启)</string>
<string name="HappyNewYearEveryday">天天跨年(需要重启)</string>
</resources>

View File

@ -40,4 +40,7 @@
<string name="EnableResidentNotification">請讓貓咪住在通知欄裡吧</string>
<string name="DisableResidentNotification">果然通知欄還是太擠了</string>
<string name="NekogramRunning">Nekogram 正在運行</string>
<string name="ChristmasEveryday">天天是聖誕(需要重啟)</string>
<string name="NewYearEveryday">天天是新年(需要重啟)</string>
<string name="HappyNewYearEveryday">天天跨年(需要重啟)</string>
</resources>

View File

@ -18,7 +18,7 @@
<string name="TypefaceUseDefault">Use system default font</string>
<string name="NoQuoteForward">NoQuote forward</string>
<string name="Repeat">Repeat</string>
<string name="AddToSavedMessages">Add to Saved Messages</string>
<string name="AddToSavedMessages">Save Message</string>
<string name="CreateMention">Create Mention</string>
<string name="ForceTabletMode">Force tablet mode</string>
<string name="All">All</string>
@ -30,7 +30,7 @@
<string name="EnableNya">Send message with suffix on long click</string>
<string name="NyaSuffix">Message suffix</string>
<string name="NyaSuffixHint">Suffix</string>
<string name="Prpr">prpr</string>
<string name="Prpr">Peropero</string>
<string name="TransparentStatusBar">Transparent status bar</string>
<string name="NavigationBarTint">Set navigation bar and status bar color</string>
<string name="NavigationBarColor">Navigation bar color</string>
@ -40,4 +40,7 @@
<string name="EnableResidentNotification">Show a resident notification</string>
<string name="DisableResidentNotification">Disable resident notification</string>
<string name="NekogramRunning">Nekogram is running</string>
<string name="ChristmasEveryday">Christmas holiday everyday</string>
<string name="NewYearEveryday">New year\'s day everyday</string>
<string name="HappyNewYearEveryday">Happy new year everyday</string>
</resources>