Search in sources :

Example 1 with DragPointView

use of cn.cerc.summer.android.forms.view.DragPointView in project summer-android by cn-cerc.

the class FrmMain method InitView.

@SuppressLint("JavascriptInterface")
private void InitView() {
    imgBack = (ImageView) this.findViewById(R.id.imgBack);
    imgMore = (ImageView) this.findViewById(R.id.imgMore);
    lblTitle = (TextView) this.findViewById(R.id.lblTitle);
    boxTitle = (LinearLayout) findViewById(R.id.boxTitle);
    hightview = (View) findViewById(R.id.hightview);
    headview = (View) findViewById(R.id.head_view);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        hightview.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, VisualKeyboardTool.getStatusBarHeight(FrmMain.this)));
        hightview.setVisibility(View.VISIBLE);
    } else {
        hightview.setVisibility(View.GONE);
    }
    imgBack.setOnClickListener(this);
    imgMore.setOnClickListener(this);
    lblTitle.setOnClickListener(this);
    lblTitle.setSelected(true);
    dragpointview = (DragPointView) this.findViewById(R.id.dragpointview);
    dragpointview.setEnable(false);
    dragpointview.setClickable(false);
    dragpointview.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return false;
        }
    });
    dragpointview.setVisibility(View.INVISIBLE);
    mainframe = (FrameLayout) this.findViewById(R.id.mainframe);
    progress = (ProgressBar) this.findViewById(R.id.progress);
    tipsImage = (ImageView) this.findViewById(R.id.image_tips);
    linear_error = (RelativeLayout) this.findViewById(R.id.linear_error);
    btn_reload = (Button) this.findViewById(R.id.btn_reload);
    browser = (BrowserView) this.findViewById(R.id.webView);
    btn_reload.setOnClickListener(this);
    browser.getSettings().setTextZoom(settings.getInt(Constans.SCALE_SHAREDKEY, ScreenUtils.getScales(this, ScreenUtils.getInches(this))));
    // jsAndroid 供web端js调用标识,修改请通知web开发者
    browser.addJavascriptInterface(new JavaScriptProxy(this), "JSobj");
    browser.setWebViewClient(new MyWebViewClient());
    browser.setWebChromeClient(new WebChromeClient() {

        // For Android  > 4.1.1
        public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
            openFileChooserImpl(uploadMsg);
            mUploadMessage = uploadMsg;
        }

        // For Android  > 3.0
        public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
            if (mUploadMessage != null)
                return;
            mUploadMessage = uploadMsg;
        }

        // For Android  > 5.0
        @Override
        public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
            mUploadMessageForAndroid5 = filePathCallback;
            openFileChooserImplForAndroid5(filePathCallback);
            return true;
        }

        @Override
        public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
            callback.invoke(origin, true, false);
            super.onGeolocationPermissionsShowPrompt(origin, callback);
        }

        @Override
        public void onPermissionRequest(PermissionRequest request) {
            super.onPermissionRequest(request);
        }

        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
                progress.setProgress(newProgress, true);
            else
                progress.setProgress(newProgress);
            super.onProgressChanged(view, newProgress);
        }

        @Override
        public void onReceivedTitle(WebView view, String title) {
            super.onReceivedTitle(view, title);
        }

        @Override
        public void onReceivedTouchIconUrl(WebView view, String url, boolean precomposed) {
            super.onReceivedTouchIconUrl(view, url, precomposed);
        }
    });
    browser.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((keyCode == KeyEvent.KEYCODE_BACK) && event.getAction() == KeyEvent.ACTION_UP) {
                if (is_exit) {
                    Intent home = new Intent(Intent.ACTION_MAIN);
                    home.addCategory(Intent.CATEGORY_HOME);
                    startActivity(home);
                } else {
                    if (// 返回键退回
                    browser.canGoBack())
                        // 返回键退回
                        browser.goBack();
                    else
                        finish();
                }
                return true;
            } else
                return false;
        }
    });
    browser.setOnLongClickListener(this);
    AddWebView();
}
Also used : PermissionRequest(android.webkit.PermissionRequest) GeolocationPermissions(android.webkit.GeolocationPermissions) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) DragPointView(cn.cerc.summer.android.forms.view.DragPointView) WebView(android.webkit.WebView) BrowserView(cn.cerc.summer.android.forms.view.BrowserView) TextView(android.widget.TextView) Uri(android.net.Uri) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) KeyEvent(android.view.KeyEvent) WebChromeClient(android.webkit.WebChromeClient) WebView(android.webkit.WebView) LinearLayout(android.widget.LinearLayout) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 Uri (android.net.Uri)1 KeyEvent (android.view.KeyEvent)1 MotionEvent (android.view.MotionEvent)1 View (android.view.View)1 GeolocationPermissions (android.webkit.GeolocationPermissions)1 PermissionRequest (android.webkit.PermissionRequest)1 WebChromeClient (android.webkit.WebChromeClient)1 WebView (android.webkit.WebView)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 BrowserView (cn.cerc.summer.android.forms.view.BrowserView)1 DragPointView (cn.cerc.summer.android.forms.view.DragPointView)1