Commit 725de65c authored by 12people's avatar 12people

Merge branch 'bugsquash' into 'master'

Bug squash

See merge request !8
parents da7fc11f ebbc8035
......@@ -9,8 +9,8 @@ android {
applicationId "com.enjoyingfoss.feeel"
minSdkVersion 15
targetSdkVersion 27
versionCode 3
versionName "1.9"
versionCode 4
versionName "1.91"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
......
......@@ -20,11 +20,16 @@
</activity>
<activity
android:name="com.enjoyingfoss.feeel.view.CoverActivity"/>
android:name="com.enjoyingfoss.feeel.view.CoverActivity"
android:parentActivityName=".view.OverviewActivity"
android:theme="@style/AppThemeCover"
tools:ignore="UnusedAttribute"/>
<activity
android:name="com.enjoyingfoss.feeel.view.WorkoutActivity"
android:launchMode="singleTop"/>
android:launchMode="singleTop"
android:parentActivityName=".view.CoverActivity"
tools:ignore="UnusedAttribute"/>
<service android:name="com.enjoyingfoss.feeel.presenter.WorkoutService"/>
</application>
......
......@@ -8,7 +8,7 @@ import java.util.concurrent.TimeUnit
@author Miroslav Mazel
*/
class WorkoutTimer(val callback: TimerCallback, initTime: Int) {
class WorkoutTimer(private val callback: TimerCallback, initTime: Int) {
interface TimerCallback {
fun onSecondDecrease()
......@@ -22,7 +22,7 @@ class WorkoutTimer(val callback: TimerCallback, initTime: Int) {
fun start() {
if (timerFuture == null) { //todo double-check if using futures right
timerFuture = exerciseExecutor.scheduleAtFixedRate(Runnable { countSecond() }, 0, 1, TimeUnit.SECONDS) //todo is a try catch needed with the runnable?
timerFuture = exerciseExecutor.scheduleAtFixedRate({ countSecond() }, 0, 1, TimeUnit.SECONDS) //todo is a try catch needed with the runnable?
running = true
}
}
......
package com.enjoyingfoss.feeel.view
import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.enjoyingfoss.feeel.R
import com.enjoyingfoss.feeel.model.Workout
import com.enjoyingfoss.feeel.model.WorkoutRepository
import kotlinx.android.synthetic.main.activity_overview.*
import java.lang.ref.WeakReference
class OverviewActivity : AppCompatActivity() {
//todo make sure the exercise view loads back if service is in background
override fun onCreate(savedInstanceState: Bundle?) { //todo connect service and preload here
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_overview)
workoutRecycler.layoutManager = LinearLayoutManager(this)
workoutRecycler.adapter = WorkoutAdapter(WorkoutRepository.retrieveAll(), WeakReference(workoutRecycler))
workoutRecycler.addOnItemTouchListener(object: RecyclerView.SimpleOnItemTouchListener() {
})
}
internal class WorkoutAdapter(private val workouts: List<Workout>, private val recyclerView: WeakReference<RecyclerView>)
: RecyclerView.Adapter<WorkoutAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater
.from(parent.context)
.inflate(R.layout.item_workout, parent, false)
view.setOnClickListener {
val recycler = recyclerView.get()
val itemPosition = recycler?.getChildAdapterPosition(view) ?: 0
val workout = workouts[itemPosition]
val startIntent = Intent(recycler?.context, CoverActivity::class.java)
startIntent.putExtra(CoverActivity.WORKOUT_KEY, workout)
recycler?.context?.startActivity(startIntent)
}
return ViewHolder(view)
}
override fun getItemCount() = workouts.size
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.title.setText(workouts[position].titleResource)
}
internal class ViewHolder(item: View) : RecyclerView.ViewHolder(item) {
var title = item.findViewById<View>(R.id.title) as TextView
}
}
//todo consider creating service here, then just passing it onto the activity created
}
\ No newline at end of file
......@@ -12,6 +12,7 @@ import android.os.Bundle
import android.os.IBinder
import android.os.Parcelable
import android.support.v7.app.AppCompatActivity
import android.support.v7.content.res.AppCompatResources
import android.text.Html
import android.util.TypedValue
import android.view.View
......@@ -25,6 +26,8 @@ import kotlinx.android.synthetic.main.activity_workout.*
import java.lang.ref.WeakReference
//todo license info
//todo separate activity without workout
//todo force media playback audio controls at all times on this activity
......@@ -43,12 +46,13 @@ class WorkoutActivity : AppCompatActivity(), ServiceConnection, WorkoutContract.
companion object {
const val TTS_KEY = "audio"
const val WORKOUT_KEY = "workout"
private const val STATE_KEY = "STATE"
private const val CONTROLS_KEY = "CONTROLS"
}
//todo do a pager view, preload
private var presenterService: WeakReference<WorkoutService>? = null
private val STATE_KEY = "STATE"
private val CONTROLS_KEY = "controls"
private var controlsShown = false //todo not happy with this, seems hackish, only there to fix a bug with disappearing controls
private var restoredState: Parcelable? = null
private val grayscaleMatrix = ColorMatrix()
......@@ -73,6 +77,8 @@ class WorkoutActivity : AppCompatActivity(), ServiceConnection, WorkoutContract.
volumeControlStream = AudioManager.STREAM_MUSIC
setContentView(R.layout.activity_workout)
val collapseDrawable = AppCompatResources.getDrawable(this, R.drawable.ic_expand_up)
titleButton.setCompoundDrawablesWithIntrinsicBounds(null, null, collapseDrawable, null)
ttsEnabled = intent.getBooleanExtra(TTS_KEY, false)
workout = intent.getParcelableExtra(WORKOUT_KEY)
......@@ -228,11 +234,11 @@ class WorkoutActivity : AppCompatActivity(), ServiceConnection, WorkoutContract.
override fun setPaused() { //todo visibility failing on rotate sometime! I guess setPaused isn't called sometime!!!
controlsShown = true
showControls()
runOnUiThread {
tapIndicator.visibility = View.GONE
timeText.setTextSize(TypedValue.COMPLEX_UNIT_PX, resources.getDimension(R.dimen.time_headline_small))
timeText.setTextSize(TypedValue.COMPLEX_UNIT_PX, resources.getDimensionPixelSize(R.dimen.time_headline_small).toFloat())
if (Build.VERSION.SDK_INT >= 16)
exerciseImage.imageAlpha = 128
......@@ -257,10 +263,12 @@ class WorkoutActivity : AppCompatActivity(), ServiceConnection, WorkoutContract.
runOnUiThread {
if (descriptionFrame.visibility == View.GONE) {
descriptionFrame.visibility = View.VISIBLE
titleButton.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_collapse_down, 0)
val downCollapseDrawable = AppCompatResources.getDrawable(this, R.drawable.ic_collapse_down)
titleButton.setCompoundDrawablesWithIntrinsicBounds(null, null, downCollapseDrawable, null)
} else {
descriptionFrame.visibility = View.GONE
titleButton.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_expand_up, 0)
val upCollapseDrawable = AppCompatResources.getDrawable(this, R.drawable.ic_expand_up)
titleButton.setCompoundDrawablesWithIntrinsicBounds(null, null, upCollapseDrawable, null)
}
}
}
......
......@@ -9,7 +9,7 @@ import com.enjoyingfoss.feeel.WorkoutContract
import com.enjoyingfoss.feeel.model.ExerciseMeta
import java.lang.ref.WeakReference
class WorkoutChime(private val context: WeakReference<Context>) : WorkoutContract.View {
class WorkoutChime(context: WeakReference<Context>) : WorkoutContract.View {
@Suppress("DEPRECATION")
private val soundPool =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) SoundPool.Builder().build()
......@@ -24,11 +24,7 @@ class WorkoutChime(private val context: WeakReference<Context>) : WorkoutContrac
private var chimeLoaded = false
init {
soundPool.setOnLoadCompleteListener(object : SoundPool.OnLoadCompleteListener {
override fun onLoadComplete(soundPool: SoundPool, sampleId: Int, status: Int) {
chimeLoaded = true
}
})
soundPool.setOnLoadCompleteListener { _, _, _ -> chimeLoaded = true }
}
override fun setExercise(exerciseMeta: ExerciseMeta) {
......
......@@ -6,4 +6,4 @@
<path
android:fillColor="#FFFFFF"
android:pathData="M16.59,8.59L12,13.17 7.41,8.59 6,10l6,6 6,-6z"/>
</vector>
</vector>
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M12,8l-6,6 1.41,1.41L12,10.83l4.59,4.58L18,14z"/>
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:pathData="M26.6,2H5L13.1002,11.9355L26.6,2Z"
android:fillColor="#ffffff"/>
<path
android:pathData="M26.5993,11.9354H13.0995L8.5996,21.8709L26.5993,11.9354Z"
android:fillColor="#FFEFA1"/>
<path
android:pathData="M8.5999,21.871L5,2L13.0999,11.9355L8.5999,21.871Z"
android:fillColor="#FFDD9C"/>
<path
android:pathData="M8.5999,21.871L5,2V30L8.5999,21.871Z"
android:fillColor="#EDCC80"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<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"
android:background="@color/darkGrayBackground">
android:layout_height="match_parent">
<android.support.design.widget.FloatingActionButton
android:id="@+id/startExerciseButton"
......@@ -15,8 +13,8 @@
android:layout_marginRight="16dp"
android:clickable="true"
android:focusable="true"
app:fabSize="normal"
app:backgroundTint="@color/colorPrimary"
app:fabSize="normal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@android:drawable/ic_media_play"/>
......@@ -43,6 +41,7 @@
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:checked="true"
android:text="@string/cover.enable_tts"
android:textColor="#ffffff"
......
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="@string/app_name"
app:srcCompat="@drawable/ic_logo"/>
</android.support.v7.widget.Toolbar>
<android.support.v7.widget.RecyclerView
android:id="@+id/workoutRecycler"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar"/>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
......@@ -4,8 +4,7 @@
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"
android:background="@color/darkGrayBackground">
android:layout_height="match_parent">
<ImageView
android:id="@+id/successIV"
......
......@@ -50,8 +50,6 @@
android:layout_height="wrap_content"
android:layout_gravity="start"
android:background="#2C2C2C"
android:drawableEnd="@drawable/ic_expand_up"
android:drawableRight="@drawable/ic_expand_up"
android:onClick="toggleDescription"
android:paddingLeft="16dp"
android:paddingRight="16dp"
......
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:background="?android:attr/selectableItemBackground"
tools:ignore="Overdraw">
<TextView
android:id="@+id/title"
style="@style/ListTitle_DayNight"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="text">#ffffff</color>
</resources>
\ No newline at end of file
......@@ -8,12 +8,16 @@
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppThemeDarkAlways" parent="Theme.AppCompat">
<style name="AppThemeDarkAlways" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppThemeCover" parent="AppThemeDarkAlways">
<item name="android:background">@color/darkGrayBackground</item>
</style>
<style name="TimeHeadline">
<item name="android:textColor">#FFFFFF</item>
<item name="android:textSize">@dimen/time_headline</item>
......@@ -40,7 +44,7 @@
<item name="android:textColor">#FFFFFF</item>
<item name="android:textSize">16sp</item>
</style>
<style name="ListTitle_DayNight">
<item name="android:textColor">@color/text</item>
<item name="android:textSize">16sp</item>
......
Markdown is supported
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