fix: restyle conversations plus action
This commit is contained in:
@@ -2,6 +2,7 @@ package com.hyzq.boss;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
@@ -410,8 +411,36 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private void configureTopAction(WechatSurfaceMapper.RootTopAction action) {
|
private void configureTopAction(WechatSurfaceMapper.RootTopAction action) {
|
||||||
refreshButton.setText(action.label);
|
refreshButton.setText(action.label);
|
||||||
|
if (action.compactStyle) {
|
||||||
|
refreshButton.setBackgroundResource(R.drawable.bg_secondary_button);
|
||||||
|
refreshButton.setTextColor(getColor(R.color.boss_text_primary));
|
||||||
|
refreshButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
|
||||||
|
refreshButton.setMinWidth(BossUi.dp(this, 38));
|
||||||
|
refreshButton.setMinimumWidth(BossUi.dp(this, 38));
|
||||||
|
refreshButton.setMinHeight(BossUi.dp(this, 36));
|
||||||
|
refreshButton.setMinimumHeight(BossUi.dp(this, 36));
|
||||||
|
refreshButton.setPadding(
|
||||||
|
BossUi.dp(this, 12),
|
||||||
|
BossUi.dp(this, 6),
|
||||||
|
BossUi.dp(this, 12),
|
||||||
|
BossUi.dp(this, 6)
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
refreshButton.setBackgroundResource(action.primaryStyle ? R.drawable.bg_primary_button : R.drawable.bg_secondary_button);
|
refreshButton.setBackgroundResource(action.primaryStyle ? R.drawable.bg_primary_button : R.drawable.bg_secondary_button);
|
||||||
refreshButton.setTextColor(getColor(action.primaryStyle ? R.color.boss_surface : R.color.boss_green));
|
refreshButton.setTextColor(getColor(action.primaryStyle ? R.color.boss_surface : R.color.boss_green));
|
||||||
|
refreshButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
|
||||||
|
refreshButton.setMinWidth(0);
|
||||||
|
refreshButton.setMinimumWidth(0);
|
||||||
|
refreshButton.setMinHeight(0);
|
||||||
|
refreshButton.setMinimumHeight(0);
|
||||||
|
refreshButton.setPadding(
|
||||||
|
BossUi.dp(this, 12),
|
||||||
|
BossUi.dp(this, 8),
|
||||||
|
BossUi.dp(this, 12),
|
||||||
|
BossUi.dp(this, 8)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void syncTopActionVisualState(boolean refreshing) {
|
private void syncTopActionVisualState(boolean refreshing) {
|
||||||
|
|||||||
@@ -165,12 +165,12 @@ public final class WechatSurfaceMapper {
|
|||||||
|
|
||||||
public static RootTopAction rootTopAction(String activeTab, boolean refreshing) {
|
public static RootTopAction rootTopAction(String activeTab, boolean refreshing) {
|
||||||
if ("devices".equals(activeTab)) {
|
if ("devices".equals(activeTab)) {
|
||||||
return new RootTopAction("+添加", true, "add_device");
|
return new RootTopAction("+添加", true, false, "add_device");
|
||||||
}
|
}
|
||||||
if ("conversations".equals(activeTab)) {
|
if ("conversations".equals(activeTab)) {
|
||||||
return new RootTopAction("+", true, "create_group_chat");
|
return new RootTopAction("+", false, true, "create_group_chat");
|
||||||
}
|
}
|
||||||
return new RootTopAction(refreshing ? "同步中" : "刷新", false, "refresh");
|
return new RootTopAction(refreshing ? "同步中" : "刷新", false, false, "refresh");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T resolveRefreshValue(T cachedValue, T freshValue, boolean requestSucceeded) {
|
public static <T> T resolveRefreshValue(T cachedValue, T freshValue, boolean requestSucceeded) {
|
||||||
@@ -183,11 +183,13 @@ public final class WechatSurfaceMapper {
|
|||||||
public static final class RootTopAction {
|
public static final class RootTopAction {
|
||||||
public final String label;
|
public final String label;
|
||||||
public final boolean primaryStyle;
|
public final boolean primaryStyle;
|
||||||
|
public final boolean compactStyle;
|
||||||
public final String actionKey;
|
public final String actionKey;
|
||||||
|
|
||||||
RootTopAction(String label, boolean primaryStyle, String actionKey) {
|
RootTopAction(String label, boolean primaryStyle, boolean compactStyle, String actionKey) {
|
||||||
this.label = label;
|
this.label = label;
|
||||||
this.primaryStyle = primaryStyle;
|
this.primaryStyle = primaryStyle;
|
||||||
|
this.compactStyle = compactStyle;
|
||||||
this.actionKey = actionKey;
|
this.actionKey = actionKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ public class WechatSurfaceMapperTopActionTest {
|
|||||||
WechatSurfaceMapper.RootTopAction action = WechatSurfaceMapper.rootTopAction("conversations", false);
|
WechatSurfaceMapper.RootTopAction action = WechatSurfaceMapper.rootTopAction("conversations", false);
|
||||||
|
|
||||||
assertEquals("+", action.label);
|
assertEquals("+", action.label);
|
||||||
assertTrue(action.primaryStyle);
|
assertFalse(action.primaryStyle);
|
||||||
|
assertTrue(action.compactStyle);
|
||||||
assertEquals("create_group_chat", action.actionKey);
|
assertEquals("create_group_chat", action.actionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ public class WechatSurfaceMapperTopActionTest {
|
|||||||
|
|
||||||
assertEquals("+添加", action.label);
|
assertEquals("+添加", action.label);
|
||||||
assertTrue(action.primaryStyle);
|
assertTrue(action.primaryStyle);
|
||||||
|
assertFalse(action.compactStyle);
|
||||||
assertEquals("add_device", action.actionKey);
|
assertEquals("add_device", action.actionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,6 +33,7 @@ public class WechatSurfaceMapperTopActionTest {
|
|||||||
|
|
||||||
assertEquals("同步中", action.label);
|
assertEquals("同步中", action.label);
|
||||||
assertFalse(action.primaryStyle);
|
assertFalse(action.primaryStyle);
|
||||||
|
assertFalse(action.compactStyle);
|
||||||
assertEquals("refresh", action.actionKey);
|
assertEquals("refresh", action.actionKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user