@Override
 public boolean dispatchCommand(int command, Object tag) {
   if (CommonCommands.dispatchCommand(this, command, tag)) {
     return true;
   }
   return false;
 }
 @Override
 protected Dialog onCreateDialog(int id) {
   switch (id) {
     case R.id.FTP_DIALOG:
       return DialogUtils.sendWithFTPDialog((Activity) this);
     case R.id.DONATE_DIALOG:
       return DonateDialogFragment.buildDialog(this);
     case R.id.MORE_INFO_DIALOG:
       LayoutInflater li = LayoutInflater.from(this);
       View view = li.inflate(R.layout.more_info, null);
       ((TextView) view.findViewById(R.id.aboutVersionCode))
           .setText(CommonCommands.getVersionInfo(this));
       return new AlertDialog.Builder(this)
           .setTitle(R.string.pref_more_info_dialog_title)
           .setView(view)
           .setPositiveButton(android.R.string.ok, null)
           .create();
     case R.id.PLANNER_SETUP_INFO_CREATE_NEW_WARNING_DIALOG:
       return new AlertDialog.Builder(this)
           .setTitle(R.string.dialog_title_attention)
           .setMessage(R.string.planner_setup_info_create_new_warning)
           .setNegativeButton(android.R.string.cancel, null)
           .setPositiveButton(
               android.R.string.ok,
               new DialogInterface.OnClickListener() {
                 public void onClick(DialogInterface dialog, int id) {
                   // TODO: use Async Task Strict Mode violation
                   boolean success = MyApplication.getInstance().createPlanner();
                   Toast.makeText(
                           MyPreferenceActivity.this,
                           success
                               ? R.string.planner_create_calendar_success
                               : R.string.planner_create_calendar_failure,
                           Toast.LENGTH_LONG)
                       .show();
                 }
               })
           .create();
   }
   return null;
 }
 @Override
 public boolean onPreferenceClick(Preference preference) {
   if (preference.getKey().equals(MyApplication.PrefKey.CONTRIB_DONATE.getKey())) {
     Utils.contribBuyDo(MyPreferenceActivity.this);
     return true;
   }
   if (preference.getKey().equals(MyApplication.PrefKey.REQUEST_LICENCE.getKey())) {
     String androidId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
     Intent i = new Intent(android.content.Intent.ACTION_SEND);
     i.setType("plain/text");
     i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {MyApplication.FEEDBACK_EMAIL});
     i.putExtra(
         android.content.Intent.EXTRA_SUBJECT,
         "[" + getString(R.string.app_name) + "] " + getString(R.string.contrib_key));
     i.putExtra(
         android.content.Intent.EXTRA_TEXT,
         getString(R.string.request_licence_mail_head, androidId)
             + " \n\n["
             + getString(R.string.request_licence_mail_description)
             + "]");
     if (!Utils.isIntentAvailable(MyPreferenceActivity.this, i)) {
       Toast.makeText(
               getBaseContext(), R.string.no_app_handling_email_available, Toast.LENGTH_LONG)
           .show();
     } else {
       startActivity(i);
     }
     return true;
   }
   if (preference.getKey().equals(MyApplication.PrefKey.SEND_FEEDBACK.getKey())) {
     CommonCommands.dispatchCommand(this, R.id.FEEDBACK_COMMAND, null);
     return true;
   }
   if (preference.getKey().equals(MyApplication.PrefKey.RATE.getKey())) {
     PrefKey.NEXT_REMINDER_RATE.putLong(-1);
     CommonCommands.dispatchCommand(this, R.id.RATE_COMMAND, null);
     return true;
   }
   if (preference.getKey().equals(MyApplication.PrefKey.MORE_INFO_DIALOG.getKey())) {
     showDialog(R.id.MORE_INFO_DIALOG);
     return true;
   }
   if (preference.getKey().equals(MyApplication.PrefKey.RESTORE.getKey())
       || preference.getKey().equals(MyApplication.PrefKey.RESTORE_LEGACY.getKey())) {
     startActivityForResult(preference.getIntent(), RESTORE_REQUEST);
     return true;
   }
   if (preference.getKey().equals(MyApplication.PrefKey.APP_DIR.getKey())) {
     File appDir = Utils.requireAppDir();
     Preference pref = findPreference(MyApplication.PrefKey.APP_DIR.getKey());
     if (appDir == null) {
       pref.setSummary(R.string.external_storage_unavailable);
       pref.setEnabled(false);
     } else {
       Intent intent = new Intent(this, FolderBrowser.class);
       intent.putExtra(FolderBrowser.PATH, appDir.getPath());
       startActivityForResult(intent, PICK_FOLDER_REQUEST);
     }
     return true;
   }
   if (preference.getKey().equals(MyApplication.PrefKey.SHORTCUT_CREATE_TRANSACTION.getKey())) {
     Bundle extras = new Bundle();
     extras.putBoolean(AbstractWidget.EXTRA_START_FROM_WIDGET, true);
     extras.putBoolean(AbstractWidget.EXTRA_START_FROM_WIDGET_DATA_ENTRY, true);
     addShortcut(
         ".activity.ExpenseEdit",
         R.string.transaction,
         R.drawable.shortcut_create_transaction_icon,
         extras);
     return true;
   }
   if (preference.getKey().equals(MyApplication.PrefKey.SHORTCUT_CREATE_TRANSFER.getKey())) {
     Bundle extras = new Bundle();
     extras.putBoolean(AbstractWidget.EXTRA_START_FROM_WIDGET, true);
     extras.putBoolean(AbstractWidget.EXTRA_START_FROM_WIDGET_DATA_ENTRY, true);
     extras.putInt(MyApplication.KEY_OPERATION_TYPE, MyExpenses.TYPE_TRANSFER);
     addShortcut(
         ".activity.ExpenseEdit",
         R.string.transfer,
         R.drawable.shortcut_create_transfer_icon,
         extras);
     return true;
   }
   if (preference.getKey().equals(MyApplication.PrefKey.SHORTCUT_CREATE_SPLIT.getKey())) {
     Bundle extras = new Bundle();
     extras.putBoolean(AbstractWidget.EXTRA_START_FROM_WIDGET, true);
     extras.putBoolean(AbstractWidget.EXTRA_START_FROM_WIDGET_DATA_ENTRY, true);
     extras.putInt(MyApplication.KEY_OPERATION_TYPE, MyExpenses.TYPE_SPLIT);
     addShortcut(
         ".activity.ExpenseEdit",
         R.string.split_transaction,
         R.drawable.shortcut_create_split_icon,
         extras);
     return true;
   }
   return false;
 }