Skip to content

Commit

Permalink
Merge pull request #1204 from kiwix/macgills/hotfix/use-http
Browse files Browse the repository at this point in the history
- Use http instead of https - Increase read timeout - bump abi codes …
  • Loading branch information
macgills authored Jun 19, 2019
2 parents d10c2e3 + e680155 commit 7da84c0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
26 changes: 19 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ dependencies {
//update this with androidx
testImplementation 'com.jraska.livedata:testing-ktx:0.2.1'
testImplementation 'android.arch.core:core-testing:1.1.1'

}

// Set custom app import directory
Expand Down Expand Up @@ -189,15 +188,28 @@ def buildNumber = System.getenv('TRAVIS_BUILD_NUMBER') ?: "dev"
ext {
versionMajor = 2
versionMinor = 5
versionPatch = 0
versionPatch = 1
}

private String generateVersionName() {
"${ext.versionMajor}.${ext.versionMinor}.${ext.versionPatch}"
}

/*
* max version code: 210-0-00-00-00
* our template : UUU-A-ZZ-YY-XX
* where:
* X = patch version
* Y = minor version
* Z = major version (+ 20 to distinguish from previous, non semantic, versions of the app)
* A = number representing ABI split
* U = unused
*/
private Integer generateVersionCode() {
200000 + (ext.versionMajor * 10000) + (ext.versionMinor * 100) + (ext.versionPatch)
20 * 10000 +
(ext.versionMajor * 10000) +
(ext.versionMinor * 100) +
(ext.versionPatch)
}

android {
Expand Down Expand Up @@ -259,7 +271,7 @@ android {

// Main build type for debugging
debug {
buildConfigField "String", "KIWIX_DOWNLOAD_URL", "\"http://download.kiwix.org/\""
buildConfigField "String", "KIWIX_DOWNLOAD_URL", "\"http://mirror.download.kiwix.org/\""
buildConfigField "boolean", "KIWIX_ERROR_ACTIVITY", "false"
testCoverageEnabled true
}
Expand All @@ -279,7 +291,7 @@ android {
// Release Type
release {
signingConfig signingConfigs.release
buildConfigField "String", "KIWIX_DOWNLOAD_URL", "\"http://download.kiwix.org/\""
buildConfigField "String", "KIWIX_DOWNLOAD_URL", "\"http://mirror.download.kiwix.org/\""
buildConfigField "boolean", "KIWIX_ERROR_ACTIVITY", "false"
}
}
Expand Down Expand Up @@ -425,13 +437,13 @@ android {
experimental = true
}

def abiCodes = ['arm64-v8a': 5, 'x86': 2, 'x86_64': 3, 'armeabi-v7a': 4]
def abiCodes = ['arm64-v8a': 6, 'x86': 3, 'x86_64': 4, 'armeabi-v7a': 5]
splits {
abi {
enable true
reset()
include "x86", "x86_64", 'armeabi-v7a', "arm64-v8a"
universalApk false
universalApk buildNumber == "dev"
}
}
applicationVariants.all { variant ->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
android:icon="@mipmap/kiwix_icon"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:networkSecurityConfig="@xml/network_security_config"
android:supportsRtl="true">

<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,24 @@
import javax.inject.Singleton;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import okhttp3.logging.HttpLoggingInterceptor.Level;
import org.kiwix.kiwixmobile.BuildConfig;
import org.kiwix.kiwixmobile.network.KiwixService;
import org.kiwix.kiwixmobile.network.UserAgentInterceptor;

@Module public class NetworkModule {

public static String KIWIX_DOWNLOAD_URL = BuildConfig.KIWIX_DOWNLOAD_URL; //"http://download.kiwix.org/";
public static String KIWIX_DOWNLOAD_URL = BuildConfig.KIWIX_DOWNLOAD_URL;
//"http://download.kiwix.org/";
private final static String useragent = "kiwix-android-version:" + BuildConfig.VERSION_CODE;

@Provides @Singleton OkHttpClient provideOkHttpClient() {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BASIC);
logging.setLevel(BuildConfig.DEBUG ? Level.BODY : Level.BASIC);

return new OkHttpClient().newBuilder().followRedirects(true).followSslRedirects(true)
.connectTimeout(10, TimeUnit.SECONDS)
.readTimeout(10, TimeUnit.SECONDS)
.readTimeout(20, TimeUnit.SECONDS)
.addNetworkInterceptor(logging)
.addNetworkInterceptor(new UserAgentInterceptor(useragent)).build();
}
Expand All @@ -53,5 +55,4 @@
ConnectivityManager provideConnectivityManager(Context context) {
return (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
}

}
6 changes: 6 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,6 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">kiwix.org</domain>
</domain-config>
</network-security-config>

0 comments on commit 7da84c0

Please sign in to comment.