Skip to content

Commit

Permalink
解决SDK27以上HTTP无法访问的问题
Browse files Browse the repository at this point in the history
解决登录时验证码不显示的问题
  • Loading branch information
ironlz committed Aug 15, 2019
1 parent c6b258f commit 0cddd6c
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
buildToolsVersion "29.0.0"

defaultConfig {
applicationId "me.yluo.ruisiapp"
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/logo_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:networkSecurityConfig="@xml/network_security_config">
<activity
android:name=".activity.LaunchActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand Down
17 changes: 12 additions & 5 deletions app/src/main/java/me/yluo/ruisiapp/widget/InputValidDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import android.app.Dialog;
import android.app.DialogFragment;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.Image;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
Expand All @@ -11,6 +14,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

Expand All @@ -32,7 +36,7 @@
*/
public class InputValidDialog extends DialogFragment {
private EditText input;
private GifImageView gifImageView;
private ImageView gifImageView;
private ProgressBar progressBar;
private TextView statusView;
private String hash = "";
Expand Down Expand Up @@ -166,7 +170,8 @@ private void loadImage(String hash) {
}

//Log.v("===", HttpUtil.getStore(getActivity()).getCookie());
HttpUtil.getClient().addHeader("Referer", App.getBaseUrl() + UrlUtils.getLoginUrl());
String refererURI = App.getBaseUrl() + UrlUtils.getLoginUrl();
HttpUtil.getClient().addHeader("Referer", refererURI);
HttpUtil.get(url, new ResponseHandler() {
@Override
public void onStart() {
Expand All @@ -178,9 +183,11 @@ public void onStart() {
@Override
public void onSuccess(byte[] response) {
try {
GifDrawable drawable = new GifDrawable(response);
gifImageView.setImageDrawable(drawable);
} catch (IOException e) {
Bitmap img = BitmapFactory.decodeByteArray(response, 0, response.length);
gifImageView.setImageBitmap(img);
gifImageView.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
} catch (Exception e) {
e.printStackTrace();
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/dialog_input_valid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
android:maxLines="1"
android:textSize="16sp" />

<pl.droidsonroids.gif.GifImageView
<ImageView
android:id="@+id/gifview"
android:layout_width="100dp"
android:layout_height="50dp"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/xml/network_security_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.android.tools.build:gradle:3.4.2'


// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Mar 28 17:15:41 CST 2018
#Wed Jul 03 21:24:36 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

0 comments on commit 0cddd6c

Please sign in to comment.