コード例 #1
0
        /// <summary>
        /// This Ctor creates device info that represents given device action info and calls actions by
        /// jam connection service.
        /// </summary>
        /// <param name="context">
        ///            Context in which layout is created. </param>
        /// <param name="data">
        ///            DeviceActionsLayoutData object with parameters for the view to create </param>
        /// <param name="sapaAppService">
        ///            Instance of SapaAppService of this application </param>
        /// <param name="isExpanded">
        ///             Boolean indicating whether the bar should be expanded </param>
        /// <param name="orientation">
        ///            Orientation of the bar. </param>
        /// <param name="controlbar">
        ///            Reference to parent controlbar widget </param>
        protected internal DeviceActionsLayout(Context context, DeviceActionsLayoutData data, SapaAppService sapaAppService, bool isExpanded, int orientation, ControlBar controlbar) : base(context)
        {
            initAppIconMaxSize();
            mParent = controlbar;

            this.mData             = data;
            this.HorizontalGravity = Gravity.CENTER_HORIZONTAL;
            this.VerticalGravity   = Gravity.CENTER_VERTICAL;
            this.Orientation       = orientation;
            this.LayoutDirection   = LayoutDirection.INHERIT;


            // mActionButtons = new ArrayList<ImageButton>();
            this.mIsExpanded = isExpanded;
            mButtonsView     = createOpenButtonLayout();
            this.mAppButton  = createDeviceButton();
            string appName = AppName;

            if (appName != null && appName.Length > 0)
            {
                this.mAppButton.ContentDescription = Resources.getString([email protected]_btn_options, appName);
            }
            this.LayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            this.addView(this.mAppButton, getAppBtnLayoutParams(Orientation));
            this.mSapaAppService = sapaAppService;
            createActionList();
            int buttonsNo = this.mData.mActionList != null ? (this.mData.mActionList.size() + 1) : 0;

            this.mAnimationTime = ControlBar.ANIM_TIME * buttonsNo;
            if (this.mIsExpanded)
            {
                show();
            }
        }
コード例 #2
0
 private static SapaAppInfo findMainApp(SapaAppService sapaAppService, string mainAppPackageName)
 {
     if (sapaAppService != null)
     {
         IList <SapaAppInfo> activeApps = null;
         try
         {
             activeApps = sapaAppService.AllActiveApp;
             if (activeApps != null)
             {
                 foreach (SapaAppInfo appInfo in activeApps)
                 {
                     if (mainAppPackageName.Equals(appInfo.App.PackageName))
                     {
                         return(appInfo);
                     }
                 }
             }
         }
         catch (SapaConnectionNotSetException e)
         {
             Log.d(TAG, e.Message);
         }
     }
     return(null);
 }
コード例 #3
0
 public override void onCreate()
 {
     Log.d(TAG, "onCreate");
     base.onCreate();
     mBinder = new LocalBinder(this);
     this.mSapaAppService = null;
 }
コード例 #4
0
        /// <summary>
        /// @brief Get intent that started application of given instanceId
        ///
        /// TODO: Describe catched exceptions
        /// </summary>
        /// <param name="instanceId">    unique instance id
        /// </param>
        /// <returns> Intent object or null </returns>
        public virtual Intent getLaunchIntent(string instanceId)
        {
            SapaAppInfo appInfo = getAppInfo(instanceId);

            if (appInfo == null)
            {
                Log.w(TAG, "Cannot start activity for application: " + instanceId + ": app not active");
                return(null);
            }

            SapaAppService sapaAppService = SapaAppService;
            Intent         intent         = null;

            try
            {
                intent = sapaAppService.getLaunchIntent(appInfo.App);
            }
            catch (SapaConnectionNotSetException)
            {
                Log.w(TAG, "Cannot start activity for application " + instanceId + ": sapa connection has not been set");
            }
            catch (IllegalAccessException)
            {
                Log.w(TAG, "Cannot start activity for application " + instanceId + ": illegal access");
            }

            return(intent);
        }
コード例 #5
0
		public override void onCreate()
		{
			Log.d(TAG, "onCreate");
			base.onCreate();
			mBinder = new LocalBinder(this);
			this.mSapaAppService = null;
		}
コード例 #6
0
        private void setSapaAppService(SapaAppService sapaAppService, string mainAppPackageName)
        {
            Log.d(TAG, "Setting sapa app service with main: " + mainAppPackageName);
            // unregister listeners from previous one
            removeSapaListeners();

            mSapaAppService     = sapaAppService;
            mMainAppPackageName = mainAppPackageName;
            mMainApp            = findMainApp(sapaAppService, mainAppPackageName);

            // register listeners for the new one
            addSapaListeners();
        }
コード例 #7
0
		public override void onCreate()
		{
			Log.d(TAG, "onCreate");
			base.onCreate();
			this.mBinder = new LocalBinder(this);
			this.mIsPlaying = false;
			this.mSapaAppService = null;
			this.mServiceConnected = false;
			this.mActionsList = new Dictionary<string, MainService.ActionsPack>();
			this.mProcessorList = new Dictionary<string, SapaProcessor>();
			this.mAppInfoList = new Dictionary<string, SapaAppInfo>();
			this.mCallerPackageNameList = new ConcurrentDictionary<string, string>();
		}
コード例 #8
0
 public override void setSapaAppService(SapaAppService sapaAppService, string mainPackagename)
 {
     if (mInitOrientation == HORIZONTAL)
     {
         putBarOnBoard(mBarAlignment);
         mInitialAlign = mBarAlignment;
     }
     else
     {
         putBarOnBoard(mBarAlignment);
     }
     base.setSapaAppService(sapaAppService, mainPackagename);
 }
コード例 #9
0
 public override void onCreate()
 {
     Log.d(TAG, "onCreate");
     base.onCreate();
     this.mBinder                = new LocalBinder(this);
     this.mIsPlaying             = false;
     this.mSapaAppService        = null;
     this.mServiceConnected      = false;
     this.mActionsList           = new Dictionary <string, MainService.ActionsPack>();
     this.mProcessorList         = new Dictionary <string, SapaProcessor>();
     this.mAppInfoList           = new Dictionary <string, SapaAppInfo>();
     this.mCallerPackageNameList = new ConcurrentDictionary <string, string>();
 }
コード例 #10
0
        /// <summary>
        /// @brief TODO!
        /// </summary>
        /// <param name="sapaAppService"> </param>
        /// <param name="mainPackage"> </param>
        public virtual void setSapaAppService(SapaAppService sapaAppService, string mainPackage)
        {
            Log.d(TAG, "setSapaAppService(" + mainPackage + ")");
            mFcSapaConnector = new FcSapaServiceConnector(mModel, sapaAppService, mainPackage);
            mFcContext.SapaServiceConnector = mFcSapaConnector;
            MainApp = mFcSapaConnector.MainApp;
            SapaAppInfo sapaAppInfo = SapaAppInfo.getAppInfo(((Activity)Context).Intent);

            if (sapaAppInfo != null)
            {
                SelectedApp = sapaAppInfo;
            }
        }
コード例 #11
0
        private void connectConnectionBridge()
        {
            Log.d(TAG, "Connect using bridge");
            mSapaAppService = new SapaAppService(this);

            //MainService starts listening for establishment of connection.
            //MainService needs to implement AudioServiceConnectListener to be able to listen for this event.
            //When event occurs onServiceConnected() method is called.
            mSapaAppService.addConnectionListener(this);

            //MainService declares that it defines actions for this application.
            //MainService needs to implement AudioActionDefinerInterface.
            mSapaAppService.ActionDefiner = this;

            mSapaAppService.addAppStateListener(mSapaAppStateListener);

            //Connection to AudioConnectionService starts being created.
            mSapaAppService.connect();
        }
コード例 #12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private synchronized void init(android.content.Context activity, Info info, int res) throws NotActivityException
        private void init(Context activity, Info info, int res)
        {
            lock (this)
            {
                if (!(activity is Activity))
                {
                    throw new NotActivityException();
                }
                LayoutInflater.from(Context).inflate(res, this, true);
                LayoutDirection      = LAYOUT_DIRECTION_INHERIT;
                mInfo                = info;
                this.mActionsLayouts = new SortedDictionary <string, DeviceActionsLayout>();
                this.setControlBar();

                this.setDevicesLayout();

                initHorizontalScrolling();

                this.mBarHandler.OnLongClickListener = new MyLongTounchListener(this);

                this.mBarHandler.Id = Context.GetHashCode();

                this.mEnd = (ImageView)findViewById(R.id.end);
                //if (mEndImageRes != null && mEndImageRes.containsKey(getOrientation())) this.mEnd
                //      .setImageResource(mEndImageRes.get(getOrientation()));
                // else this.mEnd.setImageResource(android.R.color.transparent);
                if (mInfo.mListHidden || this.mActionsLayouts == null || this.mActionsLayouts.Count == 0)
                {
                    this.mEnd.Visibility = LinearLayout.GONE;
                }
                else
                {
                    this.mEnd.Visibility = LinearLayout.VISIBLE;
                }
                //if (getOrientation() == LinearLayout.HORIZONTAL) mEnd.setLayoutParams(new LayoutParams(
                //       LayoutParams.WRAP_CONTENT, DeviceActionsLayout.BUTTON_HEIGHT));
                //else mEnd.setLayoutParams(new LayoutParams(DeviceActionsLayout.BUTTON_HEIGHT,
                //       LayoutParams.WRAP_CONTENT));

                this.mSapaAppService = null;
                this.Orientation     = Orientation;
            }
        }
コード例 #13
0
        public override void onDestroy()
        {
            Log.d(TAG, "onDestroy");

            //Native part of application is being deactivated.
            if (mSapaService != null && mSapaProcessor != null)
            {
                mSapaProcessor.deactivate();
                mSapaService.unregister(mSapaProcessor);
                this.mSapaProcessor = null;
            }

            if (this.mSapaAppService != null)
            {
                try
                {
                    if (this.mMyInfo != null && this.mMyInfo.App != null)
                    {
                        //Application needs to declare that it was successfully deactivated.
                        this.mSapaAppService.removeFromActiveApps(this.mMyInfo.App);
                    }

                    //Action definer is being removed.
                    this.mSapaAppService.removeActionDefiner();
                }
                catch (SapaConnectionNotSetException e)
                {
                    Log.e(TAG, "Instance could not be removed from active list because of connection exception.");
                }
                //Connection with remote service is finished.
                this.mSapaAppService.disconnect();
                this.mSapaAppService = null;
            }

            this.mMyInfo = null;


            base.onDestroy();
        }
コード例 #14
0
        internal virtual void setSapaAppService(SapaAppService sapaAppService, string mainAppPackageName)
        {
            Log.d(TAG, "setSapaservice " + sapaAppService);
            SapaAppService previous = this.mSapaAppService;

            this.mSapaAppService = sapaAppService;
            if (sapaAppService != null)
            {
                mInfo.mMainApplicationPackage = mainAppPackageName;
                this.mSapaAppService.addConnectionListener(this);
                this.mSapaAppService.addAppStateListener(this);
                if (Context != null)
                {
                    try
                    {
                        ((Activity)Context).runOnUiThread(() =>
                        {
                            lock (ControlBar.this)
                            {
                                ControlBar.this.initializeActions();
                                ControlBar.this.updateBar();
                                ControlBar.this.fillBar();
                            }
                        });
                    }
                    catch (System.NullReferenceException)
                    {
                        ;
                    }
                }
                ;
            }
            else if (previous != null)
            {
                previous.removeConnectionListener(this);
                previous.removeAppStateListener(this);
            }
        }
コード例 #15
0
 internal virtual void updateSapaAppService(SapaAppService sapaAppService)
 {
     setSapaAppService(sapaAppService, mInfo.mMainApplicationPackage);
 }
コード例 #16
0
		private void connectConnectionBridge()
		{
			Log.d(TAG, "Connect using bridge");
			this.mSapaAppService = new SapaAppService(this);

			// MainService starts listening for establishment of connection.
			// MainService needs to implement AudioServiceConnectListener to be able
			// to listen for this event.
			// When event occurs onServiceConnected() method is called.
			this.mSapaAppService.addConnectionListener(this);

			// MainService declares that it defines actions for this application.
			// MainService needs to implement AudioActionDefinerInterface.
			this.mSapaAppService.ActionDefiner = this;

			this.mSapaAppService.addAppStateListener(mSapaAppStateListener);

			// Connection to AudioConnectionService starts being created.
			this.mSapaAppService.connect();
		}
コード例 #17
0
		internal virtual void updateSapaAppService(SapaAppService sapaAppService)
		{
			setSapaAppService(sapaAppService, mInfo.mMainApplicationPackage);
		}
コード例 #18
0
		private void setSapaAppService(SapaAppService sapaAppService, string mainAppPackageName)
		{
			Log.d(TAG, "Setting sapa app service with main: " + mainAppPackageName);
			// unregister listeners from previous one
			removeSapaListeners();

			mSapaAppService = sapaAppService;
			mMainAppPackageName = mainAppPackageName;
			mMainApp = findMainApp(sapaAppService, mainAppPackageName);

			// register listeners for the new one
			addSapaListeners();
		}
コード例 #19
0
		public virtual void setSapaAppService(SapaAppService sapaAppService, string mainPackagename)
		{
			mControlBar.setSapaAppService(sapaAppService, mainPackagename);
		}
コード例 #20
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private synchronized void init(android.content.Context activity, Info info, int res) throws NotActivityException
		private void init(Context activity, Info info, int res)
		{
			lock (this)
			{
				if (!(activity is Activity))
				{
					throw new NotActivityException();
				}
				LayoutInflater.from(Context).inflate(res, this, true);
				LayoutDirection = LAYOUT_DIRECTION_INHERIT;
				mInfo = info;
				this.mActionsLayouts = new SortedDictionary<string, DeviceActionsLayout>();
				this.setControlBar();
        
				this.setDevicesLayout();
        
				initHorizontalScrolling();
        
				this.mBarHandler.OnLongClickListener = new MyLongTounchListener(this);
        
				this.mBarHandler.Id = Context.GetHashCode();
        
				this.mEnd = (ImageView) findViewById(R.id.end);
				//if (mEndImageRes != null && mEndImageRes.containsKey(getOrientation())) this.mEnd
				  //      .setImageResource(mEndImageRes.get(getOrientation()));
			   // else this.mEnd.setImageResource(android.R.color.transparent);
				if (mInfo.mListHidden || this.mActionsLayouts == null || this.mActionsLayouts.Count == 0)
				{
					this.mEnd.Visibility = LinearLayout.GONE;
				}
				else
				{
					this.mEnd.Visibility = LinearLayout.VISIBLE;
				}
				//if (getOrientation() == LinearLayout.HORIZONTAL) mEnd.setLayoutParams(new LayoutParams(
				 //       LayoutParams.WRAP_CONTENT, DeviceActionsLayout.BUTTON_HEIGHT));
				//else mEnd.setLayoutParams(new LayoutParams(DeviceActionsLayout.BUTTON_HEIGHT,
				 //       LayoutParams.WRAP_CONTENT));
        
				this.mSapaAppService = null;
				this.Orientation = Orientation;
        
			}
		}
コード例 #21
0
		public override void onDestroy()
		{
			Log.d(TAG, "onDestroy");

			//Native part of application is being deactivated.
			if (mSapaService != null && mSapaProcessor != null)
			{
				mSapaProcessor.deactivate();
				mSapaService.unregister(mSapaProcessor);
				this.mSapaProcessor = null;
			}

			if (this.mSapaAppService != null)
			{
				try
				{
					if (this.mMyInfo != null && this.mMyInfo.App != null)
					{
					//Application needs to declare that it was successfully deactivated.
					this.mSapaAppService.removeFromActiveApps(this.mMyInfo.App);
					}

					//Action definer is being removed.
					this.mSapaAppService.removeActionDefiner();
				}
				catch (SapaConnectionNotSetException e)
				{
					Log.e(TAG, "Instance could not be removed from active list because of connection exception.");
				}
				//Connection with remote service is finished.
				this.mSapaAppService.disconnect();
				this.mSapaAppService = null;
			}

			this.mMyInfo = null;


			base.onDestroy();
		}
コード例 #22
0
 //in this version there is no main app
 public override void setSapaAppService(SapaAppService sapaAppService, string mainPackagename)
 {
     base.setSapaAppService(sapaAppService, mainPackagename);
 }
コード例 #23
0
		/// <summary>
		/// @brief TODO!
		/// </summary>
		/// <param name="sapaAppService"> </param>
		/// <param name="mainPackage"> </param>
		public virtual void setSapaAppService(SapaAppService sapaAppService, string mainPackage)
		{
			Log.d(TAG, "setSapaAppService(" + mainPackage + ")");
			mFcSapaConnector = new FcSapaServiceConnector(mModel, sapaAppService, mainPackage);
			mFcContext.SapaServiceConnector = mFcSapaConnector;
			MainApp = mFcSapaConnector.MainApp;
			SapaAppInfo sapaAppInfo = SapaAppInfo.getAppInfo(((Activity)Context).Intent);
			if (sapaAppInfo != null)
			{
				SelectedApp = sapaAppInfo;
			}
		}
コード例 #24
0
		/// <summary>
		/// Constructs the connector object with needed info about SapaAppService and
		/// the package name of main application.
		/// </summary>
		/// <param name="sapaAppService"> reference to SapaAppService </param>
		/// <param name="mainAppPackageName"> package name for main (host) application </param>
		/// <param name="sapaModel"> model containing current state of FloatingController </param>
		internal FcSapaServiceConnector(FcSapaModel sapaModel, SapaAppService sapaAppService, string mainAppPackageName)
		{
			mFcSapaModel = sapaModel;
			setSapaAppService(sapaAppService, mainAppPackageName);
		}
コード例 #25
0
		private static SapaAppInfo findMainApp(SapaAppService sapaAppService, string mainAppPackageName)
		{
			if (sapaAppService != null)
			{
				IList<SapaAppInfo> activeApps = null;
				try
				{
					activeApps = sapaAppService.AllActiveApp;
					if (activeApps != null)
					{
						foreach (SapaAppInfo appInfo in activeApps)
						{
							if (mainAppPackageName.Equals(appInfo.App.PackageName))
							{
								return appInfo;
							}
						}
					}
				}
				catch (SapaConnectionNotSetException e)
				{
					Log.d(TAG, e.Message);
				}
			}
			return null;
		}
コード例 #26
0
		internal virtual void setSapaAppService(SapaAppService sapaAppService, string mainAppPackageName)
		{
			Log.d(TAG, "setSapaservice " + sapaAppService);
			SapaAppService previous = this.mSapaAppService;
			this.mSapaAppService = sapaAppService;
			if (sapaAppService != null)
			{
				mInfo.mMainApplicationPackage = mainAppPackageName;
				this.mSapaAppService.addConnectionListener(this);
				this.mSapaAppService.addAppStateListener(this);
				if (Context != null)
				{
					try
					{
					((Activity) Context).runOnUiThread(() =>
					{
						lock (ControlBar.this)
						{
							ControlBar.this.initializeActions();
							ControlBar.this.updateBar();
							ControlBar.this.fillBar();
						}
					});
					}
					catch (System.NullReferenceException)
					{
						;
					}
				};
			}
			else if (previous != null)
			{
				previous.removeConnectionListener(this);
				previous.removeAppStateListener(this);
			}
		}
コード例 #27
0
 public virtual void setSapaAppService(SapaAppService sapaAppService, string mainPackagename)
 {
     mControlBar.setSapaAppService(sapaAppService, mainPackagename);
 }
コード例 #28
0
 /// <summary>
 /// This Ctor creates device info that represents given device action info and calls actions by
 /// jam connection service. Layout is created with buttons of actions hidden.
 /// </summary>
 /// <param name="context">
 ///            Context in which layout is created. </param>
 /// <param name="data">
 ///            DeviceActionsLayoutData object with parameters for the view to create </param>
 /// <param name="sapaAppService">
 ///            Instance of SapaAppService of this application </param>
 /// <param name="orientation">
 ///            Orientation of the bar. </param>
 /// <param name="controlbar">
 ///            Local instance of ControlBar </param>
 protected internal DeviceActionsLayout(Context context, DeviceActionsLayoutData data, SapaAppService sapaAppService, int orientation, ControlBar controlbar) : this(context, data, sapaAppService, false, orientation, controlbar)
 {
 }
コード例 #29
0
 /// <summary>
 /// Constructs the connector object with needed info about SapaAppService and
 /// the package name of main application.
 /// </summary>
 /// <param name="sapaAppService"> reference to SapaAppService </param>
 /// <param name="mainAppPackageName"> package name for main (host) application </param>
 /// <param name="sapaModel"> model containing current state of FloatingController </param>
 internal FcSapaServiceConnector(FcSapaModel sapaModel, SapaAppService sapaAppService, string mainAppPackageName)
 {
     mFcSapaModel = sapaModel;
     setSapaAppService(sapaAppService, mainAppPackageName);
 }