调整webView

调整客服页面
This commit is contained in:
zlzw 2024-01-19 10:43:40 +08:00
parent d6e6164549
commit 16755a9c8c
5 changed files with 45 additions and 15 deletions

View File

@ -30,6 +30,7 @@ import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.interfaces.LifeCycleListener;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.ClickUtil;
import com.yunbao.common.utils.ToastUtil;
import java.util.ArrayList;
import java.util.List;
@ -381,5 +382,7 @@ public abstract class AbsActivity extends AppCompatActivity {
break;
}
}
public boolean isKefu(String url){
return url.startsWith("https://kefu.yaoulive.com");
}
}

View File

@ -186,7 +186,7 @@ public class WebViewActivity extends AbsActivity {
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
mWebView.loadUrl(url);
AndroidBug5497Workaround.assistActivity(this);
AndroidBug5497Workaround.assistActivity(mWebView);
if (Constants.myIntoIndex == 2) {
ft_title.setVisibility(View.GONE);

View File

@ -21,11 +21,14 @@ public class AndroidBug5497Workaround {
public static void assistActivity(Activity activity) {
new AndroidBug5497Workaround(activity);
}
public static void assistActivity(View webView) {
new AndroidBug5497Workaround(webView);
}
private View mChildOfContent;
private int usableHeightPrevious;
private int defHeight = ViewGroup.LayoutParams.MATCH_PARENT;
private FrameLayout.LayoutParams frameLayoutParams;
private ViewGroup.LayoutParams frameLayoutParams;
private AndroidBug5497Workaround(Activity activity) {
FrameLayout content = (FrameLayout) activity.findViewById(android.R.id.content);
@ -34,6 +37,7 @@ public class AndroidBug5497Workaround {
public void onGlobalLayout() {
possiblyResizeChildOfContent();
int heightDiff = mChildOfContent.getRootView().getHeight() - mChildOfContent.getHeight();
System.out.println("heightDiff = " + heightDiff);
if (heightDiff < 100) {
frameLayoutParams.height = defHeight;
mChildOfContent.requestLayout();
@ -41,7 +45,24 @@ public class AndroidBug5497Workaround {
}
});
frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
frameLayoutParams = (ViewGroup.LayoutParams) mChildOfContent.getLayoutParams();
}
public AndroidBug5497Workaround(View content) {
mChildOfContent = content;
mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
possiblyResizeChildOfContent();
int heightDiff = mChildOfContent.getRootView().getHeight() - mChildOfContent.getHeight();
System.out.println("heightDiff = " + heightDiff);
if (heightDiff < 100) {
frameLayoutParams.height = defHeight;
mChildOfContent.requestLayout();
}
}
});
frameLayoutParams = (ViewGroup.LayoutParams) mChildOfContent.getLayoutParams();
}
private void possiblyResizeChildOfContent() {

View File

@ -77,11 +77,12 @@ public class CustomerServiceWebViewActivity extends AbsActivity {
rootView = findViewById(R.id.webView_root);
mWebView = findViewById(R.id.webView);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
params.topMargin = DpUtil.dp2px(1);
/*params.topMargin = DpUtil.dp2px(1);
if (getNavigationBarHeight(mContext) != 0) {
params.bottomMargin = getNavigationBarHeight(mContext);
}
mWebView.setLayoutParams(params);
}*/
AndroidBug5497Workaround.assistActivity(rootView);
//mWebView.setLayoutParams(params);
mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER);
mWebView.setWebViewClient(new WebViewClient() {
@Override
@ -178,7 +179,6 @@ public class CustomerServiceWebViewActivity extends AbsActivity {
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
mWebView.loadUrl(url);
AndroidBug5497Workaround.assistActivity(this);
}
private void openImageChooserActivity(ValueCallback<Uri> valueCallback) {
@ -235,15 +235,21 @@ public class CustomerServiceWebViewActivity extends AbsActivity {
}
protected boolean canGoBack() {
// return mWebView != null && mWebView.canGoBack();
ToastUtil.showDebug("2调用js userBackShowPraise");
if (!isKefu(mWebView.getUrl()==null?"":mWebView.getUrl())) {
mWebView.loadUrl("javascript:userBackShowPraise()");
return false;
}
// return mWebView != null && mWebView.canGoBack();
return false;
}
@Override
public void onBackPressed() {
// finish();
ToastUtil.showDebug("调用js userBackShowPraise");
if (!isKefu(mWebView.getUrl()==null?"":mWebView.getUrl())) {
finish();
return;
}
mWebView.loadUrl("javascript:userBackShowPraise()");
}

View File

@ -7,7 +7,7 @@
android:id="@+id/rootView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="68dp"
android:layout_marginBottom="8dp"
android:orientation="vertical" />
<ProgressBar