コード例 #1
0
ファイル: Tomdroid.java プロジェクト: ndhunju/tomdroid
  public void onResume() {

    // if the SyncService was stopped because Android killed it, we should not show the progress
    // dialog any more
    if (SyncManager.getInstance().getCurrentService().activity == null) {
      TLog.i(
          TAG,
          "Android killed the SyncService while in background. We will remove the dialog now.");
      removeDialog(DIALOG_SYNC);
    }

    super.onResume();
    Intent intent = this.getIntent();

    SyncService currentService = SyncManager.getInstance().getCurrentService();

    if (currentService.needsAuth() && intent != null) {
      Uri uri = intent.getData();

      if (uri != null && uri.getScheme().equals("tomdroid")) {
        TLog.i(TAG, "Got url : {0}", uri.toString());

        showDialog(DIALOG_AUTH_PROGRESS);

        Handler handler =
            new Handler() {

              @Override
              public void handleMessage(Message msg) {
                if (authProgressDialog != null) authProgressDialog.dismiss();
                if (msg.what == SyncService.AUTH_COMPLETE) startSyncing(true);
              }
            };

        ((ServiceAuth) currentService).remoteAuthComplete(uri, handler);
      }
    }

    SyncManager.setActivity(this);
    SyncManager.setHandler(this.syncMessageHandler);

    // tablet refresh
    if (rightPane != null) {
      updateTextAttributes();
      if (!creating) showNoteInPane(lastIndex);
    } else updateNotesList(query, lastIndex);

    // set the view shown when the list is empty
    updateEmptyList(query);
    creating = false;
  }
コード例 #2
0
ファイル: Tomdroid.java プロジェクト: ndhunju/tomdroid
  @SuppressWarnings("deprecation")
  private void startSyncing(boolean push) {

    String serverUri = Preferences.getString(Preferences.Key.SYNC_SERVER);
    SyncService currentService = SyncManager.getInstance().getCurrentService();

    if (currentService.needsAuth()) {

      // service needs authentication
      TLog.i(TAG, "Creating dialog");

      showDialog(DIALOG_AUTH_PROGRESS);

      Handler handler =
          new Handler() {

            @Override
            public void handleMessage(Message msg) {

              Uri authorizationUri = (Uri) msg.obj;
              if (authorizationUri != null) {

                resetSyncValues();

                Intent i = new Intent(Intent.ACTION_VIEW, authorizationUri);
                startActivity(i);

              } else {
                // Auth failed, don't update the value
                showDialog(DIALOG_CONNECT_FAILED);
              }

              if (authProgressDialog != null) authProgressDialog.dismiss();
            }
          };

      ((ServiceAuth) currentService).getAuthUri(serverUri, handler);
    } else {
      syncProcessedNotes = 0;
      syncTotalNotes = 0;
      dialogString = getString(R.string.syncing_connect);
      showDialog(DIALOG_SYNC);
      SyncManager.getInstance().startSynchronization(push); // push by default
    }
  }
コード例 #3
0
ファイル: Tomdroid.java プロジェクト: ndhunju/tomdroid
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    TLog.d(TAG, "onActivityResult called with result {0}", resultCode);

    // returning from file picker
    if (data != null && data.hasExtra(FilePickerActivity.EXTRA_FILE_PATH)) {
      // Get the file path
      File f = new File(data.getStringExtra(FilePickerActivity.EXTRA_FILE_PATH));
      Uri noteUri = Uri.fromFile(f);
      Intent intent = new Intent(this, Receive.class);
      intent.setData(noteUri);
      startActivity(intent);
    } else { // returning from sync conflict
      SyncService currentService = SyncManager.getInstance().getCurrentService();
      currentService.resolvedConflict(requestCode);
    }
  }
コード例 #4
0
ファイル: Tomdroid.java プロジェクト: ndhunju/tomdroid
  @Override
  protected void onPrepareDialog(int id, final Dialog dialog) {
    super.onPrepareDialog(id, dialog);
    final Activity activity = this;
    switch (id) {
      case DIALOG_SYNC:
        SyncService currentService = SyncManager.getInstance().getCurrentService();
        String serviceDescription = currentService.getDescription();
        ((ProgressDialog) dialog)
            .setTitle(String.format(getString(R.string.syncing), serviceDescription));
        ((ProgressDialog) dialog).setMessage(dialogString);
        ((ProgressDialog) dialog)
            .setOnCancelListener(
                new DialogInterface.OnCancelListener() {

                  public void onCancel(DialogInterface dialog) {
                    SyncManager.getInstance().cancel();
                  }
                });
        break;
      case DIALOG_NOT_FOUND_SHORTCUT:
        final Intent removeIntent =
            new NoteViewShortcutsHelper(this).getRemoveShortcutIntent(dialogString, uri);
        ((AlertDialog) dialog)
            .setButton(
                Dialog.BUTTON_POSITIVE,
                getString(R.string.btnRemoveShortcut),
                new OnClickListener() {
                  public void onClick(final DialogInterface dialogInterface, final int i) {
                    sendBroadcast(removeIntent);
                    finish();
                  }
                });
        break;
      case DIALOG_REVERT_ALL:
        ((AlertDialog) dialog)
            .setButton(
                Dialog.BUTTON_POSITIVE,
                getString(R.string.yes),
                new OnClickListener() {

                  public void onClick(DialogInterface dialog, int which) {
                    resetSyncValues();
                    startSyncing(false);
                  }
                });
        break;
      case DIALOG_DELETE_NOTE:
        ((AlertDialog) dialog)
            .setButton(
                Dialog.BUTTON_POSITIVE,
                getString(R.string.yes),
                new OnClickListener() {

                  public void onClick(DialogInterface dialog, int which) {
                    deleteNote(dialogString, dialogInt);
                  }
                });
        break;
      case DIALOG_REVERT_NOTE:
        ((AlertDialog) dialog)
            .setButton(
                Dialog.BUTTON_POSITIVE,
                getString(R.string.yes),
                new OnClickListener() {

                  public void onClick(DialogInterface dialog, int which) {
                    SyncManager.getInstance().pullNote(dialogString);
                  }
                });
        break;
      case DIALOG_SYNC_ERRORS:
        ((AlertDialog) dialog).setMessage(dialogString);
        ((AlertDialog) dialog)
            .setButton(
                Dialog.BUTTON_POSITIVE,
                getString(R.string.btnSavetoSD),
                new OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    if (!dialogBoolean) {
                      Toast.makeText(
                              activity,
                              activity.getString(R.string.messageCouldNotSave),
                              Toast.LENGTH_SHORT)
                          .show();
                    }
                    finishSync();
                  }
                });
        break;
      case DIALOG_SEND_CHOOSE:
        final Uri intentUri = Uri.parse(dialogString);
        ((AlertDialog) dialog)
            .setButton(
                Dialog.BUTTON_POSITIVE,
                getString(R.string.btnSendAsFile),
                new OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    (new Send(activity, intentUri, true)).send();
                  }
                });
        ((AlertDialog) dialog)
            .setButton(
                Dialog.BUTTON_NEGATIVE,
                getString(R.string.btnSendAsText),
                new OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    (new Send(activity, intentUri, false)).send();
                  }
                });
        break;
      case DIALOG_VIEW_TAGS:
        ((AlertDialog) dialog)
            .setTitle(String.format(getString(R.string.note_x_tags), dialogNote.getTitle()));
        dialogInput.setText(dialogNote.getTags());

        ((AlertDialog) dialog)
            .setButton(
                Dialog.BUTTON_POSITIVE,
                getString(R.string.btnOk),
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int whichButton) {
                    String value = dialogInput.getText().toString();
                    dialogNote.setTags(value);
                    dialogNote.setLastChangeDate();
                    NoteManager.putNote(activity, dialogNote);
                    removeDialog(DIALOG_VIEW_TAGS);
                  }
                });
        break;
    }
  }
コード例 #5
0
ファイル: Tomdroid.java プロジェクト: ndhunju/tomdroid
  @Override
  protected Dialog onCreateDialog(int id) {
    super.onCreateDialog(id);
    final Activity activity = this;
    AlertDialog alertDialog;
    final ProgressDialog progressDialog = new ProgressDialog(this);
    SyncService currentService = SyncManager.getInstance().getCurrentService();
    String serviceDescription = currentService.getDescription();
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);

    switch (id) {
      case DIALOG_SYNC:
        progressDialog.setIndeterminate(true);
        progressDialog.setTitle(String.format(getString(R.string.syncing), serviceDescription));
        progressDialog.setMessage(dialogString);
        progressDialog.setOnCancelListener(
            new DialogInterface.OnCancelListener() {

              public void onCancel(DialogInterface dialog) {
                SyncManager.getInstance().cancel();
              }
            });
        progressDialog.setButton(
            ProgressDialog.BUTTON_NEGATIVE,
            getString(R.string.cancel),
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int which) {
                progressDialog.cancel();
              }
            });
        return progressDialog;
      case DIALOG_AUTH_PROGRESS:
        authProgressDialog = new ProgressDialog(this);
        authProgressDialog.setTitle("");
        authProgressDialog.setMessage(getString(R.string.prefSyncCompleteAuth));
        authProgressDialog.setIndeterminate(true);
        authProgressDialog.setCancelable(false);
        return authProgressDialog;
      case DIALOG_ABOUT:
        // grab version info
        String ver;
        try {
          ver = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
        } catch (NameNotFoundException e) {
          e.printStackTrace();
          ver = "Not found!";
          return null;
        }

        // format the string
        String aboutDialogFormat = getString(R.string.strAbout);
        String aboutDialogStr =
            String.format(
                aboutDialogFormat,
                getString(R.string.app_desc), // App description
                getString(R.string.author), // Author name
                ver // Version
                );

        // build and show the dialog
        return new AlertDialog.Builder(this)
            .setMessage(aboutDialogStr)
            .setTitle(getString(R.string.titleAbout))
            .setIcon(R.drawable.icon)
            .setNegativeButton(
                getString(R.string.btnProjectPage),
                new OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    startActivity(
                        new Intent(Intent.ACTION_VIEW, Uri.parse(Tomdroid.PROJECT_HOMEPAGE)));
                    dialog.dismiss();
                  }
                })
            .setPositiveButton(
                getString(R.string.btnOk),
                new OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                  }
                })
            .create();
      case DIALOG_FIRST_RUN:
        return new AlertDialog.Builder(this)
            .setMessage(getString(R.string.strWelcome))
            .setTitle(getString(R.string.titleWelcome))
            .setNeutralButton(
                getString(R.string.btnOk),
                new OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    Preferences.putBoolean(Preferences.Key.FIRST_RUN, false);
                    dialog.dismiss();
                  }
                })
            .setIcon(R.drawable.icon)
            .create();
      case DIALOG_NOT_FOUND:
        addCommonNoteNotFoundDialogElements(builder);
        return builder.create();
      case DIALOG_NOT_FOUND_SHORTCUT:
        addCommonNoteNotFoundDialogElements(builder);
        final Intent removeIntent =
            new NoteViewShortcutsHelper(this).getRemoveShortcutIntent(dialogString, uri);
        builder.setPositiveButton(
            getString(R.string.btnRemoveShortcut),
            new OnClickListener() {
              public void onClick(final DialogInterface dialogInterface, final int i) {
                sendBroadcast(removeIntent);
                finish();
              }
            });
        return builder.create();
      case DIALOG_PARSE_ERROR:
        return new AlertDialog.Builder(this)
            .setMessage(getString(R.string.messageErrorNoteParsing))
            .setTitle(getString(R.string.error))
            .setNeutralButton(
                getString(R.string.btnOk),
                new OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    showNote(true);
                  }
                })
            .create();
      case DIALOG_REVERT_ALL:
        return new AlertDialog.Builder(this)
            .setIcon(android.R.drawable.ic_dialog_alert)
            .setTitle(R.string.revert_notes)
            .setMessage(R.string.revert_notes_message)
            .setPositiveButton(
                getString(R.string.yes),
                new OnClickListener() {

                  public void onClick(DialogInterface dialog, int which) {
                    resetSyncValues();
                    startSyncing(false);
                  }
                })
            .setNegativeButton(R.string.no, null)
            .create();
      case DIALOG_CONNECT_FAILED:
        return new AlertDialog.Builder(this)
            .setMessage(getString(R.string.prefSyncConnectionFailed))
            .setNeutralButton(
                getString(R.string.btnOk),
                new OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                  }
                })
            .create();
      case DIALOG_DELETE_NOTE:
        return new AlertDialog.Builder(this)
            .setIcon(android.R.drawable.ic_dialog_alert)
            .setTitle(R.string.delete_note)
            .setMessage(R.string.delete_message)
            .setPositiveButton(getString(R.string.yes), null)
            .setNegativeButton(R.string.no, null)
            .create();
      case DIALOG_REVERT_NOTE:
        return new AlertDialog.Builder(this)
            .setIcon(android.R.drawable.ic_dialog_alert)
            .setTitle(R.string.revert_note)
            .setMessage(R.string.revert_note_message)
            .setPositiveButton(getString(R.string.yes), null)
            .setNegativeButton(R.string.no, null)
            .create();
      case DIALOG_SYNC_ERRORS:
        return new AlertDialog.Builder(activity)
            .setTitle(getString(R.string.error))
            .setMessage(dialogString)
            .setPositiveButton(getString(R.string.yes), null)
            .setNegativeButton(
                getString(R.string.close),
                new OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    finishSync();
                  }
                })
            .create();
      case DIALOG_SEND_CHOOSE:
        final Uri intentUri = Uri.parse(dialogString);
        return new AlertDialog.Builder(activity)
            .setMessage(getString(R.string.sendChoice))
            .setTitle(getString(R.string.sendChoiceTitle))
            .setPositiveButton(getString(R.string.btnSendAsFile), null)
            .setNegativeButton(getString(R.string.btnSendAsText), null)
            .create();
      case DIALOG_VIEW_TAGS:
        dialogInput = new EditText(this);
        return new AlertDialog.Builder(activity)
            .setMessage(getString(R.string.edit_tags))
            .setTitle(String.format(getString(R.string.note_x_tags), dialogNote.getTitle()))
            .setView(dialogInput)
            .setNegativeButton(
                R.string.btnCancel,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int whichButton) {
                    removeDialog(DIALOG_VIEW_TAGS);
                  }
                })
            .setPositiveButton(R.string.btnOk, null)
            .create();
      default:
        alertDialog = null;
    }
    return alertDialog;
  }
コード例 #6
0
ファイル: Tomdroid.java プロジェクト: ndhunju/tomdroid
 @Override
 protected void onDestroy() {
   SyncManager.getInstance().cancel();
   removeDialog(DIALOG_SYNC);
   super.onDestroy();
 }
コード例 #7
0
ファイル: Tomdroid.java プロジェクト: ndhunju/tomdroid
  /** Called when the activity is created. */
  @SuppressLint("NewApi")
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Preferences.init(this, CLEAR_PREFERENCES);
    context = this;
    SyncManager.setActivity(this);
    SyncManager.setHandler(this.syncMessageHandler);

    main = View.inflate(this, R.layout.main, null);

    setContentView(main);

    // get the Path to the notes-folder from Preferences
    if (Preferences.getString(Preferences.Key.SD_LOCATION).startsWith("/")) {
      NOTES_PATH = Preferences.getString(Preferences.Key.SD_LOCATION);
    } else {
      NOTES_PATH =
          Environment.getExternalStorageDirectory()
              + "/"
              + Preferences.getString(Preferences.Key.SD_LOCATION)
              + "/";
    }

    // generate the http header we want to send on syncing
    getPackageManager();
    try {
      PackageInfo pi =
          getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_META_DATA);
      HTTP_HEADER =
          String.format(
              "%1$s v%2$s, build %3$s, Android v%4$s, %5$s/%6$s",
              pi.packageName,
              pi.versionName,
              pi.versionCode,
              Build.VERSION.RELEASE,
              Build.MANUFACTURER,
              Build.MODEL);
    } catch (NameNotFoundException e) {
      e.printStackTrace();
      HTTP_HEADER = "Tomdroid vunknown, build unknown, Android unknown, unknown/unknown";
    }
    TLog.v(TAG, "Generated http-header: {0}: {1}", "X-Tomboy-Client", Tomdroid.HTTP_HEADER);

    // did we already show the warning and got destroyed by android's activity killer?
    if (Preferences.getBoolean(Preferences.Key.FIRST_RUN)) {
      TLog.i(TAG, "Tomdroid is first run.");

      // add a first explanatory note
      NoteManager.putNote(this, FirstNote.createFirstNote(this));

      // Warn that this is a "will eat your babies" release
      showDialog(DIALOG_FIRST_RUN);
    }

    this.intent = getIntent();

    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
      this.setTitle(getString(R.string.app_name) + " - " + getString(R.string.SearchResultTitle));
      query = intent.getStringExtra(SearchManager.QUERY);

      // adds query to search history suggestions
      SearchRecentSuggestions suggestions =
          new SearchRecentSuggestions(
              this, SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE);
      suggestions.saveRecentQuery(query, null);
    } else {
      // if main view -> disable the tomdroid icon home button
      setHomeButtonEnabled(false);
    }

    String defaultSortOrder = Preferences.getString(Preferences.Key.SORT_ORDER);
    NoteManager.setSortOrder(defaultSortOrder);

    // set list adapter
    updateNotesList(query, -1);

    // add note to pane for tablet
    rightPane = (LinearLayout) findViewById(R.id.right_pane);
    registerForContextMenu(findViewById(android.R.id.list));

    // check if receiving note
    if (getIntent().hasExtra("view_note")) {
      uri = getIntent().getData();
      getIntent().setData(null);
      Intent i = new Intent(Intent.ACTION_VIEW, uri, this, ViewNote.class);
      startActivity(i);
    }

    if (rightPane != null) {
      content = (TextView) findViewById(R.id.content);
      title = (TextView) findViewById(R.id.title);

      // this we will call on resume as well.
      updateTextAttributes();
      showNoteInPane(0);
    }

    // set the view shown when the list is empty
    updateEmptyList(query);

    // Syncing if SyncOnStart (pref) set AND onCreate_SyncOnStart set false for syncing only on
    // startup
    if (Preferences.getBoolean(Preferences.Key.SYNC_ON_START) && first_onCreate_run) {
      startSyncing(true);
      TLog.i(TAG, "SyncOnStart activated");
    }

    // we already run onCreate now!
    first_onCreate_run = false;
  }
コード例 #8
0
ファイル: Tomdroid.java プロジェクト: ndhunju/tomdroid
    @Override
    public void handleMessage(Message msg) {

      SyncService currentService = SyncManager.getInstance().getCurrentService();
      String serviceDescription = currentService.getDescription();
      String message = "";
      boolean dismiss = false;

      switch (msg.what) {
        case SyncService.AUTH_COMPLETE:
          message = getString(R.string.messageAuthComplete);
          message = String.format(message, serviceDescription);
          Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
          break;
        case SyncService.AUTH_FAILED:
          dismiss = true;
          message = getString(R.string.messageAuthFailed);
          message = String.format(message, serviceDescription);
          Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
          break;
        case SyncService.PARSING_COMPLETE:
          final ErrorList errors = (ErrorList) msg.obj;
          if (errors == null || errors.isEmpty()) {
            message = getString(R.string.messageSyncComplete);
            message = String.format(message, serviceDescription);
            Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
            finishSync();
          } else {
            TLog.v(TAG, "syncErrors: {0}", TextUtils.join("\n", errors.toArray()));
            dialogString = getString(R.string.messageSyncError);
            dialogBoolean = errors.save();
            showDialog(DIALOG_SYNC_ERRORS);
          }
          break;
        case SyncService.CONNECTING_FAILED:
          dismiss = true;
          message = getString(R.string.messageSyncConnectingFailed);
          message = String.format(message, serviceDescription);
          Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
          break;
        case SyncService.PARSING_FAILED:
          dismiss = true;
          message = getString(R.string.messageSyncParseFailed);
          message = String.format(message, serviceDescription);
          Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
          break;
        case SyncService.PARSING_NO_NOTES:
          dismiss = true;
          message = getString(R.string.messageSyncNoNote);
          message = String.format(message, serviceDescription);
          Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
          break;

        case SyncService.NO_INTERNET:
          dismiss = true;
          Toast.makeText(activity, getString(R.string.messageSyncNoConnection), Toast.LENGTH_SHORT)
              .show();
          break;

        case SyncService.NO_SD_CARD:
          dismiss = true;
          Toast.makeText(activity, activity.getString(R.string.messageNoSDCard), Toast.LENGTH_SHORT)
              .show();
          break;
        case SyncService.SYNC_CONNECTED:
          dialogString = getString(R.string.gettings_notes);
          showDialog(DIALOG_SYNC);
          break;
        case SyncService.BEGIN_PROGRESS:
          syncTotalNotes = msg.arg1;
          syncProcessedNotes = 0;
          dialogString = getString(R.string.syncing_local);
          showDialog(DIALOG_SYNC);
          break;
        case SyncService.SYNC_PROGRESS:
          if (msg.arg1 == 90) {
            dialogString = getString(R.string.syncing_remote);
            showDialog(DIALOG_SYNC);
          }
          break;
        case SyncService.NOTE_DELETED:
          message = getString(R.string.messageSyncNoteDeleted);
          message = String.format(message, serviceDescription);
          // Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
          break;

        case SyncService.NOTE_PUSHED:
          message = getString(R.string.messageSyncNotePushed);
          message = String.format(message, serviceDescription);
          // Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();

          break;
        case SyncService.NOTE_PULLED:
          message = getString(R.string.messageSyncNotePulled);
          message = String.format(message, serviceDescription);
          // Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
          break;

        case SyncService.NOTE_DELETE_ERROR:
          dismiss = true;
          message = getString(R.string.messageSyncNoteDeleteError);
          message = String.format(message, serviceDescription);
          Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
          break;

        case SyncService.NOTE_PUSH_ERROR:
          dismiss = true;
          message = getString(R.string.messageSyncNotePushError);
          message = String.format(message, serviceDescription);
          Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
          break;
        case SyncService.NOTE_PULL_ERROR:
          dismiss = true;
          message = getString(R.string.messageSyncNotePullError);
          message = String.format(message, serviceDescription);
          Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
          break;
        case SyncService.IN_PROGRESS:
          Toast.makeText(
                  activity,
                  activity.getString(R.string.messageSyncAlreadyInProgress),
                  Toast.LENGTH_SHORT)
              .show();
          dismiss = true;
          break;
        case SyncService.NOTES_BACKED_UP:
          Toast.makeText(
                  activity, activity.getString(R.string.messageNotesBackedUp), Toast.LENGTH_SHORT)
              .show();
          break;
        case SyncService.SYNC_CANCELLED:
          dismiss = true;
          message = getString(R.string.messageSyncCancelled);
          message = String.format(message, serviceDescription);
          Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
          break;
        default:
          break;
      }
      if (dismiss) removeDialog(DIALOG_SYNC);
    }