Commit 260c5fa2 by 霍志良

Merge remote-tracking branch 'origin/4.1.64' into 4.1.64

parents fa6bb25f 3631faf9
......@@ -70,10 +70,6 @@
android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" />
<activity
android:name=".ui.AliAuthDemoActivity"
android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" />
<activity
android:name=".wxapi.WXEntryActivity"
android:exported="true"
android:launchMode="singleTop" />
......
package com.yidianling.user.ui;
import android.Manifest;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.util.SparseArray;
import android.util.TypedValue;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mobile.auth.gatewayauth.AuthRegisterViewConfig;
import com.mobile.auth.gatewayauth.AuthUIConfig;
import com.mobile.auth.gatewayauth.CustomInterface;
import com.mobile.auth.gatewayauth.PhoneNumberAuthHelper;
import com.mobile.auth.gatewayauth.PreLoginResultListener;
import com.mobile.auth.gatewayauth.TokenResultListener;
import com.mobile.auth.gatewayauth.model.InitResult;
import com.yidianling.common.tools.ToastUtil;
import com.yidianling.user.R;
@Route(path = "/user/aliAuthDemo")
public class AliAuthDemoActivity extends Activity {
private PhoneNumberAuthHelper mAlicomAuthHelper;
private TokenResultListener mTokenListener;
private Button mVaildBtn, mLoginBtn;
private TextView mRetTV;
private InitResult mAutCheckResult;
private SparseArray<PermissionCallback> mPerMissionCallbackCache;
private int mCurrentPermissionRequestCode = 0;
private ProgressDialog mProgressDialog;
private String token;
private TextView mDynamicView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.user_activity_ali_auth_demo);
mVaildBtn = (Button) findViewById(R.id.vaild_button);
mLoginBtn = (Button) findViewById(R.id.login_button);
mRetTV = (TextView) findViewById(R.id.operator_name_tv);
init();
}
private void initDynamicView() {
mDynamicView = new TextView(getApplicationContext());
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
layoutParams.setMargins(0, dp2px(this, 450), 0, 0);
mDynamicView.setText("----- 自定义view -----");
mDynamicView.setTextColor(0xff999999);
mDynamicView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13.0F);
mDynamicView.setLayoutParams(layoutParams);
}
public static int dp2px(Context context, float dipValue) {
try {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dipValue * scale + 0.5f);
} catch (Exception e) {
return (int) dipValue;
}
}
private void init() {
/*
* 1.init get token callback Listener
*/
mTokenListener = new TokenResultListener() {
@Override
public void onTokenSuccess(final String ret) {
mDynamicView = null;
AliAuthDemoActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
/*
* setText just show the result for get token。
* use ret to verfiy number。
*/
hideLoadingDialog();
token = ret;
mRetTV.setText("成功:\n" + ret);
mAlicomAuthHelper.quitAuthActivity();
}
});
}
@Override
public void onTokenFailed(final String ret) {
mDynamicView = null;
AliAuthDemoActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
/*
* setText just show the result for get token
* do something when getToken failed, such as use sms verify code.
*/
hideLoadingDialog();
mRetTV.setText("失败:\n" + ret);
mAlicomAuthHelper.quitAuthActivity();
}
});
}
};
/*
* 2.init AlicomAuthHelper with tokenListener
*/
mAlicomAuthHelper = PhoneNumberAuthHelper.getInstance(this, mTokenListener);
/*
* 3.set debugMode when app is in debug mode, sdk will print log in debug mode
*/
// if (isApkInDebug(this)) {
mAlicomAuthHelper.setDebugMode(true);
// }
/*
* 4.ask permission from user, this step is not necessary
* just do when your app is needed
*/
if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
requestPermission(new String[]{Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, new PermissionCallback() {
@Override
public void onPermissionGranted(boolean isRequestUser) {
/*
* 5.sdk init
*/
mAutCheckResult = mAlicomAuthHelper.checkAuthEnvEnable();
}
@Override
public void onPermissionDenied(boolean isRequestUser) {
ToastUtil.toastShort(AliAuthDemoActivity.this, "请允许相关权限");
}
});
} else {
/*
* 5.sdk init
*/
mAutCheckResult = mAlicomAuthHelper.checkAuthEnvEnable();
}
mVaildBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showLoadingDialog("正在请求认证token");
mAlicomAuthHelper.getAuthToken(5000);
}
});
mLoginBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
initDynamicView();
mAlicomAuthHelper.addAuthRegistViewConfig("my_tv", new AuthRegisterViewConfig.Builder()
.setView(mDynamicView)
.setRootViewId(AuthRegisterViewConfig.RootViewId.ROOT_VIEW_ID_BODY)
.setCustomInterface(new CustomInterface() {
@Override
public void onClick(Context context) {
ToastUtil.toastShort(context, "点击自定义控件");
}
}).build());
showLoadingDialog("正在请求登录Token");
mAlicomAuthHelper.getLoginToken(5000);
}
});
/*
* 7.user sdk init result to do someting
* this step is also not necessary
* if you do this step, user experience maybe better
*/
if (mAutCheckResult != null) {
//judge the phone condition can use 4g auth
if (!mAutCheckResult.isCan4GAuth()) {
mVaildBtn.setClickable(false);
mRetTV.setText("请开启移动网络后重试!");
}
}
/*
* 8.config authorization page ui to adapte app ui theme
*/
mAlicomAuthHelper.setAuthUIConfig(new AuthUIConfig.Builder()
.setAppPrivacyOne("自定义协议", "https://www.aliyun.com/product/dypns")
.setLogoImgPath("ic_launcher")
.setPrivacyState(true)
.setCheckboxHidden(true)
.create());
mAlicomAuthHelper.preLogin(5, new PreLoginResultListener() {
@Override
public void onTokenSuccess(final String s) {
AliAuthDemoActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
/*
* 推荐在登录页初始化的时候调用
* 如果没有合适的调用时机
* 不调用此接口也没关系
* 千万不要APP冷启动初始化就调用!!!!
* 最好判断用户是否登录,若已登录不要使用此接口!!!!
*/
mRetTV.setText("预取号成功:" + s);
}
});
}
@Override
public void onTokenFailed(final String s, final String s1) {
/*
* 预取号调用失败
* 不用太关注,还是可以直接在用户点击"登录"时,调用getLoginToken
*/
mRetTV.setText("预取号失败:" + s + s1);
}
});
}
@Override
protected void onDestroy() {
/*
* 8.remember on destory
*/
mAlicomAuthHelper.onDestroy();
super.onDestroy();
}
/*
* Dynamic request application permissions
*/
protected void requestPermission(String[] permissions, PermissionCallback callback) {
int result = PackageManager.PERMISSION_GRANTED;
for (String s : permissions) {
if (ContextCompat.checkSelfPermission(this, s) != PackageManager.PERMISSION_GRANTED)
result = PackageManager.PERMISSION_DENIED;
}
if (result == PackageManager.PERMISSION_GRANTED && callback != null) {
callback.onPermissionGranted(false);
} else {
if (Build.VERSION.SDK_INT >= 23) {
if (mPerMissionCallbackCache == null)
mPerMissionCallbackCache = new SparseArray<PermissionCallback>();
mPerMissionCallbackCache.put(mCurrentPermissionRequestCode, callback);
requestPermissions(permissions, mCurrentPermissionRequestCode++);
} else if (callback != null) {
callback.onPermissionDenied(false);
}
}
}
public interface PermissionCallback {
void onPermissionGranted(boolean isRequestUser);
void onPermissionDenied(boolean isRequestUser);
}
public boolean isApkInDebug(Context context) {
try {
ApplicationInfo info = context.getApplicationInfo();
return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
} catch (Exception e) {
return false;
}
}
public void showLoadingDialog(String hint) {
if (mProgressDialog == null) {
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
}
mProgressDialog.setMessage(hint);
mProgressDialog.setCancelable(true);
mProgressDialog.show();
}
public void hideLoadingDialog() {
if (mProgressDialog != null)
if (mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
}
}
......@@ -191,7 +191,7 @@ object OneKeyLoginHelp {
RelativeLayout.LayoutParams.WRAP_CONTENT
)
tvAuthParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE)
tvAuthParams.setMargins(0, RxImageTool.dp2px(250f), 0, 0)
tvAuthParams.setMargins(0, RxImageTool.dp2px(235f), 0, 0)
when (phoneNumberAuthHelper.currentCarrierName) {
"CUCC" -> {
tvAuth.text = "中国联通提供认证服务"
......@@ -273,11 +273,11 @@ object OneKeyLoginHelp {
.setSloganHidden(true) // 设置slogan是否隐藏
.setNumberColor(Color.parseColor("#242424"))
.setNumberSize(24)
.setNumFieldOffsetY(215)
.setNumFieldOffsetY(200)
.setLogBtnBackgroundPath("bg_one_click_login") // 设置登录按钮背景图片
.setLogBtnTextColor(Color.parseColor("#ffffff")) // 设置登录按钮文字颜色
.setLogBtnTextSize(15)
.setLogBtnMarginLeftAndRight(40) // 设置登录按钮距离左右距离
.setLogBtnTextSize(17)
.setLogBtnMarginLeftAndRight(23) // 设置登录按钮距离左右距离
.setLogBtnHeight(78)
.setSwitchAccText("切换号码")
.setSwitchAccTextSize(15)
......@@ -325,10 +325,10 @@ object OneKeyLoginHelp {
.setNumFieldOffsetY(unit +10)
.setLogBtnBackgroundPath("bg_one_click_login") // 设置登录按钮背景图片
.setLogBtnTextColor(Color.parseColor("#ffffff")) // 设置登录按钮颜色
.setLogBtnTextSize(16)
.setLogBtnMarginLeftAndRight(35) // 设置登录按钮距离左右距离
.setLogBtnTextSize(17)
.setLogBtnMarginLeftAndRight(23) // 设置登录按钮距离左右距离
.setLogBtnHeight(78)
.setLogBtnOffsetY((unit * 2.5).toInt())
.setLogBtnOffsetY(unit * 3-4)
.setSwitchAccText("其它方式登录")
.setSwitchAccTextSize(15)
.setSwitchAccTextColor(Color.parseColor("#666666"))
......@@ -361,13 +361,13 @@ object OneKeyLoginHelp {
}
}
ResultCode.CODE_SUCCESS -> { // 获取token成功
val param = PhoneLoginAutoParam(tokenRet.token, JPushUtils.getRegistrationID(),2,2,"",
RxAppTool.getAppVersionName(BaseApp.Companion.getApp()))
val param = PhoneLoginAutoParam(tokenRet.token, JPushUtils.getRegistrationID(),2,2,"", RxAppTool.getAppVersionName(BaseApp.Companion.getApp()))
LoginApiRequestUtil.autoLogin(param)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
if (it.code == 200) {
ToastUtil.toastShort("登录成功")
saveUserData(it.data)
if (it.data.firstLogin == 1) {//第一次登录:是注册
StatusUtils.isFirstLogin = true
......
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp"
android:text="欢迎使用阿里巴巴本机认证服务"
android:textColor="#ff5000"
android:textSize="18dp" />
</LinearLayout>
<TextView
android:id="@+id/operator_name_tv"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="15dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<Button
android:id="@+id/login_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:background="@color/platform_gray7"
android:text="获取登录Token" />
<Button
android:id="@+id/vaild_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="@color/platform_gray7"
android:text="获取认证token" />
</LinearLayout>
</LinearLayout>
</ScrollView>
\ No newline at end of file
......@@ -52,8 +52,8 @@ javaapi.test = https://testapi.ydl.com/api/
javaapi.auto_test = https://auto_testapi.ydl.com/api/
javaapi.prod = https://api.ydl.com/api/
# 开启网关加密appKey和appSecret
# 网关加密的appKey和appSecret
appKey.test = 20BB42485BD448DE888DD745899C457D
appSecret.test = ABA88F2FF7E64A688D2213B20A9B3A3E
appKey.prod =
appSecret.prod =
appKey.prod = 49A4A1BBFBC74CA2B0B5C6B77FF13A80
appSecret.prod = ABA88F2FF7E64A688D2213B20A9B3A3E
......@@ -720,7 +720,11 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
if (overridePayUrl != null) {
return overridePayUrl;
}
if (!TextUtils.isEmpty(url) && url.startsWith("http")) {
if (!TextUtils.isEmpty(url)&&url.endsWith(".apk")){
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
} else if (!TextUtils.isEmpty(url) && url.startsWith("http")) {
loadUrl(setUrlHeightParams(url));
} else {
if (YDLRouterManager.Companion.router(url)) {
......@@ -799,8 +803,10 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
return overridePayUrl;
}
if (!TextUtils.isEmpty(url) && url.startsWith("http")) {
if (!TextUtils.isEmpty(url)&&url.endsWith(".apk")){
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
} else if (!TextUtils.isEmpty(url) && url.startsWith("http")) {
loadUrl(setUrlHeightParams(url));
} else {
if (YDLRouterManager.Companion.router(url)) {
......
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