Skip to content

Commit a839fd6

Browse files
committed
增加通知与公告
1 parent c5bd765 commit a839fd6

File tree

28 files changed

+516
-78
lines changed

28 files changed

+516
-78
lines changed

APPTest/src/main/java/com/bihe0832/android/test/DebugMainActivity.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.os.Build
66
import android.os.Bundle
77
import android.os.StrictMode
88
import androidx.core.content.ContextCompat
9+
import com.bihe0832.android.app.message.addMessageAction
910
import com.bihe0832.android.app.router.RouterConstants
1011
import com.bihe0832.android.app.update.UpdateManager
1112
import com.bihe0832.android.framework.ui.main.CommonActivity
@@ -20,9 +21,14 @@ import com.bihe0832.android.lib.utils.os.BuildUtils
2021
@APPMain
2122
@Module(RouterConstants.MODULE_NAME_DEBUG)
2223
class DebugMainActivity : CommonActivity() {
24+
25+
override fun getLayoutID(): Int {
26+
return R.layout.activity_debug_main
27+
}
28+
2329
override fun onCreate(savedInstanceState: Bundle?) {
2430
super.onCreate(savedInstanceState)
25-
initToolbar("DebugMainActivity", false)
31+
initToolbar(R.id.common_toolbar, "DebugMainActivity", false, needBack = true, iconRes = R.mipmap.ic_left_arrow_white)
2632
if (BuildUtils.SDK_INT > Build.VERSION_CODES.GINGERBREAD) {
2733
StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder().permitAll().build())
2834
}
@@ -39,7 +45,7 @@ class DebugMainActivity : CommonActivity() {
3945
})
4046
hideBottomUIMenu()
4147
CommonDBManager.init(this)
42-
48+
addMessageAction(findViewById(R.id.message), findViewById(R.id.message_unread))
4349
}
4450

4551
override fun getStatusBarColor(): Int {

APPTest/src/main/java/com/bihe0832/android/test/module/DebugRouterFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class DebugRouterFragment : com.bihe0832.android.common.debug.module.DebugRouter
1111
add(RouterItem("zixie://m3u8"))
1212
add(RouterItem("zixie://m3u8list"))
1313
add(RouterItem("zixie://guide"))
14+
add(RouterItem("zixie://message"))
1415
}
1516
}
1617

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:id="@+id/drawer_layout"
6+
android:layout_width="match_parent"
7+
android:layout_height="match_parent"
8+
android:fitsSystemWindows="true"
9+
android:gravity="center">
10+
11+
<LinearLayout
12+
android:layout_width="match_parent"
13+
android:layout_height="wrap_content"
14+
android:orientation="vertical">
15+
16+
<androidx.appcompat.widget.Toolbar
17+
android:id="@+id/common_toolbar"
18+
style="@style/AAF.AppTheme.Toolbar.Light"
19+
app:title="是防守打法">
20+
21+
<androidx.constraintlayout.widget.ConstraintLayout
22+
android:layout_width="wrap_content"
23+
android:layout_height="match_parent"
24+
android:layout_gravity="center_vertical|end">
25+
26+
<ImageView
27+
android:id="@+id/message"
28+
android:layout_width="24dp"
29+
android:layout_height="24dp"
30+
android:layout_marginRight="16dp"
31+
android:scaleType="centerInside"
32+
android:src="@mipmap/message_black"
33+
app:layout_constraintBottom_toBottomOf="parent"
34+
app:layout_constraintEnd_toEndOf="parent"
35+
app:layout_constraintTop_toTopOf="parent" />
36+
37+
<com.bihe0832.android.lib.ui.textview.TextViewWithBackground
38+
android:id="@+id/message_unread"
39+
android:layout_width="wrap_content"
40+
android:layout_height="wrap_content"
41+
android:layout_marginTop="-2dp"
42+
android:layout_marginEnd="-2dp"
43+
android:gravity="center"
44+
android:minWidth="8dp"
45+
android:paddingLeft="4dp"
46+
android:paddingRight="4dp"
47+
android:textColor="@color/colorOnPrimary"
48+
android:textSize="8dp"
49+
app:bgtv_backgroundColor="@color/red_dot"
50+
app:bgtv_isRadiusHalfHeight="true"
51+
app:layout_constraintEnd_toEndOf="@+id/message"
52+
app:layout_constraintTop_toTopOf="@+id/message"
53+
tools:text="99+"
54+
tools:visibility="visible" />
55+
56+
57+
</androidx.constraintlayout.widget.ConstraintLayout>
58+
</androidx.appcompat.widget.Toolbar>
59+
60+
<FrameLayout
61+
android:id="@+id/common_fragment_content"
62+
android:layout_width="match_parent"
63+
android:layout_height="wrap_content"
64+
android:scrollbars="none" />
65+
</LinearLayout>
66+
67+
<FrameLayout
68+
android:id="@+id/navigation_drawer_fl"
69+
android:layout_width="200dp"
70+
android:layout_height="match_parent"
71+
android:layout_gravity="end"
72+
android:background="@color/permission_window_bg" />
73+
74+
</androidx.drawerlayout.widget.DrawerLayout>

APPTest/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<resources>
22
<string name="update_url">https://cdn.bihe0832.com/app/update/get_apk.json</string>
33
<string name="version_url">https://cdn.bihe0832.com/app/help/zapk.html</string>
4+
<string name="message_url">https://cdn.bihe0832.com/app/msg/aaf_msg_debug.json</string>
45
<!-- <string name="agreement_url">https://blog.bihe0832.com</string>-->
56
<!-- <string name="privacy_url">https://blog.bihe0832.com</string>-->
67
<!-- <string name="privacy_agreement_content">请你务必审慎阅读、充分理解「用户协议」和「隐私政策」各条款,包括但不限于:为了向你提供应用管理、内容分享等服务,我们需要收集你的设备信息、操作日志、用户网络等个人信息。你可以在「设置」中管理你的授权。&lt;BR&gt; 你可阅读&lt;font color=\'#428bca\'&gt;「隐私政策」&lt;/font&gt;和&lt;font color=\'#428bca\'&gt;「用户协议」&lt;/font&gt;了解详细信息。如你同意,请点击「同意」开始接受我们的服务</string>-->

Application/src/main/AndroidManifest.xml

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,40 @@
1313
<!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />-->
1414

1515
<application
16-
android:name="com.bihe0832.android.app.Application"
17-
tools:replace="android:name">
16+
android:name="com.bihe0832.android.app.Application"
17+
tools:replace="android:name">
1818

1919
<activity
20-
android:name="com.bihe0832.android.app.about.AboutActivity"
21-
android:configChanges="orientation|screenSize|keyboardHidden"
22-
android:screenOrientation="portrait"
23-
android:theme="@style/AAF.ActivityTheme" />
24-
<!-- <activity-->
25-
<!-- android:name="com.bihe0832.android.common.webview.WebPageActivity"-->
26-
<!-- android:configChanges="orientation|screenSize|keyboardHidden"-->
27-
<!-- android:theme="@style/activityTheme"-->
28-
<!-- android:hardwareAccelerated="true"-->
29-
<!-- android:launchMode="singleInstance"-->
30-
<!-- android:process=":web"-->
31-
<!-- android:screenOrientation="portrait">-->
32-
33-
<!-- <intent-filter>-->
34-
<!-- <action android:name="android.intent.action.VIEW" />-->
35-
36-
<!-- <category android:name="android.intent.category.DEFAULT" />-->
37-
<!-- <category android:name="android.intent.category.BROWSABLE" />-->
38-
39-
<!-- <data android:scheme="http" />-->
40-
<!-- <data android:scheme="https" />-->
41-
<!-- </intent-filter>-->
42-
<!-- </activity>-->
20+
android:name="com.bihe0832.android.app.message.AAFMessageActivity"
21+
android:configChanges="orientation|screenSize|keyboardHidden"
22+
android:screenOrientation="portrait"
23+
android:theme="@style/AAF.ActivityTheme" />
24+
25+
<activity
26+
android:name="com.bihe0832.android.app.about.AboutActivity"
27+
android:configChanges="orientation|screenSize|keyboardHidden"
28+
android:screenOrientation="portrait"
29+
android:theme="@style/AAF.ActivityTheme" />
30+
<!-- <activity-->
31+
<!-- android:name="com.bihe0832.android.common.webview.WebPageActivity"-->
32+
<!-- android:configChanges="orientation|screenSize|keyboardHidden"-->
33+
<!-- android:theme="@style/activityTheme"-->
34+
<!-- android:hardwareAccelerated="true"-->
35+
<!-- android:launchMode="singleInstance"-->
36+
<!-- android:process=":web"-->
37+
<!-- android:screenOrientation="portrait">-->
38+
39+
<!-- <intent-filter>-->
40+
<!-- <action android:name="android.intent.action.VIEW" />-->
41+
42+
<!-- <category android:name="android.intent.category.DEFAULT" />-->
43+
<!-- <category android:name="android.intent.category.BROWSABLE" />-->
44+
45+
<!-- <data android:scheme="http" />-->
46+
<!-- <data android:scheme="https" />-->
47+
<!-- </intent-filter>-->
48+
<!-- </activity>-->
49+
50+
4351
</application>
4452
</manifest>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.bihe0832.android.app.message;
2+
3+
import android.os.Bundle;
4+
5+
import androidx.annotation.Nullable;
6+
7+
import com.bihe0832.android.app.router.RouterConstants;
8+
import com.bihe0832.android.framework.ui.main.CommonActivity;
9+
import com.bihe0832.android.lib.router.annotation.Module;
10+
11+
12+
@Module(RouterConstants.MODULE_NAME_MESSAGE)
13+
public final class AAFMessageActivity extends CommonActivity {
14+
@Override
15+
protected void onCreate(@Nullable Bundle savedInstanceState) {
16+
super.onCreate(savedInstanceState);
17+
initToolbar("消息中心", true);
18+
if (findFragment(AAFMessageListFragment.class) == null) {
19+
loadRootFragment(new AAFMessageListFragment());
20+
}
21+
}
22+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.bihe0832.android.app.message
2+
3+
import android.app.Activity
4+
import com.bihe0832.android.common.message.base.MessageManager
5+
import com.bihe0832.android.common.message.data.MessageInfoItem
6+
import com.bihe0832.android.common.message.list.BaseMessageFragment
7+
8+
9+
class AAFMessageListFragment : BaseMessageFragment() {
10+
11+
override fun getMessageManager(): MessageManager {
12+
return AAFMessageManager
13+
}
14+
15+
override fun showMessage(activity: Activity, messageInfoItem: MessageInfoItem, showFace: Boolean) {
16+
AAFMessageManager.showMessage(activity, messageInfoItem, showFace)
17+
}
18+
}

Application/src/main/java/com/bihe0832/android/app/message/AAFMessageManager.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ object AAFMessageManager : MessageManager() {
2828
?: "", ""))
2929
}
3030

31-
fun showNotice(activity: Activity, messageInfoItem: MessageInfoItem, showFace: Boolean) {
31+
fun showMessage(activity: Activity, messageInfoItem: MessageInfoItem, showFace: Boolean) {
3232
mDependenceBlockDialogManager.getDependentTaskManager().addTask(messageInfoItem.messageID, {
3333
ThreadManager.getInstance().runOnUIThread {
34-
showNotice(activity, messageInfoItem, showFace, object : OnDialogListener {
34+
showMessage(activity, messageInfoItem, showFace, object : OnDialogListener {
3535
override fun onPositiveClick() {
3636
mDependenceBlockDialogManager.getDependentTaskManager().finishTask(messageInfoItem.messageID)
3737
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.bihe0832.android.app.message
2+
3+
import android.widget.ImageView
4+
import com.bihe0832.android.app.R
5+
import com.bihe0832.android.app.router.RouterConstants
6+
import com.bihe0832.android.app.router.RouterHelper
7+
import com.bihe0832.android.common.message.data.MessageInfoItem
8+
import com.bihe0832.android.framework.ui.BaseActivity
9+
import com.bihe0832.android.lib.ui.textview.TextViewWithBackground
10+
import com.bihe0832.android.lib.ui.textview.ext.changeStatusWithUnreadMsg
11+
import com.bihe0832.android.lib.utils.os.DisplayUtil
12+
13+
/**
14+
*
15+
* @author hardyshi code@bihe0832.com
16+
* Created on 2023/3/9.
17+
* Description: Description
18+
*
19+
*/
20+
21+
private val mAutoShowMessageList = mutableListOf<String>()
22+
23+
fun BaseActivity.addMessageAction(messageView: ImageView, unreadView: TextViewWithBackground) {
24+
AAFMessageManager.getMessageLiveData().value?.let { updateMessageMenuAndShowFace(it, this, unreadView) }
25+
AAFMessageManager.getMessageLiveData().observe(this) { t ->
26+
updateMessageMenuAndShowFace(t, this, unreadView)
27+
}
28+
29+
messageView.apply {
30+
setColorFilter(resources.getColor(R.color.colorOnPrimary))
31+
setOnClickListener {
32+
RouterHelper.openPageByRouter(RouterConstants.MODULE_NAME_MESSAGE)
33+
}
34+
}
35+
}
36+
37+
@Synchronized
38+
fun updateMessageMenuAndShowFace(noticeList: List<MessageInfoItem>, activity: BaseActivity, unreadView: TextViewWithBackground) {
39+
noticeList.filter { !it.hasRead() }.let {
40+
if (it.isNotEmpty()) {
41+
unreadView.changeStatusWithUnreadMsg(it.size, DisplayUtil.dip2px(activity, 8f))
42+
} else {
43+
unreadView.changeStatusWithUnreadMsg(-1, DisplayUtil.dip2px(activity, 8f))
44+
}
45+
}
46+
47+
noticeList.distinctBy { it.messageID }.filter { !mAutoShowMessageList.contains(it.messageID) && AAFMessageManager.canShowFace(it, false) }.forEach {
48+
mAutoShowMessageList.add(it.messageID)
49+
AAFMessageManager.showMessage(activity, it, true)
50+
}
51+
}

Application/src/main/java/com/bihe0832/android/app/router/RouterConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class RouterConstants extends com.bihe0832.android.framework.router.Route
1919

2020
public static final String MODULE_NAME_M3U8_LIST = "m3u8list";
2121
public static final String MODULE_NAME_MAIN = "main";
22+
public static final String MODULE_NAME_MESSAGE = "message";
2223

2324
public static final String MODULE_NAME_BROWSER_LIST = "weblist";
2425

0 commit comments

Comments
 (0)