Commit 811afb2a authored by mengcuiguang's avatar mengcuiguang

添加一键登录

parent d90937f3
...@@ -11,8 +11,8 @@ android { ...@@ -11,8 +11,8 @@ android {
applicationId "com.mints.highgold" applicationId "com.mints.highgold"
minSdkVersion rootProject.ext.androidMinSdkVersion minSdkVersion rootProject.ext.androidMinSdkVersion
targetSdkVersion rootProject.ext.androidTargetSdkVersion targetSdkVersion rootProject.ext.androidTargetSdkVersion
versionCode 15 versionCode 16
versionName "1.1.4" versionName "1.1.5"
flavorDimensions "default" flavorDimensions "default"
// dex突破65535的限制 // dex突破65535的限制
...@@ -217,8 +217,9 @@ dependencies { ...@@ -217,8 +217,9 @@ dependencies {
implementation(name: 'open_ad_sdk', ext: 'aar') implementation(name: 'open_ad_sdk', ext: 'aar')
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.6' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.6'
// 极光推送 // 极光推送
implementation 'cn.jiguang.sdk:jpush:3.0.9' implementation 'cn.jiguang.sdk:jpush:3.6.6'
implementation 'cn.jiguang.sdk:jcore:1.1.7' implementation 'cn.jiguang.sdk:jcore:2.3.8'
implementation 'cn.jiguang.sdk:jverification:2.6.4'
// 支付宝 SDK AAR 包所需的配置 // 支付宝 SDK AAR 包所需的配置
implementation(name: 'alipaySdk-15.7.4-20200228192319-noUtdid', ext: 'aar') implementation(name: 'alipaySdk-15.7.4-20200228192319-noUtdid', ext: 'aar')
// 广点通广告 腾讯 // 广点通广告 腾讯
......
...@@ -347,21 +347,21 @@ ...@@ -347,21 +347,21 @@
# ===================== 极光推送 START ================ # ===================== 极光推送 START ================
# -dontoptimize -keep class * extends cn.jpush.android.helpers.JPushMessageReceiver { *; }
# -dontpreverify
# # ===================== 极光一键登录 ================
# -dontwarn cn.jpush.** -dontoptimize
# -keep class cn.jpush.** { *; } -dontpreverify
# -keep class * extends cn.jpush.android.helpers.JPushMessageReceiver { *; } -dontwarn cn.jpush.**
# -keep class cn.jpush.** { *; }
# -dontwarn cn.jiguang.** -dontwarn cn.jiguang.**
# -keep class cn.jiguang.** { *; } -keep class cn.jiguang.** { *; }
# -dontwarn com.cmic.**
# -dontwarn com.google.** -keep class com.cmic.** { *; }
# -keep class com.google.gson.** {*;} -dontwarn com.unicom.**
# -keep class com.unicom.** { *; }
# -dontwarn com.google.** -dontwarn cn.com.chinatelecom.**
# -keep class com.google.protobuf.** {*;} -keep class cn.com.chinatelecom.** { *; }
# ======================= 极光推送 END ================ # ======================= 极光推送 END ================
......
...@@ -299,6 +299,32 @@ ...@@ -299,6 +299,32 @@
android:name="android.support.FILE_PROVIDER_PATHS" android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" /> android:resource="@xml/provider_paths" />
</provider> </provider>
<!-- 极光一键登录 -->
<!-- since 2.0.0 optional 可选项,使用一键登录功能必须添加 -->
<!-- since 2.1.1 optional 可选项,通过screenOrientation设置授权页面横竖屏展示 -->
<activity
android:name="com.cmic.sso.sdk.activity.OAuthActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop">
</activity>
<!-- since 2.0.0 optional 可选项,使用一键登录功能必须添加 -->
<!-- since 2.1.1 optional 可选项,通过screenOrientation设置授权页面横竖屏展示 -->
<activity
android:name="com.cmic.sso.sdk.activity.LoginAuthActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop">
</activity>
<!-- since 2.0.0 optional 可选项,使用一键登录功能必须添加 -->
<!-- since 2.1.1 optional 可选项,通过screenOrientation设置授权页面横竖屏展示 -->
<activity android:name="cn.jiguang.verifysdk.CtLoginActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop">
</activity>
<!-- Required -->
<meta-data android:name="JPUSH_APPKEY" android:value="${JPUSH_APPKEY}"/>
<meta-data android:name="JPUSH_CHANNEL" android:value="${JPUSH_CHANNEL}"/>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
#统计平台
PRODUCE_STATISTICAL=https://daily.m.zzx9.cn
#取号平台
PRODUCE_DZH=https://auth.wosms.cn
...@@ -59,6 +59,8 @@ import com.yilan.sdk.ui.configs.YLUIConfig; ...@@ -59,6 +59,8 @@ import com.yilan.sdk.ui.configs.YLUIConfig;
import java.util.Map; import java.util.Map;
import cn.jiguang.verifysdk.api.JVerificationInterface;
import cn.jiguang.verifysdk.api.RequestCallback;
import cn.jpush.android.api.BasicPushNotificationBuilder; import cn.jpush.android.api.BasicPushNotificationBuilder;
import cn.jpush.android.api.JPushInterface; import cn.jpush.android.api.JPushInterface;
import rx.Scheduler; import rx.Scheduler;
...@@ -231,10 +233,10 @@ public class MintsApplication extends MultiDexApplication { ...@@ -231,10 +233,10 @@ public class MintsApplication extends MultiDexApplication {
// 创神广告 // 创神广告
initChuangshen(); initChuangshen();
}
// 极光一键登录
initJLogin();
}
/** /**
* 移动安装联盟 获取OAID等设备标识符 * 移动安装联盟 获取OAID等设备标识符
...@@ -463,6 +465,20 @@ public class MintsApplication extends MultiDexApplication { ...@@ -463,6 +465,20 @@ public class MintsApplication extends MultiDexApplication {
.build()); .build());
} }
/**
* 极光一键登录
*/
private void initJLogin() {
JVerificationInterface.setDebugMode(true);
final long start = System.currentTimeMillis();
JVerificationInterface.init(this, new RequestCallback<String>() {
@Override
public void onResult(int code, String result) {
LogUtil.d(TAG, "[init] code = " + code + " result = " + result + " consists = " + (System.currentTimeMillis() - start));
}
});
}
/** /**
* app退出 * app退出
*/ */
......
package com.mints.highgold.ui.activitys; package com.mints.highgold.ui.activitys;
import android.Manifest; import android.Manifest;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Point;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import com.mints.highgold.BuildConfig; import com.mints.highgold.BuildConfig;
...@@ -14,11 +20,11 @@ import com.mints.highgold.common.Constant; ...@@ -14,11 +20,11 @@ import com.mints.highgold.common.Constant;
import com.mints.highgold.login.LoginApi; import com.mints.highgold.login.LoginApi;
import com.mints.highgold.login.OnLoginListener; import com.mints.highgold.login.OnLoginListener;
import com.mints.highgold.manager.AmapLocationManager; import com.mints.highgold.manager.AmapLocationManager;
import com.mints.highgold.manager.UserManager;
import com.mints.highgold.mvp.model.WXInfo; import com.mints.highgold.mvp.model.WXInfo;
import com.mints.highgold.mvp.presenters.WxLoginPresenter; import com.mints.highgold.mvp.presenters.WxLoginPresenter;
import com.mints.highgold.mvp.views.WxLoginView; import com.mints.highgold.mvp.views.WxLoginView;
import com.mints.highgold.ui.activitys.base.BaseActivity; import com.mints.highgold.ui.activitys.base.BaseActivity;
import com.mints.highgold.utils.LogUtil;
import com.mints.highgold.utils.SPUtil; import com.mints.highgold.utils.SPUtil;
import com.mints.library.base.BaseWebActivity; import com.mints.library.base.BaseWebActivity;
import com.mints.library.net.netstatus.NetUtils; import com.mints.library.net.netstatus.NetUtils;
...@@ -29,7 +35,12 @@ import com.tbruyelle.rxpermissions.RxPermissions; ...@@ -29,7 +35,12 @@ import com.tbruyelle.rxpermissions.RxPermissions;
import java.util.HashMap; import java.util.HashMap;
import butterknife.Bind; import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import cn.jiguang.verifysdk.api.JVerificationInterface;
import cn.jiguang.verifysdk.api.JVerifyUIClickCallback;
import cn.jiguang.verifysdk.api.JVerifyUIConfig;
import cn.jiguang.verifysdk.api.VerifyListener;
import cn.sharesdk.framework.Platform; import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.PlatformDb; import cn.sharesdk.framework.PlatformDb;
import cn.sharesdk.framework.ShareSDK; import cn.sharesdk.framework.ShareSDK;
...@@ -44,10 +55,14 @@ import cn.sharesdk.wechat.friends.Wechat; ...@@ -44,10 +55,14 @@ import cn.sharesdk.wechat.friends.Wechat;
public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLoginListener { public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLoginListener {
//public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLoginListener,PlatformActionListener { //public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLoginListener,PlatformActionListener {
private static final String TAG = WxLoginActivity.class.getSimpleName();
@Bind(R.id.tv_activity_back) @Bind(R.id.tv_activity_back)
ImageView tvActivityBack; ImageView tvActivityBack;
@Bind(R.id.tv_activity_title) @Bind(R.id.tv_activity_title)
TextView tvActivityTitle; TextView tvActivityTitle;
@Bind(R.id.tv_jpush_login)
TextView tvJpushLogin;
private WxLoginPresenter wxLoginPresenter; private WxLoginPresenter wxLoginPresenter;
private SPUtil spUtil; private SPUtil spUtil;
...@@ -61,6 +76,9 @@ public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLogi ...@@ -61,6 +76,9 @@ public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLogi
private PlatformDb platDB; //平台授权数据DB private PlatformDb platDB; //平台授权数据DB
private int winHeight;
private int winWidth;
@Override @Override
protected int getContentViewLayoutID() { protected int getContentViewLayoutID() {
return R.layout.activity_wx_login; return R.layout.activity_wx_login;
...@@ -68,6 +86,18 @@ public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLogi ...@@ -68,6 +86,18 @@ public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLogi
@Override @Override
protected void initViewsAndEvents() { protected void initViewsAndEvents() {
Display defaultDisplay = getWindowManager().getDefaultDisplay();
Point point = new Point();
defaultDisplay.getSize(point);
Log.d(TAG, "winHeight px=" + point.y);
if (point.x > point.y) {
winHeight = point.x;
winWidth = point.y;
} else {
winHeight = point.y;
winWidth = point.x;
}
spUtil = SPUtil.getInstance(getApplicationContext()); spUtil = SPUtil.getInstance(getApplicationContext());
// ps = PreferencesService.getInstance(getApplicationContext()); // ps = PreferencesService.getInstance(getApplicationContext());
...@@ -137,6 +167,18 @@ public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLogi ...@@ -137,6 +167,18 @@ public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLogi
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
try {
if (JVerificationInterface.checkVerifyEnable(this)) {
// 支持
tvJpushLogin.setVisibility(View.VISIBLE);
} else {
// 不支持
tvJpushLogin.setVisibility(View.GONE);
}
} catch (Exception e) {
}
if (wxLoginFlag && !isFinishing()) { if (wxLoginFlag && !isFinishing()) {
wxLoginFlag = false; wxLoginFlag = false;
hideLoading(); hideLoading();
...@@ -163,7 +205,7 @@ public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLogi ...@@ -163,7 +205,7 @@ public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLogi
} }
@OnClick({R.id.tv_activity_back, R.id.tv_wx_login, R.id.tv_mobile_login @OnClick({R.id.tv_activity_back, R.id.tv_wx_login, R.id.tv_mobile_login
, R.id.tv_wxlogin_agreement, R.id.tv_wxlogin_policy}) , R.id.tv_wxlogin_agreement, R.id.tv_wxlogin_policy, R.id.tv_jpush_login})
public void onClick(View view) { public void onClick(View view) {
if (AntiShake.check(view.getId())) return; if (AntiShake.check(view.getId())) return;
...@@ -176,6 +218,43 @@ public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLogi ...@@ -176,6 +218,43 @@ public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLogi
case R.id.tv_activity_back: case R.id.tv_activity_back:
finish(); finish();
break; break;
case R.id.tv_jpush_login:
new RxPermissions(WxLoginActivity.this)
.request(Manifest.permission.READ_PHONE_STATE, Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION)
.subscribe(granted -> {
if (granted) {
AmapLocationManager.getInstance().startLocation(mLocationHandler);
showLoading("加载中...");
JVerificationInterface.setCustomUIWithConfig(getFullScreenPortraitConfig());
JVerificationInterface.loginAuth(this, new VerifyListener() {
@Override
public void onResult(final int code, final String token, String operator) {
LogUtil.d(TAG, "onResult: code=" + code + ",token=" + token + ",operator=" + operator);
runOnUiThread(new Runnable() {
@Override
public void run() {
hideLoading();
if (code == 6000) {
//登录成功
// toSuccessActivity(5,token);
showToast("登录成功");
readyGo(MainActivity.class);
} else if (code != 6002) {
showToast(operator);
}
}
});
}
});
} else {
showMissingPermissionDialog("设备,地理位置");
}
});
break;
case R.id.tv_wx_login: case R.id.tv_wx_login:
new RxPermissions(WxLoginActivity.this) new RxPermissions(WxLoginActivity.this)
.request(Manifest.permission.READ_PHONE_STATE, Manifest.permission.ACCESS_COARSE_LOCATION, .request(Manifest.permission.READ_PHONE_STATE, Manifest.permission.ACCESS_COARSE_LOCATION,
...@@ -226,6 +305,38 @@ public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLogi ...@@ -226,6 +305,38 @@ public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLogi
} }
} }
// public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
// private void getPhoneNum(String token) {
// new Thread(){
// @Override
// public void run() {
// super.run();
// try {
// OkHttpClient client = new OkHttpClient();
// JSONObject bodyJson = new JSONObject();
// bodyJson.put("token",token);
// String body = bodyJson.toString();
// RequestBody requestBody = RequestBody.create(JSON,body);
// Request request = new Request.Builder().url(Constants.verifyUrl).post(requestBody).build();
// Response response = client.newCall(request).execute();
// String responseData = response.body().string();
// Log.d(TAG,"response :"+responseData);
// JSONObject responseJson = new JSONObject(responseData);
// String phone = responseJson.optString("phone");
// Message message = handler.obtainMessage();
// message.what = 0;
// message.obj = phone;
// phoneNum = phone;
// handler.sendMessage(message);
// } catch (Throwable e) {
// Message message = handler.obtainMessage();
// message.what = 1;
// handler.sendMessage(message);
// }
// }
// }.start();
// }
@Override @Override
public void loginSuc() { public void loginSuc() {
// UserManager.getInstance().userLogout(); // UserManager.getInstance().userLogout();
...@@ -329,4 +440,37 @@ public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLogi ...@@ -329,4 +440,37 @@ public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLogi
// public void onCancel(Platform platform, int i) { // public void onCancel(Platform platform, int i) {
// showToast("取消授权"); // showToast("取消授权");
// } // }
private JVerifyUIConfig getFullScreenPortraitConfig() {
JVerifyUIConfig.Builder uiConfigBuilder = new JVerifyUIConfig.Builder();
uiConfigBuilder.setSloganTextColor(0xFFD0D0D9);
uiConfigBuilder.setLogoOffsetY(103);
uiConfigBuilder.setNumFieldOffsetY(190);
uiConfigBuilder.setPrivacyState(true);
uiConfigBuilder.setNavTransparent(true);
uiConfigBuilder.setNavReturnImgPath("ic_activity_arrow");
uiConfigBuilder.setCheckedImgPath(null);
uiConfigBuilder.setNumberColor(0xFF222328);
uiConfigBuilder.setLogBtnImgPath("selector_btn_normal");
uiConfigBuilder.setLogBtnTextColor(0xFFFFFFFF);
uiConfigBuilder.setLogBtnText("一键登录");
uiConfigBuilder.setLogBtnOffsetY(255);
uiConfigBuilder.setLogBtnWidth(300);
uiConfigBuilder.setLogBtnHeight(45);
uiConfigBuilder.setAppPrivacyColor(0xFFBBBCC5, 0xFF8998FF);
uiConfigBuilder.setPrivacyText("登录即同意《", "", "", "》并授权淘金空间高额版获取本机号码");
uiConfigBuilder.setPrivacyCheckboxHidden(true);
uiConfigBuilder.setPrivacyTextCenterGravity(true);
uiConfigBuilder.setPrivacyTextSize(12);
return uiConfigBuilder.build();
}
private int dp2Pix(Context context, float dp) {
try {
float density = context.getResources().getDisplayMetrics().density;
return (int) (dp * density + 0.5F);
} catch (Exception e) {
return (int) dp;
}
}
} }
...@@ -1041,34 +1041,34 @@ public class VersusFragment extends BaseFragment ...@@ -1041,34 +1041,34 @@ public class VersusFragment extends BaseFragment
viewVersusWeixin.setVisibility(View.GONE); viewVersusWeixin.setVisibility(View.GONE);
} }
//绑定手机号 Complete 0-未完成 1-完成 2-领取 // //绑定手机号 Complete 0-未完成 1-完成 2-领取
int challengeMobileComplete = data.getChallenge_mobile_complete(); // int challengeMobileComplete = data.getChallenge_mobile_complete();
if (challengeMobileComplete == 0) { // if (challengeMobileComplete == 0) {
llVersusMobile.setVisibility(View.VISIBLE); // llVersusMobile.setVisibility(View.VISIBLE);
viewVersusMobile.setVisibility(View.VISIBLE); // viewVersusMobile.setVisibility(View.VISIBLE);
tvVersusMobileGold.setText("+" + data.getChallenge_mobile_coin()); // tvVersusMobileGold.setText("+" + data.getChallenge_mobile_coin());
//
// if (!userManager.userIsLogin()) { //// if (!userManager.userIsLogin()) {
//// tvVersusMobile.setText("去完成");
//// tvVersusMobile.setBackground(getResources().getDrawable(R.drawable.shape_main_water));
////
//// } else {
//// tvVersusMobile.setText("立即领取");
//// tvVersusMobile.setBackground(getResources().getDrawable(R.drawable.shape_tv_gold));
////
//// }
// tvVersusMobile.setText("去完成"); // tvVersusMobile.setText("去完成");
// tvVersusMobile.setBackground(getResources().getDrawable(R.drawable.shape_main_water)); // tvVersusMobile.setBackground(getResources().getDrawable(R.drawable.shape_main_water));
// // } else if (challengeMobileComplete == 1) {
// } else { // llVersusMobile.setVisibility(View.VISIBLE);
// viewVersusMobile.setVisibility(View.VISIBLE);
// tvVersusMobileGold.setText("+" + data.getChallenge_mobile_coin());
// tvVersusMobile.setText("立即领取"); // tvVersusMobile.setText("立即领取");
// tvVersusMobile.setBackground(getResources().getDrawable(R.drawable.shape_tv_gold)); // tvVersusMobile.setBackground(getResources().getDrawable(R.drawable.shape_tv_gold));
// // } else {
// llVersusMobile.setVisibility(View.GONE);
// viewVersusMobile.setVisibility(View.GONE);
// } // }
tvVersusMobile.setText("去完成");
tvVersusMobile.setBackground(getResources().getDrawable(R.drawable.shape_main_water));
} else if (challengeMobileComplete == 1) {
llVersusMobile.setVisibility(View.VISIBLE);
viewVersusMobile.setVisibility(View.VISIBLE);
tvVersusMobileGold.setText("+" + data.getChallenge_mobile_coin());
tvVersusMobile.setText("立即领取");
tvVersusMobile.setBackground(getResources().getDrawable(R.drawable.shape_tv_gold));
} else {
llVersusMobile.setVisibility(View.GONE);
viewVersusMobile.setVisibility(View.GONE);
}
//首次提现 Complete 0-未完成 1-完成 2-领取 //首次提现 Complete 0-未完成 1-完成 2-领取
......
...@@ -38,6 +38,19 @@ ...@@ -38,6 +38,19 @@
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView
android:id="@+id/tv_jpush_login"
android:layout_width="match_parent"
android:layout_height="86pt"
android:layout_marginLeft="70pt"
android:layout_marginTop="30pt"
android:layout_marginRight="70pt"
android:background="@drawable/rb_index_selected"
android:gravity="center"
android:text="一键登录"
android:textColor="@color/main_mints"
android:textSize="14sp" />
<TextView <TextView
android:id="@+id/tv_mobile_login" android:id="@+id/tv_mobile_login"
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -119,4 +119,5 @@ ...@@ -119,4 +119,5 @@
<item name="android:textColor">#cb4a39</item> <item name="android:textColor">#cb4a39</item>
<item name="android:fontFamily">sans-serif-condensed</item> <item name="android:fontFamily">sans-serif-condensed</item>
</style> </style>
</resources> </resources>
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