コード例 #1
0
  private static void storeIssue(FailureLevel level, String tag, String message) {
    if (Application.get() == null || !Application.isDebug() || !sEnabled) {
      return;
    }

    final LogEntry log = new LogEntry(System.currentTimeMillis(), level, tag, message);
    sHelper.insertLog(log);

    if (sLastCheck < (SystemClock.elapsedRealtime() - 5 * 1000)) {
      sLastCheck = SystemClock.elapsedRealtime();

      new SendTask(false).start();
    }
  }
コード例 #2
0
    @Override
    public void postExecute() {
      if (!mForce && !mEnabled) {
        return; // do nothing
      }

      File file = new File(Environment.getExternalStorageDirectory(), LOG_FILE);
      if (Application.isDebug() && mStatus && file.exists()) {
        Intent intent = new Intent(Application.get(), DialogActivity.class);
        if (Build.VERSION.SDK_INT > 10) {
          intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
          intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        } else {
          intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        }

        Application.get().startActivity(intent);
      }
    }
コード例 #3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final File file = new File(Environment.getExternalStorageDirectory(), RemoteLog.LOG_FILE);
    if (!Application.isDebug() || !file.exists() || file.length() == 0) {
      finish();
      return;
    }

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.remotelog_dialog);

    Button cancel = (Button) findViewById(R.id.btn_negative);
    cancel.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View arg0) {
            file.delete();

            Prefs.saveLastEmail(System.currentTimeMillis());
            finish();
          }
        });

    Button download = (Button) findViewById(R.id.btn_positive);
    download.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View arg0) {
            PackageInfo pkgInfo = null;
            try {
              pkgInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
            } catch (PackageManager.NameNotFoundException e) {
              // pokemon
            }

            StringBuilder info = new StringBuilder();
            info.append("Application: ");
            info.append(getString(R.string.app_name));

            if (pkgInfo != null) {
              info.append("\n");

              info.append("- package: ");
              info.append(pkgInfo.packageName);
              info.append("\n");

              info.append("- version: ");
              info.append(pkgInfo.versionName);
              info.append(" / ");
              info.append(pkgInfo.versionCode);
              info.append("\n");

              info.append("- updated: ");
              info.append(new Date(pkgInfo.lastUpdateTime).toString());
            }

            info.append("\n\n");
            info.append("Something developers should to know? > ");

            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("message/rfc822");
            intent.putExtra(Intent.EXTRA_EMAIL, new String[] {"*****@*****.**"});
            intent.putExtra(
                Intent.EXTRA_SUBJECT, "Application log: " + getString(R.string.app_name));
            intent.putExtra(Intent.EXTRA_TEXT, info.toString());
            intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));

            startActivity(Intent.createChooser(intent, "Send logs..."));

            Prefs.saveLastEmail(System.currentTimeMillis());
            finish();
          }
        });
  }
コード例 #4
0
 static {
   sHelper = new LogHelper(Application.get());
 }
コード例 #5
0
 /**
  * Are we in debug mode?
  *
  * @return debug mode
  */
 private static boolean isRemoteLoggingEnabled() {
   return Application.isDebug();
 }