|
|
@@ -2,35 +2,24 @@ package com.android.chmo.ui.activity;
|
|
|
|
|
|
import android.app.Activity;
|
|
|
import android.content.Context;
|
|
|
-import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
import android.graphics.Bitmap;
|
|
|
import android.graphics.BitmapFactory;
|
|
|
+import android.net.Uri;
|
|
|
import android.os.Build;
|
|
|
import android.support.annotation.NonNull;
|
|
|
-import android.support.annotation.Nullable;
|
|
|
import android.support.v7.app.AlertDialog;
|
|
|
-import android.support.v7.app.AppCompatActivity;
|
|
|
-import android.os.Bundle;
|
|
|
import android.text.TextUtils;
|
|
|
-import android.util.DisplayMetrics;
|
|
|
-import android.util.Log;
|
|
|
-import android.util.TypedValue;
|
|
|
-import android.view.Gravity;
|
|
|
import android.view.KeyEvent;
|
|
|
import android.view.View;
|
|
|
-import android.view.ViewGroup;
|
|
|
import android.webkit.JavascriptInterface;
|
|
|
-import android.webkit.JsPromptResult;
|
|
|
import android.webkit.JsResult;
|
|
|
import android.webkit.WebChromeClient;
|
|
|
import android.webkit.WebSettings;
|
|
|
import android.webkit.WebView;
|
|
|
import android.webkit.WebViewClient;
|
|
|
-import android.widget.ImageView;
|
|
|
import android.widget.ProgressBar;
|
|
|
-import android.widget.RelativeLayout;
|
|
|
-import android.widget.Toast;
|
|
|
+import android.widget.TextView;
|
|
|
|
|
|
import com.android.chmo.R;
|
|
|
import com.android.chmo.app.ChmoApplication;
|
|
|
@@ -44,7 +33,6 @@ import com.android.chmo.ui.activity.model.FansActivity;
|
|
|
import com.android.chmo.ui.activity.model.ModelDetailActivity;
|
|
|
import com.android.chmo.ui.dialog.SendGiftDialog;
|
|
|
import com.android.chmo.ui.dialog.ShareDialog;
|
|
|
-import com.android.chmo.ui.view.TopBar;
|
|
|
import com.android.chmo.wxapi.WeChatManager;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
|
|
|
@@ -53,14 +41,15 @@ import com.tencent.mm.opensdk.modelmsg.WXWebpageObject;
|
|
|
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
+import butterknife.OnClick;
|
|
|
|
|
|
public class WebViewActivity extends BaseActivity implements ShareDialog.OnShareListener {
|
|
|
@BindView(R.id.webView)
|
|
|
WebView webView;
|
|
|
@BindView(R.id.progressbar)
|
|
|
ProgressBar progressBar;
|
|
|
- @BindView(R.id.top_bar)
|
|
|
- TopBar topBar;
|
|
|
+ @BindView(R.id.tv_title)
|
|
|
+ TextView tvTitle;
|
|
|
|
|
|
private String url;
|
|
|
private String activitypk;
|
|
|
@@ -77,7 +66,6 @@ public class WebViewActivity extends BaseActivity implements ShareDialog.OnShare
|
|
|
intent.putExtra("activitypk", activitypk);
|
|
|
intent.putExtra("modelpk", modelpk);
|
|
|
context.startActivity(intent);
|
|
|
- ((Activity) context).overridePendingTransition(R.anim.push_right_in, R.anim.push_left_out);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -85,27 +73,26 @@ public class WebViewActivity extends BaseActivity implements ShareDialog.OnShare
|
|
|
return R.layout.activity_web_view;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ protected int getStatusBarStyle() {
|
|
|
+ return STATUS_BAR_STYLE_LIGHT_CONTENT;
|
|
|
+ }
|
|
|
+
|
|
|
+ @OnClick(R.id.btn_back)
|
|
|
+ void back() {
|
|
|
+ if (webView.canGoBack()) {
|
|
|
+ webView.goBack();
|
|
|
+ } else {
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void initView() {
|
|
|
url = getIntent().getStringExtra("url");
|
|
|
modelpk = getIntent().getStringExtra("modelpk");
|
|
|
activitypk = getIntent().getStringExtra("activitypk");
|
|
|
|
|
|
- ImageView imageView = new ImageView(this);
|
|
|
- RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, getResources().getDimensionPixelSize(R.dimen.top_bar_height));
|
|
|
- params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
|
|
- params.rightMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, getResources().getDisplayMetrics());
|
|
|
- imageView.setLayoutParams(params);
|
|
|
- imageView.setImageResource(R.mipmap.icon_fenxiang);
|
|
|
- imageView.setScaleType(ImageView.ScaleType.CENTER);
|
|
|
- imageView.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- share();
|
|
|
- }
|
|
|
- });
|
|
|
- topBar.addView(imageView);
|
|
|
-
|
|
|
webView.addJavascriptInterface(this, "chmo");//添加js监听 这样html就能调用客户端
|
|
|
webView.setWebChromeClient(webChromeClient);
|
|
|
webView.setWebViewClient(webViewClient);
|
|
|
@@ -157,6 +144,12 @@ public class WebViewActivity extends BaseActivity implements ShareDialog.OnShare
|
|
|
|
|
|
@Override
|
|
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
|
|
+ if (url.startsWith("tel:")) {
|
|
|
+ Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url));
|
|
|
+ startActivity(intent);
|
|
|
+ view.reload();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
return super.shouldOverrideUrlLoading(view, url);
|
|
|
}
|
|
|
|
|
|
@@ -187,7 +180,7 @@ public class WebViewActivity extends BaseActivity implements ShareDialog.OnShare
|
|
|
@Override
|
|
|
public void onReceivedTitle(WebView view, String title) {
|
|
|
super.onReceivedTitle(view, title);
|
|
|
- topBar.setTitle(title);
|
|
|
+ tvTitle.setText(title);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -208,7 +201,6 @@ public class WebViewActivity extends BaseActivity implements ShareDialog.OnShare
|
|
|
intent.putExtra("model", model);
|
|
|
intent.putExtra("modelPk", model.modelpk);
|
|
|
startActivity(intent);
|
|
|
- overridePendingTransition(R.anim.push_right_in, R.anim.push_left_out);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -218,6 +210,7 @@ public class WebViewActivity extends BaseActivity implements ShareDialog.OnShare
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ @OnClick(R.id.btn_share)
|
|
|
@JavascriptInterface
|
|
|
public void share() {
|
|
|
runOnUiThread(() -> shareDialog.show());
|
|
|
@@ -260,7 +253,6 @@ public class WebViewActivity extends BaseActivity implements ShareDialog.OnShare
|
|
|
intent.putExtra("modelPk", model.modelpk);
|
|
|
intent.putExtra("sendVideo", true);
|
|
|
startActivity(intent);
|
|
|
- overridePendingTransition(R.anim.push_right_in, R.anim.push_left_out);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -301,7 +293,7 @@ public class WebViewActivity extends BaseActivity implements ShareDialog.OnShare
|
|
|
WXMediaMessage message = new WXMediaMessage();
|
|
|
message.mediaObject = webpageObject;
|
|
|
message.title = TextUtils.isEmpty(shareTitle) ? "千模通告" : shareTitle;
|
|
|
- message.description = TextUtils.isEmpty(shareDesc) ? topBar.getTitle() : shareDesc;
|
|
|
+ message.description = TextUtils.isEmpty(shareDesc) ? tvTitle.getText().toString() : shareDesc;
|
|
|
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
|
|
|
message.setThumbImage(bmp);
|
|
|
SendMessageToWX.Req req = new SendMessageToWX.Req();
|
|
|
@@ -315,8 +307,8 @@ public class WebViewActivity extends BaseActivity implements ShareDialog.OnShare
|
|
|
WXWebpageObject webpageObject = new WXWebpageObject(TextUtils.isEmpty(shareUrl) ? webView.getUrl() : shareUrl);
|
|
|
WXMediaMessage message = new WXMediaMessage();
|
|
|
message.mediaObject = webpageObject;
|
|
|
- message.title = TextUtils.isEmpty(shareTitle) ? topBar.getTitle() : shareTitle;
|
|
|
- message.description = TextUtils.isEmpty(shareDesc) ? topBar.getTitle() : shareDesc;
|
|
|
+ message.title = TextUtils.isEmpty(shareTitle) ? tvTitle.getText().toString() : shareTitle;
|
|
|
+ message.description = TextUtils.isEmpty(shareDesc) ? tvTitle.getText().toString() : shareDesc;
|
|
|
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
|
|
|
message.setThumbImage(bmp);
|
|
|
SendMessageToWX.Req req = new SendMessageToWX.Req();
|