Пример #1
0
        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) //setimage on text view
        {
            base.OnActivityResult(requestCode, resultCode, data);
            Bitmap bitmap = null;

            switch (requestCode)
            {
            case GALLERY_REQUEST:
                if (resultCode == Result.Ok)
                {
                    Android.Net.Uri selectedImage = data.Data;
                    string          Tag           = '[' + selectedImage.LastPathSegment + ']';
                    bitmap = Multitools.decodeSampledBitmapFromUri(this, selectedImage, 2000, 2000);
                    bitmap = Multitools.getResizedBitmap(bitmap, Resources.DisplayMetrics.WidthPixels - 100, Resources.DisplayMetrics.WidthPixels - 100);

                    var        imageSpan = new ImageSpan(this, bitmap); //Find your drawable.
                    int        selStart  = EditText.SelectionEnd;
                    var        span      = EditText.EditableText.GetSpans(0, EditText.Length(), Java.Lang.Class.FromType(typeof(ImageSpan)));
                    ISpannable spann     = SpannableFactory.Instance.NewSpannable(Tag);
                    spann.SetSpan(imageSpan, 0, Tag.Length, SpanTypes.ExclusiveExclusive);
                    if (selStart != 0)
                    {
                        EditText.EditableText.Insert(selStart, "\n");
                    }
                    selStart = EditText.SelectionEnd;
                    EditText.EditableText.Insert(selStart, spann);
                    textWatcher.Editing = false;
                    EditText.EditableText.Insert(selStart + Tag.Length, "\n");
                    textWatcher.Editing = true;
                }
                break;
            }
        }
Пример #2
0
        public Bitmap ReturnDrawableBase(long id, string path)
        {
            string[] col   = { "ColumnBitmap" };
            string[] param = { path };
            cursor = WritableDatabase.Query("ContentTable", col, "ColumnPath = ?", param, null, null, null);
            cursor.MoveToFirst();
            byte[] array = cursor.GetBlob(cursor.GetColumnIndex(COLUMN_BITMAP));
            Bitmap b     = Multitools.ConvertToBitmap(array);

            return(b);
        }
Пример #3
0
        public void SaveBitmapBase(long id, string path, int start, int end, Bitmap image) //SAVE IMAGE IN DB
        {
            byte[]        bytearray = Multitools.ConvertoBLob(image);
            ContentValues cv        = new ContentValues();

            cv.Put(COLUMN_ID, id);
            cv.Put(COLUMN_IMGPATH, path);
            cv.Put(COLUMN_START, start);
            cv.Put(COLUMN_END, end);
            cv.Put(COLUMN_BITMAP, bytearray);
            WritableDatabase.Insert(CONTENTTABLE, null, cv);
        }
Пример #4
0
        public override void OnReceive(Context context, Intent intent)
        {
            Intent resultIntent;
            int    id = Convert.ToInt32(intent.GetLongExtra("_id", 0));

            databasehelper = new Databasehelper(context);

            Db = databasehelper.WritableDatabase;

            resultIntent = new Intent(context, typeof(WriteActivity));
            resultIntent.PutExtra("_id", id.ToString());



            ContentValues cv = new ContentValues();

            cv.Put(Databasehelper.COLUMN_NOTIFY, 0);
            Db.Update(Databasehelper.TEXTTABLE, cv, "_id= ?", new string[] { id.ToString() });
            Db.ExecSQL("VACUUM");
            Android.App.PendingIntent resultPendingIntent = Android.App.PendingIntent.GetActivity(context, id, resultIntent,
                                                                                                  Android.App.PendingIntentFlags.UpdateCurrent);
            NotificationCompat.Builder builder =
                new NotificationCompat.Builder(context, "ID")
                .SetSmallIcon(Android.Resource.Drawable.IcButtonSpeakNow)
                .SetContentTitle("Вам напоминание!")
                .SetContentText(intent.GetStringExtra("message"))
                .SetPriority((int)Android.App.NotificationPriority.Default)
                .SetContentIntent(resultPendingIntent)
                .SetAutoCancel(true)
            ;
            Android.App.NotificationManager manager = (Android.App.NotificationManager)context.GetSystemService(Context.NotificationService);

            Android.App.Notification notification = builder.Build();


            Multitools.createChannelIfNeeded(manager);
            manager.Notify(id, notification);
        }
Пример #5
0
        //изменить цвет фона
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            base.GetView(position, convertView, parent);
            string title;

            string[] nameNote;
            if (Build.VERSION.SdkInt >= BuildVersionCodes.N)
            {
                nameNote = Html.FromHtml(Cursor.GetString(Cursor.GetColumnIndex("ColumnText")), FromHtmlOptions.ModeCompact).ToString().Split("\n");
            }
            else
            {
                nameNote = Html.FromHtml(Cursor.GetString(Cursor.GetColumnIndex("ColumnText"))).ToString().Split("\n");
            }
            int IsNotify = Cursor.GetInt(Cursor.GetColumnIndex(Databasehelper.COLUMN_NOTIFY));

            SqlHelper = new Databasehelper(context);
            Db        = SqlHelper.ReadableDatabase;
            if (convertView == null)
            {
                convertView = View.Inflate(context, Resource.Layout.activity_rows, null);
                Cursor.MoveToPosition(position);

                viewHolder = new ViewHolder(convertView);


                convertView.Tag = viewHolder;
            }
            else
            {
                viewHolder = (ViewHolder)convertView.Tag;
            }
            try
            {
                cursor1 = Db.RawQuery("select " + Databasehelper.COLUMN_IMGPATH + " from " + Databasehelper.CONTENTTABLE + " where _id == " + GetItemId(position).ToString(), null);
                title   = Multitools.GetNameNote(nameNote[0], cursor1);
            }
            catch { title = nameNote[0]; }
            viewHolder.namenotes.Text = title; //Set Title In List
            if (IsNotify == 1)
            {
                viewHolder.image.Visibility = ViewStates.Visible;
            }
            else
            {
                viewHolder.image.Visibility = ViewStates.Invisible;
            }
            viewHolder.editingTime.Text = Cursor.GetString(Cursor.GetColumnIndex(Databasehelper.COLUMN_EDITINGTIME));
            Color c = new Color(Cursor.GetInt(Cursor.GetColumnIndex(Databasehelper.COLUMN_COLOR)));

            viewHolder.layout.SetBackgroundColor(c);

            if (IsShow)
            {
                viewHolder.checkBox.Visibility = ViewStates.Visible;
            }
            else
            {
                viewHolder.checkBox.Visibility = ViewStates.Invisible;
            }

            if (IsShow)
            {
                viewHolder.checkBox.Checked = IsChecked[position];
            }
            if (!viewHolder.checkBox.HasOnClickListeners)
            {
                viewHolder.checkBox.Click += (sender, e) =>
                {
                    IsChecked[position] = !IsChecked[position];
                }
            }
            ;
            return(convertView);
        }
Пример #6
0
 void ChangeNotifyContent()
 {
     cursor = Db.RawQuery(("select " + Databasehelper.COLUMN_IMGPATH + " from " + Databasehelper.CONTENTTABLE + " where _id == " + NoteNumber.ToString()), null);
     notifyFragment.Content = Multitools.GetNameNote(EditText.Text.Split("\n")[0], cursor);
     notifyFragment.ChangeIntent(this);
 }
Пример #7
0
        void OnClickAccept(object sender, EventArgs e)
        {
            if ((DateTime.Now.Date == Date && (DateTime.Now.Hour > Hour || DateTime.Now.Hour == Hour && DateTime.Now.Minute >= Minute)) || DateTime.Now.Date > Date) //If current date, check hour is not less current hour, and if current date and hour, check minute
            {
                Toast toast = Toast.MakeText(Context, "Нельзя установить прошедшее время или дату.", ToastLength.Short);
                toast.Show();
            }
            else
            {
                Id = SqlHelper.SaveText(Editable, Args);

                if (Args == null)
                {
                    Args = new Bundle();
                    Args.PutString("_id", Id.ToString());
                }
                cursor  = Db.RawQuery(("select " + Databasehelper.COLUMN_IMGPATH + " from " + Databasehelper.CONTENTTABLE + " where _id == " + Id.ToString()), null);
                Content = Multitools.GetNameNote(Editable.ToString().Split("\n")[0], cursor);
                Calendar calendar = Calendar.Instance;

                calendar.Set(CalendarField.Year, Date.Year);
                calendar.Set(CalendarField.Month, Date.Month - 1);
                calendar.Set(CalendarField.DayOfMonth, Date.Day);
                calendar.Set(CalendarField.HourOfDay, Hour);
                calendar.Set(CalendarField.Minute, Minute);
                calendar.Set(CalendarField.Second, 0);
                NotifyManager notify = new NotifyManager();
                alarm  = (Android.App.AlarmManager)Context.GetSystemService(Context.AlarmService);
                intent = new Intent(Context, typeof(NotifyManager));

                intent.PutExtra("_id", Id);
                intent.PutExtra("message", Content);
                //ChangeIntent(Context);
                pendingIntent = Android.App.PendingIntent.GetBroadcast(Context, Convert.ToInt32(Id), intent, Android.App.PendingIntentFlags.UpdateCurrent);



                if (Convert.ToInt32(Build.VERSION.Sdk) >= 19)
                {
                    alarm.SetExact(Android.App.AlarmType.RtcWakeup, calendar.TimeInMillis, pendingIntent);
                }
                else
                {
                    alarm.Set(Android.App.AlarmType.RtcWakeup, calendar.TimeInMillis, pendingIntent);
                }

                ContentValues cv = new ContentValues();
                cv.Put(Databasehelper.COLUMN_NOTIFY, 1);
                cv.Put(Databasehelper.COLUMN_TIME, calendar.TimeInMillis);
                //cv.Put(Databasehelper.COLUMN_TIME, calendar.TimeInMillis);
                //cv.Put(Databasehelper.START_ID, uniqueId);
                //cv.Put(Databasehelper.NEW_ID, Id); //While id is identific

                Db.Update(Databasehelper.TEXTTABLE, cv, "_id=?", new string[] { Id.ToString() });
                //PrefsEditor.PutBoolean(Id.ToString(), true);
                //PrefsEditor.Apply();


                Dialog.Cancel();
            }
        }