移除LogView.添加消息状态栏。
This commit is contained in:
parent
a69572e216
commit
73ff3d1726
@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Tue Jun 10 19:49:43 GMT 2025
|
||||
#Tue Jun 10 21:10:05 GMT 2025
|
||||
stageCount=0
|
||||
libraryProject=
|
||||
baseVersion=15.0
|
||||
publishVersion=15.0.0
|
||||
buildCount=19
|
||||
buildCount=33
|
||||
baseBetaVersion=15.0.1
|
||||
|
@ -24,6 +24,7 @@ import cc.winboll.studio.webpagesources.R;
|
||||
import cc.winboll.studio.webpagesources.activities.AboutActivity;
|
||||
import cc.winboll.studio.webpagesources.fragment.SourcesFragment;
|
||||
import cc.winboll.studio.webpagesources.fragment.WebFragment;
|
||||
import cc.winboll.studio.webpagesources.view.StatusBarView;
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements IWinBoLLActivity {
|
||||
|
||||
@ -34,7 +35,8 @@ public class MainActivity extends AppCompatActivity implements IWinBoLLActivity
|
||||
|
||||
public static final String MSG_UPDATE_URL = "MSG_UPDATE_URL";
|
||||
|
||||
LogView mLogView;
|
||||
static MainActivity _MainActivity;
|
||||
StatusBarView mStatusBarView;
|
||||
WebFragment mWebFragment;
|
||||
SourcesFragment mSourcesFragment;
|
||||
static boolean _mIsLoadedHomePage;
|
||||
@ -55,9 +57,7 @@ public class MainActivity extends AppCompatActivity implements IWinBoLLActivity
|
||||
setContentView(R.layout.activity_main);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
mLogView = findViewById(R.id.logview);
|
||||
mLogView.start();
|
||||
|
||||
|
||||
FragmentTransaction ft = ((FragmentManager)getSupportFragmentManager()).beginTransaction();
|
||||
mSourcesFragment = new SourcesFragment();
|
||||
ft.add(R.id.activitymainFrameLayout1, mSourcesFragment, SourcesFragment.TAG);
|
||||
@ -70,6 +70,10 @@ public class MainActivity extends AppCompatActivity implements IWinBoLLActivity
|
||||
|
||||
// 处理 onCreate 时的 Intent
|
||||
handleIntent(getIntent());
|
||||
|
||||
mStatusBarView = findViewById(R.id.activitymainStatusBarView1);
|
||||
_MainActivity = this;
|
||||
postStatusBarMessage("主窗口加载完成。");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -97,6 +101,12 @@ public class MainActivity extends AppCompatActivity implements IWinBoLLActivity
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void postStatusBarMessage(String msg) {
|
||||
if(_MainActivity != null) {
|
||||
_MainActivity.mStatusBarView.postMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
@ -152,7 +162,6 @@ public class MainActivity extends AppCompatActivity implements IWinBoLLActivity
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mLogView.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -196,6 +196,7 @@ public class BaseWebView extends WebView {
|
||||
|
||||
@Override
|
||||
public void loadUrl(String url) {
|
||||
MainActivity.postStatusBarMessage(String.format("正在加载:%s", url));
|
||||
Pattern patternHttp = Pattern.compile("(?i)^http[s]{0,1}://", Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcherHttp = patternHttp.matcher(url);
|
||||
if (matcherHttp.matches()) {
|
||||
@ -303,6 +304,7 @@ public class BaseWebView extends WebView {
|
||||
mIOnPageFinished.onPageFinished(url);
|
||||
LogUtils.d(TAG, "Page load finished : " + url);
|
||||
_mszLastUrl = url;
|
||||
MainActivity.postStatusBarMessage(String.format("加载完成:%s", url));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,79 @@
|
||||
package cc.winboll.studio.webpagesources.view;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import cc.winboll.studio.webpagesources.R;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen<zhangsken@188.com>
|
||||
* @Date 2025/06/11 04:11
|
||||
* @Describe 网页状态信息栏
|
||||
*/
|
||||
public class StatusBarView extends LinearLayout {
|
||||
|
||||
public static final String TAG = "StatusBar";
|
||||
|
||||
public static final int MESSAGE_NEWS = 0;
|
||||
|
||||
Context mContext;
|
||||
TextView mtvMessage;
|
||||
|
||||
public StatusBarView(Context context) {
|
||||
super(context);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
public StatusBarView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
public StatusBarView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
public StatusBarView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
void initView(Context context) {
|
||||
mContext = context;
|
||||
View viewMain = inflate(context, R.layout.view_statusbar, null);
|
||||
mtvMessage = viewMain.findViewById(R.id.tv_message);
|
||||
|
||||
// 设置布局参数为MATCH_PARENT,并确保最大尺寸显示
|
||||
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
addView(viewMain, params);
|
||||
}
|
||||
|
||||
public void postMessage(String msg) {
|
||||
if (mContext != null) {
|
||||
Message message = new Message();
|
||||
message.what = MESSAGE_NEWS;
|
||||
message.obj = msg;
|
||||
mHandler.dispatchMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
Handler mHandler = new Handler(){
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == MESSAGE_NEWS) {
|
||||
mtvMessage.setText((String)msg.obj);
|
||||
}
|
||||
//super.handleMessage(msg);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
@ -6,42 +6,35 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/toolbar"/>
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/toolbar"/>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1.0">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/activitymainFrameLayout1"/>
|
||||
|
||||
</LinearLayout>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="300dp">
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1.0">
|
||||
|
||||
<cc.winboll.studio.libappbase.LogView
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/logview"/>
|
||||
android:id="@+id/activitymainFrameLayout1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<cc.winboll.studio.webpagesources.view.StatusBarView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="36dp"
|
||||
android:id="@+id/activitymainStatusBarView1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
24
webpagesources/src/main/res/layout/view_statusbar.xml
Normal file
24
webpagesources/src/main/res/layout/view_statusbar.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#FFCCCCCC">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Text"
|
||||
android:id="@+id/tv_message"
|
||||
android:textIsSelectable="true"/>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user