Browse Source

1.增加多渠道打包更改包名、跳转host已经app名称

FailedToRead 3 years ago
parent
commit
74375edc29

+ 22 - 8
app/build.gradle

@@ -10,8 +10,10 @@ android {
         targetSdkVersion 30
         versionCode 1
         versionName "1.0"
+        multiDexEnabled true
         flavorDimensions "versionCode"
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+        manifestPlaceholders = [APP_SCHEME_HOST: "com.edufound.bytedance.yuwen.prepare"]
     }
     signingConfigs {
         efunbox {
@@ -21,7 +23,7 @@ android {
             storePassword "edufound123"
         }
     }
-
+    123123123
     buildTypes {
         release {
             minifyEnabled false
@@ -39,29 +41,41 @@ android {
         // 语文预习
         yuwen_prepare {
             applicationId 'com.edufound.bytedance.yuwen.prepare'
-//            manifestPlaceholders = [app_name: "app", app_icon: "@mipmap/ic_launcher"]
+            manifestPlaceholders = [schemeHost: "com.edufound.bytedance.yuwen.prepare",
+                                    appName   : "语文预习"
+            ]
         }
 
         // 语文复习
         yuwen_review {
             applicationId 'com.edufound.bytedance.yuwen.review'
-//            manifestPlaceholders = [app_name: "app1", app_icon: "@mipmap/ic_launcher"]
+            manifestPlaceholders = [schemeHost: "com.edufound.bytedance.yuwen.review",
+                                    appName   : "语文复习"
+            ]
         }
         // 数学预习
         mathematics_prepare {
             applicationId 'com.edufound.bytedance.mathematics.prepare'
-//            manifestPlaceholders = [app_name: "app", app_icon: "@mipmap/ic_launcher"]
+            manifestPlaceholders = [schemeHost: "com.edufound.bytedance.mathematics.prepare",
+                                    appName   : "数学预习"
+            ]
         }
 
         // 数学复习
         mathematics_review {
             applicationId 'com.edufound.bytedance.mathematics.review'
-//            manifestPlaceholders = [app_name: "app1", app_icon: "@mipmap/ic_launcher"]
+            manifestPlaceholders = [schemeHost: "com.edufound.bytedance.mathematics.review",
+                                    appName   : "数学复习"
+            ]
         }
     }
-//    productFlavors.all {
-//        flavor -> flavor.manifestPlaceholders = []
-//    }
+    productFlavors.all {
+        flavor ->
+            flavor.manifestPlaceholders = [
+                    APP_SCHEME_HOST: manifestPlaceholders.schemeHost,
+                    APP_NAME       : manifestPlaceholders.appName
+            ]
+    }
 }
 
 repositories {

+ 2 - 2
app/src/main/AndroidManifest.xml

@@ -19,7 +19,7 @@
         android:name="com.edufound.bytedance.application.MyApplication"
         android:allowBackup="true"
         android:icon="@mipmap/ic_launcher"
-        android:label="@string/app_name"
+        android:label="${APP_NAME}"
         android:networkSecurityConfig="@xml/network_security_config"
         android:roundIcon="@mipmap/ic_launcher_round"
         android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
@@ -44,7 +44,7 @@
                 <category android:name="android.intent.category.BROWSABLE" />
 
                 <data
-                    android:host="com.edufound.ott.zijie.yuwen"
+                    android:host="${APP_SCHEME_HOST}"
                     android:path="/main"
                     android:scheme="efunbox" />
             </intent-filter>

+ 26 - 2
app/src/main/java/com/edufound/bytedance/mvp/model/MainModel.java

@@ -11,7 +11,10 @@ import com.edufound.bytedance.util.SharedPerfenceUtil;
 
 public class MainModel implements MainModelInter {
     //    private String LOAD_URL = "http://reader-test.efunbox.cn/build/stage/index/index.html?wareId=1604565055981663";
-    private String LOAD_URL = "https://www.baidu.com";
+    private String LOAD_URL_YUWEN_PREPARE = "http://zijie-web.ai160.com/stage/index/index.html";
+    private String LOAD_URL_YUWEN_REVIEW = "http://zijie-web.ai160.com/stage/review/review.html";
+    private String LOAD_URL_MATHEMATICS_PREPARE = "https://www.baidu.com";
+    private String LOAD_URL_MATHEMATICS_REVIEW = "https://www.baidu.com";
     private DeviceUtil deviceUtil;
 
     public MainModel() {
@@ -20,7 +23,28 @@ public class MainModel implements MainModelInter {
 
     @Override
     public String getDefaultWebUrl() {
-        return LOAD_URL;
+        String url = "";
+        try {
+            int app_code = Integer.valueOf(MyApplication.getAppCode());
+            switch (app_code) {
+                case 4001:
+                    url = LOAD_URL_YUWEN_PREPARE;
+                    break;
+                case 4002:
+                    url = LOAD_URL_YUWEN_REVIEW;
+                    break;
+                case 4003:
+                    url = LOAD_URL_MATHEMATICS_PREPARE;
+                    break;
+                case 4004:
+                    url = LOAD_URL_MATHEMATICS_REVIEW;
+                    break;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return "";
+        }
+        return url + "?";
     }
 
     @Override