Commit 72748b4f by sikang

UPDATE

parent 45b1bc40
...@@ -35,7 +35,7 @@ import static com.facebook.accountkit.internal.AccountKitController.getApplicati ...@@ -35,7 +35,7 @@ import static com.facebook.accountkit.internal.AccountKitController.getApplicati
public class LibConfig { public class LibConfig {
/** /**
* 存储 App Module的 BuildConfig 数据 * BuildConfig 数据
*/ */
private static Context CONTEXT; private static Context CONTEXT;
public static boolean DEBUG; public static boolean DEBUG;
......
package tech.starwin.broadcast;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import tech.starwin.utils.PreferencesManager;
import tech.starwin.utils.collection.UploadManager;
/**
* 监听并保存安装referrer
* 测试方法:
* 1 进到adb shell
* 2 打开GAv4的log:setprop log.tag.GAv4 VERBOSE
* 3 发送广播通知:
* am broadcast -a com.android.vending.INSTALL_REFERRER -n com.mango.cash/com.daunkredit.program
* .sulu.broadcast.InstallReferrerReceiver --es "referrer"
* "utm_source=testSource&utm_medium=testMedium&utm_term=testTerm&utm_content=11&PARTNER_ID=111
* &PARTNER_CLICK_ID=222"
*/
public class InstallReferrerReceiver extends BroadcastReceiver {
public static String install_referrer_store_key = "GA_install_referrer_store_key";
public void onReceive(Context context, Intent data) {
PreferencesManager.get().saveInstallReferrer(getReferrerValue(data.getExtras()));
}
private String getReferrerValue(Bundle bundle) {
String referrerValue = "";
try {
if (bundle != null) {
referrerValue = bundle.getString("referrer");
}
if (referrerValue == null) {
referrerValue = "";
}
if (TextUtils.isEmpty(referrerValue)) {
} else {
}
} catch (Exception e) {
UploadManager.uploadException(e, "InstallReferrerReceiver.getReferrerValue");
}
try {
referrerValue = URLDecoder.decode(referrerValue, "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Log.i("InstallReferrerReceiver", "referrer " + referrerValue);
return referrerValue;
}
}
...@@ -8,6 +8,7 @@ import java.io.Serializable; ...@@ -8,6 +8,7 @@ import java.io.Serializable;
public class DisplayBean implements Serializable { public class DisplayBean implements Serializable {
private String description; private String description;
private String customerMobile; private String customerMobile;
private String loginType;
public String getDescription() { public String getDescription() {
return description; return description;
...@@ -24,4 +25,12 @@ public class DisplayBean implements Serializable { ...@@ -24,4 +25,12 @@ public class DisplayBean implements Serializable {
public void setCustomerMobile(String customerMobile) { public void setCustomerMobile(String customerMobile) {
this.customerMobile = customerMobile; this.customerMobile = customerMobile;
} }
public String getLoginType() {
return loginType;
}
public void setLoginType(String loginType) {
this.loginType = loginType;
}
} }
...@@ -358,16 +358,9 @@ public class UserPresenter extends BasePresenter<UserApi> { ...@@ -358,16 +358,9 @@ public class UserPresenter extends BasePresenter<UserApi> {
} }
/** /**
* 获取客户热线电话 * 获取客户自定义配置
*/ */
public void getHotlineNumber(String action) { public void getCustomerConfig(String action) {
handleRequest(action, apiService.display());
}
/**
* 获取公司介绍
*/
public void getAboutUsMsg(String action) {
handleRequest(action, apiService.display()); handleRequest(action, apiService.display());
} }
......
package tech.starwin.network;
import java.io.IOException;
import okhttp3.Headers;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import tech.starwin.LibConfig;
import tech.starwin.utils.GeneralUtils;
import tech.starwin.utils.LoginManager;
import tech.starwin.utils.PreferencesManager;
import tech.starwin.utils.collection.UploadManager;
/**
* Created by XLEO on 2018/1/30.
*/
public class FirebaseHeaderInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request newRequest = chain.request();
try {
if (newRequest != null) {
Request.Builder builder = chain.request().newBuilder();
builder.addHeader("X-REFERRER", PreferencesManager.get().getInstallReferrer())
// .addHeader("X-REFERRER-SDK", FirebaseAnalytics.getInstance(LibConfig.getContext()).)
.addHeader("X-ANDROID-ID", GeneralUtils.getAndroidID(LibConfig.getContext()));
//登录后的上传
if (!existHeader(newRequest.headers(), "X-AUTH-TOKEN") &&
LoginManager.get().getToken() != null) {
builder.addHeader("X-AUTH-TOKEN", LoginManager.get().getToken());
}
newRequest = builder.build();
}
} catch (Exception e) {
e.printStackTrace();
UploadManager.uploadException(e, "FirebaseHeaderInterceptor.intercept");
}
return chain.proceed(newRequest);
}
private static boolean existHeader(Headers headers, String header) {
if (headers == null || headers.names() == null || header == null || headers.size() == 0 || header.length() == 0) {
return false;
}
return headers.names().contains(header);
}
private static String install_referrer_uploaded_key = "install_referrer_uploaded_key";
private static String install_referrer_uploaded_with_token_key = "install_referrer_uploaded_with_token_key";
}
...@@ -30,6 +30,7 @@ public class ServiceGenerator { ...@@ -30,6 +30,7 @@ public class ServiceGenerator {
.writeTimeout(TIME_OUT, TimeUnit.SECONDS) .writeTimeout(TIME_OUT, TimeUnit.SECONDS)
.readTimeout(TIME_OUT, TimeUnit.SECONDS) .readTimeout(TIME_OUT, TimeUnit.SECONDS)
.addInterceptor(new DefaultHeaderAddInterceptor()) .addInterceptor(new DefaultHeaderAddInterceptor())
.addInterceptor(new FirebaseHeaderInterceptor())
.build(); .build();
serviceMap = new HashMap<>(); serviceMap = new HashMap<>();
......
...@@ -100,6 +100,9 @@ public class PreferencesManager { ...@@ -100,6 +100,9 @@ public class PreferencesManager {
} }
/**
* 手机默认短信应用的包名
*/
public void saveDefaultSmsPackage(String pkgName) { public void saveDefaultSmsPackage(String pkgName) {
saveData("default_sms_pkg", pkgName); saveData("default_sms_pkg", pkgName);
} }
...@@ -109,6 +112,17 @@ public class PreferencesManager { ...@@ -109,6 +112,17 @@ public class PreferencesManager {
} }
/** /**
* 存取 install referrer
*/
public void saveInstallReferrer(String referrer) {
saveData("install_referrer", referrer);
}
public String getInstallReferrer() {
return getString("install_referrer", "");
}
/**
* 存取活体识别截图 * 存取活体识别截图
*/ */
public void saveVerificationData(byte[] data) { public void saveVerificationData(byte[] data) {
......
...@@ -4,9 +4,10 @@ import android.Manifest; ...@@ -4,9 +4,10 @@ import android.Manifest;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Base64;
import com.annimon.stream.Stream; import com.annimon.stream.Stream;
import com.annimon.stream.function.BiFunction;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
...@@ -25,9 +26,7 @@ import java.util.List; ...@@ -25,9 +26,7 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import io.reactivex.Observable; import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Function; import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
import tech.starwin.LibConfig; import tech.starwin.LibConfig;
...@@ -39,7 +38,6 @@ import tech.starwin.utils.GeneralUtils; ...@@ -39,7 +38,6 @@ import tech.starwin.utils.GeneralUtils;
import tech.starwin.utils.LogUtils; import tech.starwin.utils.LogUtils;
import tech.starwin.utils.LoginManager; import tech.starwin.utils.LoginManager;
import tech.starwin.utils.PreferencesManager; import tech.starwin.utils.PreferencesManager;
import tech.starwin.utils.RetryWithDelay;
import tech.starwin.utils.context_utils.PermissionsHelper; import tech.starwin.utils.context_utils.PermissionsHelper;
/** /**
...@@ -56,7 +54,7 @@ public class UploadManager { ...@@ -56,7 +54,7 @@ public class UploadManager {
} }
/** /**
* 上传贷款相关数据 * 申请贷款时需要上传的数据(联系人、通话记录、短信记录 等)
*/ */
public static void uploadCollectInfo(String sessionId) { public static void uploadCollectInfo(String sessionId) {
if (TextUtils.isEmpty(sessionId)) { if (TextUtils.isEmpty(sessionId)) {
...@@ -87,7 +85,7 @@ public class UploadManager { ...@@ -87,7 +85,7 @@ public class UploadManager {
/** /**
* 上传搜集的用户数据(联系人、通话记录、短信记录 等) * 开始上传
*/ */
public static void startUpload(List<CollectInfoEntity> infoList, String sessionId) throws RuntimeException { public static void startUpload(List<CollectInfoEntity> infoList, String sessionId) throws RuntimeException {
Socket socket = null; Socket socket = null;
...@@ -100,11 +98,24 @@ public class UploadManager { ...@@ -100,11 +98,24 @@ public class UploadManager {
ins = socket.getInputStream(); ins = socket.getInputStream();
List<String> datas = Stream.of(infoList) List<String> datas = Stream.of(infoList)
.map(t -> GZipUtil.compress(t.getBody(), "utf-8")) .map(new com.annimon.stream.function.Function<CollectInfoEntity, byte[]>() {
.map(t -> android.util.Base64.encodeToString(t, 0)) @Override
.reduce(new ArrayList<>(), (array, t) -> { public byte[] apply(CollectInfoEntity collectInfoEntity) {
array.add(t); return GZipUtil.compress(collectInfoEntity.getBody(), "utf-8");
return array; }
})
.map(new com.annimon.stream.function.Function<byte[], String>() {
@Override
public String apply(byte[] bytes) {
return Base64.encodeToString(bytes, 0);
}
})
.reduce(new ArrayList<>(), new BiFunction<ArrayList<String>, String, ArrayList<String>>() {
@Override
public ArrayList<String> apply(ArrayList<String> array, String value) {
array.add(value);
return array;
}
}); });
...@@ -253,14 +264,9 @@ public class UploadManager { ...@@ -253,14 +264,9 @@ public class UploadManager {
return array; return array;
} }
/**
public interface OnUploadListener { * 上传异常信息
void onSuccess(String sessionId); * */
void onFailed(String sessionId, Throwable e);
}
public static void uploadException(Throwable ex, @NonNull String tag) { public static void uploadException(Throwable ex, @NonNull String tag) {
Observable.just(true) Observable.just(true)
......
package tech.starwin.utils; package tech.starwin.utils.ui_utils;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
...@@ -68,11 +68,11 @@ public class AnimatorGenerator { ...@@ -68,11 +68,11 @@ public class AnimatorGenerator {
closeAnimator.addUpdateListener(listener); closeAnimator.addUpdateListener(listener);
} }
public void open() { public void start() {
openAnimator.start(); openAnimator.start();
} }
public void close() { public void revert() {
closeAnimator.start(); closeAnimator.start();
} }
......
...@@ -10,14 +10,11 @@ import android.support.annotation.DrawableRes; ...@@ -10,14 +10,11 @@ import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.qmuiteam.qmui.widget.QMUIEmptyView; import com.qmuiteam.qmui.widget.QMUIEmptyView;
import com.qmuiteam.qmui.widget.QMUITabSegment; import com.qmuiteam.qmui.widget.QMUITabSegment;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView; import com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView;
import com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView; import com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView;
...@@ -57,7 +54,7 @@ public class QMUIHelper { ...@@ -57,7 +54,7 @@ public class QMUIHelper {
emptyView.setBackgroundColor(Color.WHITE); emptyView.setBackgroundColor(Color.WHITE);
//给targetView 套壳 //给targetView 套壳
final PageStateLayout pageStateLayout = new PageStateLayout.Builder(targetView) final PageStateLayout pageStateLayout = new PageStateLayout.Builder(targetView)
.setCustomView(emptyView) .setStateView(emptyView)
.setOnRetryListener(listener) .setOnRetryListener(listener)
.create(); .create();
//不同状态的UI处理 //不同状态的UI处理
......
...@@ -21,7 +21,7 @@ import java.util.Map; ...@@ -21,7 +21,7 @@ import java.util.Map;
/** /**
* Created by SiKang on 2018/10/12. * Created by SiKang on 2018/10/12.
* 页面状态展示 loading、错误、无数据、重新请求 等 * 页面状态展示 loading、错误、无数据、重新请求 等
* 通过 setCustomView() 指定一个View,在view和父布局之间,嵌套一层FrameLayout,并加入自定义的展示界面 * 通过 setStateView() 指定一个View,在view和父布局之间,嵌套一层FrameLayout,并加入自定义的展示界面
*/ */
public class PageStateLayout extends FrameLayout { public class PageStateLayout extends FrameLayout {
private View mStateView; private View mStateView;
...@@ -41,7 +41,7 @@ public class PageStateLayout extends FrameLayout { ...@@ -41,7 +41,7 @@ public class PageStateLayout extends FrameLayout {
super(context, attrs, defStyleAttr); super(context, attrs, defStyleAttr);
} }
private void setCustomView(@NonNull View view) { private void setStateView(@NonNull View view) {
mStateView = view; mStateView = view;
viewHolder = new ViewHolder(view); viewHolder = new ViewHolder(view);
addView(mStateView); addView(mStateView);
...@@ -111,8 +111,8 @@ public class PageStateLayout extends FrameLayout { ...@@ -111,8 +111,8 @@ public class PageStateLayout extends FrameLayout {
pageStateLayout.addView(view); pageStateLayout.addView(view);
} }
public Builder setCustomView(@NonNull View view) { public Builder setStateView(@NonNull View view) {
pageStateLayout.setCustomView(view); pageStateLayout.setStateView(view);
return this; return this;
} }
......
...@@ -12,7 +12,8 @@ import android.widget.TextView; ...@@ -12,7 +12,8 @@ import android.widget.TextView;
/** /**
* Created by SiKang on 2018/10/24. * Created by SiKang on 2018/10/24.
* 行按钮 * 行按钮,用于 文字 + 图标 的itemList型布局(避免Layout 和 child 分开处理的复杂操作)
* 提供 setText() 和 setOnclick(),默认将第一个TextView类型的 child 作为 setText() 对象
*/ */
public class SpanButton extends LinearLayout { public class SpanButton extends LinearLayout {
private TextWatcher watcher; private TextWatcher watcher;
...@@ -51,6 +52,9 @@ public class SpanButton extends LinearLayout { ...@@ -51,6 +52,9 @@ public class SpanButton extends LinearLayout {
bindTextWatcher(child); bindTextWatcher(child);
} }
/**
* 为第一个为TextView类型的child setText
*/
public void setText(String text) { public void setText(String text) {
if (!TextUtils.isEmpty(text)) { if (!TextUtils.isEmpty(text)) {
for (int i = 0; i < getChildCount(); i++) { for (int i = 0; i < getChildCount(); i++) {
......
...@@ -15,7 +15,7 @@ import android.widget.TextView; ...@@ -15,7 +15,7 @@ import android.widget.TextView;
* Created by SiKang on 2018/10/25. * Created by SiKang on 2018/10/25.
* 标题 + 文本 布局 * 标题 + 文本 布局
* 第一个Child 默认为Title * 第一个Child 默认为Title
* 当EditText/TextView中有内容输入时,显示Title, 反之隐藏(无输入内容时直接用hintText展示 * 当EditText/TextView中有内容输入时,显示Title, 反之隐藏Title显示 hintText
*/ */
public class TitleSpan extends LinearLayout { public class TitleSpan extends LinearLayout {
public TitleSpan(Context context) { public TitleSpan(Context context) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment