| @@ -8,7 +8,10 @@ import android.media.MediaPlayer | |||||
| import android.net.Uri | import android.net.Uri | ||||
| import android.os.Bundle | import android.os.Bundle | ||||
| import android.support.v7.app.AppCompatActivity | import android.support.v7.app.AppCompatActivity | ||||
| import android.view.LayoutInflater | |||||
| import android.view.animation.LinearInterpolator | import android.view.animation.LinearInterpolator | ||||
| import android.widget.FrameLayout | |||||
| import android.widget.GridLayout | |||||
| import android.widget.ProgressBar | import android.widget.ProgressBar | ||||
| import android.widget.TextView | import android.widget.TextView | ||||
| import java.io.BufferedInputStream | import java.io.BufferedInputStream | ||||
| @@ -20,6 +23,8 @@ class MainActivity : AppCompatActivity() { | |||||
| super.onCreate(savedInstanceState) | super.onCreate(savedInstanceState) | ||||
| setContentView(R.layout.activity_main) | setContentView(R.layout.activity_main) | ||||
| duplicateButton() | |||||
| loadPreferences() | loadPreferences() | ||||
| var player: MediaPlayer? = null | var player: MediaPlayer? = null | ||||
| @@ -75,6 +80,30 @@ class MainActivity : AppCompatActivity() { | |||||
| } | } | ||||
| } | } | ||||
| private fun duplicateButton() { | |||||
| val inflater = getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater | |||||
| val parent = findViewById<GridLayout>(R.id.grid_layout) | |||||
| parent.columnCount = 2 | |||||
| for (row in 0..1) { | |||||
| for (col in 0..1) { | |||||
| val newFrame = inflater.inflate(R.layout.layout_button, null) | |||||
| // newFrame.findViewById<ProgressBar>(R.id.progress_bar) | |||||
| // newFrame.findViewById<TextView>(R.id.text_view_button) | |||||
| val params = GridLayout.LayoutParams() | |||||
| params.columnSpec = GridLayout.spec(col, 1, 1.0f) | |||||
| params.rowSpec = GridLayout.spec(row, 1, 1.0f) | |||||
| params.width = 0 | |||||
| params.height = 0 | |||||
| newFrame.layoutParams = params | |||||
| parent.addView(newFrame) | |||||
| } | |||||
| } | |||||
| } | |||||
| private fun loadPreferences() { | private fun loadPreferences() { | ||||
| val preferences = getPreferences(Context.MODE_PRIVATE) | val preferences = getPreferences(Context.MODE_PRIVATE) | ||||
| val caption = preferences.getString("caption", "") | val caption = preferences.getString("caption", "") | ||||
| @@ -7,69 +7,12 @@ | |||||
| tools:context="de.mlte.soundboard.MainActivity"> | tools:context="de.mlte.soundboard.MainActivity"> | ||||
| <GridLayout | <GridLayout | ||||
| android:id="@+id/grid_layout" | |||||
| android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
| android:layout_height="match_parent" | android:layout_height="match_parent" | ||||
| android:columnCount="1" | android:columnCount="1" | ||||
| android:padding="1dp"> | android:padding="1dp"> | ||||
| <FrameLayout | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_column="0" | |||||
| android:layout_columnWeight="1" | |||||
| android:layout_row="0" | |||||
| android:layout_rowWeight="1" | |||||
| android:padding="2dp"> | |||||
| <ProgressBar | |||||
| android:id="@+id/progress_bar" | |||||
| style="?android:attr/progressBarStyleHorizontal" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="match_parent" | |||||
| android:indeterminate="false" | |||||
| android:progressDrawable="@drawable/progress_bar_states" /> | |||||
| <TextView | |||||
| android:id="@+id/text_view_button" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="match_parent" | |||||
| android:gravity="center" | |||||
| android:padding="6dp" | |||||
| android:text="Enter" | |||||
| android:textColor="@android:color/white" | |||||
| android:textSize="16sp" | |||||
| android:textStyle="bold" /> | |||||
| </FrameLayout> | |||||
| <FrameLayout | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_column="0" | |||||
| android:layout_columnWeight="1" | |||||
| android:layout_row="1" | |||||
| android:layout_rowWeight="1" | |||||
| android:padding="2dp"> | |||||
| <ProgressBar | |||||
| style="?android:attr/progressBarStyleHorizontal" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="match_parent" | |||||
| android:indeterminate="false" | |||||
| android:progressDrawable="@drawable/progress_bar_states" /> | |||||
| <TextView | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="match_parent" | |||||
| android:gravity="center" | |||||
| android:padding="6dp" | |||||
| android:text="Enter" | |||||
| android:textColor="@android:color/white" | |||||
| android:textSize="16sp" | |||||
| android:textStyle="bold" /> | |||||
| </FrameLayout> | |||||
| </GridLayout> | </GridLayout> | ||||
| </android.support.constraint.ConstraintLayout> | </android.support.constraint.ConstraintLayout> | ||||
| @@ -0,0 +1,25 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:padding="2dp"> | |||||
| <ProgressBar | |||||
| android:id="@+id/progress_bar" | |||||
| style="?android:attr/progressBarStyleHorizontal" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="match_parent" | |||||
| android:indeterminate="false" | |||||
| android:progressDrawable="@drawable/progress_bar_states" /> | |||||
| <TextView | |||||
| android:id="@+id/text_view_button" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="match_parent" | |||||
| android:gravity="center" | |||||
| android:padding="6dp" | |||||
| android:text="Enter" | |||||
| android:textColor="@android:color/white" | |||||
| android:textSize="16sp" | |||||
| android:textStyle="bold" /> | |||||
| </FrameLayout> | |||||