Commit 078e8ff0 authored by nk2's avatar nk2 🙃

Init layouts

parent 677f6b94
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
......
import android.app.*
import android.view.*
import android.widget.*
import org.jetbrains.anko.*
import android.os.Bundle
class SomeActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super<Activity>.onCreate(savedInstanceState)
android.support.constraint.ConstraintLayout {
android.support.constraint.ConstraintLayout {
backgroundColor = 0x20bf6b.opaque
id = Ids.topPanel
app:layout_constraintBottom_toTopOf = @id/bottomPanel
app:layout_constraintEnd_toEndOf = parent
app:layout_constraintStart_toStartOf = parent
app:layout_constraintTop_toTopOf = parent
app:layout_constraintVertical_chainStyle = packed
linearLayout {
id = Ids.currentValues
textView("your bullshit").lparams(width = wrapContent, height = wrapContent)
}.lparams(width = matchParent, height = wrapContent)
com.txusballesteros.SnakeView {
app:layout_constraintBottom_toBottomOf = parent
app:layout_constraintEnd_toEndOf = parent
app:layout_constraintStart_toStartOf = parent
app:layout_constraintTop_toBottomOf = @id/currentValues
app:strokeColor = #ffffff
}.lparams(width = matchParent, height = dp(0))
}.lparams(width = matchParent, height = dp(0))
android.support.constraint.ConstraintLayout {
backgroundColor = 0xffffff.opaque
id = Ids.bottomPanel
app:layout_constraintBottom_toBottomOf = parent
app:layout_constraintEnd_toEndOf = parent
app:layout_constraintStart_toStartOf = parent
app:layout_constraintTop_toBottomOf = @id/topPanel
textView("122/21312").lparams(width = wrapContent, height = wrapContent)
}.lparams(width = matchParent, height = dp(0))
}
}
private object Ids {
val bottomPanel = 1
val currentValues = 2
val topPanel = 3
}
}
\ No newline at end of file
apply plugin: 'com.android.application'
apply plugin: "com.android.application"
apply plugin: "kotlin-android"
//apply plugin: "kotlin-kapt"
apply plugin: "kotlin-android-extensions"
apply plugin: "realm-android"
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
......@@ -14,20 +15,100 @@ android {
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation "com.android.support:appcompat-v7:26.1.0"
testImplementation "junit:junit:4.12"
androidTestImplementation "com.android.support.test:runner:1.0.1"
androidTestImplementation "com.android.support.test.espresso:espresso-core:3.0.1"
//Support
compile "com.android.support:support-compat:$appcompat_version"
compile "com.android.support:design:$appcompat_version"
compile "com.android.support:support-core-ui:$appcompat_version"
compile "com.android.support:multidex:$multidex_version"
compile "com.android.support:appcompat-v7:$appcompat_version"
compile "com.android.support:cardview-v7:$appcompat_version"
compile "com.android.support:gridlayout-v7:$appcompat_version"
compile "com.android.support:recyclerview-v7:$appcompat_version"
compile "com.android.support:palette-v7:$appcompat_version"
compile "com.android.support.constraint:constraint-layout:$constraintlayout_version"
//Anko
compile "org.jetbrains.anko:anko:$anko_version"
compile "org.jetbrains.anko:anko-commons:$anko_version"
compile "org.jetbrains.anko:anko-appcompat-v7-commons:$anko_version"
compile "org.jetbrains.anko:anko-appcompat-v7:$anko_version"
compile "org.jetbrains.anko:anko-coroutines:$anko_version"
compile "org.jetbrains.anko:anko-cardview-v7:$anko_version"
compile "org.jetbrains.anko:anko-design:$anko_version"
compile "org.jetbrains.anko:anko-design-coroutines:$anko_version"
compile "org.jetbrains.anko:anko-gridlayout-v7:$anko_version"
compile "org.jetbrains.anko:anko-percent:$anko_version"
compile "org.jetbrains.anko:anko-recyclerview-v7:$anko_version"
compile "org.jetbrains.anko:anko-recyclerview-v7-coroutines:$anko_version"
compile "org.jetbrains.anko:anko-support-v4-commons:$anko_version"
compile "org.jetbrains.anko:anko-support-v4:$anko_version"
compile "org.jetbrains.anko:anko-constraint-layout:$anko_version"
//MVP
compile "com.arello-mobile:moxy:$moxy_version"
compile "com.arello-mobile:moxy-app-compat:$moxy_version"
kapt "com.arello-mobile:moxy-compiler:$moxy_version"
//Rx
compile "io.reactivex.rxjava2:rxandroid:$rxandroid_version"
compile "io.reactivex.rxjava2:rxjava:$rxjava_version"
compile "com.evernote:android-job:$job_version"
//View
compile "com.flipboard:bottomsheet-core:$bottomsheet_version"
compile "com.flipboard:bottomsheet-commons:$bottomsheet_version"
compile "com.txusballesteros:snake:$snakeview_version"
compile "com.github.vipulasri:timelineview:$timelineview_version"
//Time
compile "com.github.debop:koda-time:$kodatime_version"
//DI
compile "com.google.dagger:dagger:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
compile "com.google.dagger:dagger-android:$dagger_version"
compile "com.google.dagger:dagger-android-support:$dagger_version"
kapt "com.google.dagger:dagger-android-processor:$dagger_version"
//Json
compile "com.squareup.moshi:moshi:$moshi_version"
compile "com.squareup.moshi:moshi-kotlin:$moshi_version"
//Data
compile "com.pixplicity.easyprefs:library:$easyprefs_version"
//Perms
compile "com.github.karanchuri:PermissionManager:$perms_version"
}
kotlin {
experimental {
coroutines "enable"
}
}
kapt {
generateStubs = true
}
......@@ -9,7 +9,7 @@ import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
* Instrumented screen_main, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
......@@ -17,7 +17,7 @@ import org.junit.Assert.*
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
// Context of the app under screen_main.
val appContext = InstrumentationRegistry.getTargetContext()
assertEquals("ga.nk2ishere.dev.musclecar", appContext.packageName)
}
......
......@@ -2,10 +2,22 @@
package="ga.nk2ishere.dev.musclecar">
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme" />
android:theme="@style/AppTheme" >
<activity
android:name=".features.pulse.PulseActivity"
android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
package ga.nk2ishere.dev.musclecar
import android.app.Application
import android.content.Context
import android.support.multidex.MultiDex
import com.evernote.android.job.JobCreator
import com.evernote.android.job.JobManager
import com.pixplicity.easyprefs.library.Prefs
import ga.nk2ishere.dev.musclecar.common.modules.AppModule
import ga.nk2ishere.dev.musclecar.common.modules.ContextModule
import ga.nk2ishere.dev.musclecar.common.modules.DaggerAppModule
import io.realm.Realm
import io.realm.RealmConfiguration
/**
* Created by nk2 on 03/02/2018.
*/
class App: Application() {
companion object {
lateinit var appComponent: AppModule
}
override fun onCreate() {
super.onCreate()
Realm.init(this)
Realm.setDefaultConfiguration(RealmConfiguration.Builder()
.name("db.realm")
.schemaVersion(1)
.build())
Prefs.Builder()
.setContext(this)
.build()
JobManager
.create(this)
appComponent = DaggerAppModule
.builder()
.contextModule(ContextModule(this))
.build()
}
override fun attachBaseContext(base: Context) {
super.attachBaseContext(base)
MultiDex.install(this)
}
}
\ No newline at end of file
package ga.nk2ishere.dev.musclecar.common.libs
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
/**
* Created by nk2 on 04/02/2018.
*/
abstract class AbstractAdapter<ITEM> constructor(
protected var itemList: List<ITEM>,
private val layoutResId: Int)
: RecyclerView.Adapter<AbstractAdapter.Holder>() {
override fun getItemCount() = itemList.size
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
val view = parent inflate layoutResId
val viewHolder = Holder(view)
val itemView = viewHolder.itemView
itemView.setOnClickListener {
val adapterPosition = viewHolder.adapterPosition
if (adapterPosition != RecyclerView.NO_POSITION) {
onItemClick(itemView, adapterPosition)
}
}
return viewHolder
}
protected open fun onItemClick(itemView: View, position: Int) {
}
override fun onBindViewHolder(holder: Holder, position: Int) {
val item = itemList[position]
holder.itemView.bind(item)
}
protected open fun View.bind(item: ITEM) {
}
class Holder(itemView: View) : RecyclerView.ViewHolder(itemView)
}
class Kadapter<ITEM>(items: List<ITEM>,
layoutResId: Int,
private val bindHolder: View.(ITEM) -> Unit)
: AbstractAdapter<ITEM>(items, layoutResId) {
private var itemClick: ITEM.() -> Unit = {}
constructor(items: List<ITEM>,
layoutResId: Int,
bindHolder: View.(ITEM) -> Unit,
itemClick: ITEM.() -> Unit = {}) : this(items, layoutResId, bindHolder) {
this.itemClick = itemClick
}
override fun onBindViewHolder(holder: Holder, position: Int) {
holder.itemView.bindHolder(itemList[position])
}
override fun onItemClick(itemView: View, position: Int) {
itemList[position].itemClick()
}
}
fun <ITEM> RecyclerView.setUp(items: List<ITEM>,
layoutResId: Int,
bindHolder: View.(ITEM) -> Unit,
itemClick: ITEM.() -> Unit = {},
manager: RecyclerView.LayoutManager = LinearLayoutManager(this.context)): Kadapter<ITEM> {
return Kadapter(items, layoutResId, {
bindHolder(it)
}, {
itemClick()
}).apply {
layoutManager = manager
adapter = this
}
}
\ No newline at end of file
package ga.nk2ishere.dev.musclecar.common.libs
import io.reactivex.Single
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
/**
* Created by nk2 on 04/02/2018.
*/
fun <T> Single<T>.applySchedulers() = this.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())!!
\ No newline at end of file
package ga.nk2ishere.dev.musclecar.common.libs
import android.view.LayoutInflater
import android.view.ViewGroup
/**
* Created by nk2 on 04/02/2018.
*/
infix fun ViewGroup.inflate(id: Int) = LayoutInflater.from(this.context).inflate(id, this, false)
\ No newline at end of file
package ga.nk2ishere.dev.musclecar.common.modules
import android.content.Context
import dagger.Component
import ga.nk2ishere.dev.musclecar.features.pulse.data.repositories.RepositoryModule
import javax.inject.Singleton
/**
* Created by nk2 on 03/02/2018.
*/
@Singleton
@Component(modules = arrayOf(
ContextModule::class,
RepositoryModule::class
)) interface AppModule {
fun getContext(): Context
}
\ No newline at end of file
package ga.nk2ishere.dev.musclecar.common.modules
import android.content.Context
import dagger.Module
import dagger.Provides
import javax.inject.Singleton
/**
* Created by nk2 on 03/02/2018.
*/
@Module class ContextModule(private var context: Context) {
@Provides @Singleton fun provideContext() = context
}
\ No newline at end of file
package ga.nk2ishere.dev.musclecar.features.pulse
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import ga.nk2ishere.dev.musclecar.R
/**
* Created by nk2 on 04/02/2018.
*/
class PulseActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_pulse)
}
}
\ No newline at end of file
package ga.nk2ishere.dev.musclecar.features.pulse
import android.view.View
import com.arellomobile.mvp.MvpView
/**
* Created by nk2 on 04/02/2018.
*/
interface PulseView: MvpView {
fun updateMusclePulse(pulse: Int)
fun updateCurrentCount(count: Int)
fun initNeededCount(count: Int)
fun initCurrentThreshold(threshold: Int)
fun showBottomSheet(view: View)
}
\ No newline at end of file
package ga.nk2ishere.dev.musclecar.features.pulse.data
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
import java.util.*
/**
* Created by nk2 on 04/02/2018.
*/
open class ThresholdData : RealmObject() {
@PrimaryKey var uuid: String = UUID.randomUUID().toString()
var name: String = ""
var threshold: Int = 0
}
\ No newline at end of file
package ga.nk2ishere.dev.musclecar.features.pulse.data.repositories
import dagger.Module
import dagger.Provides
import javax.inject.Singleton
/**
* Created by nk2 on 04/02/2018.
*/
@Module class RepositoryModule {
@Singleton @Provides fun provideThresholdRepository() = ThresholdRepository()
}
\ No newline at end of file
package ga.nk2ishere.dev.musclecar.features.pulse.data.repositories
/**
* Created by nk2 on 04/02/2018.
*/
class ThresholdRepository {
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="#999999"/>
<size
android:width="120dp"
android:height="120dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:color="#ffffff"
android:dashWidth="10px"
android:dashGap="10px"
android:width="2dp"/>
</shape>
\ 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">
<path
android:fillColor="#FF000000"
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z"/>
</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"
app:layout_constraintVertical_chainStyle="packed"
android:background="@color/colorPrimary"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/calibrationText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="Calibration"
android:textColor="#FFFFFF"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/hintText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:text="Pulse your muscle on sound!"
android:textColor="#FFFFFF"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/calibrationText" />
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<com.flipboard.bottomsheet.BottomSheetLayout
android:id="@+id/bottomSheet"
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:background="@android:color/background_light"
android:fitsSystemWindows="true">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapseBar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|snap"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
<android.support.constraint.ConstraintLayout
android:id="@+id/topPanel"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="#20bf6b"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed">
<LinearLayout
android:id="@+id/currentValues"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Your muscles' pulse:"
android:textColor="#ffffff"
android:textSize="24sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|center_horizontal"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="is "
android:textColor="#ffffff"
android:textSize="22sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="231"
android:textColor="#ffffff"
android:textSize="24sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" now"
android:textColor="#ffffff"
android:textSize="22sp" />
</LinearLayout>
</LinearLayout>
<com.txusballesteros.SnakeView
android:id="@+id/rateGraph"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/currentValues"
app:strokeColor="#ffffff" />
<View
android:id="@+id/dashSplitter"
android:background="@drawable/dashes"
android:layout_width="wrap_content"
android:layout_marginTop="16dp"