Skip to content

Commit

Permalink
version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowbluesky committed May 17, 2019
1 parent a54387e commit 55fabe6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.antony.muzei.pixiv"
minSdkVersion 19
targetSdkVersion 28
versionCode 141
versionName "1.4.1"
versionCode 142
versionName "1.4.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
17 changes: 6 additions & 11 deletions app/src/main/java/com/antony/muzei/pixiv/PixivArtWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,23 @@ private Response authLogin(String loginId, String loginPassword) throws IOExcept
.appendQueryParameter("password", loginPassword)
.build();

Response response = sendPostRequest(PixivArtProviderDefines.OAUTH_URL, authQuery);
return response;
return sendPostRequest(PixivArtProviderDefines.OAUTH_URL, authQuery);
}

// Acquire an access token from an existing refresh token
// Returns a response containing an error or the tokens
// It is up to the caller to handle any errors
private Response authRefreshToken(String refreshToken) throws IOException, JSONException
{
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

Uri authQuery = new Uri.Builder()
.appendQueryParameter("get_secure_url", Integer.toString(1))
.appendQueryParameter("client_id", PixivArtProviderDefines.CLIENT_ID)
.appendQueryParameter("client_secret", PixivArtProviderDefines.CLIENT_SECRET)
.appendQueryParameter("grant_type", "refresh_token")
.appendQueryParameter("refresh_token", sharedPrefs.getString("refreshToken", ""))
.appendQueryParameter("refresh_token", refreshToken)
.build();

Response response = sendPostRequest(PixivArtProviderDefines.OAUTH_URL, authQuery);
return response;
return sendPostRequest(PixivArtProviderDefines.OAUTH_URL, authQuery);
}

// Upon successful authentication this function stores tokens returned from Pixiv into device memory
Expand All @@ -123,8 +119,8 @@ private String getAccessToken()
// If we possess an access token, AND it has not expired, instantly return it
// Must be a divide by 1000, cannot be subtract 3600 * 1000
String accessToken = sharedPrefs.getString("accessToken", "");
//long accessTokenIssueTime = sharedPrefs.getLong("accessTokenIssueTime", 0);
long accessTokenIssueTime = 1;
long accessTokenIssueTime = sharedPrefs.getLong("accessTokenIssueTime", 0);
//long accessTokenIssueTime = 1;
if (!accessToken.isEmpty() && accessTokenIssueTime > (System.currentTimeMillis() / 1000) - 3600)
{
Log.i(LOG_TAG, "Existing access token found");
Expand All @@ -144,8 +140,7 @@ private String getAccessToken()
String loginId = sharedPrefs.getString("pref_loginId", "");
String loginPassword = sharedPrefs.getString("pref_loginPassword", "");
response = authLogin(loginId, loginPassword);
}
else
} else
{
Log.d(LOG_TAG, "using refresh token");
String refreshToken = sharedPrefs.getString("refreshToken", "");
Expand Down

0 comments on commit 55fabe6

Please sign in to comment.