Procházet zdrojové kódy

Merge branch 'sheep_develop' of 10.8.230.114:xmy_android/small_sheep_android into sheep_develop

hanjing před 7 roky
rodič
revize
4cef926c96

+ 4 - 1
app/src/main/java/com/sheep/gamegroup/absBase/BaseActivity.java

@@ -97,7 +97,7 @@ public abstract class BaseActivity extends RxAppCompatActivity implements BackHa
 
         ActionBar actionBar = getSupportActionBar();
         if (actionBar != null) {
-            actionBar.setCustomView(R.layout.title);
+            actionBar.setCustomView(getTitleLayoutId());
             actionBar.hide();
             actionBar.setDisplayShowCustomEnabled(true);
             actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
@@ -114,6 +114,9 @@ public abstract class BaseActivity extends RxAppCompatActivity implements BackHa
             EventBus.getDefault().register(this);
         initSlidr();
     }
+    protected int getTitleLayoutId(){
+        return R.layout.title;
+    }
     protected void initSlidr(){
         SlidrConfig config = new SlidrConfig.Builder()
 //                .primaryColor(getResources().getColor(R.color.primary)

+ 5 - 0
app/src/main/java/com/sheep/gamegroup/module/webview/fragment/FgtWebX5.java

@@ -94,6 +94,11 @@ public class FgtWebX5 extends BaseFgtWeb {
     public void initView() {
         ViewUtil.setImage(act_web_loading_iv, R.drawable.gif_sheep_loading);
 
+        if(webParams == null){
+            LogUtil.println("程序出错了 没有初始化webParams");
+            //程序出错了
+            return;
+        }
         String url = webParams.getUrl();
         String jsUrl = webParams.getJsUrl();
         if (!TextUtils.isEmpty(url)) {

+ 1 - 0
app/src/main/java/com/sheep/gamegroup/util/SysAppUtil.java

@@ -853,6 +853,7 @@ public class SysAppUtil {
             PendingIntent successCallback = PendingIntent.getBroadcast(context, 0, pinnedShortcutCallbackIntent, 0);
 
             ShortcutManagerCompat.requestPinShortcut(context, pinShortcutInfo, successCallback.getIntentSender());
+            G.showToast("正在尝试添加桌面快捷方式");
             return true;
         }
         return false;

+ 47 - 19
app/src/main/java/com/sheep/gamegroup/view/activity/ActWebX5.java

@@ -7,17 +7,21 @@ import android.content.Intent;
 import android.graphics.Bitmap;
 import android.net.Uri;
 import android.os.Build;
+import android.os.Bundle;
 import android.os.Environment;
 import android.provider.MediaStore;
+import android.support.annotation.Nullable;
 import android.support.annotation.RequiresApi;
 import android.support.v7.app.ActionBar;
 import android.support.v7.app.AlertDialog;
 import android.text.TextUtils;
+import android.view.LayoutInflater;
 import android.view.View;
 import android.view.animation.Animation;
 import android.view.animation.AnimationUtils;
 import android.widget.ImageView;
 import android.widget.ProgressBar;
+import android.widget.RelativeLayout;
 
 import com.sheep.gamegroup.model.entity.DialogConfig;
 import com.sheep.gamegroup.model.entity.WebParams;
@@ -58,6 +62,7 @@ import java.io.File;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.zip.Inflater;
 
 import butterknife.BindView;
 import okhttp3.Call;
@@ -79,6 +84,20 @@ public class ActWebX5 extends BaseActWeb {
     protected WebParams webParams;
 
     @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        initWebParams();
+        super.onCreate(savedInstanceState);
+    }
+
+    @Override
+    protected int getTitleLayoutId() {
+        if(checkWebParams(webParams)){
+            return R.layout.title_yf;
+        }
+        return super.getTitleLayoutId();
+    }
+
+    @Override
     protected int getLayoutId() {
         return R.layout.act_web_x5;
     }
@@ -88,13 +107,20 @@ public class ActWebX5 extends BaseActWeb {
     public void initView() {
         ViewUtil.setImage(act_web_loading_iv, R.drawable.gif_sheep_loading);
 
-        initWebParams();
         String url = webParams.getUrl();
         String jsUrl = webParams.getJsUrl();
         if (!TextUtils.isEmpty(url)) {
             url = url.trim();
         }
-        if (webParams.isShowTitle()) {
+        if(checkWebParams(webParams)){
+            TitleBarUtils
+                    .getInstance()
+                    .setShowOrHide(this, true)
+                    .setTitle(this, webParams.getTitle())
+                    .setRightSecondBtn(this, R.mipmap.tianjtb, view -> SysAppUtil.addShortcutTest(this))
+                    .setRightImgBotton(this, R.mipmap.guanb, view -> super.finish())
+                    .setTitleFinish(this);
+        } else if (webParams.isShowTitle()) {
             TitleBarUtils
                     .getInstance()
                     .setShowOrHide(this, true)
@@ -122,25 +148,27 @@ public class ActWebX5 extends BaseActWeb {
     public void initWebParams() {
         Intent intent = getIntent();
         webParams = (WebParams) intent.getSerializableExtra(WebParams.class.getSimpleName());
-        checkWebParams(webParams);
     }
 
-    //忽略 添加有范商城快捷入口
-    public static final String KEY_IGNORE_ADD_YOU_FAN_LAUNCHER = "ignore_add_you_fan_launcher";
-    private void checkWebParams(WebParams webParams) {
-        if(webParams.getUrl().startsWith(Config.YF_SHOP_HOME_SHEEP.split("\\?")[0]) || webParams.getUrl().startsWith(Config.YF_SHOP_HOME_SHEEP_TEST.split("\\?")[0])) {//检测是否是有范商城地址
-            boolean isIgnore = SpUtils.getAsBoolean(KEY_IGNORE_ADD_YOU_FAN_LAUNCHER, false);
-            boolean hasShortcut = SysAppUtil.hasShortcut(SheepApp.getInstance(), Config.YF_SHOP_NAME);
-            boolean isShow = !hasShortcut && !isIgnore && !CommonUtil.getInstance().hasYouFanLauncher();//未忽略并且没有添加有范商品入口
-//            boolean isShow = !isIgnore && !SysAppUtil.isEnableComponentYf();
-            if (isShow) {
-                ViewUtil.showMsgDialog(this, new DialogConfig().setTitle("温馨提示")
-                        .setMsg("亲,喜欢的话,就添加一个商城的桌面快捷入口吧!(点击否将不再提示)")
-                        .setBtnLeftText("否").setBtnLeftOnClickListener(view -> SpUtils.putAsBoolean(KEY_IGNORE_ADD_YOU_FAN_LAUNCHER, true))
-                        .setBtnRightText("是").setBtnRightOnClickListener(view -> CommonUtil.getInstance().addYouFanLauncher()));
-//                        .setBtnRightText("是").setBtnRightOnClickListener(view -> SysAppUtil.enableComponentYf()));
-            }
-        }
+//    //忽略 添加有范商城快捷入口
+//    public static final String KEY_IGNORE_ADD_YOU_FAN_LAUNCHER = "ignore_add_you_fan_launcher";
+//    private void checkWebParams(WebParams webParams) {
+//        if(webParams.getUrl().startsWith(Config.YF_SHOP_HOME_SHEEP.split("\\?")[0]) || webParams.getUrl().startsWith(Config.YF_SHOP_HOME_SHEEP_TEST.split("\\?")[0])) {//检测是否是有范商城地址
+//            boolean isIgnore = SpUtils.getAsBoolean(KEY_IGNORE_ADD_YOU_FAN_LAUNCHER, false);
+//            boolean hasShortcut = SysAppUtil.hasShortcut(SheepApp.getInstance(), Config.YF_SHOP_NAME);
+//            boolean isShow = !hasShortcut && !isIgnore && !CommonUtil.getInstance().hasYouFanLauncher();//未忽略并且没有添加有范商品入口
+////            boolean isShow = !isIgnore && !SysAppUtil.isEnableComponentYf();
+//            if (isShow) {
+//                ViewUtil.showMsgDialog(this, new DialogConfig().setTitle("温馨提示")
+//                        .setMsg("亲,喜欢的话,就添加一个商城的桌面快捷入口吧!(点击否将不再提示)")
+//                        .setBtnLeftText("否").setBtnLeftOnClickListener(view -> SpUtils.putAsBoolean(KEY_IGNORE_ADD_YOU_FAN_LAUNCHER, true))
+//                        .setBtnRightText("是").setBtnRightOnClickListener(view -> CommonUtil.getInstance().addYouFanLauncher()));
+////                        .setBtnRightText("是").setBtnRightOnClickListener(view -> SysAppUtil.enableComponentYf()));
+//            }
+//        }
+//    }
+    private boolean checkWebParams(WebParams webParams) {
+        return webParams.getUrl().startsWith(Config.YF_SHOP_HOME_SHEEP.split("\\?")[0]) || webParams.getUrl().startsWith(Config.YF_SHOP_HOME_SHEEP_TEST.split("\\?")[0]);//检测是否是有范商城地址
     }
 
     //初始化js代码数据

binární
app/src/main/res/drawable-xxhdpi/waik.png


+ 72 - 0
app/src/main/res/layout/title_yf.xml

@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/layout_navigationBar"
+    android:layout_width="match_parent"
+    android:layout_height="?attr/actionBarSize"
+    android:background="@color/white">
+
+    <ImageView
+        android:id="@+id/img_baseactivity_title"
+        android:layout_width="wrap_content"
+        android:layout_height="match_parent"
+        android:layout_centerVertical="true"
+        android:gravity="center_vertical"
+        android:minWidth="?attr/actionBarSize"
+        android:scaleType="centerInside"
+        android:src="@drawable/narrow_back_black" />
+
+    <TextView
+        android:id="@+id/txt_baseactivity_title"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_centerVertical="true"
+        android:layout_marginStart="?attr/actionBarSize"
+        android:layout_marginEnd="100dp"
+        android:ellipsize="end"
+        android:gravity="start"
+        android:singleLine="true"
+        android:text="@string/app_name"
+        android:textColor="@color/black_text_deep"
+        android:textSize="18sp" />
+
+    <LinearLayout
+        android:layout_width="76dp"
+        android:layout_height="30dp"
+        android:layout_alignParentEnd="true"
+        android:layout_centerVertical="true"
+        android:gravity="center_vertical"
+        android:layout_marginEnd="15dp"
+        android:background="@drawable/waik"
+        android:orientation="horizontal">
+
+        <ImageButton
+            android:id="@+id/ibtn_two_right"
+            android:layout_width="30dp"
+            android:layout_height="match_parent"
+            android:layout_marginStart="8dp"
+            android:background="@color/translate"
+            android:padding="5dp"
+            android:src="@mipmap/tianjtb" />
+
+        <ImageView
+            android:layout_width="1dp"
+            android:layout_height="16dp"
+            android:layout_marginStart="3dp"
+            android:src="@mipmap/shux" />
+
+        <ImageButton
+            android:id="@+id/ibtn_baseactivity_right"
+            android:layout_width="30dp"
+            android:background="@color/translate"
+            android:layout_height="match_parent"
+            android:layout_marginStart="1dp"
+            android:padding="10dp"
+            android:src="@mipmap/guanb" />
+    </LinearLayout>
+
+    <include
+        layout="@layout/title_bottom_line"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true" />
+</RelativeLayout>

binární
app/src/main/res/mipmap-xxhdpi/guanb.png


binární
app/src/main/res/mipmap-xxhdpi/shux.png


binární
app/src/main/res/mipmap-xxhdpi/tianjtb.png