Beispiel #1
0
 protected override void onListItemClick(ListView l, View v, int position, long id)
 {
     ICursor item = (ICursor) adapter.Item[position];
     NoteViewShortcutsHelper helper = new NoteViewShortcutsHelper(this);
     SetResult(Result.Ok, helper.getCreateShortcutIntent(item));
     Finish();
 }
Beispiel #2
0
        protected override Dialog OnCreateDialog(int id)
        {
            base.OnCreateDialog (id);
            Activity activity = this;
            AlertDialog alertDialog;
            ProgressDialog progressDialog = new ProgressDialog(this);
            SyncService currentService = SyncManager.getInstance().getCurrentService();
            string serviceDescription = currentService.getDescription();
            AlertDialog.Builder builder = new AlertDialog.Builder(this);

            switch(id) {
                case DIALOG_SYNC:
                    progressDialog.SetIndeterminate(true);
                    progressDialog.SetTitle(string.Format(GetString(Resource.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(Resource.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(Resource.String.prefSyncCompleteAuth));
                    authProgressDialog.SetIndeterminate(true);
                    authProgressDialog.SetCancelable(false);
                    return authProgressDialog;
                case DIALOG_ABOUT:
                    // grab version info
                    string ver;
                    try {
                    ver = PackageManager.GetPackageInfo(PackageName, 0).VersionName;
                    } catch (NameNotFoundException e) {
                        e.PrintStackTrace();
                        ver = "Not found!";
                        return null;
                    }

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

                    // build and show the dialog
                    var ad = new AlertDialog.Builder(this).SetMessage(aboutDialogStr)
                                                          .SetTitle(Resources.GetString(GetString (Resource.String.btnProjectPage)))
                                                  		  .SetIcon(Resource.Drawable.Icon)
                        ;

            //							.setNegativeButton(GetString(Resource.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(Resource.String.btnOk), new OnClickListener() {
            //								public void onClick(DialogInterface dialog, int which) {
            //									dialog.dismiss();
            //								}
                    return ad.Create();
                case DIALOG_FIRST_RUN:
            //					.setNeutralButton(GetString(Resource.String.btnOk), new OnClickListener() {
            //						public void onClick(DialogInterface dialog, int which) {
            //							Preferences.putBoolean(Preferences.Key.FIRST_RUN, false);
            //							dialog.dismiss();
            //						}
            //					})

                var adFirstRun = new AlertDialog.Builder(this).SetMessage(Resources.GetString(Resource.String.strWelcome))
                                                      .SetTitle(Resources.GetString(Resource.String.titleWelcome))
                        .SetIcon(Resource.Drawable.Icon);
                return adFirstRun.Create();
                case DIALOG_NOT_FOUND:
                    addCommonNoteNotFoundDialogElements(builder);
                    return builder.Create();
                case DIALOG_NOT_FOUND_SHORTCUT:
                    addCommonNoteNotFoundDialogElements(builder);
                    Intent removeIntent = new NoteViewShortcutsHelper(this).getRemoveShortcutIntent(dialogstring, uri);
            //			        builder.setPositiveButton(GetString(Resource.String.btnRemoveShortcut), new OnClickListener() {
            //			            public void onClick(DialogInterface dialogInterface, readonly int i) {
            //			                sendBroadcast(removeIntent);
            //			                Finish();
            //			            }
            //			        });
                    return builder.Create();
                case DIALOG_PARSE_ERROR:
                    return new AlertDialog.Builder(this)
                    .SetMessage(GetString(Resource.String.messageErrorNoteParsing))
                    .setTitle(GetString(Resource.String.error))
            //					.setNeutralButton(GetString(Resource.String.btnOk), new OnClickListener() {
            //						public void onClick(DialogInterface dialog, int which) {
            //							showNote(true);
            //						}})
                    .create();
                case DIALOG_REVERT_ALL:
                    return new AlertDialog.Builder(this)
                    .SetIcon(Resource.Drawable.ic_dialog_alert)
                    .setTitle(Resource.String.revert_notes)
                    .setMessage(Resource.String.revert_notes_message)
            //			    	.setPositiveButton(GetString(Resource.String.yes), new OnClickListener() {
            //
            //			            public void onClick(DialogInterface dialog, int which) {
            //			        		Preferences.putLong(Preferences.Key.LATEST_SYNC_REVISION, 0);
            //			        		Preferences.putstring(Preferences.Key.LATEST_SYNC_DATE, new Time().Format3339(false));
            //			            	startSyncing(false);
            //			           }
            //
            //			        })
                    .setNegativeButton(Resource.String.no, null)
                    .create();
                case DIALOG_CONNECT_FAILED:
                    return new AlertDialog.Builder(this)
                    .SetMessage(GetString(Resource.String.prefSyncConnectionFailed))
            //					.setNeutralButton(GetString(Resource.String.btnOk), new OnClickListener() {
            //						public void onClick(DialogInterface dialog, int which) {
            //							dialog.dismiss();
            //						}})
                    .create();
                case DIALOG_DELETE_NOTE:
                    return new AlertDialog.Builder(this)
                    .SetIcon(Resource.Drawable.ic_dialog_alert)
                    .setTitle(Resource.String.delete_note)
                    .setMessage(Resource.String.delete_message)
                    .setPositiveButton(GetString(Resource.String.yes), null)
                    .setNegativeButton(Resource.String.no, null)
                    .create();
                case DIALOG_REVERT_NOTE:
                    return new AlertDialog.Builder(this)
                    .SetIcon(Resource.Drawable.ic_dialog_alert)
                    .setTitle(Resource.String.revert_note)
                    .setMessage(Resource.String.revert_note_message)
                    .setPositiveButton(GetString(Resource.String.yes), null)
                    .setNegativeButton(Resource.String.no, null)
                    .create();
                case DIALOG_SYNC_ERRORS:
                    return new AlertDialog.Builder(activity)
                    .SetTitle(Resources.GetString(Resource.String.error))
                    .SetMessage(dialogstring)
                    .SetPositiveButton(Resources.GetString(Resource.String.yes), null)
            //					.setNegativeButton(GetString(Resource.String.close), new OnClickListener() {
            //						public void onClick(DialogInterface dialog, int which) { finishSync(); }
            //					})
                    .create();
                case DIALOG_SEND_CHOOSE:
                    Uri intentUri = Uri.Parse(dialogstring);
                    return new AlertDialog.Builder(activity)
                    .SetMessage(GetString(Resource.String.sendChoice))
                    .SetTitle(GetString(Resource.String.sendChoiceTitle))
                    .SetPositiveButton(Resources.GetString(Resource.String.btnSendAsFile), null)
                    .SetNegativeButton(Resources.GetString(Resource.String.btnSendAsText), null)
                    .Create();
                case DIALOG_VIEW_TAGS:
                    dialogInput = new EditText(this);
                    return new AlertDialog.Builder(activity)
                    .SetMessage(GetString(Resource.String.edit_tags))
                    .SetTitle(string.Format(GetString(Resource.String.note_x_tags),dialogNote.getTitle()))
                    .SetView(dialogInput)
            //			    	.setNegativeButton(Resource.String.btnCancel, new DialogInterface.OnClickListener() {
            //						public void onClick(DialogInterface dialog, int whichButton) {
            //							removeDialog(DIALOG_VIEW_TAGS);
            //						}
            //			    	})
                    .setPositiveButton(Resource.String.btnOk, null)
                    .create();
                default:
                    alertDialog = null;
                }
            return alertDialog;
        }
Beispiel #3
0
        protected override void OnPrepareDialog(int id, Dialog dialog)
        {
            base.OnPrepareDialog (id, dialog);
            Activity activity = this;
            switch(id) {
                case DIALOG_SYNC:
                    SyncService currentService = SyncManager.getInstance().getCurrentService();
                    string serviceDescription = currentService.getDescription();
                    ((ProgressDialog) dialog).SetTitle(string.Format(GetString(Resource.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:
                    Intent removeIntent = new NoteViewShortcutsHelper(this).getRemoveShortcutIntent(dialogstring, uri);
            //			        ((AlertDialog) dialog).setButton(Dialog.BUTTON_POSITIVE, GetString(Resource.String.btnRemoveShortcut), new OnClickListener() {
            //			            public void onClick( DialogInterface dialogInterface, readonly int i) {
            //			                sendBroadcast(removeIntent);
            //			                Finish();
            //			            }
            //			        });
                    break;
                case DIALOG_REVERT_ALL:
            //			    	((AlertDialog) dialog).setButton(Dialog.BUTTON_POSITIVE, GetString(Resource.String.yes), new OnClickListener() {
            //
            //			            public void onClick(DialogInterface dialog, int which) {
            //			        		Preferences.putLong(Preferences.Key.LATEST_SYNC_REVISION, 0);
            //			        		Preferences.putstring(Preferences.Key.LATEST_SYNC_DATE, new Time().Format3339(false));
            //			            	startSyncing(false);
            //			           }
            //
            //			        });
                    break;
                case DIALOG_DELETE_NOTE:
            //			    	((AlertDialog) dialog).setButton(Dialog.BUTTON_POSITIVE, GetString(Resource.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(Resource.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(Resource.String.btnSavetoSD), new OnClickListener() {
            //						public void onClick(DialogInterface dialog, int which) {
            //							if(!dialogBoolean) {
            //								Toast.MakeText(activity, activity.GetString(Resource.String.messageCouldNotSave),
            //										ToastLength.Short).Show();
            //							}
            //							finishSync();
            //						}
            //					});
                    break;
                case DIALOG_SEND_CHOOSE:
            //	                readonly Uri intentUri = Uri.Parse(dialogstring);
            //			    	((AlertDialog) dialog).setButton(Dialog.BUTTON_POSITIVE, GetString(Resource.String.btnSendAsFile), new OnClickListener() {
            //						public void onClick(DialogInterface dialog, int which) {
            //							(new Send(activity, intentUri, true)).send();
            //
            //						}
            //					});
            //			    	((AlertDialog) dialog).setButton(Dialog.BUTTON_NEGATIVE, GetString(Resource.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(Resource.String.note_x_tags),dialogNote.getTitle()));
                    dialogInput.SetText(dialogNote.getTags());

            //			    	((AlertDialog) dialog).setButton(Dialog.BUTTON_POSITIVE, GetString(Resource.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;
            }
        }
Beispiel #4
0
        public override bool OnContextItemSelected(IMenuItem item)
        {
            AdapterContextMenuInfo info = (AdapterContextMenuInfo)item.MenuInfo;
            long noteId = info.id;

            Uri intentUri = Uri.Parse(Tomdroid.CONTENT_URI+"/"+noteId);

            switch (item.ItemId) {
                case Resource.Id.menu_send:
                    dialogstring = intentUri.ToString();
                    ShowDialog(DIALOG_SEND_CHOOSE);
                    return true;
                case Resource.Id.view:
                    this.ViewNote(noteId);
                    break;
                case Resource.Id.edit:
                    this.startEditNote(noteId);
                    break;
                case Resource.Id.tags:
                    ShowDialog(DIALOG_VIEW_TAGS);
                    break;
                case Resource.Id.revert:
                    this.revertNote(note.getGuid());
                    break;
                case Resource.Id.delete:
                    dialogstring = dialogNote.getGuid();
                    dialogInt = dialogPosition;
                    ShowDialog(DIALOG_DELETE_NOTE);
                    return true;
                case Resource.Id.undelete:
                    undeleteNote(dialogNote);
                    return true;
                case Resource.Id.create_shortcut:
                    NoteViewShortcutsHelper helper = new NoteViewShortcutsHelper(this);
                    SendBroadcast(helper.getBroadcastableCreateShortcutIntent(intentUri, dialogNote.getTitle()));
                    break;
                default:
                    break;
            }

            return base.OnContextItemSelected(item);
        }