@@ -26,6 +26,7 @@ class AztecToolbar : FrameLayout, OnMenuItemClickListener {
2626 private var headingMenu: PopupMenu ? = null
2727 private var sourceEditor: SourceViewEditText ? = null
2828 private var dialogShortcuts: AlertDialog ? = null
29+ private var isMediaModeEnabled: Boolean = false ;
2930
3031 constructor (context: Context ) : super (context) {
3132 initView()
@@ -228,13 +229,15 @@ class AztecToolbar : FrameLayout, OnMenuItemClickListener {
228229 super .onRestoreInstanceState(savedState.superState)
229230 val restoredState = savedState.state
230231 toggleHtmlMode(restoredState.getBoolean(" isSourceVisible" ))
232+ enableMediaMode(restoredState.getBoolean(" isMediaMode" ))
231233 }
232234
233235 override fun onSaveInstanceState (): Parcelable {
234236 val superState = super .onSaveInstanceState()
235237 val savedState = SourceViewEditText .SavedState (superState)
236238 val bundle = Bundle ()
237239 bundle.putBoolean(" isSourceVisible" , sourceEditor?.visibility == View .VISIBLE )
240+ bundle.putBoolean(" isMediaMode" , isMediaModeEnabled)
238241 savedState.state = bundle
239242 return savedState
240243 }
@@ -408,6 +411,21 @@ class AztecToolbar : FrameLayout, OnMenuItemClickListener {
408411 }
409412 }
410413
414+ fun isMediaModeEnabled (): Boolean {
415+ return isMediaModeEnabled;
416+ }
417+
418+ fun enableMediaMode (isEnabled : Boolean ) {
419+ isMediaModeEnabled = isEnabled;
420+ ToolbarAction .values().forEach { action ->
421+ if (action == ToolbarAction .ADD_MEDIA ) {
422+ toggleButton(findViewById(action.buttonId), isEnabled)
423+ } else {
424+ toggleButtonState(findViewById(action.buttonId), ! isEnabled)
425+ }
426+ }
427+ }
428+
411429 private fun showDialogShortcuts () {
412430 val layout = LayoutInflater .from(context).inflate(R .layout.dialog_shortcuts, null )
413431 val builder = AlertDialog .Builder (context)
0 commit comments