Пример #1
1
        public ViewShowcaseStep(Activity activity, int viewId)
        {
            this.parentActivity = new WeakReference<Activity>(activity);
            this.viewId = viewId;

            Setup();
        }
Пример #2
1
        public void CriarChamada(Activity activity)
        {
            isRecording = !isRecording;
            if (isRecording)
            {
                // Cria o INTENT
                var voiceIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
                voiceIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);

                // Abre um modal com uma mensagem de voz
                voiceIntent.PutExtra(RecognizerIntent.ExtraPrompt, "Diga o nome da pessoa");

                // Se passar de 5.5s considera que não há mensagem falada
                voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 5500);
                voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500);
                voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 15000);
                voiceIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 1);

                // Para chamadas em outras líguas
                // voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.German);
                // if you wish it to recognise the default Locale language and German
                // if you do use another locale, regional dialects may not be recognised very well

                voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.Default);
                activity.StartActivityForResult(voiceIntent, Constants.VOICE);
            }
        }
Пример #3
0
        public override void OnAttach(Android.App.Activity activity)
        {
            base.OnAttach(activity);
            Android.Util.Log.Debug("Leaderboard", "OnAttach");
            TabTypes tabTypes = new TabTypes();

            TabType[] types    = tabTypes.ToArray();
            var       testData = new Dictionary <string, UserStatEntry[]> {
                { "*****@*****.**", new UserStatEntry[] {
                      new UserStatEntry {
                          Type = types[0], Given = 2, Gotten = 3
                      },
                      new UserStatEntry {
                          Type = types[3], Given = 0, Gotten = 5
                      },
                      new UserStatEntry {
                          Type = types[4], Given = 1, Gotten = 0
                      }
                  } }
            };

            var trans = FragmentManager.BeginTransaction();

            foreach (var kvp in testData)
            {
                var frag = new UserStatisticFragment(() => kvp);
                trans.Add(Resource.Id.EntriesLayout, frag);
            }
            trans.Commit();
        }
 public static void HandleException(Exception ex, Activity activity)
 {
     AlertDialog.Builder builder = new AlertDialog.Builder(activity);
     builder.SetTitle("Error");
     builder.SetMessage(ex.Message);
     builder.Create().Show();
 }
Пример #5
0
        public ZXingSurfaceView(Activity activity)
            : base(activity)
        {
            this.activity = activity;

            Init ();
        }
Пример #6
0
        /// <summary>
        /// Presents the necessary UI for the user to sign in to their account.
        /// </summary>
        /// <returns>
        /// A task for when authentication has completed.
        /// </returns>
        public virtual Task <IEnumerable <Account> > GetAccountsWithAuthUIAsync(UIContext context)
        {
            var tcs = new TaskCompletionSource <IEnumerable <Account> > ();

            var authenticator = GetEmbeddedAuthenticator();

            if (authenticator == null)
            {
                throw new NotSupportedException("This service does not support authentication via a controller.");
            }

            authenticator.Error += (sender, e) => {
                tcs.TrySetException(e.Exception ?? new SocialException(e.Message));
            };

            authenticator.Completed += (sender, e) => {
                if (e.IsAuthenticated)
                {
                    SaveAccount(e.Account, context);
                    tcs.TrySetResult(new [] { e.Account });
                }
                else
                {
                    tcs.TrySetCanceled();
                }
            };

            var authenticatorUi = authenticator.GetUI(context);

            context.StartActivity(authenticatorUi);

            return(tcs.Task);
        }
Пример #7
0
        public Screen7Summary(Activity context, PointDto point)
            : base(context, Resource.Layout.Edit7Summary, point)
        {
            PointPart7Summary item = Point.PointDataDto.PointPart7Summary;

            invalidMoveAvailable = View.FindViewById<Spinner>(Resource.Id.invalid_move_availability);
            invalidHearingAvailable = View.FindViewById<Spinner>(Resource.Id.invalid_hearing_availability);
            invalidEyeAvailable = View.FindViewById<Spinner>(Resource.Id.invalid_eye_availability);
            otherText = View.FindViewById<EditText>(Resource.Id.otherComments);
            reportDate = View.FindViewById<EditText>(Resource.Id.protocolDate);

            invalidMoveAvailable.Adapter = new BoolSpinnerAdapter(context, "ќбъект доступен",
                                                                  "ќбъект не доступен (если нет пандуса, не соответствует ширина проемов, высота порогов)");
            invalidHearingAvailable.Adapter = new BoolSpinnerAdapter(context, "ќбъект доступен",
                                                                     "ќбъект не доступен (если отсутствуют световые табло, индукционна¤ петл¤)");
            invalidEyeAvailable.Adapter = new BoolSpinnerAdapter(context, "ќбъект доступен",
                                                                 "ќбъект не доступен (если отсутствуют тактильные маршруты, звуковое оповещение, контрастна¤ маркировка дверей и стекл¤нных поверхностей)");

            reportDate.Text = item.ReportDate.ToLocalTime().Date.ToString(CultureInfo.CurrentCulture);

            invalidMoveAvailable.SetSelection(BoolSpinnerAdapter.SetPositionOf(item.InvalidMoveAvailability));
            invalidHearingAvailable.SetSelection(BoolSpinnerAdapter.SetPositionOf(item.InvalidHearingAvailability));
            invalidEyeAvailable.SetSelection(BoolSpinnerAdapter.SetPositionOf(item.InvalidEyeAvailability));

            otherText.Text = item.OtherComments;
        }
Пример #8
0
        /// <summary>
        /// Gets the necessary UI for the user to sign in to their account.
        /// </summary>
        /// <returns>
        /// A platform-specific UI type for the user to present.
        /// </returns>
        /// <param name="context">The context for the UI.</param>
        /// <param name="completedHandler">A callback for when authentication has completed successfuly.</param>
        public AuthenticateUIType GetAuthenticateUI(UIContext context, Action <Account> completedHandler)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            var auth = GetAuthenticator();

            if (auth == null)
            {
                throw new NotSupportedException("Account authentication in is not supported.");
            }
            auth.Completed += (sender, e) => {
                if (e.IsAuthenticated)
                {
                    AccountStore.Create(context).Save(e.Account, ServiceId);
                }
                if (completedHandler != null)
                {
                    completedHandler(e.Account);
                }
            };
            auth.Title = Title;
            return(auth.GetUI(context));
        }
        public SystemUiHiderHoneycomb(Activity activity, View anchorView, int flags)
            : base(activity, anchorView, flags)
        {
            #if __ANDROID_11__
            m_ShowFlags = (int)SystemUiFlags.Visible;
            m_HideFlags = (int)SystemUiFlags.LowProfile;
            m_TestFlags = (int)SystemUiFlags.LowProfile;

            if ((m_Flags & FLAG_FULLSCREEN) != 0)
            {
                // If the client requested fullscreen, add flags relevant to hiding
                // the status bar. Note that some of these constants are new as of
                // API 16 (Jelly Bean). It is safe to use them, as they are inlined
                // at compile-time and do nothing on pre-Jelly Bean devices.
                m_ShowFlags |= (int)SystemUiFlags.LayoutFullscreen;
                m_HideFlags |= (int)SystemUiFlags.LayoutFullscreen | (int)SystemUiFlags.Fullscreen;
            }

            if ((m_Flags & FLAG_HIDE_NAVIGATION) != 0)
            {
                // If the client requested hiding navigation, add relevant flags.
                m_ShowFlags |= (int)SystemUiFlags.LayoutHideNavigation;
                m_HideFlags |= (int)SystemUiFlags.LayoutHideNavigation
                        | (int)SystemUiFlags.HideNavigation;
                m_TestFlags = (int)SystemUiFlags.HideNavigation;
            }
            #endif
        }
Пример #10
0
 public ViewBookingsAdapter(Activity parentIn)
     : base()
 {
     parent = parentIn;
     items.Add("Current");
     items.Add("Past");
 }
Пример #11
0
        public void OpenUri(Android.App.Activity activity, Uri uri)
        {
            //OpenUriSimple(activity, uri);
            OpenUriXamarinAuthWebViewActivity(activity, uri);

            return;
        }
Пример #12
0
    public static void CloseProgressDialog(Activity context) {
        if (!context.IsFinishing && _mProgressDialog != null)
        {
    		_mProgressDialog.Dismiss();
    	}
    	_mProgressDialog = null;
	}
Пример #13
0
 internal void OnActivityResumed(Activity activity)
 {
     if (activity is IFrameworkActivity)
     {
         _navigationProvider.ActivityResumed((IFrameworkActivity)activity);
     }
 }
 public GlobalLayoutListener(Android.App.Activity activity, SoftwareKeyboardService softwarekeyboardservice)
 {
     _softwarekeyboardservice = softwarekeyboardservice;
     _activity = activity;
     ObtainInputManager();
     GetDisplayData();
 }
 public void OnActivityDestroyed(Android.App.Activity activity)
 {
     if (activity is MainActivity)
     {
         setApplicationEventBadge();
     }
 }
		public AdvertisementItemListAdapter(Activity context, List<AdvertisementItemShort> advertisementItems, IInfiniteScrollListener infiniteScrollListener) {
			this.AdvertisementItems = advertisementItems;
			this.context = context;
			this.bitmapOperationService = new BitmapOperationService();
			this.infiniteScrollListener = infiniteScrollListener;
			CalculateSizeForPhotoImageView();
		}
 public static void HandleException(AggregateException ex, Activity activity)
 {
     AlertDialog.Builder builder = new AlertDialog.Builder(activity);
     builder.SetTitle("One or more Error(s)");
     builder.SetMessage("First:" + ex.InnerExceptions.First().Message);
     builder.Create().Show();
 }
		public MyVote_ChangeButton(Activity context, string imgId, ImageView imgView,int position)
		{
			this.context = context;
			imageID = imgId;
			imageView = imgView;
			this.position = position;
		}
        /// <summary>
        /// Binds the Activity to the Custom Tabs Service. </summary>
        /// <param name="activity"> the activity to be binded to the service. </param>
        public virtual void BindCustomTabsService(Android.App.Activity activity)
        {
            if (custom_tabs_client != null)
            {
                return;
            }
            ;

            List <string> packages    = PackageManagerHelper.GetPackageNameToUse(activity, this.UriTest);
            string        packageName = "";

            if (packageName == null)
            {
                Toast.MakeText
                (
                    activity,
                    "No packages supporting CustomTabs found!",
                    ToastLength.Short
                ).Show();

                return;
            }

            custom_tabs_service_connection = new ServiceConnection(this);
            CustomTabsClient.BindCustomTabsService(activity, packageName, custom_tabs_service_connection);

            return;
        }
Пример #20
0
		protected override void OnElementChanged (ElementChangedEventArgs<Page> e)
		{
			base.OnElementChanged (e);

			if (e.OldElement != null || Element == null)
				return;

			try {
				activity = this.Context as Activity;
				view = activity.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false);
				cameraType = CameraFacing.Back;

				textureView = view.FindViewById<TextureView> (Resource.Id.textureView);
				textureView.SurfaceTextureListener = this;

				takePhotoButton = view.FindViewById<global::Android.Widget.Button> (Resource.Id.takePhotoButton);
				takePhotoButton.Click += TakePhotoButtonTapped;

				switchCameraButton = view.FindViewById<global::Android.Widget.Button> (Resource.Id.switchCameraButton);
				switchCameraButton.Click += SwitchCameraButtonTapped;

				toggleFlashButton = view.FindViewById<global::Android.Widget.Button> (Resource.Id.toggleFlashButton);
				toggleFlashButton.Click += ToggleFlashButtonTapped;

				AddView (view);
			} catch (Exception ex) {
				//Xamarin.Insights.Report (ex);
			}
		}
		public void BindDataToView(TextView characterCountTextView, Action validate, Activity activity, SuggestionsLayout suggestionsView)
		{
			Validate = validate;
			CharacterCountTextView = characterCountTextView;
			Activity = activity;
			SuggestionsView = suggestionsView;
		}
Пример #22
0
		public HorizontalMenuLabel (Activity activity) : base (activity)
		{
			defaultTextColor = TextColor;
			Gravity = GravityFlags.Center;
			TextColor = CustomColors.DarkColor;
			TextSize = Sizes.GetRealSize (9);
		}
			public  FileItemAdapter(Activity context) 
				: base()
			{
				this.context = context;
				this.Items = new List<FileItem>();
				this.SelectedItems = new List<FileItem>();
			}
Пример #24
0
        public ExpendListAdapter(Activity activity,
			Dictionary<string, List<string> > dictGroup)
        {
            _dictGroup = dictGroup;
            _activity = activity;
            _lstGroupID = dictGroup.Keys.ToList();
        }
        public static void Transition(Activity activity, Android.Support.V4.App.FragmentTransaction fragmentTransaction, int frameResId, Android.Support.V4.App.Fragment fragment)
        {
            InitTransaction(fragmentTransaction);

            fragmentTransaction.Replace(frameResId, fragment);
            fragmentTransaction.Commit();
        }
Пример #26
0
        public static bool switchByIdFromList(int id, Android.App.Activity activity)
        {
            switch (id)
            {
            case 2:
                activity.StartActivity((typeof(PlaylistsActivity)));
                return(true);

            case 3:
                activity.StartActivity((typeof(ArtistsActivity)));
                return(true);

            case 4:
                activity.StartActivity((typeof(GenresPageActivity)));
                return(true);

            case 6:
                activity.StartActivity(typeof(AccountActivity));
                return(true);

            case 7:
                activity.StartActivity(typeof(PasswordChangeActivity));
                return(true);

            case 8:
                switchSavedUser(null);
                activity.StartActivity(typeof(LoginActivity));
                activity.Finish();
                return(true);

            default:
                return(false);
            }
        }
Пример #27
0
		public static void Init(Activity activity, Bundle bundle)
		{
			if (IsInitialized)
				return;
			IsInitialized = true;

			Context = activity;

			MapRenderer.Bundle = bundle;

#pragma warning disable 618
			if (GooglePlayServicesUtil.IsGooglePlayServicesAvailable(Context) == ConnectionResult.Success)
#pragma warning restore 618
			{
				try
				{
					MapsInitializer.Initialize(Context);
				}
				catch (Exception e)
				{
					Console.WriteLine("Google Play Services Not Found");
					Console.WriteLine("Exception: {0}", e);
				}
			}

			GeocoderBackend.Register(Context);
		}
Пример #28
0
		public AvatarAdapter(Activity context, ProfileViewModel viewModel)
		{
			this.context = context;
			this.viewModel = viewModel;
			viewModel.Avatars.CollectionChanged += (sender, e) => context.RunOnUiThread (NotifyDataSetChanged);

		}
Пример #29
0
		public UnbindPopWindow (Activity _activity,GuardianInfoListItem item)
		{
			activity = _activity;
			LayoutInflater inflater = (LayoutInflater) activity.GetSystemService (Context.LayoutInflaterService);
			contentView = inflater.Inflate(Resource.Layout.customunbinddialogLayout, null);  

			ContentView = contentView;
			Width = 900;
			Height = 450;
			Focusable = true;
			OutsideTouchable = true;
			//Update ();
			SetBackgroundDrawable (new ColorDrawable());
			AnimationStyle = Resource.Style.AnimationPreview;
			var btn_confirm = contentView.FindViewById<Button> (Resource.Id.btn_confirm);
			btn_confirm.Click += (sender, e) => 
			{
				Dismiss();

				if(UnBindEventHandler != null)
					UnBindEventHandler(item);
		
			};
			var btn_cancel = contentView.FindViewById<Button> (Resource.Id.btn_cancel);
			btn_cancel.Click += (sender, e) => 
			{
				Dismiss();
			};

			DismissEvent += (sender, e) => 
			{
				BackgroundAlpha(1f);

			};
		}
Пример #30
0
        private ProtoPadServer(View window, int? overrideListeningPort = null, string overrideBroadcastedAppName = null)
        {
            _window = window;
            _contextActivity = window.Context as Activity;

            _httpServer = new SimpleHttpServer(responseBytes =>
            {
                var response = "{}";
                var remoteCommandDoneEvent = new AutoResetEvent(false);
                _contextActivity.RunOnUiThread(() => Response(responseBytes, remoteCommandDoneEvent, ref response));
                remoteCommandDoneEvent.WaitOne();
                return response;
            });

            IPAddress broadCastAddress;
            using (var wifi = _contextActivity.GetSystemService(Android.Content.Context.WifiService) as WifiManager)
            {
                _mcLock = wifi.CreateMulticastLock("ProtoPadLock");
                _mcLock.Acquire();
                broadCastAddress = GetBroadcastAddress(wifi);
            }

            BroadcastedAppName = overrideBroadcastedAppName ?? String.Format("ProtoPad Service on ANDROID Device {0}", Android.OS.Build.Model);
            ListeningPort = overrideListeningPort ?? 8080;
            LocalIPAddress = Helpers.GetCurrentIPAddress();

            _udpServer = new UdpDiscoveryServer(BroadcastedAppName, String.Format("http://{0}:{1}/", LocalIPAddress, ListeningPort), broadCastAddress);
        }
		public MyVote_YesOrNoDialog(Activity context, string imgId, ImageView imgView,int position)
		{
			this.context = context;
			imageId = imgId;
			imageView = imgView;
			this.position = position;
		}
Пример #32
0
        private string GetLastPhotoInGallery(Activity activity)
        {
            string result = null;
            string[] projection = { MediaStore.Images.ImageColumns.Id };
            ICursor cursor = null;
            try
            {
                cursor = activity.ContentResolver
                    .Query(MediaStore.Images.Media.ExternalContentUri
                        , projection
                        , null
                        , null
                        , MediaStore.Images.ImageColumns.DateTaken + " DESC");
                if (cursor.MoveToFirst())
                    result = cursor.GetString(0);
            }
            finally
            {
                if (cursor != null)
                {
                    cursor.Close();
                    cursor.Dispose();
                }
            }

            return result;
        }
Пример #33
0
        /// <summary>
        /// 网络是否联通
        /// </summary>
        public static bool isNetworkConnected(Activity active)
        {
            bool net = false;

            ConnectivityManager connManager = (ConnectivityManager)active.GetSystemService(Context.ConnectivityService);

            // connManager.ActiveNetworkInfo ==null   手机无法连接网络
            if (connManager.ActiveNetworkInfo != null)
            {
                //获得 wifi 连接管理
                NetworkInfo networkInfo = connManager.GetNetworkInfo(ConnectivityType.Wifi);
                //获得 GPRS 连接管理
                NetworkInfo gp = connManager.GetNetworkInfo(ConnectivityType.Mobile);
                if (networkInfo != null && networkInfo.IsAvailable != false)
                {
                    //Toast.MakeText(active, "WIFI打开!", ToastLength.Long).Show();
                    net = true;
                }
                // gp.IsConnected==false 有信号无网络
                if (gp != null && gp.IsConnected != false)
                {
                    //Toast.MakeText(active, "有信号gprs打开!", ToastLength.Long).Show();
                    net = true;
                }
            }
            else
            {
                //Toast.MakeText(active, "无法连接到互联网!", ToastLength.Long).Show();
            }
            return net;
        }
 public PilotListCounterFragment(string title, PilotListAdapter pilotList, Activity parent)
     : base()
 {
     mTitle = title;
     mPilotList = pilotList;
     mParent = parent;
 }
Пример #35
0
		//protected override void OnElementChanged(VisualElement oldModel, VisualElement newModel)
		//protected override void OnElementChanged(ElementChangedEventArgs<TabbedPage> e)
		protected override void OnDraw(Canvas canvas)
		{
			_activity = this.Context as Activity;
			ActionBar actionBar = _activity.ActionBar;

			if (actionBar.TabCount > 0)
			{
				ActionBar.Tab tabPrompting = actionBar.GetTabAt(0);
				ActionBar.Tab tabActivities = actionBar.GetTabAt(1);
				ActionBar.Tab tabReminders = actionBar.GetTabAt(2);
				ActionBar.Tab tabMapping = actionBar.GetTabAt(3);
				ActionBar.Tab tabSettings = actionBar.GetTabAt(4);

				//Set the tab icons
				tabPrompting.SetIcon(Resource.Drawable.ic_description_white_24dp);
				tabActivities.SetIcon(Resource.Drawable.ic_local_activity_white_24dp);
				tabReminders.SetIcon(Resource.Drawable.ic_schedule_white_24dp);
				tabMapping.SetIcon(Resource.Drawable.ic_map_white_24dp);
				tabSettings.SetIcon(Resource.Drawable.ic_settings_white_24dp);

				//Remove the page's title from the tab
				tabPrompting.SetText("");
				tabActivities.SetText("");
				tabReminders.SetText("");
				tabMapping.SetText("");
				tabSettings.SetText("");

				base.OnDraw(canvas);
			}
		}
Пример #36
0
        public void OnActivityStarted(Activity activity)
        {
            CrossCurrentActivity.Current.Activity = activity;
#if !XTC
            HockeyApp.Tracking.StartUsage(activity);
#endif
        }
Пример #37
0
        public static void Init(Activity activity, Bundle bundle)
        {
            if (IsInitialized)
                return;

            IsInitialized = true;
            Context = activity;
            UnifiedMapRenderer.Bundle = bundle;

            int resultCode = GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(Context);
            if (resultCode == ConnectionResult.Success)
            {
                try
                {
                    MapsInitializer.Initialize(Context);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Google Play Services Not Found");
                    Console.WriteLine("Exception: {0}", ex);
                }
            }
            else
            {
                Console.WriteLine("Google Play services not available");
            }
        }
Пример #38
0
 public ProgressShower(Activity activity)
     : base(activity)
 {
     Indeterminate = true;
     SetProgressStyle(ProgressDialogStyle.Horizontal);
     SetButton("Cancel",_click);
 }
        //Shows the soft keyboard
        public void showSoftKeyboard(Android.App.Activity activity, View view)
        {
            InputMethodManager inputMethodManager = (InputMethodManager)activity.GetSystemService(Context.InputMethodService);

            view.RequestFocus();
            inputMethodManager.ShowSoftInput(view, 0);
            inputMethodManager.ToggleSoftInput(ShowFlags.Forced, HideSoftInputFlags.ImplicitOnly);//personal line added
        }
 public void OnActivityStopped(Android.App.Activity activity)
 {
     if (activity is MainActivity)
     {
         new SharedPrefs().Save(appStateKey, appstopValue);
     }
     setApplicationEventBadge();
 }
Пример #41
0
 public override void OnAttach(Android.App.Activity activity)
 {
     base.OnAttach(activity);
     if (prefs == null)
     {
         prefs = new PreferenceManager(activity);
     }
 }
Пример #42
0
        protected void OpenUriXamarinAuthWebViewActivity(Android.App.Activity activity, Uri uri)
        {
            Intent intent = new Intent(activity, typeof(Xamarin.Auth.WebViewActivity));

            intent.PutExtra(Xamarin.Auth.WebViewActivity.EXTRA_URL, uri.ToString());
            activity.StartActivity(intent);

            return;
        }
 public static Intent CreateTokenIntent(Android.App.Activity launchingActivity, string cardNumber = null, Integer month = null, Integer year = null, string cvc = null, string publishableKey = null)
 {
     return(new Intent(launchingActivity, typeof(TokenIntentService))
            .PutExtra(EXTRA_CARD_NUMBER, cardNumber)
            .PutExtra(EXTRA_MONTH, month)
            .PutExtra(EXTRA_YEAR, year)
            .PutExtra(EXTRA_CVC, cvc)
            .PutExtra(EXTRA_PUBLISHABLE_KEY, publishableKey));
 }
Пример #44
0
        protected void OpenUriSimple(Android.App.Activity activity, Uri uri)
        {
            Intent intent = new Intent(Intent.ActionView);

            intent.SetData(uri);
            activity.StartActivity(intent);

            return;
        }
Пример #45
0
 /// <summary>
 /// 摧毁本库的 AcpActivity
 /// </summary>
 private void OnDestroy()
 {
     if (mActivity != null)
     {
         mActivity.Finish();
         mActivity = null;
     }
     mCallback = null;
 }
Пример #46
0
 public RecyclerViewAdapter(Android.App.Activity activity, List <Recipe> items, Context context, RecipeListFragment recipeListFragment)
 {
     this.recipeListFragment = recipeListFragment;
     parent       = activity;
     this.context = context;
     activity.Theme.ResolveAttribute(Resource.Attribute.selectableItemBackground, typedValue, true);
     background = typedValue.ResourceId;
     values     = items;
 }
        // Hides the soft keyboard
        public void hideSoftKeyboard(Android.App.Activity activity)
        {
            var currentFocus = activity.CurrentFocus;

            if (currentFocus != null)
            {
                InputMethodManager inputMethodManager = (InputMethodManager)activity.GetSystemService(Context.InputMethodService);
                inputMethodManager.HideSoftInputFromWindow(currentFocus.WindowToken, HideSoftInputFlags.None);
            }
        }
Пример #48
0
        private void SetupUserInterface()
        {
            _activity = Context as Android.App.Activity;
            _view     = _activity?.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false);

            if (_view != null)
            {
                _textureView = _view.FindViewById <TextureView>(Resource.Id.textureView);
            }
            _textureView.SurfaceTextureListener = this;
        }
Пример #49
0
 /**
  * Unregister the {@link BroadcastReceiver}.
  */
 public void Detach()
 {
     if (mTokenBroadcastReceiver != null)
     {
         LocalBroadcastManager.GetInstance(mActivity)
         .UnregisterReceiver(mTokenBroadcastReceiver);
         mTokenBroadcastReceiver = null;
         mActivity = null;
     }
     mCardInputWidget = null;
 }
        public void OnActivityCreated(Android.App.Activity activity, Android.OS.Bundle savedInstanceState)
        {
            if (IsInit == false)
            {
                MainApplication.RunningApp = new object();

                IsInit = true;
                //AppContext = this.ApplicationContext;
                StartPushService();
            }
        }
Пример #51
0
        public AndroidCv(Context context, App.Activity activity, ImageView imageView = null)
        {
            Logger.WriteMethod = new Logger.WriteMethodDelegate((string s) => { Log.WriteLine(LogPriority.Debug, "Vision.Android", s); });

            AppContext     = context;
            this.imageView = imageView;
            this.activity  = activity;

            OpenCvSharp.Android.NativeBinding.Init(context, activity, imageView);
            SharpFace.Android.Native.Init();
            SharpFace.NativeTest.Test();
        }
Пример #52
0
        /// <summary>
        /// Gets an <see cref="Android.Content.Intent"/> that can be used to start the share activity.
        /// </summary>
        /// <returns>
        /// The <see cref="Android.Content.Intent"/>.
        /// </returns>
        /// <param name='activity'>
        /// The <see cref="Android.App.Activity"/> that will invoke the returned <see cref="Android.Content.Intent"/>.
        /// </param>
        /// <param name='item'>
        /// The item to share.
        /// </param>
        /// <param name='completionHandler'>
        /// Handler called when the share UI has finished.
        /// </param>
        public virtual ShareUIType GetShareUI(UIContext activity, Item item, Action <ShareResult> completionHandler)
        {
            var intent = new Android.Content.Intent(activity, typeof(ShareActivity));
            var state  = new ShareActivity.State {
                Service           = this,
                Item              = item,
                CompletionHandler = completionHandler,
            };

            intent.PutExtra("StateKey", ShareActivity.StateRepo.Add(state));
            return(intent);
        }
Пример #53
0
        //int? IGallery.ImagesSelection
        //{
        //    get
        //    {
        //        return Convert.ToInt32(Xamarin.Forms.Application.Current.Properties["ImagesSelection"]);
        //    }

        //    set
        //    {
        //        Xamarin.Forms.Application.Current.Properties["ImagesSelection"] = value;
        //    }
        //}

        public void OpenGallery(int imageselection)
        {
            Android.App.Activity objActivity = CrossCurrentActivity.Current.Activity;
            //var imageIntent = new Intent(Intent.ActionView, MediaStore.Images.Media.ExternalContentUri);
            Intent imageIntent = new Intent(Intent.ActionPick);

            imageIntent.SetType("image/*");
            imageIntent.PutExtra(Intent.ExtraAllowMultiple, true);
            imageIntent.SetAction(Intent.ActionGetContent);
            ((Activity)objActivity).StartActivityForResult(Intent.CreateChooser(imageIntent, "Select photo"), 1);
            Toast.MakeText(Android.App.Application.Context, "Select a maximum of " + imageselection + " image/s", ToastLength.Long).Show();
        }
        public Permissions(app.Activity activity)
        {
            _Activity = activity;

            _RequestPermissionsActivity = _Activity as IRequestPermissionsActivity;
            if (_RequestPermissionsActivity == null)
            {
                throw new Exception($"The Activity must implement the {typeof(IRequestPermissionsActivity).FullName} interface, and this Activity must raise the {nameof(IRequestPermissionsActivity.PermissionsRequestCompleted)} event when the OnRequestPermissionsResult callback is made. OnRequestPermissionsResult must be overriden in the Activity for this to work. See XML documentation in the interface for more information.");
            }

            _RequestPermissionsActivity.PermissionsRequestCompleted += RequestPermissionsActivity_PermissionsRequestCompleted;
        }
Пример #55
0
        public static void Initialize(Android.App.Activity activity, string licenseKey = null)
        {
            _initizalized = true;
            Activity      = activity;
            Context       = activity as Android.Content.Context;
            FormsGestures.Droid.Settings.Init(Context);

            if (licenseKey != null)
            {
                System.Console.WriteLine("Forms9Patch is now open source using the MIT license ... so it's free, including for commercial use.  Why?  The more people who use it, the faster bugs will be found and fixed - which helps me and you.  So, please help get the word out - tell your friends, post on social media, write about it on the bathroom walls at work!  If you have purchased a license from me, please don't get mad - you did a good deed.  They really were not that expensive and you did a great service in encouraging me keep working on Forms9Patch.");
            }
        }
        /// <summary>
        /// Unbinds the Activity from the Custom Tabs Service. </summary>
        /// <param name="activity"> the activity that is connected to the service. </param>
        public virtual void UnbindCustomTabsService(Android.App.Activity activity)
        {
            if (custom_tabs_service_connection == null)
            {
                return;
            }
            activity.UnbindService(custom_tabs_service_connection);
            custom_tabs_client             = null;
            custom_tabs_session            = null;
            custom_tabs_service_connection = null;

            return;
        }
Пример #57
0
        private static void InitComponent(Android.App.Activity activity)
        {
            _activity = activity;

            activity.Window.SetSoftInputMode(SoftInput.AdjustResize | SoftInput.StateAlwaysHidden);

            //AndroidBug5497WorkaroundForXamarinAndroid.assistActivity(activity);

            DependencyService.Register <IWebViewService, WebViewService>();

            //Instanciate GeckoView type in BlazorMobile assemnly for Android
            BlazorWebViewFactory.SetInternalBlazorGeckoViewType(typeof(BlazorGeckoView));

            BlazorGeckoViewRenderer.Init(activity);
        }
Пример #58
0
 public static MyAndroidIntentUtils GetInstance(Android.App.Activity activity = null)
 {
     lock (objLock)
     {
         if (s_Instance == null)
         {
             s_Instance = new MyAndroidIntentUtils();
             if (s_Instance.mAppActivity == null && activity == null)
             {
                 throw new Exception("MyAndroidIntentUtils.GetInstance 单例首次创建, 请传入 activity 参数");
             }
             if (activity != null)
             {
                 s_Instance.mAppActivity = activity;
             }
         }
         return(s_Instance);
     }
 }
Пример #59
0
 public static MyAndroidPermission_InTestSolution GetInstance(Android.App.Activity activity = null)
 {
     lock (objLock)
     {
         if (s_Instance == null)
         {
             s_Instance = new MyAndroidPermission_InTestSolution();
             if (s_Instance.mAppActivity == null && activity == null)
             {
                 throw new Exception("MyPermission.GetInstance 单例首次创建, 请传入 activity 参数");
             }
             if (activity != null)
             {
                 s_Instance.mAppActivity = activity;
             }
         }
         return(s_Instance);
     }
 }
Пример #60
0
        public static Task <T> WaitOnUiThread <T>(this Android.App.Activity act, Func <T> f)
        {
            TaskCompletionSource <T> tcs = new TaskCompletionSource <T>();

            act.RunOnUiThread(() =>
            {
                T result = default(T);
                try
                {
                    result = f();
                }
                catch (Exception e)
                {
                    // Ignore it. But it should be impossible for now
                }
                tcs.SetResult(result);
            });
            return(tcs.Task);
        }