Пример #1
0
        public static Note createFirstNote(Activity activity)
        {
            TLog.v(TAG, "Creating first note");

            Note note = new Note();

            note.setTitle(activity.GetString(Resource.String.firstNoteTitle));
            // FIXME as soon as we can create notes, make sure GUID is unique! - we are referencing this UUID elsewhere, don't forget to check!
            note.setGuid("8f837a99-c920-4501-b303-6a39af57a714");
            note.setLastChangeDate("2010-10-09T16:50:12.219-04:00");

            // reconstitute HTML in note content

            string[] contentarray = activity.Resources.GetStringArray(Resource.Array.firstNoteContent);
            string content = TextUtils.Join("\n", contentarray);

            content = content.Replace("(?m)^=(.+)=$", "<size:large>$1</size:large>")
                    .Replace("(?m)^-(.+)$", "<list-item dir=\"ltr\">$1</list-item>")
                    .Replace("/list-item>\n<list-item", "/list-item><list-item")
                    .Replace("(<list-item.+</list-item>)", "<list>$1</list>")
                    .Replace("/list-item><list-item", "/list-item>\n<list-item");

            note.setXmlContent(content);

            return note;
        }
		void StartQuizActivityWithTransition(Activity activity, View toolbar, Category category) {
			var pairs = TransitionHelper.CreateSafeTransitionParticipants(activity, false, new Pair(toolbar, activity.GetString(Resource.String.transition_toolbar)));
			var sceneTransitionAnimation = ActivityOptions.MakeSceneTransitionAnimation(activity, pairs);

			// Start the activity with the participants, animating from one to the other.
			var transitionBundle = sceneTransitionAnimation.ToBundle();
			activity.StartActivity(QuizActivity.GetStartIntent(activity, category), transitionBundle);
		}
Пример #3
0
 public MessageDialog(Activity ctx, int messageRefId, DialogDidEndDelegate didEnd)
     : base(ctx, Resource.String.OK, NoValue, didEnd)
 {
     Message = ctx.GetString(messageRefId);
 }
Пример #4
0
        public static void ShowSftpDialog(Activity activity, FileSelectedHandler onStartBrowse, Action onCancel)
        {
            #if !EXCLUDE_JAVAFILESTORAGE && !NoNet
            AlertDialog.Builder builder = new AlertDialog.Builder(activity);
            View dlgContents = activity.LayoutInflater.Inflate(Resource.Layout.sftpcredentials, null);
            builder.SetView(dlgContents);
            builder.SetPositiveButton(Android.Resource.String.Ok,
                                      (sender, args) =>
                                          {
                                              string host = dlgContents.FindViewById<EditText>(Resource.Id.sftp_host).Text;
                                              string portText = dlgContents.FindViewById<EditText>(Resource.Id.sftp_port).Text;
                                              int port = Keepass2android.Javafilestorage.SftpStorage.DefaultSftpPort;
                                              if (!string.IsNullOrEmpty(portText))
                                                  int.TryParse(portText, out port);
                                              string user = dlgContents.FindViewById<EditText>(Resource.Id.sftp_user).Text;
                                              string password = dlgContents.FindViewById<EditText>(Resource.Id.sftp_password).Text;
                                              string initialPath = dlgContents.FindViewById<EditText>(Resource.Id.sftp_initial_dir).Text;
                                              string sftpPath = new Keepass2android.Javafilestorage.SftpStorage().BuildFullPath(host, port, initialPath, user,
                                                                                                              password);
                                              onStartBrowse(sftpPath);
                                          });
            EventHandler<DialogClickEventArgs> evtH = new EventHandler<DialogClickEventArgs>( (sender, e) => onCancel());

            builder.SetNegativeButton(Android.Resource.String.Cancel, evtH);
            builder.SetTitle(activity.GetString(Resource.String.enter_sftp_login_title));
            Dialog dialog = builder.Create();

            dialog.Show();
            #endif
        }
Пример #5
0
 public static void QueryCredentials(IOConnectionInfo ioc, Action<IOConnectionInfo> afterQueryCredentials, Activity activity)
 {
     //Build dialog to query credentials:
     AlertDialog.Builder builder = new AlertDialog.Builder(activity);
     builder.SetTitle(activity.GetString(Resource.String.credentials_dialog_title));
     builder.SetPositiveButton(activity.GetString(Android.Resource.String.Ok), (dlgSender, dlgEvt) =>
     {
         Dialog dlg = (Dialog)dlgSender;
         string username = ((EditText)dlg.FindViewById(Resource.Id.cred_username)).Text;
         string password = ((EditText)dlg.FindViewById(Resource.Id.cred_password)).Text;
         int credentialRememberMode = ((Spinner)dlg.FindViewById(Resource.Id.cred_remember_mode)).SelectedItemPosition;
         ioc.UserName = username;
         ioc.Password = password;
         ioc.CredSaveMode = (IOCredSaveMode)credentialRememberMode;
         afterQueryCredentials(ioc);
     });
     builder.SetView(activity.LayoutInflater.Inflate(Resource.Layout.url_credentials, null));
     builder.SetNeutralButton(activity.GetString(Android.Resource.String.Cancel),
                              (dlgSender, dlgEvt) => { });
     Dialog dialog = builder.Create();
     dialog.Show();
     ((EditText)dialog.FindViewById(Resource.Id.cred_username)).Text = ioc.UserName;
     ((EditText)dialog.FindViewById(Resource.Id.cred_password)).Text = ioc.Password;
     ((Spinner)dialog.FindViewById(Resource.Id.cred_remember_mode)).SetSelection((int)ioc.CredSaveMode);
 }
Пример #6
0
            public void Bind(Activity _context, int _position)
            {
                context = _context;
                position = _position;

                switch (position)
                {
                    case 0:
                        txtInfo.Visibility = ViewStates.Gone;
                        txtSub.Visibility = ViewStates.Gone;
                        txtUrl.Visibility = ViewStates.Gone;
                        txtSub0.Visibility = ViewStates.Gone;
                        break;
                    case 1:
                        txtInfo.Visibility = ViewStates.Visible;
                        txtSub.Visibility = ViewStates.Gone;
                        txtUrl.Visibility = ViewStates.Gone;
                        txtSub0.Visibility = ViewStates.Visible;
                        txtSub0.Text = "";
                        txtInfo.Text = context.GetString(Resource.String.txtInfoSubdomain);
                        break;
                    case 2:
                        txtInfo.Visibility = ViewStates.Visible;
                        txtSub.Visibility = ViewStates.Visible;
                        txtUrl.Visibility = ViewStates.Visible;
                        txtSub0.Visibility = ViewStates.Gone;
                        txtSub.Text = "";
                        txtUrl.Text = "";
                        txtInfo.Text = context.GetString(Resource.String.txtInfoURL);
                        break;
                }
            }
Пример #7
0
 public static ShowcaseView InsertShowcaseView(ITarget target, Activity activity, int title, int detail, ConfigOptions options)
 {
     return InsertShowcaseViewInternal(target, activity, activity.GetString(title), activity.GetString(detail), options);
 }
Пример #8
0
 public static ShowcaseView InsertShowcaseView(ITarget target, Activity activity, int title, int detail)
 {
     return InsertShowcaseViewInternal(target, activity, activity.GetString(title), activity.GetString(detail), null);
 }
Пример #9
0
 public static void CreateShortCut(Activity act, int iconResId, int appnameResId)
 {
     Intent shortcutintent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
     // 不允许重复创建  
     shortcutintent.PutExtra("duplicate", true);
     // 需要现实的名称  
     shortcutintent.PutExtra(Intent.ExtraShortcutName,
             act.GetString(appnameResId));
     // 快捷图片  
     Android.Content.Intent.ShortcutIconResource icon = Intent.ShortcutIconResource.FromContext(act.ApplicationContext, iconResId);
     shortcutintent.PutExtra(Intent.ExtraShortcutIconResource, icon);
     // 点击快捷图片,运行的程序主入口  
     shortcutintent.PutExtra(Intent.ExtraShortcutIntent,
             new Intent(act.ApplicationContext, act.Class));
     // 发送广播  
     act.SendBroadcast(shortcutintent);
 }
Пример #10
0
 private string GetCancel(Activity activity)
 {
     return activity.GetString(Android.Resource.String.Cancel);
 }
Пример #11
0
 private string GetOk(Activity activity)
 {
     return activity.GetString(Android.Resource.String.Ok);
 }
Пример #12
0
		public static bool checkValidateTimeBooking (Activity _activity, DateTime currentTime, DateTime startTime, DateTime endTime, TextView tvTimeError)
		{
			TimeSpan tsDiffStart = startTime - currentTime;
			if (tsDiffStart.TotalMinutes >= (MApplication.getInstance().systemConfig.minimumLeadTime - 1)) {
				if (tsDiffStart.TotalMinutes <= MApplication.getInstance ().systemConfig.maximumLeadTime) {
					TimeSpan tsDiffEnd = endTime - startTime;
					if (tsDiffEnd.TotalMinutes >= MApplication.getInstance ().systemConfig.minimumBooking) {
						if (tsDiffEnd.TotalMinutes <= MApplication.getInstance ().systemConfig.maximumBooking) {
							return true;
						} else {
							tvTimeError.Text = String.Format (_activity.GetString(Resource.String.max_endTime_err), MApplication.getInstance().systemConfig.maximumBooking);
							return false;
						}
					} else {
						tvTimeError.Text = String.Format (_activity.GetString(Resource.String.min_endTime_err), MApplication.getInstance().systemConfig.minimumBooking);
						return false;
					}
				} else {
					tvTimeError.Text = String.Format (_activity.GetString(Resource.String.max_startTime_err), MApplication.getInstance().systemConfig.maximumLeadTime);
					return false;
				}
			} else {
				tvTimeError.Text = String.Format (_activity.GetString(Resource.String.min_startTime_err), MApplication.getInstance().systemConfig.minimumLeadTime);
				return false;
			}
		}
Пример #13
0
        /**
         * validateNoteTitle
         * check title against titles that exist in database, returning modified title if necessary
         * @param activity - the calling activity
         * @param noteTitle - the title to check
         * @param guid - the note's guid, to avoid checking against itself
         * @return new title
         */
        public static string validateNoteTitle(Activity activity, string noteTitle, string guid)
        {
            string origTitle = noteTitle;

            // check for empty titles, set to Resource.String.NewNoteTitle

            if (noteTitle == null || noteTitle.Replace(" ","").Equals("")) {
                noteTitle = activity.GetString(Resource.String.NewNoteTitle);
                origTitle = noteTitle; // have to set this too!
            }

            // check for duplicate titles - add number to end

            ICursor cursor = getTitles(activity);

            // cursor must not be null and must return more than 0 entry
            if (!(cursor == null || cursor.Count == 0)) {

                List<string> titles = new List<string>();

                cursor.MoveToFirst();
                do {
                    string aguid = cursor.GetString(cursor.GetColumnIndexOrThrow(Note.GUID));
                    if(!guid.Equals(aguid)) // skip this note
                        titles.Add(cursor.GetString(cursor.GetColumnIndexOrThrow(Note.TITLE)));
                } while (cursor.MoveToNext());

                // sort to get {"Note","Note 2", "Note 3", ... }
                Collections.sort(titles);

                int inc = 2;
                foreach(string atitle in titles) {
                    if(atitle.Length == 0)
                        continue;

                    if(atitle.EqualsIgnoreCase(noteTitle)) {
                        if(inc == 1)  // first match, matching "Note", set to "Note 2"
                            noteTitle = noteTitle + " 2";
                        else // later match, matching "Note X", set to "Note X+1"
                            noteTitle = origTitle + " " + inc;
                        inc++;
                    }
                }
            }

            return noteTitle;
        }