Example usage for android.webkit ConsoleMessage message

List of usage examples for android.webkit ConsoleMessage message

Introduction

In this page you can find the example usage for android.webkit ConsoleMessage message.

Prototype

public String message() 

Source Link

Usage

From source file:org.globalquakemodel.org.idctdo.EQForm_MapView.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (DEBUG_LOG)
        Log.d(TAG, "ON CREATE");
    setContentView(R.layout.map_view);/* w  ww.j  a  v  a  2s .c  o  m*/
    mContext = this;

    MyStateSaver data = (MyStateSaver) getLastNonConfigurationInstance();
    if (data != null) {
        // Show splash screen if still loading
        if (data.showSplashScreen) {
            showSplashScreen();
        }
        setContentView(R.layout.map_view);

        // Rebuild your UI with your saved state here
    } else {
        showSplashScreen();
        setContentView(R.layout.map_view);
        // Do your heavy loading here on a background thread

    }

    //showSplashScreen();

    mWebView = (WebView) findViewById(R.id.map_webview);
    mWebView.getSettings().setAllowFileAccess(true);
    mWebView.getSettings().setJavaScriptEnabled(true);

    mWebView.setWebChromeClient(new WebChromeClient() {
        public boolean onConsoleMessage(ConsoleMessage cm) {
            if (DEBUG_LOG)
                Log.d(TAG, cm.message() + " -- From line " + cm.lineNumber() + " of " + cm.sourceId());
            return true;
        }
    });

    if (DEBUG_LOG)
        Log.d(TAG, "adding JS interface");
    mWebView.addJavascriptInterface(this, "webConnector");

    mWebView.loadUrl("file:///android_asset/idct_map.html");
    mWebView.setWebViewClient(new MapWebViewClient());
    progressBar = new ProgressDialog(EQForm_MapView.this);
    progressBar.setMessage("Loading maps...");
    progressBar.setCancelable(false);
    progressBar.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    //Create Folder
    mediaFile = new File(Environment.getExternalStorageDirectory().toString() + "/idctdo/gemmedia");
    mediaFile.mkdirs();

    //Create Folder
    vectorsFile = new File(Environment.getExternalStorageDirectory().toString() + "/idctdo/kml");
    vectorsFile.mkdirs();

    mapTilesFile = new File(Environment.getExternalStorageDirectory().toString() + "/idctdo/maptiles");
    mapTilesFile.mkdirs();

    File testFile = new File(
            Environment.getExternalStorageDirectory().toString() + "/idctdo/kml/PUT_KML_FILES_HERE");
    try {
        testFile.createNewFile();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    File testFile2 = new File(Environment.getExternalStorageDirectory().toString()
            + "/idctdo/maptiles/PUT_DIRECTORIES_OF_ZYX_TILES_HERE");
    try {
        testFile2.createNewFile();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    /** Creating a progress dialog window */
    mProgressDialog = new ProgressDialog(this);

    /** Close the dialog window on pressing back button */
    mProgressDialog.setCancelable(true);

    /** Setting a horizontal style progress bar */
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);

    /** Setting a message for this progress dialog
    * Use the method setTitle(), for setting a title
    * for the dialog window
    *  */
    mProgressDialog.setMessage("Loading map data...");

    vectorsFile.toString();
    new SingleMediaScanner(this, testFile);
    new SingleMediaScanner(this, testFile2);

    sdCardPath = "file:///" + Environment.getExternalStorageDirectory().getAbsolutePath() + "/";
    if (DEBUG_LOG)
        Log.d(TAG, "sdcard Path: " + sdCardPath);
    // Restore preferences
    PreferenceManager.getDefaultSharedPreferences(this);
    //SharedPreferences settings = getSharedPreferences("R.xml.prefs"), 0);

    mlocListener = new MyLocationListener();
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    currentLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

    btn_locateMe = (Button) findViewById(R.id.btn_locate_me);
    btn_locateMe.setOnClickListener(locateMeListener);

    btn_takeCameraPhoto = (Button) findViewById(R.id.btn_take_photo);
    btn_takeCameraPhoto.setOnClickListener(takePhotoListener);

    //btn_take_survey_photo=(Button)findViewById(R.id.btn_take_survey_photo);
    //btn_take_survey_photo.setVisibility(View.INVISIBLE);//Poss Dodgy threading stuff using this

    btn_startSurvey = (Button) findViewById(R.id.btn_start_survey);
    btn_startSurvey.setVisibility(View.INVISIBLE);//Dodgy threading stuff using this
    btn_startSurvey.setOnClickListener(startSurveyListener);

    btn_cancelSurveyPoint = (Button) findViewById(R.id.btn_cancel_survey_point);
    btn_cancelSurveyPoint.setVisibility(View.INVISIBLE);//Dodgy threading stuff using this
    btn_cancelSurveyPoint.setOnClickListener(cancelSurveyPointListener);

    btn_startSurveyFavourite = (Button) findViewById(R.id.btn_start_survey_with_favourite);
    btn_startSurveyFavourite.setVisibility(View.INVISIBLE);//Dodgy threading stuff using this
    btn_startSurveyFavourite.setOnClickListener(selectFavouriteListener);

    btn_selectLayer = (Button) findViewById(R.id.btn_select_layer);
    btn_selectLayer.setOnClickListener(selectLayerListener);

    btn_selectVectorLayer = (Button) findViewById(R.id.btn_select_vector_layer);
    btn_selectVectorLayer.setOnClickListener(selectVectorLayerListener);

    btn_zoomIn = (Button) findViewById(R.id.btn_zoom_in);
    btn_zoomIn.setOnClickListener(zoomInListener);
    btn_zoomOut = (Button) findViewById(R.id.btn_zoom_out);
    btn_zoomOut.setOnClickListener(zoomOutListener);

    btn_edit_points = (ToggleButton) findViewById(R.id.btn_edit_points);
    btn_edit_points.setOnClickListener(editPointsListener);

    text_view_gpsInfo = (TextView) findViewById(R.id.text_view_gpsInfo);
    text_view_gpsInfo2 = (TextView) findViewById(R.id.text_view_gpsInfo2);

    //Load any of the previous survey points
    loadPrevSurveyPoints();
}

From source file:com.android.mail.ui.ConversationViewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.conversation_view, container, false);
    mConversationContainer = (ConversationContainer) rootView.findViewById(R.id.conversation_container);
    mConversationContainer.setAccountController(this);

    mTopmostOverlay = (ViewGroup) mConversationContainer.findViewById(R.id.conversation_topmost_overlay);
    mTopmostOverlay.setOnKeyListener(this);
    inflateSnapHeader(mTopmostOverlay, inflater);
    mConversationContainer.setupSnapHeader();

    setupNewMessageBar();/*w w w .ja v  a 2 s .c  o m*/

    mProgressController = new ConversationViewProgressController(this, getHandler());
    mProgressController.instantiateProgressIndicators(rootView);

    mWebView = (ConversationWebView) mConversationContainer.findViewById(R.id.conversation_webview);

    mWebView.addJavascriptInterface(mJsBridge, "mail");
    // On JB or newer, we use the 'webkitAnimationStart' DOM event to signal load complete
    // Below JB, try to speed up initial render by having the webview do supplemental draws to
    // custom a software canvas.
    // TODO(mindyp):
    //PAGE READINESS SIGNAL FOR JELLYBEAN AND NEWER
    // Notify the app on 'webkitAnimationStart' of a simple dummy element with a simple no-op
    // animation that immediately runs on page load. The app uses this as a signal that the
    // content is loaded and ready to draw, since WebView delays firing this event until the
    // layers are composited and everything is ready to draw.
    // This signal does not seem to be reliable, so just use the old method for now.
    final boolean isJBOrLater = Utils.isRunningJellybeanOrLater();
    final boolean isUserVisible = isUserVisible();
    mWebView.setUseSoftwareLayer(!isJBOrLater);
    mEnableContentReadySignal = isJBOrLater && isUserVisible;
    mWebView.onUserVisibilityChanged(isUserVisible);
    mWebView.setWebViewClient(mWebViewClient);
    final WebChromeClient wcc = new WebChromeClient() {
        @Override
        public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
            if (consoleMessage.messageLevel() == ConsoleMessage.MessageLevel.ERROR) {
                LogUtils.e(LOG_TAG, "JS: %s (%s:%d) f=%s", consoleMessage.message(), consoleMessage.sourceId(),
                        consoleMessage.lineNumber(), ConversationViewFragment.this);
            } else {
                LogUtils.i(LOG_TAG, "JS: %s (%s:%d) f=%s", consoleMessage.message(), consoleMessage.sourceId(),
                        consoleMessage.lineNumber(), ConversationViewFragment.this);
            }
            return true;
        }
    };
    mWebView.setWebChromeClient(wcc);

    final WebSettings settings = mWebView.getSettings();

    final ScrollIndicatorsView scrollIndicators = (ScrollIndicatorsView) rootView
            .findViewById(R.id.scroll_indicators);
    scrollIndicators.setSourceView(mWebView);

    settings.setJavaScriptEnabled(true);

    ConversationViewUtils.setTextZoom(getResources(), settings);

    if (Utils.isRunningLOrLater()) {
        CookieManager.getInstance().setAcceptThirdPartyCookies(mWebView, true /* accept */);
    }

    mViewsCreated = true;
    mWebViewLoadedData = false;

    return rootView;
}

From source file:com.tct.mail.ui.ConversationViewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    //TS: chao-zhang 2015-12-10 EMAIL BUGFIX_1121860 MOD_S    544
    //NOTE: when infalte conversationView which is implements from WebView,webview.jar is not exist
    //or not found,NameNotFoundException exception thrown,and InflateException thrown in Email,BAD!!!
    View rootView;// ww w. j av a  2s . c om
    try {
        rootView = inflater.inflate(R.layout.conversation_view, container, false);
    } catch (InflateException e) {
        LogUtils.e(LOG_TAG, e, "InflateException happen during inflate conversationView");
        //TS: xing.zhao 2016-4-1 EMAIL BUGFIX_1892015 MOD_S
        if (getActivity() == null) {
            return null;
        } else {
            rootView = new View(getActivity().getApplicationContext());
            return rootView;
        }
        //TS: xing.zhao 2016-4-1 EMAIL BUGFIX_1892015 MOD_E
    }
    //TS: chao-zhang 2015-12-10 EMAIL BUGFIX_1121860 MOD_E
    //TS: tao.gan 2015-09-10 EMAIL FEATURE-559891 ADD_S
    //Here we romve the imagebutton and then add it ,to make it show on the top level.
    //Because we can't add the fab button at last on the layout xml.
    mFabButton = (ConversationReplyFabView) rootView.findViewById(R.id.conversation_view_fab);
    FrameLayout framelayout = (FrameLayout) rootView.findViewById(R.id.conversation_view_framelayout);
    framelayout.removeView(mFabButton);
    framelayout.addView(mFabButton);
    //TS: tao.gan 2015-09-10 EMAIL FEATURE-559891 ADD_E
    mConversationContainer = (ConversationContainer) rootView.findViewById(R.id.conversation_container);
    mConversationContainer.setAccountController(this);

    mTopmostOverlay = (ViewGroup) mConversationContainer.findViewById(R.id.conversation_topmost_overlay);
    mTopmostOverlay.setOnKeyListener(this);
    inflateSnapHeader(mTopmostOverlay, inflater);
    mConversationContainer.setupSnapHeader();

    setupNewMessageBar();

    mProgressController = new ConversationViewProgressController(this, getHandler());
    mProgressController.instantiateProgressIndicators(rootView);

    mWebView = (ConversationWebView) mConversationContainer.findViewById(R.id.conversation_webview);
    //TS: junwei-xu 2015-3-25 EMAIL BUGFIX_919767 ADD_S
    if (mWebView != null) {
        mWebView.setActivity(getActivity());
    }
    //TS: junwei-xu 2015-3-25 EMAIL BUGFIX_919767 ADD_E
    //TS: tao.gan 2015-09-10 EMAIL FEATURE-559891 ADD_S
    mWebView.setFabButton(mFabButton);
    //TS: tao.gan 2015-09-10 EMAIL FEATURE-559891 ADD_E

    mWebView.addJavascriptInterface(mJsBridge, "mail");
    // On JB or newer, we use the 'webkitAnimationStart' DOM event to signal load complete
    // Below JB, try to speed up initial render by having the webview do supplemental draws to
    // custom a software canvas.
    // TODO(mindyp):
    //PAGE READINESS SIGNAL FOR JELLYBEAN AND NEWER
    // Notify the app on 'webkitAnimationStart' of a simple dummy element with a simple no-op
    // animation that immediately runs on page load. The app uses this as a signal that the
    // content is loaded and ready to draw, since WebView delays firing this event until the
    // layers are composited and everything is ready to draw.
    // This signal does not seem to be reliable, so just use the old method for now.
    final boolean isJBOrLater = Utils.isRunningJellybeanOrLater();
    final boolean isUserVisible = isUserVisible();
    mWebView.setUseSoftwareLayer(!isJBOrLater);
    mEnableContentReadySignal = isJBOrLater && isUserVisible;
    mWebView.onUserVisibilityChanged(isUserVisible);
    mWebView.setWebViewClient(mWebViewClient);
    final WebChromeClient wcc = new WebChromeClient() {
        @Override
        public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
            if (consoleMessage.messageLevel() == ConsoleMessage.MessageLevel.ERROR) {
                //TS: wenggangjin 2015-01-29 EMAIL BUGFIX_-917007 MOD_S
                //                    LogUtils.wtf(LOG_TAG, "JS: %s (%s:%d) f=%s", consoleMessage.message(),
                LogUtils.w(LOG_TAG, "JS: %s (%s:%d) f=%s", consoleMessage.message(), consoleMessage.sourceId(),
                        consoleMessage.lineNumber(), ConversationViewFragment.this);
                //TS: wenggangjin 2015-01-29 EMAIL BUGFIX_-917007 MOD_E
            } else {
                LogUtils.i(LOG_TAG, "JS: %s (%s:%d) f=%s", consoleMessage.message(), consoleMessage.sourceId(),
                        consoleMessage.lineNumber(), ConversationViewFragment.this);
            }
            return true;
        }
    };
    mWebView.setWebChromeClient(wcc);

    final WebSettings settings = mWebView.getSettings();

    final ScrollIndicatorsView scrollIndicators = (ScrollIndicatorsView) rootView
            .findViewById(R.id.scroll_indicators);
    scrollIndicators.setSourceView(mWebView);

    settings.setJavaScriptEnabled(true);

    ConversationViewUtils.setTextZoom(getResources(), settings);
    //Enable third-party cookies. b/16014255
    if (Utils.isRunningLOrLater()) {
        CookieManager.getInstance().setAcceptThirdPartyCookies(mWebView, true /* accept */);
    }

    mViewsCreated = true;
    mWebViewLoadedData = false;

    return rootView;
}