コード例 #1
0
        public override void OnAttachedToWindow()
        {
            base.OnAttachedToWindow();

            Java.Lang.Class         classForId      = Java.Lang.Class.ForName("com.android.internal.R$id");
            Java.Lang.Reflect.Field timePickerField = classForId.GetField("timePicker");

            timePicker = FindViewById <TimePicker> (timePickerField.GetInt(null));

            Java.Lang.Reflect.Field field = classForId.GetField("minute");

            NumberPicker mMinuteSpinner = timePicker.FindViewById <NumberPicker> (field.GetInt(null));

            if (mMinuteSpinner != null)
            {
                mMinuteSpinner.MinValue = 0;
                mMinuteSpinner.MaxValue = (60 / interval) - 1;

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

                for (int i = 0; i < 60; i += interval)
                {
                    displayedValues.Add(i.ToString("00"));
                }

                mMinuteSpinner.SetDisplayedValues(displayedValues.ToArray());
            }
            OnTimeChanged(timePicker, hourOfDay, minute / interval);
        }
コード例 #2
0
        public static void SetNumberPickerFont(NumberPicker numberPicker, Typeface fontFamily, float textSizeInSp)
        {
            int count = numberPicker.ChildCount;

            for (int i = 0; i < count; i++)
            {
                Android.Views.View?child = numberPicker.GetChildAt(i);

                if (child is EditText editText)
                {
                    try
                    {
                        Java.Lang.Reflect.Field selectorWheelPaintField = numberPicker.Class
                                                                          .GetDeclaredField("mSelectorWheelPaint");
                        selectorWheelPaintField.Accessible = true;
                        ((Paint)selectorWheelPaintField.Get(numberPicker) !).TextSize = textSizeInSp;
                        editText.Typeface = fontFamily;
                        editText.SetTextSize(Android.Util.ComplexUnitType.Px, textSizeInSp);
                        numberPicker.Invalidate();
                    }
                    catch (System.Exception e)
                    {
                        System.Diagnostics.Debug.WriteLine("SetNumberPickerFont failed.", e);
                    }
                }
            }
        }
コード例 #3
0
        private void setSearchIcons(SearchView mSearchView)
        {
            try
            {
                Java.Lang.Reflect.Field searchField = mSearchView.Class.GetDeclaredField("mSearchButton");
                searchField.Accessible = true;
                ImageView searchBtn = (ImageView)searchField.Get(mSearchView);
                searchBtn.Background = null;

                searchBtn.SetImageResource(Resource.Drawable.search123);
                searchBtn.SetScaleType(ImageView.ScaleType.FitCenter);
                //searchBtn.LayoutParameters.Width = 80;
                //searchBtn.LayoutParameters.Height = 80;
                searchBtn.RequestLayout();
                searchField            = mSearchView.Class.GetDeclaredField("mSearchPlate");
                searchField.Accessible = true;
                LinearLayout searchPlate = (LinearLayout)searchField.Get(mSearchView);
                ImageView    closeBtn    = ((ImageView)searchPlate.GetChildAt(1));
                closeBtn.SetImageResource(Resource.Drawable.closed);
                closeBtn.SetScaleType(ImageView.ScaleType.FitCenter);
                //closeBtn.LayoutParameters.Width = 80;
                //closeBtn.LayoutParameters.Height = 80;
                closeBtn.RequestLayout();
                //searchPlate.SetBackgroundResource(Resource.Drawable.SearchPlate);
                //searchPlate.LayoutParameters.Height = 1;
            }
            catch (System.Exception e)
            {
                string dst = "sdfsfs";
            }
        }
コード例 #4
0
        private void SetTextColor(NumberPicker numberPicker, Color textColor)
        {
            int count = numberPicker.ChildCount;

            for (int i = 0; i < count; i++)
            {
                var child    = numberPicker.GetChildAt(i);
                var editText = child as EditText;

                if (editText != null)
                {
                    try
                    {
                        Java.Lang.Reflect.Field selectorWheelPaintField = numberPicker.Class
                                                                          .GetDeclaredField("mSelectorWheelPaint");
                        selectorWheelPaintField.Accessible = true;
                        ((Paint)selectorWheelPaintField.Get(numberPicker)).Color = textColor;
                        editText.SetTextColor(textColor);
                        numberPicker.Invalidate();
                    }
                    catch (System.Exception e)
                    {
                        System.Diagnostics.Debug.WriteLine("SetNumberPickerTextColor failed.", e);
                    }
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// </summary>
        /// <see cref="http://stackoverflow.com/questions/22962075/change-the-text-color-of-numberpicker"/>
        /// <param name="numberPicker">Number picker.</param>
        /// <param name="textSizeInSp">Text size in pixel.</param>
        private static void SetTextSize(NumberPicker numberPicker, Typeface fontFamily, float textSizeInSp)
        {
            int count = numberPicker.ChildCount;

            for (int i = 0; i < count; i++)
            {
                var child    = numberPicker.GetChildAt(i);
                var editText = child as EditText;

                if (editText != null)
                {
                    try
                    {
                        Java.Lang.Reflect.Field selectorWheelPaintField = numberPicker.Class
                                                                          .GetDeclaredField("mSelectorWheelPaint");
                        selectorWheelPaintField.Accessible = true;
                        ((Paint)selectorWheelPaintField.Get(numberPicker)).TextSize = textSizeInSp;
                        editText.Typeface = fontFamily;
                        editText.SetTextSize(ComplexUnitType.Px, textSizeInSp);
                        numberPicker.Invalidate();
                    }
                    catch (System.Exception e)
                    {
                        System.Diagnostics.Debug.WriteLine("SetNumberPickerTextColor failed.", e);
                    }
                }
            }
        }
コード例 #6
0
        /**
         * @param clazz
         * @param varName
         * @return search in clazz of possible variable name (varName) and return its value
         */
        public Java.Lang.Object getValueInt(Class clazz, string varName)
        {
            Java.Lang.Reflect.Field fieldRequested = null;

            try
            {
                fieldRequested = clazz.GetField(varName);
                if (fieldRequested != null)
                {
                    return(fieldRequested.Get(clazz));
                }
            }
            catch (SecurityException e)
            {
                e.PrintStackTrace();
            }
            catch (NoSuchFieldException e)
            {
                e.PrintStackTrace();
            }
            catch (IllegalAccessException e)
            {
                e.PrintStackTrace();
            }
            catch (IllegalArgumentException e)
            {
                e.PrintStackTrace();
            }
            return(null);
        }
コード例 #7
0
        private void ChangeCursorColor(Color color)
        {
            if (this.Control == null)
            {
                return;
            }

            try
            {
                if ((int)Build.VERSION.SdkInt >= 29)                // Android.OS.BuildVersionCodes.Q)
                {
                    var qCursorDrawable = this.Control.TextCursorDrawable;

                    qCursorDrawable.SetColorFilter(color, PorterDuff.Mode.SrcIn);

                    this.Control.TextCursorDrawable = qCursorDrawable;

                    return;
                }

                var cursorResource = Java.Lang.Class.FromType(typeof(TextView)).GetDeclaredField(CURSOR_DRAWABLE_RESOURCE);

                cursorResource.Accessible = true;

                int resId = cursorResource.GetInt(this.Control);

                Java.Lang.Reflect.Field editorField = Java.Lang.Class.FromType(typeof(TextView)).GetDeclaredField(EDITOR_FIELD);

                editorField.Accessible = true;

                Drawable cursorDrawable = Context.GetDrawable(resId);

                cursorDrawable.SetColorFilter(color, PorterDuff.Mode.SrcIn);



                Java.Lang.Object editor = editorField.Get(this.Control);

                if ((int)Build.VERSION.SdkInt >= 28)                //Android.OS.BuildVersionCodes.P)
                {
                    Java.Lang.Reflect.Field drawableForCursorField = editor.Class.GetDeclaredField(DRAWABLE_FOR_CURSOR_FIELD);

                    drawableForCursorField.Accessible = true;

                    drawableForCursorField.Set(editor, cursorDrawable);
                }
                else
                {
                    Java.Lang.Reflect.Field cursorDrawableField = editor.Class.GetDeclaredField(CUSROR_DRAWABLE_FIELD);

                    cursorDrawableField.Accessible = true;

                    cursorDrawableField.Set(editor, new[] { cursorDrawable, cursorDrawable });
                }
            }
            catch (Exception ex)
            {
                // Whoops chaning the cursor color is not supported :(
            }
        }
コード例 #8
0
 public static void SetNumberPickerDividerColor(NumberPicker numberPicker, Xamarin.Forms.Color color)
 {
     try
     {
         Java.Lang.Reflect.Field field = numberPicker.Class.GetDeclaredField("mSelectionDivider");
         field.Accessible = true;
         field.Set(numberPicker, new ColorDrawable(color.ToAndroid()));
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine("SetNumberPickerDividerColor failed.", e);
     }
 }
コード例 #9
0
 public static void SetNumberPickerDividerHeight(NumberPicker numberPicker, int height)
 {
     try
     {
         Java.Lang.Reflect.Field field = numberPicker.Class.GetDeclaredField("mSelectionDividerHeight");
         field.Accessible = true;
         field.Set(numberPicker, height);
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine("SetNumberPickerDividerHeight failed.", e);
     }
 }
コード例 #10
0
        private Java.Lang.Reflect.Field GetDeclaredField(string fieldName)
        {
            Java.Lang.Reflect.Field field = null;

            try
            {
                field = Control.Class.GetDeclaredField(fieldName);
            }
            catch (NoSuchFieldException)
            {
                Log.Info("XfxEntryRendererDroid", $"Swallowing NoSuchFieldException - {fieldName}.");
            }

            return(field);
        }
コード例 #11
0
        public void SetInputTextLayoutColor(TextInputLayout til, Android.Graphics.Color color)
        {
            try
            {
                Java.Lang.Reflect.Field fDefaultTextColor = Java.Lang.Class.FromType(typeof(TextInputLayout)).GetDeclaredField("mDefaultTextColor");
                fDefaultTextColor.Accessible = true;
                fDefaultTextColor.Set(til, new ColorStateList(new int[][] { new int[] { 0 } }, new int[] { entry.PlaceholderColor.ToAndroid() }));

                Java.Lang.Reflect.Field fFocusedTextColor = Java.Lang.Class.FromType(typeof(TextInputLayout)).GetDeclaredField("mFocusedTextColor");
                fFocusedTextColor.Accessible = true;
                fFocusedTextColor.Set(til, new ColorStateList(new int[][] { new int[] { 0 } }, new int[] { entry.TextColor.ToAndroid() }));
            }
            catch
            {
            }
        }
コード例 #12
0
        private void setSearchIcons(SearchView mSearchView)
        {
            try
            {
                Java.Lang.Reflect.Field searchField = mSearchView.Class.GetDeclaredField("mSearchButton");
                searchField.Accessible = true;
                ImageView searchBtn = (ImageView)searchField.Get(mSearchView);
                searchBtn.Background = null;

                searchBtn.SetImageResource(Resource.Drawable.search123);
                searchBtn.SetScaleType(ImageView.ScaleType.FitCenter);
                //searchBtn.LayoutParameters.Width = 80;
                //searchBtn.LayoutParameters.Height = 80;
                searchBtn.RequestLayout();
                searchField            = mSearchView.Class.GetDeclaredField("mSearchPlate");
                searchField.Accessible = true;
                LinearLayout searchPlate = (LinearLayout)searchField.Get(mSearchView);
                ImageView    closeBtn    = ((ImageView)searchPlate.GetChildAt(1));
                closeBtn.SetImageResource(Resource.Drawable.closed);
                closeBtn.SetScaleType(ImageView.ScaleType.FitCenter);
                //closeBtn.LayoutParameters.Width = 80;
                //closeBtn.LayoutParameters.Height = 80;
                closeBtn.RequestLayout();
                //searchPlate.SetBackgroundResource(Resource.Drawable.SearchPlate);
                //searchPlate.LayoutParameters.Height = 1;


                int      searchPlateId = mSearchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null);
                EditText plate         = (EditText)mSearchView.FindViewById(searchPlateId);
                //plate.SetBackgroundColor(Color.White);
                plate.SetTextColor(Color.White);
                int voiceSearchPlateId = mSearchView.Context.Resources.GetIdentifier("android:id/submit_area", null, null);
                mSearchView.FindViewById(voiceSearchPlateId).SetBackgroundResource(Resource.Drawable.rounded_textview);

                // change hint color
                int      searchTextViewId = mSearchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null);
                TextView searchTextView   = (TextView)mSearchView.FindViewById(searchTextViewId);
                searchTextView.SetHintTextColor(Resources.GetColor(Color.LightGray));
            }
            catch (Exception ex)
            {
                string dst = "sdfsfs";
                CustomLogger.CustomLog("From Activity: " + bitopiApplication.CurrentActivity + "\nMessage: " + ex.Message + "\nStack Trace: " + ex.StackTrace + "\n\n", "", bitopiApplication.User != null ?
                                       bitopiApplication.User.UserName : "");
            }
        }
コード例 #13
0
 internal override void SetCount(int badgeCount)
 {
     try
     {
         CurrentCount = badgeCount;
         Java.Lang.Class         miuiNotificationClass = Java.Lang.Class.ForName("android.app.MiuiNotification");
         Java.Lang.Object        miuiNotification      = miuiNotificationClass.NewInstance();
         Java.Lang.Reflect.Field field = miuiNotification.Class.GetDeclaredField("messageCount");
         field.Accessible = true;
         field.Set(miuiNotification, badgeCount == 0 ? "" : badgeCount.ToString());
     }
     catch (Exception e)
     {
         Intent localIntent = new Intent(
             INTENT_ACTION);
         localIntent.PutExtra(EXTRA_UPDATE_APP_COMPONENT_NAME, GetContextPackageName() + "/" + GetEntryActivityName());
         localIntent.PutExtra(EXTRA_UPDATE_APP_MSG_TEXT, badgeCount == 0 ? "" : badgeCount.ToString());
         mContext.SendBroadcast(localIntent);
     }
 }
        private bool CheckSmallIconInMIUI(Notification notification)
        {
            try
            {
                Java.Lang.Class         miuiNotificationClass = Java.Lang.Class.ForName("android.app.MiuiNotification");
                Java.Lang.Object        miuiNotification      = miuiNotificationClass.NewInstance();
                Java.Lang.Reflect.Field field = miuiNotification.Class.GetDeclaredField("customizedIcon");
                field.Accessible = true;
                field.Set(miuiNotification, true);
                field            = notification.Class.GetField("extraNotification");
                field.Accessible = true;
                field.Set(notification, miuiNotification);

                return(true);
            }
            catch (Java.Lang.Exception e)
            {
                return(false);
            }
        }
コード例 #15
0
        public static void DisableShiftMode(BottomNavigationView view)
        {
            BottomNavigationMenuView menuView = (BottomNavigationMenuView)view.GetChildAt(0);

            try
            {
                Java.Lang.Reflect.Field shiftingMode = menuView.Class.GetDeclaredField("mShiftingMode");
                shiftingMode.Accessible = true;
                shiftingMode.SetBoolean(menuView, false);
                shiftingMode.Accessible = false;
                for (int i = 0; i < menuView.ChildCount; i++)
                {
                    BottomNavigationItemView itemView = (BottomNavigationItemView)menuView.GetChildAt(i);
                    itemView.SetShiftingMode(false);
                    itemView.SetChecked(itemView.ItemData.IsChecked);
                }
            }
            catch (Exception ex)
            {
                BuglyUtil.PostException("unable to get shift mode field" + ex);
            }
        }
コード例 #16
0
        public static int GetNumFd(ParcelFileDescriptor fdObj)
        {
            try
            {
                if (mFdField != null)
                {
                    return(mFdField.GetInt(fdObj.FileDescriptor));
                }
                mFdField            = FdClass.GetDeclaredField(FdFieldName);
                mFdField.Accessible = true;

                return(mFdField.GetInt(fdObj.FileDescriptor));
            }
            catch (NoSuchFieldException e)
            {
                e.PrintStackTrace();
                return(-1);
            }
            catch (IllegalAccessException e)
            {
                e.PrintStackTrace();
                return(-1);
            }
        }
コード例 #17
0
        private void ChangeCursorColor(Color color)
        {
            if (this.Control == null)
            {
                return;
            }

            try
            {
                var cursorResource = Java.Lang.Class.FromType(typeof(TextView)).GetDeclaredField(CURSOR_DRAWABLE_RESOURCE);

                cursorResource.Accessible = true;

                int resId = cursorResource.GetInt(this.Control);

                Java.Lang.Reflect.Field editorField = Java.Lang.Class.FromType(typeof(TextView)).GetDeclaredField(EDITOR_FIELD);

                editorField.Accessible = true;

                Drawable cursorDrawable = Context.GetDrawable(resId);

                cursorDrawable.SetColorFilter(new BlendModeColorFilter(color, BlendMode.SrcIn));

                Java.Lang.Object editor = editorField.Get(this.Control);

                Java.Lang.Reflect.Field cursorDrawableField = editor.Class.GetDeclaredField(CUSROR_DRAWABLE_FIELD);

                cursorDrawableField.Accessible = true;

                cursorDrawableField.Set(editor, new[] { cursorDrawable, cursorDrawable });
            }
            catch (Exception)
            {
                // Whoops chaning the cursor color is not supported :(
            }
        }
コード例 #18
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            //Window.RequestFeature(WindowFeatures.NoTitle);
            Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.LatestMain);

            SqliteDatabase.newInstance(Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "gps_coordinate.db3"));
            SqliteDatabase.CreateTables();
            //SqliteDatabase.ClearData();

            CacheManager.Init(Application.Context);

            ActionBar mActionBar = this.ActionBar;

            mActionBar.SetDisplayShowHomeEnabled(false);
            mActionBar.SetDisplayShowTitleEnabled(false);
            LayoutInflater mInflater   = LayoutInflater.From(this);
            View           mCustomView = mInflater.Inflate(Resource.Layout.CustomTitlebar, null);

            mActionBar.DisplayOptions = ActionBarDisplayOptions.ShowCustom;
            mActionBar.CustomView     = mCustomView;
            mActionBar.SetDisplayShowCustomEnabled(true);

            FindViewById <Button>(Resource.Id.btnDownload).Click += DownloadButton_OnClick;
            FindViewById <Button>(Resource.Id.btnUpload).Click   += UploadButton_OnClick;

            _latitudeText  = FindViewById <EditText>(Resource.Id.et_latitude);
            _longitudeText = FindViewById <EditText>(Resource.Id.et_longitude);
            _accuracyText  = FindViewById <EditText>(Resource.Id.et_accuracy);
            FindViewById <Button>(Resource.Id.btn_get_coordinates).Click += GetCoordinatesButton_OnClick;
            FindViewById <Button>(Resource.Id.btn_prev).Click            += PrevButton_OnClick;
            FindViewById <Button>(Resource.Id.btn_next).Click            += NextButton_OnClick;
            FindViewById <Button>(Resource.Id.btn_go).Click += GoButton_OnClick;

            FindViewById <EditText>(Resource.Id.et_tph).TextChanged += TphEditText_TextChanged;

            _locationProgress = new ProgressDialog(this);
            _locationProgress.Indeterminate = true;
            _locationProgress.SetProgressStyle(ProgressDialogStyle.Spinner);
            _locationProgress.SetMessage("Waiting for gps. Please wait...");
            _locationProgress.SetCancelable(false);
            _locationProgress.SetButton("Cancel", (senderAlert, args) =>
            {
                CancelEvent();
            });

            InitializeLocationManager();

            _tmrCounter          = new Timer();
            _tmrCounter.Interval = 1000;
            _tmrCounter.Elapsed += tmrCounter_Elapsed;

            _processProgress = new ProgressDialog(this);
            _processProgress.Indeterminate = true;
            _processProgress.SetProgressStyle(ProgressDialogStyle.Spinner);
            _processProgress.SetMessage("Loading...");
            _processProgress.SetCancelable(false);

            _estateSpinner   = FindViewById <Spinner>(Resource.Id.spin_estate);
            _afdelingSpinner = FindViewById <Spinner>(Resource.Id.spin_afdeling);
            _blockSpinner    = FindViewById <Spinner>(Resource.Id.spin_block);

            try
            {
                Java.Lang.Reflect.Field popup = _blockSpinner.Class.GetDeclaredField("mPopup");
                popup.Accessible = true;

                // Get private mPopup member variable and try cast to ListPopupWindow
                var popupWindow = (ListPopupWindow)popup.Get(_blockSpinner);

                // Set popupWindow height to 300px
                popupWindow.Height = 300;
            }
            catch (Java.Lang.Exception ex)
            {
                Log.Debug("Java Exception", ex.Message);
                // Failed...
            }
            catch (System.Exception ex)
            {
                Log.Debug("System Exception", ex.Message);
                // Failed...
            }

            _estateSpinner.ItemSelected   += SpinEstate_ItemSelected;
            _afdelingSpinner.ItemSelected += SpinAfdeling_ItemSelected;
            _blockSpinner.ItemSelected    += SpinBlock_ItemSelected;

            PopulateEstate();
        }
コード例 #19
0
 private void SetHintLabelColor(Java.Lang.Reflect.Field hint, AColor color)
 {
     hint.Accessible = true;
     hint.Set(Control, new ColorStateList(new[] { new[] { 0 } }, new int[] { color }));
 }