@@ -13,6 +13,19 @@ android { | |||||
versionName "1.0" | versionName "1.0" | ||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||||
// App首页链接地址 | |||||
buildConfigField "String", "APP_HOME_URL", "\"${project.properties.appHomeUrl}\"" | |||||
// AndroidManifest.xml占位符 | |||||
manifestPlaceholders = [ | |||||
// App名称 | |||||
APP_NAME: "${project.properties.appName}", | |||||
// App图标 | |||||
APP_ICON: "@mipmap/ic_launcher_${project.properties.appIconKey}", | |||||
// App圆角图标 | |||||
APP_ROUND_ICON: "@mipmap/ic_launcher_${project.properties.appIconKey}_round" | |||||
] | |||||
} | } | ||||
signingConfigs { | signingConfigs { | ||||
@@ -31,6 +44,11 @@ android { | |||||
minifyEnabled false | minifyEnabled false | ||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||||
signingConfig signingConfigs.release | signingConfig signingConfigs.release | ||||
//resValue("string", "app_custom_name", "\"${project.properties.appName}\"") | |||||
} | |||||
debug { | |||||
signingConfig signingConfigs.release | |||||
//resValue("string", "app_custom_name", "\"${project.properties.appName}\"") | |||||
} | } | ||||
} | } | ||||
compileOptions { | compileOptions { | ||||
@@ -18,19 +18,30 @@ | |||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | ||||
<!-- android:icon 、 android:roundIcon 是APP显示图标--> | <!-- android:icon 、 android:roundIcon 是APP显示图标--> | ||||
<!-- | |||||
APP_NAME占位符: | |||||
可以在 /gradle.properties 里配置 appName="自定义名称", 必须携带双引号; 或appName=@string/app_name, 使用国际化文件字符串资源时不要携带双引号 | |||||
也可以在命令行添加 -PappName="自定义名称", 必须携带双引号; 不支持国际化文件字符串资源 | |||||
APP_ICON占位符: | |||||
APP_ROUND_ICON占位符: | |||||
可以在 /gradle.properties 里配置 appIconKey=图标类型, 不要携带双引号 | |||||
也可以在命令行添加 -PappIconKey=图标类型, 不要携带双引号 | |||||
APP_ICON拼接为 @mipmap/ic_launcher_${APP_ICON} | |||||
APP_ROUND_ICON拼接为 @mipmap/ic_launcher_${APP_ICON}_round | |||||
--> | |||||
<application | <application | ||||
android:requestLegacyExternalStorage="true" | android:requestLegacyExternalStorage="true" | ||||
android:allowBackup="true" | android:allowBackup="true" | ||||
android:icon="@mipmap/ic_launcher_yhzl" | |||||
android:roundIcon="@mipmap/ic_launcher_yhzl_round" | |||||
android:label="@string/app_name" | |||||
android:icon="${APP_ICON}" | |||||
android:roundIcon="${APP_ROUND_ICON}" | |||||
android:label="${APP_NAME}" | |||||
android:supportsRtl="true" | android:supportsRtl="true" | ||||
android:usesCleartextTraffic="true" | android:usesCleartextTraffic="true" | ||||
android:theme="@style/Theme.Nsgk_rural_web"> | android:theme="@style/Theme.Nsgk_rural_web"> | ||||
<activity | <activity | ||||
android:name=".WelcomeActivity" | android:name=".WelcomeActivity" | ||||
android:configChanges="orientation|keyboardHidden|screenSize|layoutDirection|uiMode" | android:configChanges="orientation|keyboardHidden|screenSize|layoutDirection|uiMode" | ||||
android:label="@string/app_name" | |||||
android:label="${APP_NAME}" | |||||
android:theme="@style/Theme.Nsgk_rural_web.Fullscreen"> | android:theme="@style/Theme.Nsgk_rural_web.Fullscreen"> | ||||
<intent-filter> | <intent-filter> | ||||
<action android:name="android.intent.action.MAIN" /> | <action android:name="android.intent.action.MAIN" /> | ||||
@@ -0,0 +1,14 @@ | |||||
package com.nsgk.ruralWeb; | |||||
public class Constants | |||||
{ | |||||
/** | |||||
* App首页链接地址 | |||||
* 可以在 /gradle.properties 里配置 appHomeUrl=链接地址, 不要携带双引号 | |||||
* 也可以在命令行添加 -PappHomeUrl="链接地址", 双引号可携带也可不携带 | |||||
*/ | |||||
public static String AppHomeUrl() | |||||
{ | |||||
return BuildConfig.APP_HOME_URL; | |||||
} | |||||
} |
@@ -3,6 +3,7 @@ package com.nsgk.ruralWeb; | |||||
import android.annotation.SuppressLint; | import android.annotation.SuppressLint; | ||||
import android.content.Intent; | import android.content.Intent; | ||||
import android.os.Bundle; | import android.os.Bundle; | ||||
import android.util.Log; | |||||
import android.view.KeyEvent; | import android.view.KeyEvent; | ||||
import android.view.ViewGroup; | import android.view.ViewGroup; | ||||
import android.widget.LinearLayout; | import android.widget.LinearLayout; | ||||
@@ -30,6 +31,8 @@ public class FullscreenActivity extends AppCompatActivity { | |||||
super.onCreate(savedInstanceState); | super.onCreate(savedInstanceState); | ||||
setContentView(R.layout.activity_fullscreen); | setContentView(R.layout.activity_fullscreen); | ||||
String appHomeUrl = Constants.AppHomeUrl(); | |||||
Log.i("NSGK", "App home url: " + appHomeUrl); | |||||
// init(); | // init(); | ||||
mAgentWeb = AgentWeb.with(this)// | mAgentWeb = AgentWeb.with(this)// | ||||
.setAgentWebParent((RelativeLayout) findViewById(R.id.ll), -1, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))//传入AgentWeb的父控件。 | .setAgentWebParent((RelativeLayout) findViewById(R.id.ll), -1, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))//传入AgentWeb的父控件。 | ||||
@@ -43,7 +46,7 @@ public class FullscreenActivity extends AppCompatActivity { | |||||
.interceptUnkownUrl() //拦截找不到相关页面的Url AgentWeb 3.0.0 加入。 | .interceptUnkownUrl() //拦截找不到相关页面的Url AgentWeb 3.0.0 加入。 | ||||
.createAgentWeb()//创建AgentWeb。 | .createAgentWeb()//创建AgentWeb。 | ||||
.ready()//设置 WebSettings。 | .ready()//设置 WebSettings。 | ||||
.go("http://218.59.175.43:71/yinnongLogin"); //WebView载入该url地址的页面并显示。 | |||||
.go(appHomeUrl); //WebView载入该url地址的页面并显示。 | |||||
/* 上边url是各个APP项目的入口地址 | /* 上边url是各个APP项目的入口地址 | ||||
事项审批 http://116.255.223.226:82/yinnongLogin 图标 ic_launcher_sxsp 或者 ic_launcher_yhzl | 事项审批 http://116.255.223.226:82/yinnongLogin 图标 ic_launcher_sxsp 或者 ic_launcher_yhzl | ||||
@@ -20,4 +20,12 @@ android.useAndroidX=true | |||||
storeFile=../app-keystore.jks | storeFile=../app-keystore.jks | ||||
storePassword=ns61GK32x% | storePassword=ns61GK32x% | ||||
keyAlias=nsgk_rural_web | keyAlias=nsgk_rural_web | ||||
keyPassword=ns61GK32x% | |||||
keyPassword=ns61GK32x% | |||||
# Command line arguments | |||||
# ["String"] App home url | |||||
appHomeUrl=http://218.59.175.43:71/yinnongLogin | |||||
# ["String"] App custom name, it will be set on res/values/strings.xml with key app_custom_name | |||||
appName=@string/app_name | |||||
# [String] App icon mipmap key name in res/mipmaps, icon = ic_launcher_${appIconKey}, round icon = ic_launcher_${appIconKey}_round | |||||
appIconKey=yhzl |
@@ -2,7 +2,26 @@ | |||||
echo 构建apk(正式) | echo 构建apk(正式) | ||||
echo 用法: %0 App主页链接地址 App名称 App图标 | |||||
echo 任意参数不传则使用App项目里gradle.properties的默认配置 | |||||
set NUM_ARG=0 | |||||
for %%x in (%*) do ( | |||||
set /a NUM_ARG+=1 | |||||
) | |||||
echo %NUM_ARG% | |||||
if %NUM_ARG% GEQ 3 ( | |||||
call gradlew assembleRelease -PappHomeUrl="%1" -PappName="%2" -PappIconKey="%3" | |||||
) else if %NUM_ARG% GEQ 2 ( | |||||
call gradlew assembleRelease -PappHomeUrl="%1" -PappName="%2" | |||||
) else if %NUM_ARG% GEQ 1 ( | |||||
call gradlew assembleRelease -PappHomeUrl="%1" | |||||
) else ( | |||||
call gradlew assembleRelease | call gradlew assembleRelease | ||||
) | |||||
echo 打开app-release.apk所在目录...... | echo 打开app-release.apk所在目录...... | ||||
start "" app\build\outputs\apk\release | start "" app\build\outputs\apk\release | ||||