Skip to content

Commit

Permalink
Changed from string resource to BuildConfig (Add values to github.pro…
Browse files Browse the repository at this point in the history
…perties)
  • Loading branch information
Meisolsson committed Jul 11, 2015
1 parent 275e563 commit 17f19f4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -127,3 +127,6 @@ tmp/

# TeXlipse plugin
.texlipse

#GitHub application codes (local and personal)
github.properties
16 changes: 15 additions & 1 deletion app/build.gradle
Expand Up @@ -9,6 +9,20 @@ android {
targetSdkVersion 22
versionCode 1900
versionName '1.9.0'

def Properties githubProps = new Properties()
githubProps.load(new FileInputStream(file('../github.properties')))

assert githubProps["GITHUB_SECRET"]
resValue "string", "github_secret", githubProps["GITHUB_SECRET"]

assert githubProps["GITHUB_CLIENT"]
resValue "string", "github_client", githubProps["GITHUB_CLIENT"]

assert githubProps["GITHUB_CALLBACK"]
def oauth = githubProps["GITHUB_CALLBACK"]
resValue "string", "github_oauth", oauth
resValue "string", "github_oauth_scheme", oauth.split("://")[0]
}

packagingOptions {
Expand All @@ -33,7 +47,7 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'org.roboguice:roboguice:2.0'
compile 'com.github.kevinsawicki:http-request:5.6'
compile 'com.google.code.gson:gson:2.3.1'
Expand Down
15 changes: 11 additions & 4 deletions app/src/main/java/com/github/mobile/accounts/LoginActivity.java
Expand Up @@ -49,6 +49,7 @@
import com.github.mobile.ui.MainActivity;
import com.github.mobile.ui.roboactivities.RoboActionBarAccountAuthenticatorActivity;
import com.google.inject.Inject;
import com.squareup.okhttp.HttpUrl;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -74,7 +75,7 @@ public class LoginActivity extends RoboActionBarAccountAuthenticatorActivity imp
*/
public static final String PARAM_USERNAME = "username";

public static final String OAUTH_URL = "https://github.com/login/oauth/authorize";
public static final String OAUTH_HOST = "www.github.com";

private static final String TAG = "LoginActivity";

Expand Down Expand Up @@ -195,15 +196,21 @@ public void handleLogin() {

private void openLoginInBrowser(ApiClient client) {
String initialScope = "user,public_repo,repo,delete_repo,notifications,gist";
final String url = String.format("%s?client_id=%s&scope=%s",
OAUTH_URL, client.getApiClient(), initialScope);
HttpUrl.Builder url = new HttpUrl.Builder()
.scheme("https")
.host(OAUTH_HOST)
.addPathSegment("login")
.addPathSegment("oauth")
.addPathSegment("authorize")
.addQueryParameter("client_id", client.getApiClient())
.addQueryParameter("scope", initialScope);

final List<ResolveInfo> browserList = getBrowserList();

final List<LabeledIntent> intentList = new ArrayList<>();

for (final ResolveInfo resolveInfo : browserList) {
final Intent newIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
final Intent newIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url.build().toString()));
newIntent.setComponent(new ComponentName(resolveInfo.activityInfo.packageName,
resolveInfo.activityInfo.name));

Expand Down
10 changes: 0 additions & 10 deletions app/src/main/res/values/config.xml
@@ -1,14 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="account_type">com.github</string>

<!--The values below are needed for running the app-->
<string name="github_client"></string>

<string name="github_secret"></string>

<string name="github_oauth"></string>

//The thing before the "://..." in github_oauth, used for identifying the intent call
<string name="github_oauth_scheme"></string>
</resources>

0 comments on commit 17f19f4

Please sign in to comment.