start using fabric for bug reporting

This commit is contained in:
Mariotaku Lee 2015-12-29 15:26:52 +08:00
parent 70dce6fc07
commit 5e31c1f643
14 changed files with 65 additions and 57 deletions

View File

@ -1,8 +1,18 @@
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
import fr.avianey.androidsvgdrawable.gradle.SvgDrawableTask
import java.text.SimpleDateFormat
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'androidsvgdrawable'
@ -52,6 +62,7 @@ android {
repositories {
maven { url 'https://s3.amazonaws.com/repo.commonsware.com' }
maven { url 'https://maven.fabric.io/public' }
flatDir { dirs "$projectDir/lib" }
}
@ -88,13 +99,12 @@ dependencies {
compile 'org.apache.commons:commons-lang3:3.4'
compile 'commons-primitives:commons-primitives:1.0'
compile 'com.bluelinelabs:logansquare:1.3.4'
compile 'ch.acra:acra:4.7.0'
compile 'org.jraf:android-switch-backport:2.0.1'
compile 'com.github.FasterXML:jackson-jr-trees:5baf62567e'
compile 'com.makeramen:roundedimageview:2.1.1'
compile 'com.soundcloud.android:android-crop:1.0.1@aar'
compile 'com.hannesdorfmann.parcelableplease:annotation:1.0.1'
compile 'com.github.mariotaku:PickNCrop:1dff3ed574'
compile 'com.github.mariotaku:PickNCrop:6c9d888a9d'
compile 'com.github.mariotaku.RestFu:library:0.9.8'
compile 'com.github.mariotaku.RestFu:okhttp:0.9.8'
compile 'com.diogobernardino:williamchart:2.1'
@ -114,6 +124,9 @@ dependencies {
compile fileTree(dir: 'libs/main', include: ['*.jar'])
provided 'javax.annotation:jsr250-api:1.0'
// googleCompile fileTree(dir: 'libs/google', include: ['*.jar'])
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true;
}
}
task svgToDrawable(type: SvgDrawableTask) {

View File

@ -77,6 +77,10 @@
android:name="com.sec.android.app.multiwindow"
android:required="false"/>
<meta-data
android:name="io.fabric.ApiKey"
android:value="dc4ee756d3b705e00011782f1426fc8656ad3bd9" />
<meta-data
android:name="com.google.android.backup.api_key"
android:value="AEdPqrEAAAAIKbKATV1AGbLB4kem3w8QaPVJSPVVumbMHxkfwA"/>

View File

@ -23,7 +23,9 @@ import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.view.MarginLayoutParamsCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.WindowCompat;
import android.view.View;
import android.view.WindowManager;
@ -61,11 +63,11 @@ public class ImageCropperActivity extends CropImageActivity implements IThemedAc
}
@Override
public void onCreate(final Bundle icicle) {
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
super.onCreate(icicle);
final int themeColor = getThemeColor();
final int themeResId = getCurrentThemeResourceId();
final String backgroundOption = getCurrentThemeBackgroundOption();

View File

@ -1114,9 +1114,8 @@ public class ComposeActivity extends ThemedFragmentActivity implements OnMenuIte
* Has media & Not reply: [Take photo][Media menu][Attach location][Drafts]
* Is reply: [Media menu][View status][Attach location][Drafts]
*/
MenuUtils.setMenuItemAvailability(menu, R.id.take_photo, hasInReplyTo);
MenuUtils.setMenuItemAvailability(menu, R.id.add_image, !hasMedia && !hasInReplyTo);
MenuUtils.setMenuItemAvailability(menu, R.id.media_menu, hasMedia || hasInReplyTo);
MenuUtils.setMenuItemAvailability(menu, R.id.add_image, !hasMedia);
MenuUtils.setMenuItemAvailability(menu, R.id.media_menu, hasMedia);
MenuUtils.setMenuItemAvailability(menu, R.id.toggle_sensitive, hasMedia);
MenuUtils.setMenuItemAvailability(menu, R.id.link_to_quoted_status, isQuote());
MenuUtils.setMenuItemAvailability(menu, R.id.schedule, isScheduleSupported());

View File

@ -435,6 +435,11 @@ public class HomeActivity extends BaseAppCompatActivity implements OnClickListen
@Override
protected void onResume() {
super.onResume();
if (ThemeUtils.isDarkTheme(getCurrentThemeResourceId())) {
// TODO show dark bar
} else {
ActivitySupport.setTaskDescription(this, new TaskDescriptionCompat(null, null, getThemeColor()));
}
sendBroadcast(new Intent(BROADCAST_HOME_ACTIVITY_ONRESUME));
invalidateOptionsMenu();
updateActionsButtonStyle();
@ -794,7 +799,6 @@ public class HomeActivity extends BaseAppCompatActivity implements OnClickListen
mTabIndicator.setStripColor(contrastColor);
mTabIndicator.setIconColor(contrastColor);
mTabIndicator.setLabelColor(contrastColor);
ActivitySupport.setTaskDescription(this, new TaskDescriptionCompat(null, null, themeColor));
}
mHomeContent.setDrawColor(true);
mHomeContent.setDrawShadow(false);

View File

@ -237,7 +237,6 @@ public class LinkHandlerActivity extends BaseAppCompatActivity implements System
}
mMainContent.setOnFitSystemWindowsListener(this);
setStatusBarColor(linkId, data);
setTaskInfo(linkId, data);
Utils.logOpenNotificationFromUri(this, data);
if (!showFragment(linkId, data)) {
finish();
@ -395,21 +394,6 @@ public class LinkHandlerActivity extends BaseAppCompatActivity implements System
StatusBarProxy.setStatusBarDarkIcon(getWindow(), TwidereColorUtils.getYIQLuminance(statusBarColor) > ThemeUtils.ACCENT_COLOR_THRESHOLD);
}
private void setTaskInfo(int linkId, Uri uri) {
switch (linkId) {
// case LINK_ID_USER: {
// break;
// }
default: {
if (ThemeUtils.isColoredActionBar(getCurrentThemeResourceId())) {
ActivitySupport.setTaskDescription(this, new TaskDescriptionCompat(null, null,
getCurrentThemeColor()));
}
break;
}
}
}
private boolean showFragment(final int linkId, final Uri uri) {
final Intent intent = getIntent();
intent.setExtrasClassLoader(getClassLoader());
@ -589,6 +573,15 @@ public class LinkHandlerActivity extends BaseAppCompatActivity implements System
return mActionBarHeight = ThemeUtils.getActionBarHeight(this);
}
@Override
protected void onResume() {
super.onResume();
if (ThemeUtils.isColoredActionBar(getCurrentThemeResourceId())) {
ActivitySupport.setTaskDescription(this, new TaskDescriptionCompat(null, null,
getCurrentThemeColor()));
}
}
public ActionBarContainer getActionBarContainer() {
return mActionBarContainer;
}

View File

@ -39,7 +39,6 @@ import com.nostra13.universalimageloader.cache.disc.DiskCache;
import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache;
import com.squareup.okhttp.Dns;
import org.acra.annotation.ReportsCrashes;
import org.apache.commons.lang3.ArrayUtils;
import org.mariotaku.twidere.BuildConfig;
import org.mariotaku.twidere.Constants;
@ -67,9 +66,6 @@ import static org.mariotaku.twidere.util.Utils.getInternalCacheDir;
import static org.mariotaku.twidere.util.Utils.initAccountColor;
import static org.mariotaku.twidere.util.Utils.startRefreshServiceIfNeeded;
@ReportsCrashes(formUri = "https://twidere-bugreport.herokuapp.com/reports",
buildConfigClass = BuildConfig.class, sendReportsInDevMode = false,
sendReportsAtShutdown = false)
public class TwidereApplication extends MultiDexApplication implements Constants,
OnSharedPreferenceChangeListener {

View File

@ -108,6 +108,14 @@ public final class AsyncTaskManager {
return false;
}
public void cancel(final String tag) {
for (final ManagedAsyncTask<?, ?, ?> task : getTaskSpecList()) {
if (tag.equals(task.getTag())) {
task.cancel(true);
}
}
}
public boolean isExecuting(final int hashCode) {
final ManagedAsyncTask<?, ?, ?> task = findTask(hashCode);
return task != null && task.getStatus() == AsyncTask.Status.RUNNING;

View File

@ -20,14 +20,16 @@
package org.mariotaku.twidere.util;
import android.app.Application;
import android.os.AsyncTask;
import android.support.annotation.Nullable;
import android.util.Log;
import org.acra.ACRA;
import com.crashlytics.android.Crashlytics;
import org.mariotaku.twidere.BuildConfig;
import org.mariotaku.twidere.Constants;
import io.fabric.sdk.android.Fabric;
/**
* Created by mariotaku on 15/7/8.
*/
@ -58,28 +60,12 @@ public class TwidereBugReporter extends BugReporter implements Constants {
}
private void handleSilentException(final Throwable throwable) {
AsyncTask.execute(new Runnable() {
@Override
public void run() {
ACRA.getErrorReporter().handleSilentException(throwable);
}
});
Crashlytics.logException(throwable);
}
@Override
protected void initImpl(final Application application) {
// ACRA sets it self as DefaultUncaughtExceptionHandler, we hijack it to suppress some errors
ACRA.init(application);
// handler should be ACRA's ErrorReporter now
final Thread.UncaughtExceptionHandler handler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable ex) {
// We can't fix OOM, so just don't report it and try to save VM
if (Utils.isOutOfMemory(ex)) return;
handler.uncaughtException(thread, ex);
}
});
Fabric.with(application, new Crashlytics());
}
}

View File

@ -9,7 +9,6 @@ import android.net.SSLCertificateSocketFactory;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.UiThread;
import android.support.annotation.WorkerThread;
import android.text.TextUtils;
import android.webkit.URLUtil;
@ -144,11 +143,12 @@ public class TwitterAPIFactory implements TwidereConstants {
final boolean enableProxy = prefs.getBoolean(KEY_ENABLE_PROXY, false);
client.setConnectTimeout(connectionTimeout, TimeUnit.SECONDS);
final long connectionTimeoutMillis = TimeUnit.MILLISECONDS.convert(connectionTimeout, TimeUnit.SECONDS);
client.setReadTimeout(0, TimeUnit.SECONDS);
client.setWriteTimeout(0, TimeUnit.SECONDS);
final SSLSocketFactory sslSocketFactory;
if (ignoreSslError) {
// We intentionally use insecure connections
sslSocketFactory = SSLCertificateSocketFactory.getInsecure((int) connectionTimeoutMillis, null);
sslSocketFactory = SSLCertificateSocketFactory.getInsecure(0, null);
if (sslSocketFactory instanceof SSLCertificateSocketFactory) {
}

View File

@ -81,7 +81,8 @@ public class VideoLoader {
public int loadVideo(String uri, boolean forceReload, VideoLoadingListener listener) {
if (mTaskManager.hasRunningTasksForTag(uri)) {
return 0;
if (!forceReload) return 0;
mTaskManager.cancel(uri);
}
return mTaskManager.add(new PreLoadVideoTask(mContext, this, listener, uri, forceReload), true);
}

View File

@ -223,7 +223,7 @@ public class TwidereDns implements Constants, Dns {
for (final Record record : records) {
if (record instanceof CNAMERecord)
return resolveInternal(originalHost, ((CNAMERecord) record).getTarget().toString(),
+1);
depth + 1);
}
return null;
}

View File

@ -801,6 +801,7 @@
<string name="report_usage_statistics_now">Report usage statistics now</string>
<string name="cache_size_limit">Cache size limit</string>
<string name="bug_reports">Bug reports</string>
<string name="bug_reports_summary">Powered by Fabric</string>
<string name="invalid_consumer_key">Invalid consumer key</string>
<string name="invalid_consumer_secret">Invalid consumer secret</string>
<string name="page_up">Page up</string>

View File

@ -19,19 +19,20 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<Preference android:layout="@layout/header_usage_statistics" />
<Preference android:layout="@layout/header_usage_statistics"/>
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
android:defaultValue="false"
android:key="usage_statistics"
android:order="11"
android:title="@string/usage_statistics" />
android:title="@string/usage_statistics"/>
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
android:defaultValue="true"
android:key="bug_reports"
android:order="12"
android:title="@string/bug_reports" />
android:summary="@string/bug_reports_summary"
android:title="@string/bug_reports"/>
<PreferenceCategory
android:order="13"
@ -40,7 +41,7 @@
<Preference android:title="@string/research_hot_mobile">
<intent
android:action="android.intent.action.VIEW"
android:data="http://spice.hot-mobile.org/" />
android:data="http://spice.hot-mobile.org/"/>
</Preference>
</PreferenceCategory>