胡斌

add the basic modifications for embeding crosswalk

@@ -25,4 +25,5 @@ dependencies { @@ -25,4 +25,5 @@ dependencies {
25 testImplementation 'junit:junit:4.12' 25 testImplementation 'junit:junit:4.12'
26 androidTestImplementation 'com.android.support.test:runner:1.0.2' 26 androidTestImplementation 'com.android.support.test:runner:1.0.2'
27 androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 27 androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
  28 + implementation 'org.xwalk:xwalk_core_library:23.53.589.4'
28 } 29 }
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <manifest xmlns:android="http://schemas.android.com/apk/res/android" 2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:tools="http://schemas.android.com/tools"
3 package="com.xuedianyun.embedcrosswalk"> 4 package="com.xuedianyun.embedcrosswalk">
4 5
  6 + <uses-permission android:name="android.permission.INTERNET"/>
  7 + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
  8 + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
  9 + <uses-sdk tools:overrideLibrary="org.xwalk.core" />
  10 +
5 <application 11 <application
6 android:allowBackup="true" 12 android:allowBackup="true"
7 android:icon="@mipmap/ic_launcher" 13 android:icon="@mipmap/ic_launcher"
@@ -3,11 +3,44 @@ package com.xuedianyun.embedcrosswalk; @@ -3,11 +3,44 @@ package com.xuedianyun.embedcrosswalk;
3 import android.support.v7.app.AppCompatActivity; 3 import android.support.v7.app.AppCompatActivity;
4 import android.os.Bundle; 4 import android.os.Bundle;
5 5
  6 +import org.xwalk.core.XWalkPreferences;
  7 +import org.xwalk.core.XWalkView;
  8 +
6 public class MainActivity extends AppCompatActivity { 9 public class MainActivity extends AppCompatActivity {
  10 + private XWalkView xWalkWebView;
7 11
8 @Override 12 @Override
9 protected void onCreate(Bundle savedInstanceState) { 13 protected void onCreate(Bundle savedInstanceState) {
10 super.onCreate(savedInstanceState); 14 super.onCreate(savedInstanceState);
11 setContentView(R.layout.activity_main); 15 setContentView(R.layout.activity_main);
  16 + xWalkWebView = findViewById(R.id.webView);
  17 + XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true);
  18 + xWalkWebView.load("http://www.xuedianyun.com", null);
  19 + }
  20 +
  21 + @Override
  22 + protected void onPause() {
  23 + super.onPause();
  24 + if (xWalkWebView != null) {
  25 + xWalkWebView.pauseTimers();
  26 + xWalkWebView.onHide();
  27 + }
  28 + }
  29 +
  30 + @Override
  31 + protected void onResume() {
  32 + super.onResume();
  33 + if (xWalkWebView != null) {
  34 + xWalkWebView.resumeTimers();
  35 + xWalkWebView.onShow();
  36 + }
  37 + }
  38 +
  39 + @Override
  40 + protected void onDestroy() {
  41 + super.onDestroy();
  42 + if (xWalkWebView != null) {
  43 + xWalkWebView.onDestroy();
  44 + }
12 } 45 }
13 } 46 }
@@ -5,14 +5,10 @@ @@ -5,14 +5,10 @@
5 android:layout_width="match_parent" 5 android:layout_width="match_parent"
6 android:layout_height="match_parent" 6 android:layout_height="match_parent"
7 tools:context=".MainActivity"> 7 tools:context=".MainActivity">
8 -  
9 - <TextView  
10 - android:layout_width="wrap_content"  
11 - android:layout_height="wrap_content"  
12 - android:text="Hello World!"  
13 - app:layout_constraintBottom_toBottomOf="parent"  
14 - app:layout_constraintLeft_toLeftOf="parent"  
15 - app:layout_constraintRight_toRightOf="parent"  
16 - app:layout_constraintTop_toTopOf="parent" /> 8 + <org.xwalk.core.XWalkView
  9 + android:id="@+id/webView"
  10 + android:layout_width="fill_parent"
  11 + android:layout_height="fill_parent"
  12 + android:orientation="vertical" />
17 13
18 </android.support.constraint.ConstraintLayout> 14 </android.support.constraint.ConstraintLayout>
@@ -19,6 +19,9 @@ allprojects { @@ -19,6 +19,9 @@ allprojects {
19 repositories { 19 repositories {
20 google() 20 google()
21 jcenter() 21 jcenter()
  22 + maven {
  23 + url 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2'
  24 + }
22 } 25 }
23 } 26 }
24 27