Browse Source

1.修改多渠道打包无法通过intent跳转问题
2.增加video标签默认图

FailedToRead 3 years ago
parent
commit
932a486dc0

+ 37 - 5
app/build.gradle

@@ -1,5 +1,9 @@
 apply plugin: 'com.android.application'
 
+def releaseTime() {
+    return new Date().format("yyyyMMdd", TimeZone.getTimeZone("UTC"))
+}
+
 android {
     compileSdkVersion 30
     buildToolsVersion "30.0.1"
@@ -23,13 +27,37 @@ android {
             storePassword "edufound123"
         }
     }
-    123123123
     buildTypes {
         release {
             minifyEnabled false
             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
             signingConfig signingConfigs.efunbox
             zipAlignEnabled true
+            applicationVariants.all { variant ->
+                variant.outputs.each { output ->
+                    def outputFile = output.outputFileName
+                    if (outputFile != null && output.outputFileName.endsWith('.apk')) {
+                        def channel = variant.productFlavors[0].manifestPlaceholders.APP_SCHEME_HOST;
+                        def newoutputFile = "";
+                        def apptype = "";
+                        if (channel.contains("yuwen.prepare")) {
+                            newoutputFile = "\\语文预习\\"
+                            apptype = "yuwen_prepare";
+                        } else if (channel.contains("yuwen.review")) {
+                            newoutputFile = "\\语文复习\\"
+                            apptype = "yuwen_review";
+                        } else if (channel.contains("mathematics.prepare")) {
+                            newoutputFile = "\\数学预习\\"
+                            apptype = "mathematics_prepare";
+                        } else if (channel.contains("mathematics.review")) {
+                            newoutputFile = "\\数学复习\\"
+                            apptype = "mathematics_review";
+                        }
+                        def fileName = "efunbox_bytedance_v${defaultConfig.versionCode}_${releaseTime()}_${apptype}_r.apk"
+                        output.outputFileName = new File(newoutputFile, fileName)
+                    }
+                }
+            }
         }
     }
     sourceSets {
@@ -40,7 +68,8 @@ android {
     productFlavors {
         // 语文预习
         yuwen_prepare {
-            applicationId 'com.edufound.bytedance.yuwen.prepare'
+            signingConfig signingConfigs.efunbox
+            applicationIdSuffix ".yuwen.prepare"
             manifestPlaceholders = [schemeHost: "com.edufound.bytedance.yuwen.prepare",
                                     appName   : "语文预习"
             ]
@@ -48,14 +77,16 @@ android {
 
         // 语文复习
         yuwen_review {
-            applicationId 'com.edufound.bytedance.yuwen.review'
+            signingConfig signingConfigs.efunbox
+            applicationIdSuffix ".yuwen.review"
             manifestPlaceholders = [schemeHost: "com.edufound.bytedance.yuwen.review",
                                     appName   : "语文复习"
             ]
         }
         // 数学预习
         mathematics_prepare {
-            applicationId 'com.edufound.bytedance.mathematics.prepare'
+            signingConfig signingConfigs.efunbox
+            applicationIdSuffix ".mathematics.prepare"
             manifestPlaceholders = [schemeHost: "com.edufound.bytedance.mathematics.prepare",
                                     appName   : "数学预习"
             ]
@@ -63,7 +94,8 @@ android {
 
         // 数学复习
         mathematics_review {
-            applicationId 'com.edufound.bytedance.mathematics.review'
+            signingConfig signingConfigs.efunbox
+            applicationIdSuffix ".mathematics.review"
             manifestPlaceholders = [schemeHost: "com.edufound.bytedance.mathematics.review",
                                     appName   : "数学复习"
             ]

+ 5 - 0
app/src/main/java/com/edufound/bytedance/activity/MainActivity.java

@@ -85,6 +85,11 @@ public class MainActivity extends BaseActivity<MainModel, MainView, MainPersente
     }
 
     @Override
+    public boolean onKeyUp(int keyCode, KeyEvent event) {
+        return mPresenter.onKeyUp(keyCode, event);
+    }
+
+    @Override
     public MainView createView() {
         return this;
     }

+ 40 - 18
app/src/main/java/com/edufound/bytedance/mvp/presenter/MainPersenter.java

@@ -4,6 +4,7 @@ import android.app.AlertDialog;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
 import android.graphics.Color;
 import android.net.Uri;
 import android.os.Build;
@@ -18,6 +19,7 @@ import android.webkit.WebSettings;
 import android.webkit.WebView;
 import android.webkit.WebViewClient;
 
+import com.edufound.bytedance.R;
 import com.edufound.bytedance.application.MyApplication;
 import com.edufound.bytedance.base.BasePresenter;
 import com.edufound.bytedance.mvp.model.MainModel;
@@ -28,12 +30,18 @@ import com.edufound.bytedance.util.OkHttpUtil;
 import com.edufound.bytedance.util.SharedPerfenceUtil;
 import com.edufound.bytedance.util.ToastUtil;
 
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Iterator;
+
 import okhttp3.Request;
 
 public class MainPersenter extends BasePresenter<MainModel, MainView> {
 
     private String mLoadUrl;
     private MainJsMethod mMainJsMethod;
+    private Bitmap mVideoBitmap;
 
     public void initWeb() {
         if (Build.VERSION.SDK_INT >= 19) {
@@ -54,8 +62,8 @@ public class MainPersenter extends BasePresenter<MainModel, MainView> {
         getView().getWebView().getSettings().setUseWideViewPort(true);
         getView().getWebView().getSettings().setLoadWithOverviewMode(true);
         getView().getWebView().getSettings().setTextZoom(100);
-//        mVideoBitmap = BitmapFactory.decodeResource(mView.getActivity().getResources(),
-//                R.drawable.videoposterblack);
+        mVideoBitmap = BitmapFactory.decodeResource(getView().getActivity().getResources(),
+                R.drawable.videoposterblack);
         getView().getWebView().setWebChromeClient(new WebChromeClient() {
 
             @Override
@@ -80,8 +88,7 @@ public class MainPersenter extends BasePresenter<MainModel, MainView> {
 
             @Override
             public Bitmap getDefaultVideoPoster() {
-//                return mVideoBitmap;
-                return null;
+                return mVideoBitmap;
             }
         });
 
@@ -133,21 +140,36 @@ public class MainPersenter extends BasePresenter<MainModel, MainView> {
 
 
     public void openWeb(Intent intent) {
-        getView().getWebView().loadUrl("");
-        mLoadUrl = model.getDefaultWebUrl();
-        Uri uri = intent.getData();
-        String intent_url = "";
-        if (uri != null) {
-            intent_url = uri.getQueryParameter("url");
-        } else {
-            intent_url = intent.getStringExtra("url");
-        }
-        if (intent_url != null && !intent_url.isEmpty()) {
-            mLoadUrl = intent_url;
+        try {
+            getView().getWebView().loadUrl("");
+            mLoadUrl = model.getDefaultWebUrl();
+            Uri uri = intent.getData();
+            String intent_url = "";
+            if (uri != null) {
+                intent_url = uri.getQueryParameter("url");
+            } else {
+                intent_url = intent.getStringExtra("url");
+            }
+            if (intent_url != null && !intent_url.isEmpty()) {
+                mLoadUrl = intent_url;
+            }
+            StringBuffer buffer = new StringBuffer();
+            String intent_params = intent.getStringExtra("params");
+            if (intent_params != null && !intent_params.isEmpty()) {
+                JSONObject jsonObject = null;
+                jsonObject = new JSONObject(intent_params);
+                Iterator it = jsonObject.keys();
+                while (it.hasNext()) {
+                    String key = it.next().toString();
+                    buffer.append("&" + key + "=" + jsonObject.getString(key));
+                }
+            }
+            mLoadUrl = mLoadUrl + model.getLoadParams(getView().getActivity()) + buffer.toString();
+            Logger.e("mLoadUrl:" + mLoadUrl);
+            getView().getWebView().loadUrl(mLoadUrl);
+        } catch (JSONException e) {
+            e.printStackTrace();
         }
-        mLoadUrl = mLoadUrl + model.getLoadParams(getView().getActivity());
-        Logger.e("mLoadUrl:" + mLoadUrl);
-        getView().getWebView().loadUrl(mLoadUrl);
     }
 
 

+ 1 - 1
app/src/main/java/com/edufound/bytedance/util/Logger.java

@@ -4,7 +4,7 @@ import android.util.Log;
 
 public class Logger {
 
-    static String TAG = "com.edufound.ott.zijie.yuwen";
+    static String TAG = ContextUtil.getmApplicationContext().getPackageName();
 
     public static void e(String message) {
         Log.e(TAG, message);

BIN
app/src/main/res/drawable/videoposterblack.jpg