Bladeren bron

Merge branch 'feature_audio_track_edit'

# Conflicts:
#	src/main/java/com/bomostory/sceneeditmodule/MovieEditActivity.kt
Shan-PC\Shan 6 jaren geleden
bovenliggende
commit
de1e4329c7

+ 20 - 2
src/main/java/com/bomostory/sceneeditmodule/MovieEditActivity.kt

@@ -5,11 +5,12 @@ import android.app.ProgressDialog
 import android.content.DialogInterface
 import android.content.Intent
 import android.net.Uri
+import android.support.v7.app.AppCompatActivity
 import android.os.Bundle
 import android.os.Environment
 import android.os.Handler
 import android.support.v4.app.DialogFragment
-import android.support.v7.app.AppCompatActivity
+import android.util.Log
 import android.view.View
 import android.widget.CompoundButton
 import android.widget.SeekBar
@@ -31,7 +32,15 @@ import kotlinx.android.synthetic.main.activity_movie_edit.*
 import java.io.File
 
 
-class MovieEditActivity : AppCompatActivity(), DialogInterface.OnDismissListener, MusicSelectFragment.OnFragmentInteractionListener {
+class MovieEditActivity : AppCompatActivity(),
+        DialogInterface.OnDismissListener,
+        MusicSelectFragment.OnFragmentInteractionListener,
+        MusicEditDialog.OnFragmentInteractionListener {
+
+    override fun onFragmentInteraction(uri: Uri) {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
     override fun onDismiss(dialog: DialogInterface?) {
         musicPlayer.stop()
         musicPlayer.release()
@@ -124,6 +133,7 @@ class MovieEditActivity : AppCompatActivity(), DialogInterface.OnDismissListener
     companion object {
         const val PROJECT_KEY = "project_key"
         const val MUSIC_SELECT_DIALOG_TAG = "music_select_dialog_tag"
+        const val MUSIC_EDIT_DIALOG_TAG = "music_edit_dialog_tag"
         const val FPS: Int = 30
         private const val UI_ANIMATION_DELAY = 300
     }
@@ -139,6 +149,7 @@ class MovieEditActivity : AppCompatActivity(), DialogInterface.OnDismissListener
         movieEditView.onPlayClickListener = View.OnClickListener(this::playMovie)
         movieEditView.onPauseClickListener = View.OnClickListener(this::pauseMovie)
         movieEditView.onAddMusicClickListener = View.OnClickListener(this::addMusic)
+        movieEditView.onEditMusicClickListener = View.OnClickListener(this::editMusic)
         movieEditView.onDeleteMusicClickListener = View.OnClickListener(this::deleteMusic)
         movieEditView.onSaveMovieClickListener = View.OnClickListener(this::saveMovie)
         movieEditView.onSeekBarChangeListener = object : SeekBar.OnSeekBarChangeListener {
@@ -233,6 +244,13 @@ class MovieEditActivity : AppCompatActivity(), DialogInterface.OnDismissListener
         musicSelectDialog.show(supportFragmentManager, MUSIC_SELECT_DIALOG_TAG)
     }
 
+    private fun editMusic(view: View) {
+        Log.d("Debug", "edit music track $currentAudioPosition")
+
+        val musicEditDialog = MusicEditDialog.newInstance("", "")
+        musicEditDialog.show(supportFragmentManager, MUSIC_EDIT_DIALOG_TAG)
+    }
+
     private fun deleteMusic(view: View) {
         if (currentAudioPosition in 0 until musics.size) {
             moviePlayer.init()

+ 102 - 0
src/main/java/com/bomostory/sceneeditmodule/MusicEditDialog.kt

@@ -0,0 +1,102 @@
+package com.bomostory.sceneeditmodule
+
+import android.content.Context
+import android.net.Uri
+import android.os.Bundle
+import android.support.v4.app.DialogFragment
+import android.support.v4.app.Fragment
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+
+import com.example.tfat.myapplication.R
+
+// TODO: Rename parameter arguments, choose names that match
+// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
+private const val ARG_PARAM1 = "param1"
+private const val ARG_PARAM2 = "param2"
+
+/**
+ * A simple [Fragment] subclass.
+ * Activities that contain this fragment must implement the
+ * [MusicEditDialog.OnFragmentInteractionListener] interface
+ * to handle interaction events.
+ * Use the [MusicEditDialog.newInstance] factory method to
+ * create an instance of this fragment.
+ *
+ */
+class MusicEditDialog : DialogFragment() {
+    // TODO: Rename and change types of parameters
+    private var param1: String? = null
+    private var param2: String? = null
+    private var listener: OnFragmentInteractionListener? = null
+
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+        arguments?.let {
+            param1 = it.getString(ARG_PARAM1)
+            param2 = it.getString(ARG_PARAM2)
+        }
+    }
+
+    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
+                              savedInstanceState: Bundle?): View? {
+        // Inflate the layout for this fragment
+        return inflater.inflate(R.layout.fragment_music_edit_dialog, container, false)
+    }
+
+    // TODO: Rename method, update argument and hook method into UI event
+    fun onButtonPressed(uri: Uri) {
+        listener?.onFragmentInteraction(uri)
+    }
+
+    override fun onAttach(context: Context) {
+        super.onAttach(context)
+        if (context is OnFragmentInteractionListener) {
+            listener = context
+        } else {
+            throw RuntimeException(context.toString() + " must implement OnFragmentInteractionListener")
+        }
+    }
+
+    override fun onDetach() {
+        super.onDetach()
+        listener = null
+    }
+
+    /**
+     * This interface must be implemented by activities that contain this
+     * fragment to allow an interaction in this fragment to be communicated
+     * to the activity and potentially other fragments contained in that
+     * activity.
+     *
+     *
+     * See the Android Training lesson [Communicating with Other Fragments]
+     * (http://developer.android.com/training/basics/fragments/communicating.html)
+     * for more information.
+     */
+    interface OnFragmentInteractionListener {
+        // TODO: Update argument type and name
+        fun onFragmentInteraction(uri: Uri)
+    }
+
+    companion object {
+        /**
+         * Use this factory method to create a new instance of
+         * this fragment using the provided parameters.
+         *
+         * @param param1 Parameter 1.
+         * @param param2 Parameter 2.
+         * @return A new instance of fragment MusicEditDialog.
+         */
+        // TODO: Rename and change types and number of parameters
+        @JvmStatic
+        fun newInstance(param1: String, param2: String) =
+                MusicEditDialog().apply {
+                    arguments = Bundle().apply {
+                        putString(ARG_PARAM1, param1)
+                        putString(ARG_PARAM2, param2)
+                    }
+                }
+    }
+}

+ 5 - 0
src/main/java/com/bomostory/sceneeditmodule/view/MovieEditBtnPanelView.kt

@@ -41,6 +41,11 @@ class MovieEditBtnPanelView : ConstraintLayout {
             addMusic.setOnClickListener(value)
         }
 
+    var onEditMusicClickListener: OnClickListener? = null
+        set(value) {
+            edit.setOnClickListener(value)
+        }
+
     var onDeleteMusicClickListener: OnClickListener? = null
         set(value) {
             delete.setOnClickListener(value)

+ 5 - 0
src/main/java/com/bomostory/sceneeditmodule/view/MovieEditView.kt

@@ -63,6 +63,11 @@ class MovieEditView : ConstraintLayout {
             movieEditBtnPanel.onAddMusicClickListener = value
         }
 
+    var onEditMusicClickListener: OnClickListener? = null
+        set(value) {
+            movieEditBtnPanel.onEditMusicClickListener = value
+        }
+
     var onSaveMovieClickListener: OnClickListener? = null
         set(value) {
             movieEditBtnPanel.onSaveMovieClickListener = value

+ 32 - 0
src/main/res/drawable/ic_volume_up.xml

@@ -0,0 +1,32 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+  <path
+      android:pathData="M5,13l2.83,0l2.17,2.17l0,-6.34l-2.17,2.17l-2.83,0z"
+      android:strokeAlpha="0.3"
+      android:strokeWidth="1"
+      android:fillColor="#4E342E"
+      android:fillType="nonZero"
+      android:strokeColor="#00000000"
+      android:fillAlpha="0.3"/>
+  <path
+      android:pathData="M3,9L3,15L7,15L12,20L12,4L7,9L3,9ZM10,8.83L10,15.17L7.83,13L5,13L5,11L7.83,11L10,8.83Z"
+      android:strokeWidth="1"
+      android:fillColor="#4E342E"
+      android:fillType="nonZero"
+      android:strokeColor="#00000000"/>
+  <path
+      android:pathData="M14,7.97L14,16.02C15.48,15.29 16.5,13.77 16.5,12C16.5,10.23 15.48,8.71 14,7.97Z"
+      android:strokeWidth="1"
+      android:fillColor="#4E342E"
+      android:fillType="nonZero"
+      android:strokeColor="#00000000"/>
+  <path
+      android:pathData="M14,3.23L14,5.29C16.89,6.15 19,8.83 19,12C19,15.17 16.89,17.85 14,18.71L14,20.77C18.01,19.86 21,16.28 21,12C21,7.72 18.01,4.14 14,3.23Z"
+      android:strokeWidth="1"
+      android:fillColor="#4E342E"
+      android:fillType="nonZero"
+      android:strokeColor="#00000000"/>
+</vector>

+ 148 - 0
src/main/res/layout/fragment_music_edit_dialog.xml

@@ -0,0 +1,148 @@
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context="com.bomostory.sceneeditmodule.MusicEditDialog">
+
+    <TextView
+        android:id="@+id/musicName"
+        style="@style/TextAppearance.AppCompat.Title"
+        android:layout_width="800dp"
+        android:layout_height="64dp"
+        android:background="#ffecb3"
+        android:gravity="center" />
+
+    <TextView
+        android:id="@+id/musicLength"
+        style="@style/TextAppearance.AppCompat.Body2"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="40dp"
+        android:layout_marginTop="88dp"
+        android:text="@string/music_length"
+        android:textColor="#80000000"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <ImageButton
+        android:layout_width="24dp"
+        android:layout_height="24dp"
+        android:layout_marginStart="52dp"
+        android:layout_marginTop="169dp"
+        android:src="@drawable/ic_pause"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <com.example.audiotrack.EditAudioTrackView
+        android:id="@+id/editAudioTrackView"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="68dp"
+        android:layout_marginTop="8dp"
+        android:layout_marginEnd="8dp"
+        android:background="#99ff8cd2"
+        app:borderColor="#633150"
+        app:dialogTextSize="16sp"
+        app:endDrawable="@drawable/ic_arrow_right_b"
+        app:headDrawable="@drawable/ic_arrow_left_b"
+        app:innerColor="#ff8cd2"
+        app:innerHeight="40dp"
+        app:innerWidthRatio="1"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/musicLength"
+        app:playProgress=".5"
+        app:playProgressDialogColor="@android:color/holo_orange_light"
+        app:playProgressText="0:20"
+        app:scrollProgressDialogColor="@android:color/holo_orange_dark"
+        app:scrollProgressText="0:30" />
+
+    <TextView
+        android:id="@+id/startTime"
+        style="@style/TextAppearance.AppCompat.Body2"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="100dp"
+        android:textColor="#66000000"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/editAudioTrackView" />
+
+    <TextView
+        android:id="@+id/endTime"
+        style="@style/TextAppearance.AppCompat.Body2"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginEnd="40dp"
+        android:textColor="#66000000"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/editAudioTrackView" />
+
+    <TextView
+        style="@style/TextAppearance.AppCompat.Body2"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="40dp"
+        android:layout_marginTop="34dp"
+        android:text="@string/volume"
+        android:textColor="#80000000"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/editAudioTrackView" />
+
+    <ImageView
+        android:layout_width="24dp"
+        android:layout_height="24dp"
+        android:layout_marginStart="52dp"
+        android:layout_marginTop="278dp"
+        android:src="@drawable/ic_volume_up"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <SeekBar
+        android:id="@+id/volumeSeekBar"
+        android:layout_width="560dp"
+        android:layout_height="48dp"
+        android:layout_marginStart="108dp"
+        android:layout_marginTop="266dp"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <TextView
+        android:id="@+id/volumeText"
+        style="@style/TextAppearance.AppCompat.Body1"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="281dp"
+        android:layout_marginEnd="40dp"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <Button
+        android:id="@+id/save"
+        style="@style/TextAppearance.AppCompat.Button"
+        android:layout_width="72dp"
+        android:layout_height="36dp"
+        android:layout_marginTop="346dp"
+        android:layout_marginEnd="24dp"
+        android:layout_marginBottom="24dp"
+        android:background="@null"
+        android:text="@string/save"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <Button
+        android:id="@+id/cancel"
+        style="@style/TextAppearance.AppCompat.Button"
+        android:layout_width="72dp"
+        android:layout_height="36dp"
+        android:layout_marginTop="346dp"
+        android:layout_marginEnd="104dp"
+        android:layout_marginBottom="24dp"
+        android:background="@null"
+        android:text="@string/cancel"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+</android.support.constraint.ConstraintLayout>

+ 8 - 0
src/main/res/values/strings.xml

@@ -4,4 +4,12 @@
     <string name="title_activity_movie_edit">MovieEditActivity</string>
     <string name="dummy_button">Dummy Button</string>
     <string name="dummy_content">DUMMY\nCONTENT</string>
+
+    <string name="music_length">Music Length</string>
+    <string name="volume">Volume</string>
+    <string name="save">Save</string>
+    <string name="cancel">Cancel</string>
+
+    <!-- TODO: Remove or change this placeholder text -->
+    <string name="hello_blank_fragment">Hello blank fragment</string>
 </resources>