Commit fbee9bb6 authored by Aline Gondim Santos's avatar Aline Gondim Santos
Browse files

plugin: fixes

- fix crash while opening preferences
- fix crash while starting camera and trying to toggle null mediahandler
- fix chathandler toggling for swarm

Change-Id: Ib79d846956480b6bd4c79e26b3bb583908cf88b4
parent feb51c41
......@@ -712,9 +712,16 @@ class CallFragment : BaseSupportFragment<CallPresenter, CallView>(), CallView,
override fun displayLocalVideo(display: Boolean) {
Log.w(TAG, "DEBUG fn displayLocalVideo -> $display")
/*binding!!.pluginPreviewSurface.visibility = View.GONE
binding!!.pluginPreviewContainer.visibility = View.GONE*/
binding!!.previewContainer.visibility = if (display) View.VISIBLE else View.GONE
if (isChoosePluginMode) {
binding!!.previewContainer.visibility = View.GONE
binding!!.pluginPreviewContainer.visibility = if (display) View.VISIBLE else View.GONE
binding!!.pluginPreviewSurface.visibility = if (display) View.VISIBLE else View.GONE
binding!!.pluginPreviewSurface.setZOrderMediaOverlay(true)
} else {
binding!!.pluginPreviewSurface.visibility = View.GONE
binding!!.pluginPreviewContainer.visibility = View.GONE
binding!!.previewContainer.visibility = if (display) View.VISIBLE else View.GONE
}
}
// todo Change function name, this name is misleading, this function concerns PIP preview
......@@ -984,21 +991,17 @@ class CallFragment : BaseSupportFragment<CallPresenter, CallView>(), CallView,
mPreviewWidth = previewWidth
mPreviewHeight = previewHeight
val flip = rot % 180 != 0
binding?.previewSurface?.setAspectRatio(
if (flip) mPreviewHeight else mPreviewWidth,
if (flip) mPreviewWidth else mPreviewHeight
)
}
override fun resetPluginPreviewVideoSize(previewWidth: Int, previewHeight: Int, rot: Int) {
if (previewWidth == -1 && previewHeight == -1) return
mPreviewWidth = previewWidth
mPreviewHeight = previewHeight
val flip = rot % 180 != 0
binding?.pluginPreviewSurface?.setAspectRatio(
if (flip) mPreviewHeight else mPreviewWidth,
if (flip) mPreviewWidth else mPreviewHeight
)
if (isChoosePluginMode) {
binding?.pluginPreviewSurface?.setAspectRatio(
if (flip) mPreviewHeight else mPreviewWidth,
if (flip) mPreviewWidth else mPreviewHeight
)
} else {
binding?.previewSurface?.setAspectRatio(
if (flip) mPreviewHeight else mPreviewWidth,
if (flip) mPreviewWidth else mPreviewHeight
)
}
}
override fun resetVideoSize(videoWidth: Int, videoHeight: Int) {
......@@ -1302,23 +1305,22 @@ class CallFragment : BaseSupportFragment<CallPresenter, CallView>(), CallView,
val context: Context = requireActivity()
// Create callMediaHandlers and videoPluginsItems in a lazy manner
if (pluginsModeFirst) {
// Init
val callMediaHandlers = JamiService.getCallMediaHandlers()
val videoPluginsItems: MutableList<Drawable> = ArrayList(callMediaHandlers.size + 1)
val mediaHandlers = callMediaHandlers ?: run {
val mediaHandlers = JamiService.getCallMediaHandlers().toList().apply { callMediaHandlers = this }
val videoPluginsItems: MutableList<Drawable> = ArrayList(mediaHandlers.size + 1)
videoPluginsItems.add(context.getDrawable(R.drawable.baseline_cancel_24)!!)
// Search for plugin call media handlers icons
// If a call media handler doesn't have an icon use a standard android icon
for (callMediaHandler in callMediaHandlers) {
for (callMediaHandler in mediaHandlers) {
val details = getCallMediaHandlerDetails(callMediaHandler)
var drawablePath = details["iconPath"]
if (drawablePath != null && drawablePath.endsWith("svg")) drawablePath =
drawablePath.replace(".svg", ".png")
if (drawablePath != null && drawablePath.endsWith("svg"))
drawablePath = drawablePath.replace(".svg", ".png")
val handlerIcon = Drawable.createFromPath(drawablePath) ?: context.getDrawable(R.drawable.ic_jami)!!
videoPluginsItems.add(handlerIcon)
}
rp!!.updateData(videoPluginsItems)
pluginsModeFirst = false
mediaHandlers
}
if (isChoosePluginMode) {
// hide hang up button and other call buttons
......@@ -1328,7 +1330,7 @@ class CallFragment : BaseSupportFragment<CallPresenter, CallView>(), CallView,
movePreview(true)
// Start loading the first or previous plugin if one was active
if (callMediaHandlers!!.isNotEmpty()) {
if (mediaHandlers.isNotEmpty()) {
// If no previous plugin was active, take the first, else previous
val position: Int
if (previousPluginPosition < 1) {
......@@ -1338,12 +1340,12 @@ class CallFragment : BaseSupportFragment<CallPresenter, CallView>(), CallView,
} else {
position = previousPluginPosition
}
val callMediaId = callMediaHandlers!![position - 1]
val callMediaId = mediaHandlers[position - 1]
presenter.startPlugin(callMediaId)
}
} else {
if (previousPluginPosition > 0) {
val callMediaId = callMediaHandlers!![previousPluginPosition - 1]
val callMediaId = mediaHandlers[previousPluginPosition - 1]
presenter.toggleCallMediaHandler(callMediaId, false)
rp!!.scrollToPosition(previousPluginPosition)
}
......
......@@ -26,7 +26,7 @@ class PluginHandlersListFragment : Fragment(), PluginListItemListener {
return FragPluginHandlersListBinding.inflate(inflater, container, false).also { b ->
b.handlerList.setHasFixedSize(true)
b.handlerList.adapter = PluginsListAdapter(
PluginUtils.getChatHandlersDetails(b.handlerList.context, mPath.accountId, mPath.conversationId), this)
PluginUtils.getChatHandlersDetails(b.handlerList.context, mPath.accountId, mPath.conversationId.removePrefix("swarm:")), this)
binding = b
}.root
}
......@@ -48,11 +48,11 @@ class PluginHandlersListFragment : Fragment(), PluginListItemListener {
}
override fun onPluginItemClicked(pluginDetails: PluginDetails) {
JamiService.toggleChatHandler(pluginDetails.handlerId, mPath.accountId, mPath.conversationId, pluginDetails.isEnabled)
JamiService.toggleChatHandler(pluginDetails.handlerId, mPath.accountId, mPath.conversationId.removePrefix("swarm:"), pluginDetails.isEnabled)
}
override fun onPluginEnabled(pluginDetails: PluginDetails) {
JamiService.toggleChatHandler(pluginDetails.handlerId, mPath.accountId, mPath.conversationId, pluginDetails.isEnabled)
JamiService.toggleChatHandler(pluginDetails.handlerId, mPath.accountId, mPath.conversationId.removePrefix("swarm:"), pluginDetails.isEnabled)
}
companion object {
......
......@@ -18,68 +18,62 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package cx.ring.plugins;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
import cx.ring.R;
import cx.ring.databinding.FragPluginSettingsBinding;
import cx.ring.settings.pluginssettings.PluginDetails;
public class PluginPreferences extends Preference {
private PluginDetails mPluginDetails;
private View.OnClickListener resetClickListener;
private View.OnClickListener installClickListener;
public void setResetClickListener(View.OnClickListener clickListener) {
resetClickListener = clickListener;
package cx.ring.plugins
import android.content.Context
import android.util.AttributeSet
import android.view.View
import androidx.preference.Preference
import androidx.preference.PreferenceViewHolder
import cx.ring.R
import cx.ring.databinding.FragPluginSettingsBinding
import cx.ring.settings.pluginssettings.PluginDetails
class PluginPreferences : Preference {
private var mPluginDetails: PluginDetails? = null
private var resetClickListener: View.OnClickListener? = null
private var installClickListener: View.OnClickListener? = null
fun setResetClickListener(clickListener: View.OnClickListener?) {
resetClickListener = clickListener
}
public void setInstallClickListener(View.OnClickListener clickListener) {
installClickListener = clickListener;
fun setInstallClickListener(clickListener: View.OnClickListener?) {
installClickListener = clickListener
}
public PluginPreferences(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
constructor(
context: Context?,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int
) : super(context, attrs, defStyleAttr, defStyleRes) {
}
public PluginPreferences(Context context, PluginDetails pluginDetails) {
super(context);
mPluginDetails = pluginDetails;
setLayoutResource(R.layout.frag_plugin_settings);
constructor(context: Context?, pluginDetails: PluginDetails?) : super(context) {
mPluginDetails = pluginDetails
layoutResource = R.layout.frag_plugin_settings
}
public PluginPreferences(Context context, AttributeSet attrs) {
super(context, attrs);
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {}
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
) {
}
public PluginPreferences(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
FragPluginSettingsBinding binding = FragPluginSettingsBinding.bind(holder.itemView);
override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder)
val binding = FragPluginSettingsBinding.bind(holder.itemView)
if (mPluginDetails != null) {
binding.pluginSettingIcon.setImageDrawable(mPluginDetails.getIcon());
binding.pluginSettingTitle.setText(mPluginDetails.getName());
binding.pluginSettingIcon.setImageDrawable(mPluginDetails!!.icon)
binding.pluginSettingTitle.text = mPluginDetails!!.name
}
if (resetClickListener != null) {
binding.pluginSettingReset.setOnClickListener(resetClickListener);
binding.pluginSettingReset.setOnClickListener(resetClickListener)
}
if (installClickListener != null) {
binding.pluginSettingInstall.setOnClickListener(installClickListener);
binding.pluginSettingInstall.setOnClickListener(installClickListener)
}
}
}
}
\ No newline at end of file
......@@ -466,7 +466,8 @@ class HardwareServiceImpl(
override fun onOpened() {
val currentCall = conf?.id ?: return
if (mPluginCallId != null && mPluginCallId != currentCall) {
JamiService.toggleCallMediaHandler(mMediaHandlerId, currentCall, false)
if (mMediaHandlerId != null)
JamiService.toggleCallMediaHandler(mMediaHandlerId, currentCall, false)
mIsChoosePlugin = false
mMediaHandlerId = null
mPluginCallId = null
......
......@@ -25,19 +25,11 @@ import java.io.File
/**
* Class that contains PluginDetails like name, rootPath
*/
class PluginDetails(var name: String, rootPath: String, enabled: Boolean, val handlerId: String? = null) {
var rootPath: String = rootPath
private set
class PluginDetails(val name: String, val rootPath: String, var isEnabled: Boolean, val handlerId: String? = null) {
private val details: Map<String, String> = pluginDetails
var icon: Drawable? = null
private set
/**
* Returns the plugin activation status by the user
* @return boolean
*/
var isEnabled: Boolean = enabled
fun setIcon() {
var iconPath = details["iconPath"]
if (iconPath != null) {
......
......@@ -16,7 +16,9 @@ class PluginSettingsFragment : PreferenceFragmentCompat() {
private var mPreferencesAttributes: List<Map<String, String>>? = null
private var pluginDetails: PluginDetails? = null
private var ppds: PluginPreferencesDataStore? = null
override fun onCreatePreferences(savedInstanceState: Bundle, rootKey: String) {}
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val arguments = requireArguments()
......
......@@ -39,6 +39,7 @@ class PluginsListSettingsFragment : Fragment(), PluginListItemListener {
private var binding: FragPluginsListSettingsBinding? = null
private var mAdapter: PluginsListAdapter? = null
private val mCompositeDisposable = CompositeDisposable()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = FragPluginsListSettingsBinding.inflate(inflater, container, false)
......
......@@ -271,15 +271,12 @@ class TVCallFragment : BaseSupportFragment<CallPresenter, CallView>(), CallView
override fun displayLocalVideo(display: Boolean) {
Log.w(CallFragment.TAG, "DEBUG fn displayLocalVideo -> $display")
/*binding!!.pluginPreviewSurface.visibility = View.GONE
binding!!.pluginPreviewContainer.visibility = View.GONE*/
binding!!.previewContainer.visibility = if (display) View.VISIBLE else View.GONE
}
override fun displayPreviewSurface(display: Boolean) {
if (display) {
binding!!.videoSurface.setZOrderOnTop(false)
//mVideoPreview.setZOrderMediaOverlay(true);
binding!!.videoSurface.setZOrderMediaOverlay(false)
} else {
binding!!.videoSurface.setZOrderMediaOverlay(true)
......@@ -374,8 +371,6 @@ class TVCallFragment : BaseSupportFragment<CallPresenter, CallView>(), CallView
)
}
override fun resetPluginPreviewVideoSize(previewWidth: Int, previewHeight: Int, rot: Int) {}
override fun resetVideoSize(videoWidth: Int, videoHeight: Int) {
Log.w(TAG, "resetVideoSize " + videoWidth + "x" + videoHeight)
val rootView = view as ViewGroup? ?: return
......
......@@ -373,7 +373,6 @@ class CallPresenter @Inject constructor(
mHardwareService.updatePreviewVideoSurface(call)
videoSurfaceUpdateId(call.id)
pluginSurfaceUpdateId(call.pluginId)
//view.displayPeerVideo(hasVideo)
view.displayLocalVideo(hasActiveVideo && mDeviceRuntimeService.hasVideoPermission())
if (permissionChanged) {
mHardwareService.switchInput(call.id, permissionChanged)
......@@ -456,14 +455,6 @@ class CallPresenter @Inject constructor(
view.displayPeerVideo(false)
}
}
/*if (conference != null && conference.pluginId == event.callId) {
Log.w(TAG, "DEBUG fn onVideoEvent |4| inside => if (mConference != null && mConference!!.pluginId == event.callId)")
if (event.started) {
previewWidth = event.w
previewHeight = event.h
view.resetPluginPreviewVideoSize(previewWidth, previewHeight, event.rot)
}
}*/
}
fun positiveButtonClicked() {
......
......@@ -42,7 +42,6 @@ interface CallView {
fun initIncomingCallDisplay(hasVideo: Boolean)
fun initOutGoingCallDisplay()
fun resetPreviewVideoSize(previewWidth: Int, previewHeight: Int, rot: Int)
fun resetPluginPreviewVideoSize(previewWidth: Int, previewHeight: Int, rot: Int)
fun resetVideoSize(videoWidth: Int, videoHeight: Int)
fun goToConversation(accountId: String, conversationId: Uri)
fun goToAddContact(contact: Contact)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment