Commit 811afb2a authored by mengcuiguang's avatar mengcuiguang

添加一键登录

parent d90937f3
......@@ -11,8 +11,8 @@ android {
applicationId "com.mints.highgold"
minSdkVersion rootProject.ext.androidMinSdkVersion
targetSdkVersion rootProject.ext.androidTargetSdkVersion
versionCode 15
versionName "1.1.4"
versionCode 16
versionName "1.1.5"
flavorDimensions "default"
// dex突破65535的限制
......@@ -217,8 +217,9 @@ dependencies {
implementation(name: 'open_ad_sdk', ext: 'aar')
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.6'
// 极光推送
implementation 'cn.jiguang.sdk:jpush:3.0.9'
implementation 'cn.jiguang.sdk:jcore:1.1.7'
implementation 'cn.jiguang.sdk:jpush:3.6.6'
implementation 'cn.jiguang.sdk:jcore:2.3.8'
implementation 'cn.jiguang.sdk:jverification:2.6.4'
// 支付宝 SDK AAR 包所需的配置
implementation(name: 'alipaySdk-15.7.4-20200228192319-noUtdid', ext: 'aar')
// 广点通广告 腾讯
......
......@@ -347,21 +347,21 @@
# ===================== 极光推送 START ================
# -dontoptimize
# -dontpreverify
#
# -dontwarn cn.jpush.**
# -keep class cn.jpush.** { *; }
# -keep class * extends cn.jpush.android.helpers.JPushMessageReceiver { *; }
#
# -dontwarn cn.jiguang.**
# -keep class cn.jiguang.** { *; }
#
# -dontwarn com.google.**
# -keep class com.google.gson.** {*;}
#
# -dontwarn com.google.**
# -keep class com.google.protobuf.** {*;}
-keep class * extends cn.jpush.android.helpers.JPushMessageReceiver { *; }
# ===================== 极光一键登录 ================
-dontoptimize
-dontpreverify
-dontwarn cn.jpush.**
-keep class cn.jpush.** { *; }
-dontwarn cn.jiguang.**
-keep class cn.jiguang.** { *; }
-dontwarn com.cmic.**
-keep class com.cmic.** { *; }
-dontwarn com.unicom.**
-keep class com.unicom.** { *; }
-dontwarn cn.com.chinatelecom.**
-keep class cn.com.chinatelecom.** { *; }
# ======================= 极光推送 END ================
......
......@@ -299,6 +299,32 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</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>
</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;
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.JPushInterface;
import rx.Scheduler;
......@@ -231,10 +233,10 @@ public class MintsApplication extends MultiDexApplication {
// 创神广告
initChuangshen();
}
// 极光一键登录
initJLogin();
}
/**
* 移动安装联盟 获取OAID等设备标识符
......@@ -463,6 +465,20 @@ public class MintsApplication extends MultiDexApplication {
.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退出
*/
......
package com.mints.highgold.ui.activitys;
import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.mints.highgold.BuildConfig;
......@@ -14,11 +20,11 @@ import com.mints.highgold.common.Constant;
import com.mints.highgold.login.LoginApi;
import com.mints.highgold.login.OnLoginListener;
import com.mints.highgold.manager.AmapLocationManager;
import com.mints.highgold.manager.UserManager;
import com.mints.highgold.mvp.model.WXInfo;
import com.mints.highgold.mvp.presenters.WxLoginPresenter;
import com.mints.highgold.mvp.views.WxLoginView;
import com.mints.highgold.ui.activitys.base.BaseActivity;
import com.mints.highgold.utils.LogUtil;
import com.mints.highgold.utils.SPUtil;
import com.mints.library.base.BaseWebActivity;
import com.mints.library.net.netstatus.NetUtils;
......@@ -29,7 +35,12 @@ import com.tbruyelle.rxpermissions.RxPermissions;
import java.util.HashMap;
import butterknife.Bind;
import butterknife.ButterKnife;
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.PlatformDb;
import cn.sharesdk.framework.ShareSDK;
......@@ -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,PlatformActionListener {
private static final String TAG = WxLoginActivity.class.getSimpleName();
@Bind(R.id.tv_activity_back)
ImageView tvActivityBack;
@Bind(R.id.tv_activity_title)
TextView tvActivityTitle;
@Bind(R.id.tv_jpush_login)
TextView tvJpushLogin;
private WxLoginPresenter wxLoginPresenter;
private SPUtil spUtil;
......@@ -61,6 +76,9 @@ public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLogi
private PlatformDb platDB; //平台授权数据DB
private int winHeight;
private int winWidth;
@Override
protected int getContentViewLayoutID() {
return R.layout.activity_wx_login;
......@@ -68,6 +86,18 @@ public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLogi
@Override
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());
// ps = PreferencesService.getInstance(getApplicationContext());
......@@ -137,6 +167,18 @@ public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLogi
protected void onResume() {
super.onResume();
try {
if (JVerificationInterface.checkVerifyEnable(this)) {
// 支持
tvJpushLogin.setVisibility(View.VISIBLE);
} else {
// 不支持
tvJpushLogin.setVisibility(View.GONE);
}
} catch (Exception e) {
}
if (wxLoginFlag && !isFinishing()) {
wxLoginFlag = false;
hideLoading();
......@@ -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
, 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) {
if (AntiShake.check(view.getId())) return;
......@@ -176,6 +218,43 @@ public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLogi
case R.id.tv_activity_back:
finish();
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:
new RxPermissions(WxLoginActivity.this)
.request(Manifest.permission.READ_PHONE_STATE, Manifest.permission.ACCESS_COARSE_LOCATION,
......@@ -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
public void loginSuc() {
// UserManager.getInstance().userLogout();
......@@ -329,4 +440,37 @@ public class WxLoginActivity extends BaseActivity implements WxLoginView, OnLogi
// public void onCancel(Platform platform, int i) {
// 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
viewVersusWeixin.setVisibility(View.GONE);
}
//绑定手机号 Complete 0-未完成 1-完成 2-领取
int challengeMobileComplete = data.getChallenge_mobile_complete();
if (challengeMobileComplete == 0) {
llVersusMobile.setVisibility(View.VISIBLE);
viewVersusMobile.setVisibility(View.VISIBLE);
tvVersusMobileGold.setText("+" + data.getChallenge_mobile_coin());
// if (!userManager.userIsLogin()) {
// //绑定手机号 Complete 0-未完成 1-完成 2-领取
// int challengeMobileComplete = data.getChallenge_mobile_complete();
// if (challengeMobileComplete == 0) {
// llVersusMobile.setVisibility(View.VISIBLE);
// viewVersusMobile.setVisibility(View.VISIBLE);
// tvVersusMobileGold.setText("+" + data.getChallenge_mobile_coin());
//
//// 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.setBackground(getResources().getDrawable(R.drawable.shape_main_water));
//
// } else {
// } 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);
// }
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-领取
......
......@@ -38,6 +38,19 @@
android:textColor="@color/white"
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
android:id="@+id/tv_mobile_login"
android:layout_width="match_parent"
......
......@@ -119,4 +119,5 @@
<item name="android:textColor">#cb4a39</item>
<item name="android:fontFamily">sans-serif-condensed</item>
</style>
</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