Skip to content

Commit

Permalink
Merge branch 'release/4.4-beta7'
Browse files Browse the repository at this point in the history
  • Loading branch information
yukuku committed Sep 1, 2016
2 parents ece0b8a + 9c647a1 commit f256d18
Show file tree
Hide file tree
Showing 74 changed files with 1,356 additions and 991 deletions.
7 changes: 4 additions & 3 deletions Alkitab/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ android {
applicationId 'yuku.alkitab.debug'
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 14000266
versionName '4.4.0-beta6'
versionCode 14000267
versionName '4.4.0-beta7'
multiDexEnabled true
// Keep this synced with build.gradle resConfigs!
resConfigs 'af', 'bg', 'cs', 'da', 'de', 'es', 'fr', 'in', 'ja', 'lv', 'ms', 'nl', 'pl', 'pt', 'ro', 'ru', 'th', 'uk', 'zh-rCN', 'zh-rTW'
Expand Down Expand Up @@ -93,6 +93,7 @@ dependencies {
debugCompile "com.facebook.stetho:stetho-okhttp3:$stethoVersion"
compile "com.android.support:support-v4:$supportLibVersion"
compile "com.squareup.picasso:picasso:$picassoVersion"
compile "com.jakewharton.picasso:picasso2-okhttp3-downloader:1.0.2"
compile "com.squareup.okhttp3:okhttp:$okhttpVersion"
compile "com.squareup.okhttp3:okhttp-urlconnection:$okhttpVersion"
compile 'net.sf.trove4j:trove4j:3.0.3'
Expand All @@ -103,5 +104,5 @@ dependencies {
compile 'com.android.support:multidex:1.0.1'
compile "com.android.support:design:$supportLibVersion"
compile "com.android.support:percent:$supportLibVersion"
compile "com.android.support:preference-v14:$supportLibVersion"
compile "com.takisoft.fix:preference-v7:$supportLibVersion.0"
}
42 changes: 15 additions & 27 deletions Alkitab/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="yuku.alkitab.debug"
<manifest package="yuku.alkitab.debug"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto">
Expand Down Expand Up @@ -72,21 +71,17 @@
<activity
android:name="yuku.alkitab.base.ac.SettingsActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection"
android:label="@string/pengaturan_alkitab"
android:theme="@style/Theme.Alkitab.WithActionBar.AppCompat" />
android:label="@string/pengaturan_alkitab" />
<activity
android:name="yuku.alkitab.base.ac.ColorSettingsActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection"
android:theme="@style/Theme.Alkitab.WithActionBar.AppCompat" />
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection" />
<activity
android:name="yuku.alkitab.base.ac.MarkersActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection"
android:label="@string/activity_title_markers"
android:theme="@style/Theme.Alkitab.WithActionBar.AppCompat" />
android:label="@string/activity_title_markers" />
<activity
android:name="yuku.alkitab.base.ac.MarkerListActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection"
android:theme="@style/Theme.Alkitab.WithActionBar.AppCompat"
android:windowSoftInputMode="adjustResize|stateHidden" />
<activity
android:name="yuku.alkitab.base.ac.VersionsActivity"
Expand Down Expand Up @@ -265,8 +260,7 @@
</activity>
<activity
android:name="yuku.alkitab.base.ac.HelpActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection"
android:theme="@style/Theme.Alkitab.WithActionBar.AppCompat">
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="yuku.alkitab.base.ac.AboutActivity" />
Expand All @@ -281,12 +275,11 @@
</activity>
<activity
android:name="yuku.alkitab.base.ac.ShareActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection"
android:theme="@style/Theme.Alkitab.WithActionBar.AppCompat" />
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection" />
<activity
android:name="yuku.alkitab.base.ac.FontManagerActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection"
android:theme="@style/Theme.Alkitab.WithActionBar.AppCompat" />
android:label="@string/fm_activity_title" />
<activity
android:name="yuku.alkitab.base.ac.SongListActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection"
Expand All @@ -295,12 +288,12 @@
android:windowSoftInputMode="adjustResize|stateHidden" />
<activity
android:name="yuku.alkitab.base.ac.SongViewActivity"
android:label="@string/sn_songs_activity_title"
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection" />
<activity
android:name="yuku.alkitab.base.ac.SecretSettingsActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection"
android:label="Secret settings"
android:theme="@style/Theme.Alkitab.WithActionBar.AppCompat" />
android:label="Secret settings" />
<activity
android:name="yuku.alkitab.base.ac.SecretSyncDebugActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection"
Expand All @@ -311,26 +304,22 @@
<activity
android:name="yuku.alkitab.base.ac.PatchTextActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection"
android:theme="@style/Theme.Alkitab.WithActionBar.AppCompat"
android:windowSoftInputMode="adjustResize" />
<activity
android:name="yuku.alkitab.base.sync.SyncSettingsActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection"
android:theme="@style/Theme.Alkitab.WithActionBar.AppCompat" />
android:label="@string/sync_status_activity_title" />
<activity
android:name="yuku.alkitab.base.sync.SyncLogActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection"
android:label="@string/sync_log_activity_title"
android:theme="@style/Theme.Alkitab.WithActionBar.AppCompat" />
android:label="@string/sync_log_activity_title"/>
<activity
android:name="yuku.alkitab.base.sync.SyncLoginActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection"
android:label="@string/sync_login_activity_title"
android:theme="@style/Theme.Alkitab.WithActionBar.AppCompat" />
android:label="@string/sync_login_activity_title" />
<activity
android:name="yuku.filechooser.FileChooserActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection"
android:theme="@style/Theme.Alkitab.WithActionBar.AppCompat" />
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection" />
<activity
android:name="com.example.android.wizardpager.MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection"
Expand All @@ -348,7 +337,7 @@
<activity
android:name="yuku.alkitab.base.ac.DailyVerseAppWidgetConfigurationActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection"
android:theme="@style/Theme.Alkitab.WithActionBar.AppCompat">
android:label="@string/dv_activity_title">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
Expand Down Expand Up @@ -496,8 +485,7 @@
<activity
android:name="yuku.alkitab.reminder.ac.DevotionReminderActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection"
android:label="@string/dr_app_name"
android:theme="@style/Theme.Alkitab.WithActionBar.AppCompat" />
android:label="@string/dr_app_name" />

<receiver android:name="yuku.alkitab.reminder.br.DevotionReminderReceiver" />
<receiver android:name="yuku.alkitab.reminder.br.BootCompleteReceiver">
Expand Down
106 changes: 72 additions & 34 deletions Alkitab/src/main/java/yuku/alkitab/base/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.multidex.MultiDex;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.preference.PreferenceManager;
Expand All @@ -12,7 +14,10 @@
import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;
import com.google.gson.Gson;
import com.jakewharton.picasso.OkHttp3Downloader;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.picasso.Picasso;
import okhttp3.Cache;
import okhttp3.Call;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
Expand All @@ -25,13 +30,15 @@
import yuku.alkitab.base.storage.Prefkey;
import yuku.alkitab.base.sync.Gcm;
import yuku.alkitab.base.sync.Sync;
import yuku.alkitab.debug.BuildConfig;
import yuku.alkitab.debug.R;
import yuku.alkitab.reminder.util.DevotionReminder;
import yuku.alkitabfeedback.FeedbackSender;
import yuku.alkitabintegration.display.Launcher;
import yuku.kirimfidbek.CrashReporter;
import yuku.stethoshim.StethoShim;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.Locale;
Expand All @@ -45,39 +52,29 @@ public class App extends yuku.afw.App {
private static boolean initted = false;
private static Tracker APP_TRACKER;

static final Interceptor userAgent = chain -> {
final Request originalRequest = chain.request();
final Request requestWithUserAgent = originalRequest.newBuilder()
.removeHeader("User-Agent")
.addHeader("User-Agent", Version.userAgent() + " " + App.context.getPackageName() + "/" + App.getVersionName())
.build();
return chain.proceed(requestWithUserAgent);
};

enum OkHttpClientWrapper {
INSTANCE;

final OkHttpClient defaultClient;
final OkHttpClient longTimeoutClient;

{
final Interceptor userAgent = chain -> {
final Request originalRequest = chain.request();
final Request requestWithUserAgent = originalRequest.newBuilder()
.removeHeader("User-Agent")
.addHeader("User-Agent", Version.userAgent() + " " + App.context.getPackageName() + "/" + App.getVersionName())
.build();
return chain.proceed(requestWithUserAgent);
};

{
final OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.addNetworkInterceptor(userAgent);
StethoShim.addNetworkInterceptor(builder);
defaultClient = builder.build();
}

{
final OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder
.addNetworkInterceptor(userAgent)
.connectTimeout(300, TimeUnit.SECONDS)
.readTimeout(300, TimeUnit.SECONDS)
.writeTimeout(600, TimeUnit.SECONDS);
StethoShim.addNetworkInterceptor(builder);
longTimeoutClient = builder.build();
}
final OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder
.addNetworkInterceptor(userAgent)
.connectTimeout(300, TimeUnit.SECONDS)
.readTimeout(300, TimeUnit.SECONDS)
.writeTimeout(600, TimeUnit.SECONDS);
StethoShim.addNetworkInterceptor(builder);
longTimeoutClient = builder.build();
}
}

Expand All @@ -88,19 +85,15 @@ enum GsonWrapper {
}

public static String downloadString(String url) throws IOException {
return OkHttpClientWrapper.INSTANCE.defaultClient.newCall(new Request.Builder().url(url).build()).execute().body().string();
return downloadCall(url).execute().body().string();
}

public static byte[] downloadBytes(String url) throws IOException {
return OkHttpClientWrapper.INSTANCE.defaultClient.newCall(new Request.Builder().url(url).build()).execute().body().bytes();
return downloadCall(url).execute().body().bytes();
}

public static Call downloadCall(String url) {
return OkHttpClientWrapper.INSTANCE.defaultClient.newCall(new Request.Builder().url(url).build());
}

public static OkHttpClient getOkHttpClient() {
return OkHttpClientWrapper.INSTANCE.defaultClient;
return okhttp().newCall(new Request.Builder().url(url).build());
}

public static OkHttpClient getLongTimeoutOkHttpClient() {
Expand Down Expand Up @@ -268,4 +261,49 @@ public static void trackEvent(final String category, final String action) {
eventSubmitter.submit(() -> tracker.send(new HitBuilders.EventBuilder(category, action).build()));
}
}

private static OkHttpClient okhttp;

@NonNull
public static synchronized OkHttpClient okhttp() {
OkHttpClient res = okhttp;
if (res == null) {
final File cacheDir = new File(context.getCacheDir(), "okhttp-cache");
if (!cacheDir.exists()) {
//noinspection ResultOfMethodCallIgnored
cacheDir.mkdirs();
}

final OkHttpClient.Builder builder = new OkHttpClient.Builder()
.cache(new Cache(cacheDir, 50 * 1024 * 1024))
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.writeTimeout(30, TimeUnit.SECONDS)
.addNetworkInterceptor(userAgent);

if (BuildConfig.DEBUG) {
builder.hostnameVerifier((hostname, session) -> true);
}

StethoShim.addNetworkInterceptor(builder);

okhttp = res = builder.build();
}
return res;
}

static Picasso picasso;

@NonNull
public static synchronized Picasso picasso() {
Picasso res;
if (picasso == null) {
picasso = res = new Picasso.Builder(context)
.defaultBitmapConfig(Bitmap.Config.RGB_565)
.downloader(new OkHttp3Downloader(okhttp()))
.build();
return res;
}
return picasso;
}
}
Loading

0 comments on commit f256d18

Please sign in to comment.