Search in sources :

Example 21 with Crashlytics

use of com.crashlytics.android.Crashlytics in project Awful.apk by Awful.

the class ThreadDisplayFragment method showUrlMenu.

private void showUrlMenu(final String url) {
    if (url == null) {
        Timber.w("Passed null URL to #showUrlMenu!");
        return;
    }
    FragmentManager fragmentManager = getFragmentManager();
    if (fragmentManager == null) {
        Timber.w("showUrlMenu called but can't get FragmentManager!");
        return;
    }
    boolean isImage = false;
    boolean isGif = false;
    // TODO: parsing fails on magic webdev urls like http://tpm2016.zoffix.com/#/40
    // it thinks the # is the start of the ref section of the url, so the Path for that url is '/'
    Uri path = Uri.parse(url);
    String lastSegment = path.getLastPathSegment();
    // null-safe path checking (there may be no path segments, e.g. a link to a domain name)
    if (lastSegment != null) {
        lastSegment = lastSegment.toLowerCase();
        // using 'contains' instead of 'ends with' in case of any url suffix shenanigans, like twitter's ".jpg:large"
        isImage = (StringUtils.indexOfAny(lastSegment, ".jpg", ".jpeg", ".png", ".gif") != -1 && !StringUtils.contains(lastSegment, ".gifv")) || (lastSegment.equals("attachment.php") && path.getHost().equals("forums.somethingawful.com"));
        isGif = StringUtils.contains(lastSegment, ".gif") && !StringUtils.contains(lastSegment, ".gifv");
    }
    // TODO: 28/04/2017 remove all this when Crashlytics #717 is fixed
    if (AwfulApplication.crashlyticsEnabled()) {
        Crashlytics.setString("Menu for URL:", url);
        Crashlytics.setInt("Thread ID", getThreadId());
        Crashlytics.setInt("Page", getPageNumber());
        FragmentActivity activity = getActivity();
        Crashlytics.setBool("Activity exists", activity != null);
        if (activity != null) {
            String state = "Activity:";
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                state += (activity.isDestroyed()) ? "IS_DESTROYED " : "";
            }
            state += (activity.isFinishing()) ? "IS_FINISHING" : "";
            state += (activity.isChangingConfigurations()) ? "IS_CHANGING_CONFIGURATIONS" : "";
            Crashlytics.setString("Activity state:", state);
        }
        Crashlytics.setBool("Thread display fragment resumed", isResumed());
        Crashlytics.setBool("Thread display fragment attached", isAdded());
        Crashlytics.setBool("Thread display fragment removing", isRemoving());
    }
    // //////////////////////////////////////////////////////////////////////
    UrlContextMenu linkActions = UrlContextMenu.newInstance(url, isImage, isGif, isGif ? "Getting file size" : null);
    if (isGif) {
        queueRequest(new ImageSizeRequest(url, result -> {
            if (linkActions == null) {
                return;
            }
            String size = result == null ? "unknown" : Formatter.formatShortFileSize(getContext(), result);
            linkActions.setSubheading(String.format("Size: %s", size));
        }));
    }
    linkActions.setTargetFragment(ThreadDisplayFragment.this, -1);
    linkActions.show(fragmentManager, "Link Actions");
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) JavascriptInterface(android.webkit.JavascriptInterface) IgnoreRequest(com.ferg.awfulapp.task.IgnoreRequest) Constants(com.ferg.awfulapp.constants.Constants) SwipyRefreshLayoutDirection(com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayoutDirection) Bundle(android.os.Bundle) AwfulRequest(com.ferg.awfulapp.task.AwfulRequest) RedirectTask(com.ferg.awfulapp.task.RedirectTask) PackageManager(android.content.pm.PackageManager) MarkLastReadRequest(com.ferg.awfulapp.task.MarkLastReadRequest) AwfulURL(com.ferg.awfulapp.thread.AwfulURL) Uri(android.net.Uri) BookmarkRequest(com.ferg.awfulapp.task.BookmarkRequest) CloseOpenRequest(com.ferg.awfulapp.task.CloseOpenRequest) SwipyRefreshLayout(com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout) ThreadDisplay(com.ferg.awfulapp.thread.ThreadDisplay) WebViewJsInterface(com.ferg.awfulapp.webview.WebViewJsInterface) StringUtils(org.apache.commons.lang3.StringUtils) Manifest(android.Manifest) CookieManager(android.webkit.CookieManager) Handler(android.os.Handler) Keys(com.ferg.awfulapp.preferences.Keys) Map(java.util.Map) WebViewClient(android.webkit.WebViewClient) View(android.view.View) CookieSyncManager(android.webkit.CookieSyncManager) WebView(android.webkit.WebView) LoaderManager(android.support.v4.app.LoaderManager) ColorProvider(com.ferg.awfulapp.provider.ColorProvider) FloatingActionButton(android.support.design.widget.FloatingActionButton) AwfulUtils(com.ferg.awfulapp.util.AwfulUtils) AsyncTask(android.os.AsyncTask) AwfulThread(com.ferg.awfulapp.thread.AwfulThread) MenuItemCompat(android.support.v4.view.MenuItemCompat) ContextCompat(android.support.v4.content.ContextCompat) PostContextMenu(com.ferg.awfulapp.popupmenu.PostContextMenu) ViewGroup(android.view.ViewGroup) Timber(timber.log.Timber) ContentObserver(android.database.ContentObserver) AwfulError(com.ferg.awfulapp.util.AwfulError) AlertDialog(android.app.AlertDialog) DownloadManager(android.app.DownloadManager) AwfulPost(com.ferg.awfulapp.thread.AwfulPost) List(java.util.List) TextView(android.widget.TextView) InflateException(android.view.InflateException) FragmentActivity(android.support.v4.app.FragmentActivity) SinglePostRequest(com.ferg.awfulapp.task.SinglePostRequest) ReportRequest(com.ferg.awfulapp.task.ReportRequest) Nullable(android.support.annotation.Nullable) Request(android.app.DownloadManager.Request) AwfulMessage(com.ferg.awfulapp.thread.AwfulMessage) Context(android.content.Context) VoteRequest(com.ferg.awfulapp.task.VoteRequest) AwfulProvider(com.ferg.awfulapp.provider.AwfulProvider) Environment(android.os.Environment) DownloadListener(android.webkit.DownloadListener) Intent(android.content.Intent) CursorLoader(android.support.v4.content.CursorLoader) ShareActionProvider(android.support.v7.widget.ShareActionProvider) HashMap(java.util.HashMap) NonNull(android.support.annotation.NonNull) LoggingWebChromeClient(com.ferg.awfulapp.webview.LoggingWebChromeClient) ProfileRequest(com.ferg.awfulapp.task.ProfileRequest) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) NetworkUtils(com.ferg.awfulapp.network.NetworkUtils) PageBar(com.ferg.awfulapp.widget.PageBar) MenuInflater(android.view.MenuInflater) Toast(android.widget.Toast) Menu(android.view.Menu) Build(android.os.Build) LinkedList(java.util.LinkedList) PostRequest(com.ferg.awfulapp.task.PostRequest) DialogInterface(android.content.DialogInterface) Cursor(android.database.Cursor) Formatter(android.text.format.Formatter) UrlContextMenu(com.ferg.awfulapp.popupmenu.UrlContextMenu) Loader(android.support.v4.content.Loader) AwfulTheme(com.ferg.awfulapp.provider.AwfulTheme) LayoutInflater(android.view.LayoutInflater) AwfulPreferences(com.ferg.awfulapp.preferences.AwfulPreferences) AwfulPagedItem(com.ferg.awfulapp.thread.AwfulPagedItem) TYPE(com.ferg.awfulapp.thread.AwfulURL.TYPE) TextUtils(android.text.TextUtils) VolleyError(com.android.volley.VolleyError) ResolveInfo(android.content.pm.ResolveInfo) Color(android.graphics.Color) PagePicker(com.ferg.awfulapp.widget.PagePicker) FragmentManager(android.support.v4.app.FragmentManager) Crashlytics(com.crashlytics.android.Crashlytics) AwfulWebView(com.ferg.awfulapp.webview.AwfulWebView) ImageSizeRequest(com.ferg.awfulapp.task.ImageSizeRequest) Activity(android.app.Activity) EditText(android.widget.EditText) ContentUris(android.content.ContentUris) FragmentActivity(android.support.v4.app.FragmentActivity) UrlContextMenu(com.ferg.awfulapp.popupmenu.UrlContextMenu) Uri(android.net.Uri) ImageSizeRequest(com.ferg.awfulapp.task.ImageSizeRequest)

Example 22 with Crashlytics

use of com.crashlytics.android.Crashlytics in project AndResGuard by shwenzhang.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fabric.with(this, new Crashlytics(), new CrashlyticsNdk());
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null).show();
        }
    });
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
}
Also used : NavigationView(android.support.design.widget.NavigationView) CrashlyticsNdk(com.crashlytics.android.ndk.CrashlyticsNdk) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) FloatingActionButton(android.support.design.widget.FloatingActionButton) DrawerLayout(android.support.v4.widget.DrawerLayout) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) Crashlytics(com.crashlytics.android.Crashlytics) Toolbar(android.support.v7.widget.Toolbar)

Example 23 with Crashlytics

use of com.crashlytics.android.Crashlytics in project Just-Another-Android-App by athkalia.

the class App method initFabric.

/**
 * Setup Fabric. We also set the build time and sha key so that we can easily reproduce bug reports.
 *
 * Note 1: To send an exception to crashlytics use {@link Crashlytics#logException(Throwable)}. It will send a non-fatal exception.
 * This is reported separately in the crashlytics dashboard. See
 * https://docs.fabric.io/android/crashlytics/caught-exceptions.html?caught%20exceptions#caught-exceptions for more details.
 *
 * Note 2: To log a statement in Crashlytics use {@link Crashlytics#log(String)}. This log statement will appear when clicking on a
 * specific crash report. For example if you have a crash that occurred 10 times, one would need to click through all 10 instances of
 * that crash to see the individual log statements for every instance of this crash.
 * See https://docs.fabric.io/android/crashlytics/enhanced-reports.html for more info.
 *
 * Note 3: To log a key-value pair in Crashlytics use {@link Crashlytics#setString(String, String)}. Same concept as logging a
 * statement described in Note 2.
 */
private void initFabric() {
    CrashlyticsCore crashlyticsCore = new CrashlyticsCore.Builder().disabled(// 'debug' builds not using fabric, 'qa' and 'release' do.
    "debug".equals(BuildConfig.BUILD_TYPE)).build();
    Crashlytics crashlytics = new Crashlytics.Builder().core(crashlyticsCore).build();
    Answers answers = new Answers();
    final Fabric fabric = new Fabric.Builder(getApplicationContext()).kits(crashlytics, answers).debuggable(// 'debug' and 'qa' build types have extra log statements, 'release' build type doesn't.
    BuildConfig.DEBUG).build();
    Fabric.with(fabric);
    Crashlytics.setString("GIT_SHA_KEY", BuildConfig.GIT_SHA);
    Crashlytics.setString("BUILD_TIME", BuildConfig.BUILD_TIME);
}
Also used : CrashlyticsCore(com.crashlytics.android.core.CrashlyticsCore) Answers(com.crashlytics.android.answers.Answers) Fabric(io.fabric.sdk.android.Fabric) Crashlytics(com.crashlytics.android.Crashlytics)

Example 24 with Crashlytics

use of com.crashlytics.android.Crashlytics in project jianshi by wingjay.

the class JianShiApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    appComponent = DaggerAppComponent.builder().appModule(new AppModule(JianShiApplication.this)).build();
    final Fabric fabric = new Fabric.Builder(this).kits(new Crashlytics()).debuggable(true).build();
    Fabric.with(fabric);
    Stetho.initializeWithDefaults(this);
    instance = this;
    FlowManager.init(new FlowConfig.Builder(this).openDatabasesOnInit(true).build());
    initLog();
    CalligraphyConfig.initDefault(new CalligraphyConfig.Builder().setDefaultFontPath("fonts/jianshi_default.otf").setFontAttrId(R.attr.fontPath).build());
}
Also used : FlowConfig(com.raizlabs.android.dbflow.config.FlowConfig) AppModule(com.wingjay.jianshi.di.AppModule) Fabric(io.fabric.sdk.android.Fabric) Crashlytics(com.crashlytics.android.Crashlytics)

Example 25 with Crashlytics

use of com.crashlytics.android.Crashlytics in project MusicDNA by harjot-oberai.

the class MusicDNAApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    Fabric.with(this, new Crashlytics());
    refWatcher = LeakCanary.install(this);
}
Also used : Crashlytics(com.crashlytics.android.Crashlytics)

Aggregations

Crashlytics (com.crashlytics.android.Crashlytics)51 SharedPreferences (android.content.SharedPreferences)6 Handler (android.os.Handler)6 Intent (android.content.Intent)5 Timber (timber.log.Timber)5 View (android.view.View)4 PackageInfo (android.content.pm.PackageInfo)3 PackageManager (android.content.pm.PackageManager)3 StrictMode (android.os.StrictMode)3 Fabric (io.fabric.sdk.android.Fabric)3 File (java.io.File)3 Manifest (android.Manifest)2 SuppressLint (android.annotation.SuppressLint)2 ContentUris (android.content.ContentUris)2 DialogInterface (android.content.DialogInterface)2 IntentFilter (android.content.IntentFilter)2 Bundle (android.os.Bundle)2 Environment (android.os.Environment)2 NonNull (android.support.annotation.NonNull)2 FloatingActionButton (android.support.design.widget.FloatingActionButton)2