Skip to content

Commit

Permalink
feat(android): add new example project (#3229)
Browse files Browse the repository at this point in the history
* 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 <maxli@tencent.com>
  • Loading branch information
siguangli and siguangli2018 committed May 16, 2023
1 parent 64f9710 commit fd11863
Show file tree
Hide file tree
Showing 76 changed files with 1,924 additions and 1,463 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ buildscript {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.github.kezong:fat-aar:1.3.8'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20"
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 1, 'seconds'
Expand Down
4 changes: 1 addition & 3 deletions framework/examples/android-demo/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
/build
libs/
src/main/assets/
/build
42 changes: 26 additions & 16 deletions framework/examples/android-demo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
apply plugin: 'com.android.application'
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}

Properties gradleProperties = new Properties()
def propFileDir = "$projectDir.absolutePath/../../android/gradle.properties"
Expand All @@ -16,10 +19,12 @@ if (propFile.exists()) {
include_abi_x86_64 = gradleProperties.getProperty('INCLUDE_ABI_X86_64')
}


android {
namespace 'com.openhippy.example'
compileSdkVersion COMPILE_VERSION as int
defaultConfig {
applicationId "com.tencent.mtt.hippy.example"
applicationId "com.openhippy.example"
minSdkVersion MIN_VERSION as int
// noinspection ExpiredTargetSdkVersion
//noinspection OldTargetApi
Expand All @@ -40,7 +45,6 @@ android {

}
}

signingConfigs {
release {
keyAlias 'key0'
Expand All @@ -49,7 +53,6 @@ android {
storePassword 'hippydemostorepass!'
}
}

buildTypes {
release {
minifyEnabled false
Expand All @@ -60,6 +63,13 @@ android {
minifyEnabled false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {
Expand All @@ -73,17 +83,17 @@ dependencies {
compileOnly project(path: ':hippy-support')
compileOnly project(path: ':renderer-native')
}

// TODO(vimerzhao): needed by render-tdf.Due to `embed` don't support indirect dependency,I temporarily write here
// api "androidx.exifinterface:exifinterface:1.3.3"
// api "com.tencent.tdfcore:embedder:0.0.8"

// noinspection GradleDependency
api deps.annotation
api 'androidx.legacy:legacy-support-v4:1.0.0'
api 'androidx.appcompat:appcompat:1.3.1'
api 'androidx.recyclerview:recyclerview:1.1.0'
api 'androidx.viewpager:viewpager:1.0.0'
implementation deps.annotation
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.viewpager:viewpager:1.0.0'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

project.afterEvaluate {
Expand All @@ -92,4 +102,4 @@ project.afterEvaluate {
from "res"
into "src/main/assets"
}
}
}
Binary file removed framework/examples/android-demo/hippydemo.jks
Binary file not shown.
10 changes: 3 additions & 7 deletions framework/examples/android-demo/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in D:\Users\xiandongluo\AppData\Local\Android\sdk1/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
Expand All @@ -22,4 +18,4 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile
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 framework/examples/android-demo/src/main/AndroidManifest.xml
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>
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)
}
}

}
Loading

0 comments on commit fd11863

Please sign in to comment.