style: align native top bar icons with wechat chrome
This commit is contained in:
@@ -3,8 +3,7 @@ package com.hyzq.boss;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.TypedValue;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -18,38 +17,13 @@ public class BossUiTopActionStyleTest {
|
||||
@Test
|
||||
public void applyCompactTopActionStyle_usesWechatLikeIconSizing() {
|
||||
Context context = RuntimeEnvironment.getApplication();
|
||||
Button button = new Button(context);
|
||||
ImageButton button = new ImageButton(context);
|
||||
|
||||
BossUi.applyTopActionButtonStyle(context, button, BossUi.TopActionButtonStyle.COMPACT_ICON);
|
||||
BossUi.applyTopIconButtonStyle(context, button);
|
||||
|
||||
assertEquals(context.getColor(R.color.boss_text_primary), button.getCurrentTextColor());
|
||||
assertEquals(BossUi.dp(context, 38), button.getMinWidth());
|
||||
assertEquals(BossUi.dp(context, 36), button.getMinHeight());
|
||||
assertEquals(BossUi.dp(context, 12), button.getPaddingLeft());
|
||||
assertEquals(BossUi.dp(context, 6), button.getPaddingTop());
|
||||
assertEquals(
|
||||
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 20, context.getResources().getDisplayMetrics()),
|
||||
button.getTextSize(),
|
||||
0.01f
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applySecondaryTopActionStyle_usesDarkTextAndTightPadding() {
|
||||
Context context = RuntimeEnvironment.getApplication();
|
||||
Button button = new Button(context);
|
||||
|
||||
BossUi.applyTopActionButtonStyle(context, button, BossUi.TopActionButtonStyle.SECONDARY_TEXT);
|
||||
|
||||
assertEquals(context.getColor(R.color.boss_text_primary), button.getCurrentTextColor());
|
||||
assertEquals(0, button.getMinWidth());
|
||||
assertEquals(0, button.getMinHeight());
|
||||
assertEquals(BossUi.dp(context, 12), button.getPaddingLeft());
|
||||
assertEquals(BossUi.dp(context, 40), button.getMinimumWidth());
|
||||
assertEquals(BossUi.dp(context, 40), button.getMinimumHeight());
|
||||
assertEquals(BossUi.dp(context, 8), button.getPaddingLeft());
|
||||
assertEquals(BossUi.dp(context, 8), button.getPaddingTop());
|
||||
assertEquals(
|
||||
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 14, context.getResources().getDisplayMetrics()),
|
||||
button.getTextSize(),
|
||||
0.01f
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import static org.junit.Assert.assertTrue;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
@@ -42,11 +42,11 @@ public class ConversationFolderActivityTest {
|
||||
ReflectionHelpers.ClassParameter.from(JSONObject.class, buildFolderPayload())
|
||||
);
|
||||
|
||||
Button headerAction = activity.findViewById(R.id.screen_header_action);
|
||||
Button refreshButton = activity.findViewById(R.id.screen_refresh_button);
|
||||
ImageButton headerAction = activity.findViewById(R.id.screen_header_action);
|
||||
ImageButton refreshButton = activity.findViewById(R.id.screen_refresh_button);
|
||||
LinearLayout content = activity.findViewById(R.id.screen_content);
|
||||
|
||||
assertEquals("...", headerAction.getText().toString());
|
||||
assertEquals("更多", String.valueOf(headerAction.getContentDescription()));
|
||||
assertEquals(View.GONE, refreshButton.getVisibility());
|
||||
assertTrue(viewTreeContainsText(content, "Talking"));
|
||||
assertTrue(viewTreeContainsText(content, "查询腾讯HAI GPU服务器"));
|
||||
|
||||
@@ -8,7 +8,7 @@ import static org.junit.Assert.assertTrue;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
@@ -110,10 +110,10 @@ public class ConversationInfoActivityTest {
|
||||
.setup()
|
||||
.get();
|
||||
|
||||
Button headerAction = activity.findViewById(R.id.screen_header_action);
|
||||
Button refreshButton = activity.findViewById(R.id.screen_refresh_button);
|
||||
ImageButton headerAction = activity.findViewById(R.id.screen_header_action);
|
||||
ImageButton refreshButton = activity.findViewById(R.id.screen_refresh_button);
|
||||
|
||||
assertEquals("...", headerAction.getText().toString());
|
||||
assertEquals("更多", String.valueOf(headerAction.getContentDescription()));
|
||||
assertEquals(View.GONE, refreshButton.getVisibility());
|
||||
|
||||
ReflectionHelpers.callInstanceMethod(activity, "showMoreMenu");
|
||||
|
||||
@@ -9,7 +9,7 @@ import android.content.Intent;
|
||||
import android.os.Looper;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
@@ -217,10 +217,10 @@ public class GroupInfoActivityTest {
|
||||
.setup()
|
||||
.get();
|
||||
|
||||
Button headerAction = activity.findViewById(R.id.screen_header_action);
|
||||
Button refreshButton = activity.findViewById(R.id.screen_refresh_button);
|
||||
ImageButton headerAction = activity.findViewById(R.id.screen_header_action);
|
||||
ImageButton refreshButton = activity.findViewById(R.id.screen_refresh_button);
|
||||
|
||||
assertEquals("...", headerAction.getText().toString());
|
||||
assertEquals("更多", String.valueOf(headerAction.getContentDescription()));
|
||||
assertEquals(View.GONE, refreshButton.getVisibility());
|
||||
|
||||
ReflectionHelpers.callInstanceMethod(activity, "showMoreMenu");
|
||||
|
||||
@@ -5,8 +5,8 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import org.json.JSONArray;
|
||||
@@ -53,13 +53,13 @@ public class MainActivityConversationSearchTest {
|
||||
Shadows.shadowOf(activity.getMainLooper()).idle();
|
||||
ReflectionHelpers.callInstanceMethod(activity, "renderCurrentTab");
|
||||
|
||||
Button searchButton = activity.findViewById(R.id.search_button);
|
||||
Button actionButton = activity.findViewById(R.id.refresh_button);
|
||||
ImageButton searchButton = activity.findViewById(R.id.search_button);
|
||||
ImageButton actionButton = activity.findViewById(R.id.refresh_button);
|
||||
LinearLayout titleGroup = activity.findViewById(R.id.top_title_group);
|
||||
EditText searchInput = activity.findViewById(R.id.top_search_input);
|
||||
|
||||
assertEquals("⌕", String.valueOf(searchButton.getText()));
|
||||
assertEquals("+", String.valueOf(actionButton.getText()));
|
||||
assertEquals("搜索", String.valueOf(searchButton.getContentDescription()));
|
||||
assertEquals("快捷操作", String.valueOf(actionButton.getContentDescription()));
|
||||
assertEquals(LinearLayout.VISIBLE, titleGroup.getVisibility());
|
||||
assertEquals(EditText.GONE, searchInput.getVisibility());
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class MainActivityConversationSearchTest {
|
||||
ReflectionHelpers.callInstanceMethod(activity, "showContent");
|
||||
Shadows.shadowOf(activity.getMainLooper()).idle();
|
||||
|
||||
Button searchButton = activity.findViewById(R.id.search_button);
|
||||
ImageButton searchButton = activity.findViewById(R.id.search_button);
|
||||
searchButton.performClick();
|
||||
Shadows.shadowOf(activity.getMainLooper()).idle();
|
||||
|
||||
@@ -89,8 +89,8 @@ public class MainActivityConversationSearchTest {
|
||||
assertEquals("树莓派", searchInputAfter.getText().toString());
|
||||
assertTrue(searchInputAfter.isFocused());
|
||||
|
||||
Button actionButton = activity.findViewById(R.id.refresh_button);
|
||||
assertEquals(Button.GONE, actionButton.getVisibility());
|
||||
ImageButton actionButton = activity.findViewById(R.id.refresh_button);
|
||||
assertEquals(ImageButton.GONE, actionButton.getVisibility());
|
||||
assertFalse(activity.findViewById(R.id.search_button).isShown());
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class MainActivityConversationSelectionTest {
|
||||
ReflectionHelpers.callInstanceMethod(activity, "showContent");
|
||||
Shadows.shadowOf(activity.getMainLooper()).idle();
|
||||
|
||||
Button actionButton = activity.findViewById(R.id.refresh_button);
|
||||
ImageButton actionButton = activity.findViewById(R.id.refresh_button);
|
||||
actionButton.performClick();
|
||||
Shadows.shadowOf(activity.getMainLooper()).idle();
|
||||
assertEquals(View.VISIBLE, activity.findViewById(R.id.conversation_quick_actions_overlay).getVisibility());
|
||||
@@ -93,7 +93,7 @@ public class MainActivityConversationSelectionTest {
|
||||
ReflectionHelpers.callInstanceMethod(activity, "showContent");
|
||||
Shadows.shadowOf(activity.getMainLooper()).idle();
|
||||
|
||||
Button actionButton = activity.findViewById(R.id.refresh_button);
|
||||
ImageButton actionButton = activity.findViewById(R.id.refresh_button);
|
||||
actionButton.performClick();
|
||||
Shadows.shadowOf(activity.getMainLooper()).idle();
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
@@ -65,13 +66,13 @@ public class ProjectDetailActivityUiTest {
|
||||
|
||||
LinearLayout composerRow = activity.findViewById(R.id.project_chat_composer_row);
|
||||
LinearLayout multiSelectActions = activity.findViewById(R.id.project_chat_multi_select_actions);
|
||||
Button backButton = activity.findViewById(R.id.screen_back_button);
|
||||
Button refreshButton = activity.findViewById(R.id.screen_refresh_button);
|
||||
ImageButton backButton = activity.findViewById(R.id.screen_back_button);
|
||||
ImageButton refreshButton = activity.findViewById(R.id.screen_refresh_button);
|
||||
Button forwardButton = activity.findViewById(R.id.project_chat_multi_forward);
|
||||
|
||||
assertEquals(View.GONE, composerRow.getVisibility());
|
||||
assertEquals(View.VISIBLE, multiSelectActions.getVisibility());
|
||||
assertEquals("取消", backButton.getText().toString());
|
||||
assertEquals("取消", String.valueOf(backButton.getContentDescription()));
|
||||
assertEquals(View.GONE, refreshButton.getVisibility());
|
||||
assertEquals(false, forwardButton.isEnabled());
|
||||
|
||||
@@ -82,7 +83,7 @@ public class ProjectDetailActivityUiTest {
|
||||
|
||||
assertEquals(View.VISIBLE, composerRow.getVisibility());
|
||||
assertEquals(View.GONE, multiSelectActions.getVisibility());
|
||||
assertEquals("返回", backButton.getText().toString());
|
||||
assertEquals("返回", String.valueOf(backButton.getContentDescription()));
|
||||
assertEquals(View.GONE, refreshButton.getVisibility());
|
||||
}
|
||||
|
||||
@@ -248,9 +249,9 @@ public class ProjectDetailActivityUiTest {
|
||||
|
||||
ReflectionHelpers.callInstanceMethod(activity, "updateSelectionUi");
|
||||
|
||||
Button headerAction = activity.findViewById(R.id.screen_header_action);
|
||||
ImageButton headerAction = activity.findViewById(R.id.screen_header_action);
|
||||
assertEquals(View.VISIBLE, headerAction.getVisibility());
|
||||
assertEquals("...", headerAction.getText().toString());
|
||||
assertEquals("更多", String.valueOf(headerAction.getContentDescription()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -269,9 +270,9 @@ public class ProjectDetailActivityUiTest {
|
||||
|
||||
ReflectionHelpers.callInstanceMethod(activity, "updateSelectionUi");
|
||||
|
||||
Button headerAction = activity.findViewById(R.id.screen_header_action);
|
||||
ImageButton headerAction = activity.findViewById(R.id.screen_header_action);
|
||||
assertEquals(View.VISIBLE, headerAction.getVisibility());
|
||||
assertEquals("...", headerAction.getText().toString());
|
||||
assertEquals("更多", String.valueOf(headerAction.getContentDescription()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -11,7 +11,8 @@ public class WechatSurfaceMapperTopActionTest {
|
||||
public void rootTopAction_usesSelectionForConversations() {
|
||||
WechatSurfaceMapper.RootTopAction action = WechatSurfaceMapper.rootTopAction("conversations", false, false);
|
||||
|
||||
assertEquals("+", action.label);
|
||||
assertEquals("快捷操作", action.label);
|
||||
assertEquals("add", action.iconKey);
|
||||
assertFalse(action.primaryStyle);
|
||||
assertTrue(action.compactStyle);
|
||||
assertEquals("open_conversation_quick_actions", action.actionKey);
|
||||
@@ -21,9 +22,10 @@ public class WechatSurfaceMapperTopActionTest {
|
||||
public void rootTopAction_usesCancelDuringConversationSelection() {
|
||||
WechatSurfaceMapper.RootTopAction action = WechatSurfaceMapper.rootTopAction("conversations", false, true);
|
||||
|
||||
assertEquals("取消", action.label);
|
||||
assertEquals("取消选择", action.label);
|
||||
assertEquals("close", action.iconKey);
|
||||
assertFalse(action.primaryStyle);
|
||||
assertFalse(action.compactStyle);
|
||||
assertTrue(action.compactStyle);
|
||||
assertEquals("cancel_select_conversations", action.actionKey);
|
||||
}
|
||||
|
||||
@@ -31,9 +33,10 @@ public class WechatSurfaceMapperTopActionTest {
|
||||
public void rootTopAction_keepsAddDeviceOnDevicesTab() {
|
||||
WechatSurfaceMapper.RootTopAction action = WechatSurfaceMapper.rootTopAction("devices", false);
|
||||
|
||||
assertEquals("+添加", action.label);
|
||||
assertTrue(action.primaryStyle);
|
||||
assertFalse(action.compactStyle);
|
||||
assertEquals("添加设备", action.label);
|
||||
assertEquals("add", action.iconKey);
|
||||
assertFalse(action.primaryStyle);
|
||||
assertTrue(action.compactStyle);
|
||||
assertEquals("add_device", action.actionKey);
|
||||
}
|
||||
|
||||
@@ -41,9 +44,10 @@ public class WechatSurfaceMapperTopActionTest {
|
||||
public void rootTopAction_keepsRefreshOnMeTab() {
|
||||
WechatSurfaceMapper.RootTopAction action = WechatSurfaceMapper.rootTopAction("me", true);
|
||||
|
||||
assertEquals("同步中", action.label);
|
||||
assertEquals("刷新", action.label);
|
||||
assertEquals("refresh", action.iconKey);
|
||||
assertFalse(action.primaryStyle);
|
||||
assertFalse(action.compactStyle);
|
||||
assertTrue(action.compactStyle);
|
||||
assertEquals("refresh", action.actionKey);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user