forked from Tencent/Hippy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(android): add new example project (Tencent#3229)
* feat(android): add new example project * feat(android): new example support muti window * feat(android): impl entry of snapshot * feat(android): add engine destroy impl * feat(android): add new example project * feat(android): new example support muti window * feat(android): impl entry of snapshot * feat(android): add engine destroy impl * feat(android): support PageConfiguration orientation change * feat(android): replace old example * fix(android): add uses-permission * fix(android): delete old demo dir --------- Co-authored-by: maxli <[email protected]>
- Loading branch information
1 parent
64f9710
commit fd11863
Showing
76 changed files
with
1,924 additions
and
1,463 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
/build | ||
libs/ | ||
src/main/assets/ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...amples/android-demo/src/androidTest/java/com/openhippy/example/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.openhippy.hippy | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.example.hippy", appContext.packageName) | ||
} | ||
} |
72 changes: 42 additions & 30 deletions
72
framework/examples/android-demo/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,52 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
package="com.tencent.mtt.hippy.example" | ||
android:versionCode="2" | ||
android:versionName="2.3.4"> | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
<uses-permission android:name="android.permission.VIBRATE" /> | ||
<application | ||
android:usesCleartextTraffic="true" | ||
android:allowBackup="true" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
tools:ignore="AllowBackup,MissingApplicationIcon,UnusedAttribute"> | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@drawable/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@drawable/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.Hippy" | ||
tools:targetApi="31"> | ||
<activity | ||
android:exported="false" | ||
android:name=".PageConfiguration" | ||
android:configChanges="orientation|screenSize|keyboardHidden"> | ||
<meta-data | ||
android:name="android.app.lib_name" | ||
android:value="" /> | ||
</activity> | ||
<activity | ||
android:exported="false" | ||
android:name=".PageManagement" | ||
android:screenOrientation="portrait" | ||
android:configChanges="orientation|screenSize|keyboardHidden"> | ||
<meta-data | ||
android:name="android.app.lib_name" | ||
android:value="" /> | ||
</activity> | ||
<activity | ||
android:exported="true" | ||
android:name=".MainActivity" | ||
android:screenOrientation="portrait" | ||
android:configChanges="orientation|screenSize|keyboardHidden"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<activity android:name=".MyActivity" | ||
android:configChanges="orientation|screenSize" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<activity | ||
android:name="com.tencent.mtt.hippy.example.BaseActivity" | ||
android:configChanges="orientation|screenSize" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
|
||
<meta-data | ||
android:name="android.app.lib_name" | ||
android:value="" /> | ||
</activity> | ||
</application> | ||
|
||
</manifest> | ||
</manifest> |
46 changes: 46 additions & 0 deletions
46
framework/examples/android-demo/src/main/java/com/openhippy/example/HippyEngineHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Tencent is pleased to support the open source community by making Hippy | ||
* available. | ||
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.openhippy.example | ||
|
||
class HippyEngineHelper { | ||
|
||
companion object { | ||
|
||
private val hippyEngineList: MutableList<HippyEngineWrapper> = mutableListOf() | ||
private val abandonHippyEngineList: MutableList<HippyEngineWrapper> = mutableListOf() | ||
|
||
fun createHippyEngine( | ||
driverType: PageConfiguration.DriverMode, | ||
rendererType: PageConfiguration.RenderMode, | ||
isDebugMode: Boolean, | ||
debugServerHost: String | ||
): HippyEngineWrapper { | ||
val hippyEngineWrapper = HippyEngineWrapper(driverType, rendererType, isDebugMode, debugServerHost) | ||
hippyEngineList.add(hippyEngineWrapper) | ||
return hippyEngineWrapper | ||
} | ||
|
||
fun getHippyEngineList() : MutableList<HippyEngineWrapper> { | ||
return hippyEngineList | ||
} | ||
|
||
fun onHippyEngineDestroy(hippyEngineWrapper: HippyEngineWrapper) { | ||
hippyEngineList.remove(hippyEngineWrapper) | ||
abandonHippyEngineList.add(hippyEngineWrapper) | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.