Skip to content
This repository has been archived by the owner on Aug 26, 2019. It is now read-only.

Commit

Permalink
修正登陆错误
Browse files Browse the repository at this point in the history
  • Loading branch information
seven332 committed Aug 24, 2014
1 parent b1cf11e commit 5017861
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 9 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hippo.ehviewer"
android:versionCode="22"
android:versionName="0.6.1" >
android:versionCode="23"
android:versionName="0.6.2" >

<uses-sdk
android:minSdkVersion="14"
Expand Down
5 changes: 5 additions & 0 deletions res/raw/change_log
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Version 0.6.2 (2014-08-23)
* 修正登陆错误
* 修正翻译错误
* 修正一处可能的崩溃

Version 0.6.1 (2014-08-23)
* 修正早期系统版本布局错误
* 修正可能出现的通知闪烁
Expand Down
15 changes: 15 additions & 0 deletions src/com/hippo/ehviewer/AppContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@

import android.annotation.SuppressLint;
import android.app.Application;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;

import com.hippo.ehviewer.cache.ImageCache;
import com.hippo.ehviewer.data.Data;
import com.hippo.ehviewer.ehclient.EhClient;
import com.hippo.ehviewer.ehclient.EhInfo;
import com.hippo.ehviewer.ehclient.ExDownloaderManager;
import com.hippo.ehviewer.util.Config;
import com.hippo.ehviewer.util.Crash;
Expand Down Expand Up @@ -82,6 +85,18 @@ public void onCreate() {
new FileOutputStream(nomedia).close();
} catch (IOException e) {}
}

// Fix <=22 error
if (Config.getVersionCode() <= 22) {
EhInfo.getInstance(this).logout();
}


// Update version code
try {
PackageInfo pi= getPackageManager().getPackageInfo(getPackageName(), 0);
Config.setVersionCode(pi.versionCode);
} catch (NameNotFoundException e) {}
}

/**
Expand Down
20 changes: 13 additions & 7 deletions src/com/hippo/ehviewer/ehclient/EhInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public class EhInfo {
private static final String KEY_DISPLAYNAME = "displayname";
private static final String DEFAULT_NAME = "Hippo";
private static final String KEY_MEMBER_ID = "ipb_member_id";
private static final String DEFAULT_MEMBER_ID = "1936857";
private static final String DEFAULT_MEMBER_ID = null;
private static final String KEY_PASS_HASH = "ipb_pass_hash";
private static final String DEFAULT_PASS_HASH = "725e2726990bc34ae3852bb4f7c7879a";
private static final String DEFAULT_PASS_HASH = null;

private final Context mContext;
private final SharedPreferences mInfoPref;
Expand Down Expand Up @@ -171,11 +171,17 @@ public void setCookie(HttpURLConnection conn) {
}

public void setCookie(HttpURLConnection conn, String previewMode) {
String cookie = "ipb_member_id=" + mInfoPref.getString(KEY_MEMBER_ID, DEFAULT_MEMBER_ID) +
"; ipb_pass_hash=" + mInfoPref.getString(KEY_PASS_HASH, DEFAULT_PASS_HASH) +
"; uconfig=" + (previewMode == null ? mUconfig : getUconfigString(previewMode)) +
"; xres=" + Config.getLofiResolution();
conn.setRequestProperty("Cookie", cookie);

StringBuilder sb = new StringBuilder();
String id = mInfoPref.getString(KEY_MEMBER_ID, DEFAULT_MEMBER_ID);
String hash = mInfoPref.getString(KEY_PASS_HASH, DEFAULT_PASS_HASH);
sb.append("uconfig=").append(previewMode == null ? mUconfig : getUconfigString(previewMode))
.append("; xres=").append(Config.getLofiResolution());
if (id != null)
sb.append("; ipb_member_id=").append(id);
if (hash != null)
sb.append("; ipb_pass_hash=").append(hash);
conn.setRequestProperty("Cookie", sb.toString());
}

public boolean isLogin() {
Expand Down
12 changes: 12 additions & 0 deletions src/com/hippo/ehviewer/util/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,18 @@ public static int getPreviewColumnsLandscape() {
KEY_PREVIEW_COLUMNS_LANDSCAPE, DEFAULT_PREVIEW_COLUMNS_LANDSCAPE);
}

private static final String KEY_VERSION_CODE = "version_code";
private static final int DEFAULT_VERSION_CODE = 0;

public static int getVersionCode() {
return mConfigPre.getInt(KEY_VERSION_CODE,
DEFAULT_VERSION_CODE);
}

public static void setVersionCode(int versionCode) {
mConfigPre.edit().putInt(KEY_VERSION_CODE, versionCode).apply();
}

/****** GalleryActivity ******/

private static final String KEY_GALLERY_FIRST = "gallery_first";
Expand Down

0 comments on commit 5017861

Please sign in to comment.