mirror of
https://github.com/NekoX-Dev/NekoX.git
synced 2024-12-17 13:49:32 +01:00
improve nav bar color
This commit is contained in:
parent
501a9b16f6
commit
80ec20e6a8
@ -19,7 +19,7 @@ public class NekoConfig {
|
||||
public static String nyaSuffix = "喵";
|
||||
public static boolean transparentStatusBar = true;
|
||||
public static boolean navigationBarTint = true;
|
||||
public static boolean useMessagePanelColor = false;
|
||||
public static int navigationBarColor = 2;
|
||||
private static boolean configLoaded;
|
||||
|
||||
static {
|
||||
@ -41,7 +41,7 @@ public class NekoConfig {
|
||||
editor.putString("nyaSuffix", nyaSuffix);
|
||||
editor.putBoolean("transparentStatusBar", transparentStatusBar);
|
||||
editor.putBoolean("navigationBarTint", navigationBarTint);
|
||||
editor.putBoolean("useMessagePanelColor", useMessagePanelColor);
|
||||
editor.putInt("navigationBarColor", navigationBarColor);
|
||||
|
||||
editor.commit();
|
||||
} catch (Exception e) {
|
||||
@ -66,7 +66,7 @@ public class NekoConfig {
|
||||
nyaSuffix = preferences.getString("nyaSuffix", "喵");
|
||||
transparentStatusBar = preferences.getBoolean("transparentStatusBar", true);
|
||||
navigationBarTint = preferences.getBoolean("navigationBarTint", true);
|
||||
useMessagePanelColor = preferences.getBoolean("useMessagePanelColor", false);
|
||||
navigationBarColor = preferences.getInt("navigationBarColor", 2);
|
||||
configLoaded = true;
|
||||
}
|
||||
}
|
||||
@ -143,11 +143,11 @@ public class NekoConfig {
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public static void toggleUseMessagePanelColor() {
|
||||
useMessagePanelColor = !useMessagePanelColor;
|
||||
public static void setNavigationBarColor(int color) {
|
||||
navigationBarColor = color;
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("useMessagePanelColor", useMessagePanelColor);
|
||||
editor.putInt("navigationBarColor", navigationBarColor);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class NekoSettingsActivity extends BaseFragment {
|
||||
private int nameOrderRow;
|
||||
private int transparentStatusBarRow;
|
||||
private int navigationBarTintRow;
|
||||
private int useMessagePanelColorRow;
|
||||
private int navigationBarColorRow;
|
||||
private int forceTabletRow;
|
||||
private int settings2Row;
|
||||
|
||||
@ -173,14 +173,22 @@ public class NekoSettingsActivity extends BaseFragment {
|
||||
updateRows(true);
|
||||
UIHelper.updateStatusBarColor(getParentActivity());
|
||||
UIHelper.updateNavigationBarColor(getParentActivity());
|
||||
} else if (position == useMessagePanelColorRow) {
|
||||
} else if (position == navigationBarColorRow) {
|
||||
if (!NekoConfig.navigationBarTint)
|
||||
return;
|
||||
NekoConfig.toggleUseMessagePanelColor();
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(NekoConfig.useMessagePanelColor);
|
||||
}
|
||||
UIHelper.updateNavigationBarColor(getParentActivity());
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(LocaleController.getString("NavigationBarColor", R.string.NavigationBarColor));
|
||||
CharSequence[] items = new CharSequence[]{
|
||||
LocaleController.getString("NavigationBarColorBlack", R.string.NavigationBarColorBlack),
|
||||
LocaleController.getString("NavigationBarColorActionBar", R.string.NavigationBarColorActionBar),
|
||||
LocaleController.getString("NavigationBarColorMessagePanel", R.string.NavigationBarColorMessagePanel),
|
||||
};
|
||||
builder.setItems(items, (dialog, which) -> {
|
||||
NekoConfig.setNavigationBarColor(which + 1);
|
||||
listAdapter.notifyItemChanged(navigationBarColorRow);
|
||||
UIHelper.updateNavigationBarColor(getParentActivity());
|
||||
});
|
||||
showDialog(builder.create());
|
||||
} else if (position == useSystemEmojiRow) {
|
||||
SharedConfig.useSystemEmoji = !SharedConfig.useSystemEmoji;
|
||||
SharedPreferences.Editor editor = MessagesController.getGlobalMainSettings().edit();
|
||||
@ -300,7 +308,7 @@ public class NekoSettingsActivity extends BaseFragment {
|
||||
inappCameraRow = rowCount++;
|
||||
navigationBarTintRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? rowCount++ : -1;
|
||||
transparentStatusBarRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? rowCount++ : -1;
|
||||
useMessagePanelColorRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? rowCount++ : -1;
|
||||
navigationBarColorRow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? rowCount++ : -1;
|
||||
forceTabletRow = rowCount++;
|
||||
nameOrderRow = rowCount++;
|
||||
settings2Row = rowCount++;
|
||||
@ -382,6 +390,20 @@ public class NekoSettingsActivity extends BaseFragment {
|
||||
break;
|
||||
}
|
||||
textCell.setTextAndValue(LocaleController.getString("NameOrder", R.string.NameOrder), value, false);
|
||||
} else if (position == navigationBarColorRow) {
|
||||
String value;
|
||||
switch (NekoConfig.navigationBarColor) {
|
||||
case 3:
|
||||
value = LocaleController.getString("NavigationBarColorMessagePanel", R.string.NavigationBarColorMessagePanel);
|
||||
break;
|
||||
case 2:
|
||||
value = LocaleController.getString("NavigationBarColorActionBar", R.string.NavigationBarColorActionBar);
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
value = LocaleController.getString("NavigationBarColorBlack", R.string.NavigationBarColorBlack);
|
||||
}
|
||||
textCell.setTextAndValue(LocaleController.getString("NavigationBarColor", R.string.NavigationBarColor), value, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -397,8 +419,6 @@ public class NekoSettingsActivity extends BaseFragment {
|
||||
textCell.setTextAndCheck(LocaleController.getString("TransparentStatusBar", R.string.TransparentStatusBar), NekoConfig.transparentStatusBar, true);
|
||||
} else if (position == navigationBarTintRow) {
|
||||
textCell.setTextAndCheck(LocaleController.getString("NavigationBarTint", R.string.NavigationBarTint), NekoConfig.navigationBarTint, true);
|
||||
} else if (position == useMessagePanelColorRow) {
|
||||
textCell.setTextAndCheck(LocaleController.getString("UseMessagePanelColor", R.string.UseMessagePanelColor), NekoConfig.useMessagePanelColor, true);
|
||||
} else if (position == useSystemEmojiRow) {
|
||||
textCell.setTextAndCheck(LocaleController.getString("EmojiUseDefault", R.string.EmojiUseDefault), SharedConfig.useSystemEmoji, true);
|
||||
} else if (position == singleBigEmojiRow) {
|
||||
@ -443,7 +463,7 @@ public class NekoSettingsActivity extends BaseFragment {
|
||||
position == nameOrderRow || position == forceTabletRow || position == nyaRow ||
|
||||
(position == nyaSuffixRow && NekoConfig.nya) ||
|
||||
(position == transparentStatusBarRow && (NekoConfig.navigationBarTint || Build.VERSION.SDK_INT < Build.VERSION_CODES.O)) ||
|
||||
(position == useMessagePanelColorRow && NekoConfig.navigationBarTint);
|
||||
(position == navigationBarColorRow && NekoConfig.navigationBarTint);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -482,10 +502,10 @@ public class NekoSettingsActivity extends BaseFragment {
|
||||
public int getItemViewType(int position) {
|
||||
if (position == settings2Row || position == emoji2Row || position == connection2Row || position == chat2Row) {
|
||||
return 1;
|
||||
} else if (position == nameOrderRow) {
|
||||
} else if (position == nameOrderRow || position == navigationBarColorRow) {
|
||||
return 2;
|
||||
} else if (position == ipv6Row || position == hidePhoneRow || position == inappCameraRow ||
|
||||
position == transparentStatusBarRow || position == navigationBarTintRow || position == useMessagePanelColorRow ||
|
||||
position == transparentStatusBarRow || position == navigationBarTintRow ||
|
||||
position == ignoreBlockedRow || position == useSystemEmojiRow || position == singleBigEmojiRow ||
|
||||
position == forceTabletRow || position == nyaRow) {
|
||||
return 3;
|
||||
|
@ -41,7 +41,18 @@ public class UIHelper {
|
||||
}
|
||||
|
||||
static private void setNavigationBarColor(Activity parentActivity) {
|
||||
int color = Theme.getColor(NekoConfig.useMessagePanelColor ? Theme.key_chat_messagePanelBackground : Theme.key_actionBarDefault);
|
||||
int color;
|
||||
switch (NekoConfig.navigationBarColor) {
|
||||
case 3:
|
||||
color = Theme.getColor(Theme.key_chat_messagePanelBackground);
|
||||
break;
|
||||
case 2:
|
||||
color = Theme.getColor(Theme.key_actionBarDefault);
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
color = 0xff000000;
|
||||
}
|
||||
setNavigationBarColor(parentActivity, color);
|
||||
}
|
||||
|
||||
@ -89,7 +100,18 @@ public class UIHelper {
|
||||
}
|
||||
|
||||
public static void updateNavigationBarColor(Activity parentActivity) {
|
||||
int color = Theme.getColor(NekoConfig.useMessagePanelColor ? Theme.key_chat_messagePanelBackground : Theme.key_actionBarDefault);
|
||||
int color;
|
||||
switch (NekoConfig.navigationBarColor) {
|
||||
case 3:
|
||||
color = Theme.getColor(Theme.key_chat_messagePanelBackground);
|
||||
break;
|
||||
case 2:
|
||||
color = Theme.getColor(Theme.key_actionBarDefault);
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
color = 0xff000000;
|
||||
}
|
||||
updateNavigationBarColor(parentActivity, color);
|
||||
}
|
||||
|
||||
|
@ -29,5 +29,8 @@
|
||||
<string name="Prpr">ペロペロ</string>
|
||||
<string name="TransparentStatusBar">完全に透明なステータスバーを使う</string>
|
||||
<string name="NavigationBarTint">Nav Bar と Status Bar の色を有効にする</string>
|
||||
<string name="UseMessagePanelColor">Nav Bar アプリ Message Panel の色</string>
|
||||
<string name="NavigationBarColor">Nav Bar の色</string>
|
||||
<string name="NavigationBarColorBlack">黒</string>
|
||||
<string name="NavigationBarColorActionBar">アクションバーの色を使う</string>
|
||||
<string name="NavigationBarColorMessagePanel">メッセージパネルの色を使う</string>
|
||||
</resources>
|
@ -29,5 +29,8 @@
|
||||
<string name="Prpr">ペロペロ</string>
|
||||
<string name="TransparentStatusBar">使用完全透明的状态栏</string>
|
||||
<string name="NavigationBarTint">设置导航栏和状态栏颜色</string>
|
||||
<string name="UseMessagePanelColor">导航栏使用消息面板颜色</string>
|
||||
<string name="NavigationBarColor">导航栏颜色</string>
|
||||
<string name="NavigationBarColorBlack">使用黑色</string>
|
||||
<string name="NavigationBarColorActionBar">使用标题栏颜色</string>
|
||||
<string name="NavigationBarColorMessagePanel">使用消息面板颜色</string>
|
||||
</resources>
|
@ -29,5 +29,8 @@
|
||||
<string name="Prpr">ペロペロ</string>
|
||||
<string name="TransparentStatusBar">使用完全透明的狀態欄</string>
|
||||
<string name="NavigationBarTint">啟用導航欄和狀態欄顏色</string>
|
||||
<string name="UseMessagePanelColor">導航欄應用消息面板顏色</string>
|
||||
<string name="NavigationBarColor">導航欄顏色</string>
|
||||
<string name="NavigationBarColorBlack">使用黑色</string>
|
||||
<string name="NavigationBarColorActionBar">使用標題欄顏色</string>
|
||||
<string name="NavigationBarColorMessagePanel">使用消息面板顏色</string>
|
||||
</resources>
|
@ -29,5 +29,8 @@
|
||||
<string name="Prpr">prpr</string>
|
||||
<string name="TransparentStatusBar">Transparent status bar</string>
|
||||
<string name="NavigationBarTint">Set navigation bar and status bar color</string>
|
||||
<string name="UseMessagePanelColor">Use message panel color for nav bar</string>
|
||||
<string name="NavigationBarColor">Navigation bar color</string>
|
||||
<string name="NavigationBarColorBlack">Black</string>
|
||||
<string name="NavigationBarColorActionBar">Use action bar color</string>
|
||||
<string name="NavigationBarColorMessagePanel">Use message panel color</string>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user