Skip to content

Commit 8d56d7d

Browse files
authored
Merge pull request #16 from shiqizhenyes/develop
Landscape display adaptation
2 parents 32a4333 + 3924c47 commit 8d56d7d

20 files changed

+271
-79
lines changed

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ dependencies {
7676
implementation 'androidx.palette:palette:1.0.0'
7777
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
7878
implementation 'com.google.android:flexbox:0.2.6'
79+
implementation "com.google.android.material:material:1.4.0"
7980
implementation "androidx.annotation:annotation:1.2.0"
8081
// 3rd part Dependencies...
8182
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'

app/src/main/AndroidManifest.xml

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
<activity
3030
android:name=".module.general.RouteActivity"
31-
android:screenOrientation="portrait"
3231
android:theme="@style/SplashTheme">
3332
<intent-filter>
3433
<action android:name="android.intent.action.MAIN" />
@@ -60,66 +59,52 @@
6059
</activity>
6160
<activity
6261
android:name=".module.home.MainActivity"
63-
android:screenOrientation="portrait"
6462
android:theme="@style/NoneSlideBackableTheme" />
6563
<activity
6664
android:name=".module.drawer.dailyhot.DailyHotActivity"
67-
android:label="@string/page_daily_hot"
68-
android:screenOrientation="portrait" />
65+
android:label="@string/page_daily_hot" />
6966
<activity
7067
android:name=".module.shortcuts.DailyHotShortcut"
7168
android:label="@string/page_daily_hot"
72-
android:screenOrientation="portrait"
7369
android:theme="@style/NoneSlideBackableTheme"
7470
android:windowSoftInputMode="adjustResize" />
7571
<activity
7672
android:name=".module.create.CreateTopicActivity"
7773
android:label="@string/page_create_topic"
78-
android:screenOrientation="portrait"
7974
android:windowSoftInputMode="adjustResize" />
8075
<activity
8176
android:name=".module.shortcuts.CreateTopicShortcut"
8277
android:label="@string/page_create_topic"
83-
android:screenOrientation="portrait"
8478
android:theme="@style/NoneSlideBackableTheme" />
8579
<activity
8680
android:name=".module.topic.TopicActivity"
8781
android:label="话题"
88-
android:screenOrientation="portrait"
8982
android:windowSoftInputMode="stateHidden|adjustResize" />
9083
<activity
9184
android:name=".module.login.LoginActivity"
92-
android:label="登录V2EX"
93-
android:screenOrientation="portrait" />
85+
android:label="登录V2EX" />
9486
<activity
9587
android:name=".module.login.TwoStepLoginActivity"
96-
android:label="两步验证"
97-
android:screenOrientation="portrait" />
88+
android:label="两步验证" />
9889
<activity
9990
android:name=".module.login.SignInWithGoogleActivity"
100-
android:label="Sign in With Google"
101-
android:screenOrientation="portrait" />
91+
android:label="Sign in With Google" />
10292
<activity
10393
android:name=".module.user.UserHomeActivity"
104-
android:label="主页"
105-
android:screenOrientation="portrait" />
94+
android:label="主页" />
10695
<activity
10796
android:name=".module.drawer.care.SpecialCareActivity"
108-
android:label="特别关注"
109-
android:screenOrientation="portrait" />
97+
android:label="特别关注" />
11098
<activity
11199
android:name=".module.drawer.star.StarActivity"
112-
android:label="收藏"
113-
android:screenOrientation="portrait" />
100+
android:label="收藏" />
114101
<activity
115102
android:name=".module.shortcuts.StarTopicShortcut"
116103
android:label="收藏"
117-
android:screenOrientation="portrait"
118104
android:theme="@style/NoneSlideBackableTheme" />
119105
<activity
120106
android:name=".module.node.NodeTopicActivity"
121-
android:label="节点"
122-
android:screenOrientation="portrait" />
107+
android:label="节点" />
123108
<activity
124109
android:name=".module.general.WapActivity"
125110
android:label="" />

app/src/main/java/me/ghui/v2er/general/App.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import android.app.Application;
44
import android.preference.PreferenceManager;
5+
import android.util.Log;
6+
57
import androidx.annotation.Nullable;
68

79
import com.flurry.android.FlurryAgent;
@@ -13,6 +15,8 @@
1315
import com.tencent.mm.opensdk.openapi.IWXAPI;
1416
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
1517

18+
import java.util.Calendar;
19+
1620
import io.reactivex.plugins.RxJavaPlugins;
1721
import me.ghui.v2er.BuildConfig;
1822
import me.ghui.v2er.R;
@@ -32,6 +36,7 @@ public class App extends Application {
3236
private static App sInstance;
3337
private AppComponent mAppComponent;
3438
private IWXAPI mWechat;
39+
public int unReadMsgCount = 0;
3540

3641
public static App get() {
3742
return sInstance;

app/src/main/java/me/ghui/v2er/helper/BottomNavigationViewHelper.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.view.Gravity;
66
import android.view.LayoutInflater;
77
import android.view.View;
8+
import android.view.ViewGroup;
89
import android.widget.FrameLayout;
910
import android.widget.ImageView;
1011

@@ -15,6 +16,10 @@
1516
import com.google.android.material.bottomnavigation.BottomNavigationItemView;
1617
import com.google.android.material.bottomnavigation.BottomNavigationMenuView;
1718
import com.google.android.material.bottomnavigation.BottomNavigationView;
19+
import com.google.android.material.internal.NavigationMenuView;
20+
import com.google.android.material.navigation.NavigationBarItemView;
21+
import com.google.android.material.navigation.NavigationBarMenuView;
22+
import com.google.android.material.navigationrail.NavigationRailView;
1823

1924
import me.ghui.v2er.R;
2025
import me.ghui.v2er.util.UnreadMsgUtils;
@@ -41,18 +46,38 @@ public static void setImageSize(BottomNavigationView view, int width, int height
4146
}
4247
}
4348

49+
public static void showBadgeView(Context context, NavigationRailView navigationRailView, int viewIndex,
50+
int showNumber) {
51+
NavigationBarMenuView menuView = (NavigationBarMenuView) navigationRailView.getChildAt(0);
52+
NavigationBarItemView itemView = (NavigationBarItemView) menuView.getChildAt(viewIndex);
53+
ImageView itemIcon = itemView.findViewById(R.id.navigation_bar_item_icon_view);
54+
final View badgeView = LayoutInflater.from(context).inflate(R.layout.message_count_layout,
55+
itemView, false);
56+
MsgView mcMsgView = badgeView.findViewById(R.id.mcMsgView);
57+
final FrameLayout.LayoutParams frameLayoutParams = new FrameLayout.LayoutParams(badgeView.getLayoutParams());
58+
itemIcon.post(() -> {
59+
frameLayoutParams.gravity = Gravity.TOP | Gravity.END;
60+
UnreadMsgUtils.show(context, mcMsgView, showNumber, (width, height) -> {
61+
frameLayoutParams.rightMargin = itemView.getWidth() / 2 - width; //图片的宽度的一半
62+
frameLayoutParams.topMargin = height / 2;
63+
itemView.addView(badgeView, frameLayoutParams);
64+
});
65+
});
66+
}
67+
68+
4469
public static void showBadgeView(Context context, BottomNavigationView bottomNavigationView, int viewIndex,
4570
int showNumber) {
4671
BottomNavigationMenuView menuView = (BottomNavigationMenuView) bottomNavigationView.getChildAt(0);
4772
BottomNavigationItemView itemView = (BottomNavigationItemView) menuView.getChildAt(viewIndex);
48-
ImageView itemIcon = itemView.findViewById(R.id.icon);
73+
ImageView itemIcon = itemView.findViewById(R.id.navigation_bar_item_icon_view);
4974
final View badgeView = LayoutInflater.from(context).inflate(R.layout.message_count_layout,
5075
itemView, false);
5176
MsgView mcMsgView = badgeView.findViewById(R.id.mcMsgView);
5277
final FrameLayout.LayoutParams frameLayoutParams = new FrameLayout.LayoutParams(badgeView.getLayoutParams());
5378
itemIcon.post(() -> {
5479
frameLayoutParams.gravity = Gravity.TOP | Gravity.END;
55-
UnreadMsgUtils.show(context, mcMsgView, showNumber, width -> {
80+
UnreadMsgUtils.show(context, mcMsgView, showNumber, (width, height) -> {
5681
frameLayoutParams.rightMargin = itemView.getWidth() / 2 - width;//图片的宽度的一半
5782
itemView.addView(badgeView, frameLayoutParams);
5883
});

app/src/main/java/me/ghui/v2er/injector/module/ExploreModule.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.content.Context;
44
import android.util.Log;
5+
import android.view.View;
56
import android.widget.ImageView;
67
import android.widget.TextView;
78

@@ -22,10 +23,13 @@
2223
import me.ghui.v2er.module.home.ExploreFragment;
2324
import me.ghui.v2er.module.home.ExplorePresenter;
2425
import me.ghui.v2er.module.node.NodeTopicActivity;
26+
import me.ghui.v2er.module.topic.TopicActivity;
2527
import me.ghui.v2er.module.user.UserHomeActivity;
2628
import me.ghui.v2er.network.bean.DailyHotInfo;
2729
import me.ghui.v2er.network.bean.ExplorePageInfo;
30+
import me.ghui.v2er.network.bean.NewsInfo;
2831
import me.ghui.v2er.network.bean.NodesNavInfo;
32+
import me.ghui.v2er.network.bean.TopicBasicInfo;
2933
import me.ghui.v2er.util.ViewUtils;
3034
import me.ghui.v2er.widget.NavNodesWrapper;
3135

@@ -79,7 +83,19 @@ public void convert(ViewHolder holder, Serializable serializable, int position)
7983
DailyHotInfo.Item.Member member = item.getMember();
8084
UserHomeActivity.open(member.getUserName(), mContext, holder.getImgView(R.id.avatar_img), member.getAvatar());
8185
},
82-
R.id.avatar_img, R.id.user_name_tv, R.id.common_list_item_root_layout);
86+
R.id.avatar_img, R.id.user_name_tv);
87+
88+
holder.setOnClickListener(v -> {
89+
View shareView = holder.getView(R.id.avatar_img);
90+
TopicBasicInfo basicInfo = new TopicBasicInfo.Builder(item.getTitle(), item.getMember().getAvatar())
91+
.author(item.getMember().getUserName())
92+
.tag(item.getNode().getTitle())
93+
.tagLink(item.getNode().getUrl().substring(item.getNode().getUrl().indexOf("/go")))
94+
.commentNum(item.getReplies())
95+
.build();
96+
TopicActivity.open(item.getUrl(),
97+
weakContext.get(), shareView, basicInfo);
98+
}, R.id.common_list_item_root_layout);
8399

84100
holder.setOnClickListener(v ->
85101
NodeTopicActivity.open(item.getNode().getUrl(), mContext),

app/src/main/java/me/ghui/v2er/module/base/BaseActivity.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,14 @@ public void displayStatusBarArea(boolean displayStatusBarArea) {
133133
protected BaseToolBar attachToolbar() {
134134
int layoutId = attachToolBar() == 0 ? R.layout.appbar_wrapper_toolbar : attachToolBar();
135135
mToolbarWrapper = (AppBarLayout) getLayoutInflater().inflate(layoutId, null);
136-
return (BaseToolBar) mToolbarWrapper.findViewById(R.id.inner_toolbar);
136+
BaseToolBar baseToolBar = mToolbarWrapper.findViewById(R.id.inner_toolbar);
137+
if (baseToolBar != null) {
138+
baseToolBar.setTitleTextColor(Theme.getColor(R.attr.icon_tint_color, this));
139+
baseToolBar.setSubtitleTextColor(Theme.getColor(R.attr.icon_tint_color, this));
140+
return baseToolBar;
141+
} else {
142+
return null;
143+
}
137144
}
138145

139146
@LayoutRes

app/src/main/java/me/ghui/v2er/module/create/NodeSelectFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
135135
if (mSearchHintIcon != null) {
136136
mSearchHintIcon.setTint(Theme.getColor(R.attr.icon_tint_color, getContext()));
137137
}
138-
}catch (Exception e) {}
138+
}catch (Exception ignore) {}
139139
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
140140
@Override
141141
public boolean onQueryTextSubmit(String s) {

0 commit comments

Comments
 (0)