/// <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(); } }
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); }
public override void onCreate() { Log.d(TAG, "onCreate"); base.onCreate(); mBinder = new LocalBinder(this); this.mSapaAppService = null; }
/// <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); }
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(); }
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>(); }
public override void setSapaAppService(SapaAppService sapaAppService, string mainPackagename) { if (mInitOrientation == HORIZONTAL) { putBarOnBoard(mBarAlignment); mInitialAlign = mBarAlignment; } else { putBarOnBoard(mBarAlignment); } base.setSapaAppService(sapaAppService, mainPackagename); }
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>(); }
/// <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; } }
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(); }
//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; } }
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(); }
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); } }
internal virtual void updateSapaAppService(SapaAppService sapaAppService) { setSapaAppService(sapaAppService, mInfo.mMainApplicationPackage); }
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(); }
public virtual void setSapaAppService(SapaAppService sapaAppService, string mainPackagename) { mControlBar.setSapaAppService(sapaAppService, mainPackagename); }
//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; } }
//in this version there is no main app public override void setSapaAppService(SapaAppService sapaAppService, string mainPackagename) { base.setSapaAppService(sapaAppService, mainPackagename); }
/// <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); }
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; }
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); } }
/// <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) { }