Android Open Source - photo-paper Log Reporting






From Project

Back to project page photo-paper.

License

The source code is released under:

MIT License

If you think the Android project photo-paper listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.lukekorth.android_500px.helpers;
/*from   ww  w  .j av a2s.  c  om*/
import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Build;
import android.os.SystemClock;
import android.preference.PreferenceManager;

import com.lukekorth.android_500px.BuildConfig;
import com.lukekorth.android_500px.R;
import com.lukekorth.mailable_log.MailableLog;

import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.Map;

public class LogReporting {

  private Context mContext;
  private ProgressDialog mLoading;
    private Intent mEmailIntent;
  
  public LogReporting(Context context) {
    mContext = context;
  }
  
  public void collectAndSendLogs() {
    mLoading = ProgressDialog.show(mContext, "", mContext.getString(R.string.loading), true);
    new GenerateLogFile().execute();
  }

  private class GenerateLogFile extends AsyncTask<Void, Void, Void> {

    @SuppressLint("NewApi")
    @Override
    protected Void doInBackground(Void... args) {
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
      StringBuilder message = new StringBuilder();
      
      message.append("Android version: " + Build.VERSION.SDK_INT + "\n");
            message.append("Device manufacturer: " + Build.MANUFACTURER + "\n");
            message.append("Device model: " + Build.MODEL + "\n");
            message.append("Device product: " + Build.PRODUCT + "\n");
      message.append("App version: " + BuildConfig.VERSION_NAME + "\n");
            message.append("Debug: " + BuildConfig.DEBUG + "\n");
            message.append("Wallpaper height: " + Utils.getWallpaperHeight(mContext) + "\n");
            message.append("Wallpaper width: " + Utils.getWallpaperWidth(mContext) + "\n");
            message.append("Screen height: " + Utils.getScreenHeight(mContext) + "\n");
            message.append("Screen width: " + Utils.getScreenWidth(mContext) + "\n");
            message.append("Supports parallax: " + Utils.supportsParallax(mContext) + "\n");

      Map<String,?> keys = prefs.getAll();
      for(Map.Entry<String,?> entry : keys.entrySet()) {
                message.append(entry.getKey() + ": " + entry.getValue().toString() + "\n");
      }
      message.append("---------------------------");
            message.append("\n");

            try {
                mEmailIntent = MailableLog.buildEmailIntent(mContext, "photo-paper@lukekorth.com",
                        "Photo Paper Debug Log", "photo-paper.log", message.toString());
            } catch (IOException e) {
                LoggerFactory.getLogger("LogReporting").error(e.getMessage());
            }

            // Ensure we show the spinner and don't just flash the screen
            SystemClock.sleep(1000);

            return null;
    }

        @Override
    protected void onPostExecute(Void args) {
      if(mLoading != null && mLoading.isShowing()) {
                mLoading.cancel();
            }
        mContext.startActivity(mEmailIntent);
    }
  }
}




Java Source Code List

com.lukekorth.android_500px.HistoryActivity.java
com.lukekorth.android_500px.PhotoFragment.java
com.lukekorth.android_500px.SearchActivity.java
com.lukekorth.android_500px.SettingsActivity.java
com.lukekorth.android_500px.ViewPhotoActivity.java
com.lukekorth.android_500px.WallpaperApplication.java
com.lukekorth.android_500px.helpers.Cache.java
com.lukekorth.android_500px.helpers.LogReporting.java
com.lukekorth.android_500px.helpers.Settings.java
com.lukekorth.android_500px.helpers.ThreadBus.java
com.lukekorth.android_500px.helpers.Utils.java
com.lukekorth.android_500px.models.ActivityResumedEvent.java
com.lukekorth.android_500px.models.EnableCategoriesEvent.java
com.lukekorth.android_500px.models.Photos.java
com.lukekorth.android_500px.models.SearchCompleteEvent.java
com.lukekorth.android_500px.models.UserUpdatedEvent.java
com.lukekorth.android_500px.models.User.java
com.lukekorth.android_500px.models.WallpaperChangedEvent.java
com.lukekorth.android_500px.receivers.UserPresentReceiver.java
com.lukekorth.android_500px.receivers.WifiReceiver.java
com.lukekorth.android_500px.services.ApiService.java
com.lukekorth.android_500px.services.ClearCacheIntentService.java
com.lukekorth.android_500px.services.UserInfoIntentService.java
com.lukekorth.android_500px.services.WallpaperService.java
com.lukekorth.android_500px.views.FeatureListPreference.java
com.lukekorth.android_500px.views.SquareImageView.java
com.squareup.picasso.PicassoTools.java