Skip to content

Commit

Permalink
Added ability to run release and debug app "simultaneously"
Browse files Browse the repository at this point in the history
  • Loading branch information
Meisolsson committed Jan 26, 2018
1 parent 865d1cb commit a93a7df
Show file tree
Hide file tree
Showing 19 changed files with 105 additions and 141 deletions.
21 changes: 21 additions & 0 deletions app/build.gradle
Expand Up @@ -19,6 +19,13 @@ def preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
def clientIdIsNotSet = true;
def clientSecretIsNotSet = true;

def addConfigValues = { name, isDebug, suffix = "" ->
def value = (isDebug ? "com.github.debug" : "com.github") + suffix

android.defaultConfig.buildConfigField "String", name, "\"${value}\""
android.defaultConfig.resValue "string", name.toLowerCase(), value
}

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
Expand All @@ -31,6 +38,11 @@ android {
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
vectorDrawables.useSupportLibrary = true

addConfigValues("ACCOUNT_TYPE", false)
addConfigValues("PROVIDER_AUTHORITY_SYNC", false, ".sync")
addConfigValues("PROVIDER_AUTHORITY_SEARCH_SUGGEST_ISSUES", false, ".search.suggest.recent.issues")
addConfigValues("PROVIDER_AUTHORITY_SEARCH_SUGGEST_REPOS", false, ".search.suggest.recent.repos")

if (project.hasProperty('pockethub_github_client')) {
resValue "string", "github_client", pockethub_github_client
clientIdIsNotSet = false
Expand Down Expand Up @@ -67,7 +79,16 @@ android {
resValue "string", "github_oauth_scheme", oauth.split("://")[0]
}


buildTypes {
debug {
addConfigValues("ACCOUNT_TYPE", true)
addConfigValues("PROVIDER_AUTHORITY_SYNC", true, ".sync")
addConfigValues("PROVIDER_AUTHORITY_SEARCH_SUGGEST_ISSUES", true, ".search.suggest.recent.issues")
addConfigValues("PROVIDER_AUTHORITY_SEARCH_SUGGEST_REPOS", true, ".search.suggest.recent.repos")
applicationIdSuffix ".debug"
}

release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
Expand Down
Binary file added app/src/debug/res/drawable-hdpi/app_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/debug/res/drawable-mdpi/app_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/debug/res/drawable-xhdpi/app_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/debug/res/drawable-xxhdpi/app_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/debug/res/drawable-xxxhdpi/app_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/src/debug/res/values/strings.xml
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name" translatable="false">PocketHub Debug</string>
</resources>
115 changes: 58 additions & 57 deletions app/src/main/AndroidManifest.xml

Large diffs are not rendered by default.

Expand Up @@ -36,7 +36,7 @@ public class Intents {
/**
* Prefix for all intents created
*/
public static final String INTENT_PREFIX = "com.github.pockethub.android.";
public static final String INTENT_PREFIX = BuildConfig.APPLICATION_ID + ".";

/**
* Prefix for all extra data added to intents
Expand Down
Expand Up @@ -24,10 +24,12 @@
import android.os.Bundle;
import android.text.TextUtils;

import com.github.pockethub.android.BuildConfig;

import static android.accounts.AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE;
import static android.accounts.AccountManager.KEY_BOOLEAN_RESULT;
import static android.accounts.AccountManager.KEY_INTENT;
import static com.github.pockethub.android.accounts.AccountConstants.ACCOUNT_TYPE;
import static com.github.pockethub.android.BuildConfig.ACCOUNT_TYPE;
import static com.github.pockethub.android.accounts.LoginActivity.PARAM_AUTHTOKEN_TYPE;
import static com.github.pockethub.android.accounts.LoginActivity.PARAM_USERNAME;

Expand Down

This file was deleted.

Expand Up @@ -29,6 +29,7 @@
import android.util.Log;

import com.afollestad.materialdialogs.MaterialDialog;
import com.github.pockethub.android.BuildConfig;
import com.github.pockethub.android.R;
import com.meisolsson.githubsdk.model.User;

Expand All @@ -39,7 +40,7 @@

import static android.accounts.AccountManager.KEY_ACCOUNT_NAME;
import static android.util.Log.DEBUG;
import static com.github.pockethub.android.accounts.AccountConstants.ACCOUNT_TYPE;
import static com.github.pockethub.android.BuildConfig.ACCOUNT_TYPE;

/**
* Helpers for accessing {@link AccountManager}
Expand Down Expand Up @@ -74,8 +75,7 @@ public static boolean hasAuthenticator(final AccountManager manager) {
for (AuthenticatorDescription descriptor : types) {
if (descriptor != null
&& ACCOUNT_TYPE.equals(descriptor.type)) {
HAS_AUTHENTICATOR = "com.github.pockethub.android"
.equals(descriptor.packageName);
HAS_AUTHENTICATOR = BuildConfig.APPLICATION_ID.equals(descriptor.packageName);
break;
}
}
Expand Down
Expand Up @@ -28,6 +28,7 @@
import android.widget.Toast;

import com.afollestad.materialdialogs.MaterialDialog;
import com.github.pockethub.android.BuildConfig;
import com.github.pockethub.android.R;
import com.github.pockethub.android.rx.AutoDisposeUtils;
import com.github.pockethub.android.ui.MainActivity;
Expand All @@ -47,8 +48,6 @@
import io.reactivex.schedulers.Schedulers;
import okhttp3.HttpUrl;

import static com.github.pockethub.android.accounts.AccountConstants.PROVIDER_AUTHORITY;

/**
* Activity to login
*/
Expand Down Expand Up @@ -80,10 +79,10 @@ public class LoginActivity extends AccountAuthenticatorAppCompatActivity {
public static void configureSyncFor(Account account) {
Log.d(TAG, "Configuring account sync");

ContentResolver.setIsSyncable(account, PROVIDER_AUTHORITY, 1);
ContentResolver.setSyncAutomatically(account, PROVIDER_AUTHORITY, true);
ContentResolver.addPeriodicSync(account, PROVIDER_AUTHORITY,
new Bundle(), SYNC_PERIOD);
ContentResolver.setIsSyncable(account, BuildConfig.PROVIDER_AUTHORITY_SYNC, 1);
ContentResolver.setSyncAutomatically(account, BuildConfig.PROVIDER_AUTHORITY_SYNC, true);
ContentResolver.addPeriodicSync(account, BuildConfig.PROVIDER_AUTHORITY_SYNC,
new Bundle(), SYNC_PERIOD);
}

private AccountManager accountManager;
Expand Down
Expand Up @@ -19,13 +19,15 @@
import android.content.SearchRecentSuggestionsProvider;
import android.provider.SearchRecentSuggestions;

import com.github.pockethub.android.BuildConfig;

/**
* Suggestions provider for recently searched for issue queries
*/
public class IssueSearchSuggestionsProvider extends
SearchRecentSuggestionsProvider {

private static final String AUTHORITY = "com.github.search.suggest.recent.issues";
private static final String AUTHORITY = BuildConfig.PROVIDER_AUTHORITY_SEARCH_SUGGEST_ISSUES;

/**
* Save query to history
Expand Down
Expand Up @@ -19,13 +19,15 @@
import android.content.SearchRecentSuggestionsProvider;
import android.provider.SearchRecentSuggestions;

import com.github.pockethub.android.BuildConfig;

/**
* Suggestions provider for recently searched for repository queries
*/
public class RepositorySearchSuggestionsProvider extends
SearchRecentSuggestionsProvider {

private static final String AUTHORITY = "com.github.search.suggest.recent.repos";
private static final String AUTHORITY = BuildConfig.PROVIDER_AUTHORITY_SEARCH_SUGGEST_REPOS;

/**
* Save query to history
Expand Down
20 changes: 0 additions & 20 deletions app/src/main/res/values/config.xml

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/main/res/xml/searchable_issues.xml
Expand Up @@ -17,6 +17,6 @@
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:hint="@string/find_issues"
android:label="@string/app_name"
android:searchSuggestAuthority="com.github.search.suggest.recent.issues"
android:searchSuggestAuthority="@string/provider_authority_search_suggest_issues"
android:searchSuggestSelection=" ?"
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" />
2 changes: 1 addition & 1 deletion app/src/main/res/xml/searchable_repos_users.xml
Expand Up @@ -17,6 +17,6 @@
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:hint="@string/global_search"
android:label="@string/app_name"
android:searchSuggestAuthority="com.github.search.suggest.recent.repos"
android:searchSuggestAuthority="@string/provider_authority_search_suggest_repos"
android:searchSuggestSelection=" ?"
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" />
4 changes: 2 additions & 2 deletions app/src/main/res/xml/sync_adapter.xml
Expand Up @@ -15,6 +15,6 @@
~ limitations under the License.
-->
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="com.github"
android:contentAuthority="com.github.sync"
android:accountType="@string/account_type"
android:contentAuthority="@string/provider_authority_sync"
android:supportsUploading="false" />

0 comments on commit a93a7df

Please sign in to comment.