Ejemplo n.º 1
0
  @Override
  public void onCreate() {
    super.onCreate();
    EasyTracker.getInstance().setContext(this);

    TraceDroid.init(this);
    Log.setTAG("gobandroid");

    interaction_scope = new InteractionScope();

    if (Build.VERSION.SDK_INT > 7) // need at least 8 for C2DM
    initGCM();

    GobandroidBackend.registerDevice(this);
  }
Ejemplo n.º 2
0
  public static boolean sendStackTraces(final String email, final Context context) {
    if (TraceDroid.getStackTraceFiles().length > 0) {
      new AlertDialog.Builder(context)
          .setTitle("Problem Report")
          .setMessage(
              "A Problem with this App was detected - would you send an Crash-Report to help fixing this Problem?")
          .setPositiveButton(
              "Send",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                  final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
                  emailIntent.setType("plain/text");
                  emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {email});
                  emailIntent.putExtra(
                      android.content.Intent.EXTRA_SUBJECT,
                      "[TraceDroid Report] " + TraceDroidMetaInfo.getAppPackageName());
                  emailIntent.putExtra(
                      android.content.Intent.EXTRA_TEXT, TraceDroid.getStackTraceText(10));
                  context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
                  TraceDroid.deleteStacktraceFiles();
                }
              })
          .setNegativeButton(
              "No",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                  TraceDroid.deleteStacktraceFiles();
                }
              })
          .setNeutralButton(
              "Later",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {}
              })
          .show();

      return true;
    }
    return false;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.ticket_list);
    ButterKnife.inject(this);

    passadapter = new PassAdapter();
    listView.setAdapter(passadapter);

    inflater = getLayoutInflater();

    listView.setEmptyView(emptyView);

    // don't want too many windows in worst case - so check for errors first
    if (TraceDroid.getStackTraceFiles().length > 0) {
      Tracker.get().trackEvent("ui_event", "send", "stacktraces", null);
      TraceDroidEmailSender.sendStackTraces("*****@*****.**", this);
    } else { // if no error - check if there is a new version of the app
      Tracker.get().trackEvent("ui_event", "processInputStream", "updatenotice", null);
      MarketService ms = new MarketService(this);
      ms.level(MarketService.MINOR).checkVersion();
    }

    drawerToggle =
        new ActionBarDrawerToggle(
            this, drawer, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) {
          @Override
          public void onDrawerOpened(View drawerView) {
            App.getBus().post(new NavigationOpenedEvent());
          }
        };
    drawer.setDrawerListener(drawerToggle);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    listView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(
              final AdapterView<?> parent, final View view, final int position, long id) {
            listView.setItemChecked(position, true);
            view.refreshDrawableState();

            actionMode =
                new ActionMode.Callback() {
                  @Override
                  public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {

                    getMenuInflater().inflate(R.menu.activity_ticket_view, menu);
                    return true;
                  }

                  @Override
                  public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
                    return false;
                  }

                  @Override
                  public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
                    if (new PassMenuOptions(
                            TicketListActivity.this, App.getPassStore().getPassbookAt(position))
                        .process(menuItem)) {
                      actionMode.finish();
                      return true;
                    }

                    return false;
                  }

                  @Override
                  public void onDestroyActionMode(ActionMode actionMode) {
                    listView.setItemChecked(position, false);

                    actionMode = null;
                  }
                };

            startSupportActionMode(actionMode);

            return true;
          }
        });

    ActionBarPullToRefresh.from(this)
        .allChildrenArePullable()
        .listener(
            new OnRefreshListener() {
              @Override
              public void onRefreshStarted(View view) {
                App.getPassStore().deleteCache();
                new ScanForPassesTask().execute();
              }
            })
        .setup(mPullToRefreshLayout);
  }
Ejemplo n.º 4
0
 private void initTraceDroid() {
   TraceDroid.init(this);
   Log.setTAG("PassAndroid");
 }