public override void prepareViewHolder(FcContext fcContext, FcAdapterModel model, FcModelItem item)
		{
			cleanLayouts();

			itemView.Visibility = View.VISIBLE;

			mDeviceLayout.LayoutDirection = item.Direction;

			mDeviceActions.LayoutDirection = item.Direction;
			mDeviceActions.Visibility = View.VISIBLE;
			mDeviceActions.Gravity = Gravity.CENTER;
			IList<FcActionItem> callActions = item.CallActions;
			prepareActionButtons(fcContext, callActions, mDeviceActions);

			mDeviceOpenActions.LayoutDirection = item.Direction;
			mDeviceOpenActions.Visibility = View.VISIBLE;
			mDeviceOpenActions.Gravity = Gravity.CENTER;
			IList<FcActionItem> returnActions = item.ReturnActions;
			prepareActionButtons(fcContext, returnActions, mDeviceOpenActions);

			if (item.hasVolumeActions())
			{
				mDeviceVolumes.LayoutDirection = item.Direction;
				mDeviceVolumes.Visibility = View.VISIBLE;
				mDeviceVolumes.Gravity = Gravity.CENTER;
				IList<FcActionItem> volumeActions = item.VolumeActions;
				prepareActionButtons(fcContext, volumeActions, mDeviceVolumes);
			}
		}
		public virtual Drawable getIcon(FcContext fcContext)
		{
			Drawable drawable = null;
			try
			{
				drawable = mActionInfo.getIcon(fcContext.Context);

			}
			catch (NameNotFoundException)
			{
				Log.w(TAG, "Cannot retrieve action icon: name not found");
			}

			return drawable;
		}
		public virtual string getName(FcContext fcContext)
		{
			Log.d(TAG, "getName");
			string name = null;
			try
			{
				name = mActionInfo.getName(fcContext.Context);

			}
			catch (NameNotFoundException)
			{
				Log.w(TAG, "Cannot retrieve action name: name not found");
			}
			Log.d(TAG, "name:" + name);
			return name;
		}
Exemplo n.º 4
0
		/// <summary>
		/// @brief Construct model item from SapaAppInfo structure
		/// </summary>
		/// <param name="info">  Data structure with information retrieved from SAPA </param>
		/// <param name="type">  Type of the item (main or ordinal) </param>
		internal FcModelItem(FcContext fcContext, SapaAppInfo info, int type)
		{
			SapaApp app = info.App;

			try
			{
				mIcon = info.getIcon(fcContext.Context);
			}
			catch (NameNotFoundException e)
			{
				LogUtils.throwable(TAG, "Drawable not set: name not found", e);
			}
			mInstanceId = app.InstanceId;
			mPackageName = app.PackageName;
			mType = type;

			prepareActions(fcContext, info);
		}
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public OrdinalAppViewHolder(final FcContext context, android.view.View itemView, FcAdapter adapter)
		public OrdinalAppViewHolder(FcContext context, View itemView, FcAdapter adapter) : base(itemView)
		{

			mDeviceAppButton = (ImageButton) itemView.findViewById(R.id.device_app_button);
			mDeviceRootLayout = (LinearLayout) itemView.findViewById(R.id.device_root_layout);
			mDeviceOpenActions = (LinearLayout) itemView.findViewById(R.id.device_open_actions);
			mDeviceActions = (LinearLayout) itemView.findViewById(R.id.device_actions);

			mDeviceVolumeActions = (LinearLayout) itemView.findViewById(R.id.device_volume_actions);
			mDeviceVolumes = (LinearLayout) itemView.findViewById(R.id.device_volumes);
			mDeviceVolumesLabel = (TextView) itemView.findViewById(R.id.device_volume_label);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final FcAnimator animator = new FcAnimator();
			FcAnimator animator = new FcAnimator();
			mExpandActionsButtonListener = new AppClickedListener(this, adapter);
			mOpenAppDirectlyButtonListener = new OnClickListenerAnonymousInnerClassHelper(this, context, animator);

			mDeviceAppButton.OnClickListener = mExpandActionsButtonListener;
		}
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: private void prepareActionButtons(final FcContext context, java.util.List<FcActionItem> actions, android.widget.LinearLayout parent)
		private void prepareActionButtons(FcContext context, IList<FcActionItem> actions, LinearLayout parent)
		{
			int i = 0;
			foreach (FcActionItem action in actions)
			{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.widget.ImageButton button = context.inflate(com.samsung.android.sdk.professionalaudio.widgets.R.layout.fc_main_action_button, parent);
				ImageButton button = context.inflate(R.layout.fc_main_action_button, parent);

				button.ImageDrawable = action.getIcon(context);
				button.Enabled = action.Enabled;
				button.Visibility = action.Visible ? View.VISIBLE : View.GONE;
				button.OnClickListener = new OnClickListenerAnonymousInnerClassHelper(this);
				int index = i;
				if (parent.LayoutDirection == View.LAYOUT_DIRECTION_RTL)
				{
					index = actions.Count - index - 1;
				}
				DrawableTool.setBackground(button, index, actions.Count, context);

				parent.addView(button);
				i++;
			}
		}
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: private void addBypassAction(FcContext fcContext, android.widget.LinearLayout linearLayout, final FcActionItem fcActionItem, int buttonText)
		private void addBypassAction(FcContext fcContext, LinearLayout linearLayout, FcActionItem fcActionItem, int buttonText)
		{
			Button bypassButton = (Button) LayoutInflater.from(fcContext.Context).inflate(R.layout.bypass_action_button, mDeviceActions, false);

	//        bypassButton.setBackground(fcActionItem.getIcon(fcContext));
			bypassButton.Enabled = fcActionItem.Enabled;
			bypassButton.Visibility = fcActionItem.Visible ? View.VISIBLE : View.GONE;
			bypassButton.Text = fcContext.Context.Resources.getString(buttonText);
			bypassButton.OnClickListener = new OnClickListenerAnonymousInnerClassHelper2(this, fcActionItem);

			DrawableTool.setBackground(bypassButton, 0, 1, fcContext);
			linearLayout.addView(bypassButton);
		}
		private Drawable getBackground(FcContext fcContext, bool active)
		{
			return active ? fcContext.getDrawable(R.drawable.floating_controller_active_app_frame) : new ColorDrawable(Color.parseColor("#00ffffff"));
		}
		public override void prepareViewHolder(FcContext fcContext, FcAdapterModel model, FcModelItem item)
		{
			if (FcConstants.OPT_DETAILED_LOGS)
			{
				Log.d(TAG, "prepareViewHolder(" + item + ")");
			}
			Context context = fcContext.Context;
			cleanLayouts();

			mFcModelItem = item;
			mExpandActionsButtonListener.Item = mFcModelItem;

			if (item.Expanded)
			{
				mDeviceRootLayout.Visibility = View.VISIBLE;
				mDeviceRootLayout.LayoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
			}
			else
			{
				mDeviceRootLayout.Visibility = View.VISIBLE;
				mDeviceRootLayout.LayoutParams.width = 0;
			}
			mDeviceRootLayout.requestLayout();

			// Setting up device_app_button
			mDeviceAppButton.Background = getBackground(fcContext, item.Active);
			LinearLayout.LayoutParams @params = (LinearLayout.LayoutParams) mDeviceAppButton.LayoutParams;
			@params.gravity = Gravity.CENTER;

			int padding = context.Resources.getDimensionPixelSize(R.dimen.floating_controller_active_app_frame_stroke_width) + context.Resources.getDimensionPixelSize(R.dimen.floating_controller_ordinal_app_layout_distance_between_app_icon_and_active_indication_frame);

			Drawable deviceAppDrawable = mFcModelItem.Icon;
			if (model.isMultiInstance(item))
			{
				int number = model.getInstanceNumber(item);
				int iconSize = context.Resources.getDimensionPixelSize(R.dimen.ord_app_expand_action_button_width);
				deviceAppDrawable = DrawableTool.getDrawableWithNumber(deviceAppDrawable, number, iconSize, context);
			}

			mIsFreeze = model.isAppFreeze(item.InstanceId);

			if (mIsFreeze)
			{
				deviceAppDrawable = getFreezeDrawable(fcContext.Context, deviceAppDrawable);
			}

			int actionCount = item.CallActions.Count;
			actionCount += item.VolumeActions.Count;
			actionCount += item.ReturnActions.Count;

			if (actionCount > 1)
			{
				mDeviceAppButton.OnClickListener = mExpandActionsButtonListener;
			}
			else
			{
				mDeviceAppButton.OnClickListener = mOpenAppDirectlyButtonListener;
			}

			mDeviceAppButton.setPadding(padding, padding, padding, padding);
			mDeviceAppButton.ImageDrawable = deviceAppDrawable;

			// Open Actions
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<FcActionItem> returnActions = item.getReturnActions();
			IList<FcActionItem> returnActions = item.ReturnActions;
			int numberOfElements = returnActions.Count;

			for (int i = 0; i < numberOfElements; i++)
			{
				addActionButton(mDeviceOpenActions, returnActions[i], R.layout.fc_ordinal_open_app_button, i, numberOfElements, fcContext, false);
			}

			if (numberOfElements > 0)
			{
				mDeviceOpenActions.Visibility = View.VISIBLE;
			}
			else
			{
				mDeviceOpenActions.Visibility = View.GONE;
			}

			// Call Actions
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<FcActionItem> callActions = item.getCallActions();
			IList<FcActionItem> callActions = item.CallActions;
			numberOfElements = callActions.Count;
			string bypassOn = fcContext.Context.Resources.getString([email protected]_on);
			string bypassOff = fcContext.Context.Resources.getString([email protected]_off);

			for (int i = 0; i < numberOfElements; i++)
			{
				string itemId = callActions[i].Id;
				if (itemId.Equals(bypassOff))
				{
					addBypassAction(fcContext, mDeviceActions, callActions[i], [email protected]_text_off);
				}
				else if (itemId.Equals(bypassOn))
				{
					addBypassAction(fcContext, mDeviceActions, callActions[i], [email protected]_text_on);
				}
				else
				{
					addActionButton(mDeviceActions, callActions[i], R.layout.fc_ordinal_action_button, i, numberOfElements, fcContext, true);
				}
			}

			if (numberOfElements > 0)
			{
				mDeviceActions.Visibility = View.VISIBLE;
			}
			else
			{
				mDeviceActions.Visibility = View.GONE;
			}

			// Volume Actions
			if (item.hasVolumeActions())
			{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<FcActionItem> volumeActions = item.getVolumeActions();
				IList<FcActionItem> volumeActions = item.VolumeActions;
				numberOfElements = volumeActions.Count;

				// handle volume label anomaly
				if (item.Direction == LinearLayout.LAYOUT_DIRECTION_LTR)
				{
					for (int i = 0; i < numberOfElements; i++)
					{
						addActionButton(mDeviceVolumes, volumeActions[i], R.layout.fc_ordinal_action_button, i, numberOfElements, fcContext, true);
					}
				}
				else
				{
					for (int i = numberOfElements - 1; i >= 0; i--)
					{
						addActionButton(mDeviceVolumes, volumeActions[i], R.layout.fc_ordinal_action_button, numberOfElements - 1 - i, numberOfElements, fcContext, true);
					}
				}
				// this handles the requirement that volume label is always before volume actions in a layout
				float marginSize = fcContext.getDimensionPixelSize(R.dimen.ord_app_action_volume_layout_margin_ltr);
				if (item.Direction == LinearLayout.LAYOUT_DIRECTION_RTL)
				{
					marginSize = fcContext.getDimensionPixelSize(R.dimen.ord_app_action_volume_layout_margin_rtl);
				}
				reverseLayoutWithMargins(mDeviceVolumeActions, item.Direction, marginSize);

				mDeviceVolumeActions.Visibility = View.VISIBLE;
			}
			else
			{
				mDeviceVolumeActions.Visibility = View.GONE;
			}
		}
Exemplo n.º 10
0
		/// <summary>
		/// @brief Constructor initializing factory from the FcContext
		/// 
		/// Note: Reference to FcActionFactory inside FcContext is changed by this constructor
		/// </summary>
		/// <param name="fcContext">     Context to the FloatingController common internals </param>
		public FcActionFactory(FcContext fcContext)
		{
			mFcContext = fcContext;
		}
Exemplo n.º 11
0
		/// <summary>
		/// @brief Construct model item from SapaAppInfo structure
		/// </summary>
		/// <param name="info">  Data structure with information retrieved from SAPA
		/// </param>
		/// <returns> Model item representing main application </returns>
		public static FcModelItem createMain(FcContext fcContext, SapaAppInfo info)
		{
			return new FcModelItem(fcContext, info, FcConstants.APP_TYPE_MAIN);
		}
Exemplo n.º 12
0
		private void prepareDefaultReturnActions(FcContext fcContext, SapaAppInfo info)
		{
			FcActionFactory factory = fcContext.ActionFactory;
			mReturnActions.Add(factory.newDefaultReturnItem(info));
		}
Exemplo n.º 13
0
		/// <summary>
		/// @brief Default constructor
		/// </summary>
		public FcModel(FcContext fcContext)
		{
			mFcContext = fcContext;
			mApplicationMap = new Dictionary<string, FcModelItem>(DEFAULT_APP_CAPACITY);
			mOrderedApplications = new List<string>(DEFAULT_APP_CAPACITY);
		}
Exemplo n.º 14
0
		private void prepareCustomReturnActions(FcContext fcContext, SapaAppInfo info, int[] drawableIds, int[] activityIds)
		{
			FcActionFactory factory = fcContext.ActionFactory;
			for (int i = 0; i < drawableIds.Length; ++i)
			{
				int drawableId = drawableIds[i];
				int activityId = activityIds[i];

				mReturnActions.Add(factory.newCustomReturnItem(info, drawableId, activityId));
			}
		}
Exemplo n.º 15
0
		private void prepareReturnActions(FcContext fcContext, SapaAppInfo info)
		{
			Bundle config = info.Configuration;
			if (null != config)
			{
				int[] retButtonsIds = config.getIntArray(FcConstants.KEY_RETURN_BUTTONS);
				int[] retButtonsOpts = config.getIntArray(FcConstants.KEY_RETURN_BUTTONS_OPTS);

				if (retButtonsIds == null || retButtonsOpts == null)
				{
					prepareDefaultReturnActions(fcContext, info);

				}
				else if (retButtonsIds.Length == retButtonsOpts.Length)
				{
					prepareCustomReturnActions(fcContext, info, retButtonsIds, retButtonsOpts);

				}
				else
				{
					Log.w(TAG, "Sizes of arrays: " + FcConstants.KEY_RETURN_BUTTONS + " and " + FcConstants.KEY_RETURN_BUTTONS_OPTS + " are not equal");
					prepareDefaultReturnActions(fcContext, info);
				}
			}
			else
			{
				prepareDefaultReturnActions(fcContext, info);
			}
		}
Exemplo n.º 16
0
		private void prepareActions(FcContext fcContext, SapaAppInfo info)
		{
			prepareReturnActions(fcContext, info);
			prepareCallActions(fcContext, info);
			if (mDirection == LinearLayout.LAYOUT_DIRECTION_RTL)
			{
				reverseActions();
			}
		}
Exemplo n.º 17
0
		/// <param name="appInfo"> </param>
		public virtual void update(FcContext context, SapaAppInfo appInfo)
		{
			lock (this)
			{
				Log.d(TAG, "Updating model for " + mInstanceId);
				try
				{
					mIcon = appInfo.getIcon(context.Context);
				}
				catch (NameNotFoundException e)
				{
					LogUtils.throwable(TAG, "Drawable not set: name not found", e);
				}
        
				clearActions();
				prepareActions(context, appInfo);
			}
		}
		public virtual string getName(FcContext fcContext)
		{
			return fcContext.getApplicationName(mAppInfo.PackageName);
		}
		public virtual Drawable getIcon(FcContext fcContext)
		{
			return Default ? fcContext.getDrawable(mDrawableId) : fcContext.getApplicationDrawable(mAppInfo.PackageName, mDrawableId);
		}
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: private void addActionButton(final android.widget.LinearLayout linearLayout, final FcActionItem fcActionItem, final int resId, final int index, final int numberOfElements, final FcContext fcContext, final boolean adjustBackgroundToPositionInLayout)
		private void addActionButton(LinearLayout linearLayout, FcActionItem fcActionItem, int resId, int index, int numberOfElements, FcContext fcContext, bool adjustBackgroundToPositionInLayout)
		{
			ImageButton imageButton = (ImageButton) LayoutInflater.from(fcContext.Context).inflate(resId, mDeviceActions, false);
			imageButton.ImageDrawable = fcActionItem.getIcon(fcContext);
			imageButton.Enabled = fcActionItem.Enabled;
			imageButton.Visibility = fcActionItem.Visible ? View.VISIBLE : View.GONE;
			imageButton.OnClickListener = new OnClickListenerAnonymousInnerClassHelper3(this, fcActionItem);

			if (adjustBackgroundToPositionInLayout)
			{
				DrawableTool.setBackground(imageButton, index, numberOfElements, fcContext);
			}

			linearLayout.addView(imageButton);
		}
Exemplo n.º 21
0
		/// <summary>
		/// @brief Construct model item from SapaAppInfo structure
		/// </summary>
		/// <param name="info">  Data structure with information retrieved from SAPA
		/// </param>
		/// <returns> Model item representing ordinal application </returns>
		public static FcModelItem createOrdinal(FcContext fcContext, SapaAppInfo info)
		{
			return new FcModelItem(fcContext, info, FcConstants.APP_TYPE_ORDINAL);
		}
Exemplo n.º 22
0
		private void prepareCallActions(FcContext fcContext, SapaAppInfo appInfo)
		{
			FcActionFactory factory = fcContext.ActionFactory;
			SparseArray<SapaActionInfo> actions = appInfo.Actions;
			for (int i = 0; i < actions.size(); ++i)
			{
				SapaActionInfo actionInfo = actions.get(i);
				FcActionItem action = factory.newAppItem(appInfo, actionInfo);
				string actionName = actionInfo.Id;

				// Volume buttons needs to be separated from the rest of actions
				if (FcConstants.ACTION_VOLUME_UP.Equals(actionName))
				{
					mVolumeActions[VOLUME_UP_INDEX] = action;
				}
				else if (FcConstants.ACTION_VOLUME_DOWN.Equals(actionName))
				{
					mVolumeActions[VOLUME_DOWN_INDEX] = action;
				}
				else
				{
					mCallActions.Add(action);
				}
			}
		}
Exemplo n.º 23
0
		public FcControlBar(Context context, AttributeSet attrs, int defStyleAttr) : base(context, attrs, defStyleAttr)
		{

			mFcContext = new FcContext(context);
			mFcContext.FxContextStateChangeListener = this;
			FcActionFactory factory = new FcActionFactory(mFcContext);
			mFcContext.ActionFactory = factory;

			initView();
		}