Modernize project

This commit is contained in:
Felipe Lima 2018-08-08 20:10:59 -07:00
parent c508b7a315
commit 67bc8d3084
7 changed files with 43 additions and 64 deletions

View File

@ -1,14 +1,15 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileSdkVersion 28
buildToolsVersion '28.0.2'
defaultConfig {
applicationId "android.emu6502"
minSdkVersion 16
targetSdkVersion 25
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
@ -22,16 +23,14 @@ android {
}
dependencies {
compile 'com.android.support:design:25.2.0'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:cardview-v7:25.2.0'
compile 'org.jetbrains.kotlin:kotlin-stdlib:1.1.0'
compile "org.jetbrains.kotlin:kotlin-reflect:1.1.0"
compile 'com.jakewharton:kotterknife:0.1.0-SNAPSHOT'
compile 'com.facebook.stetho:stetho:1.3.1'
compile 'com.google.guava:guava:20.0'
implementation 'com.google.android.material:material:1.0.0-alpha1'
implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
implementation 'androidx.cardview:cardview:1.0.0-alpha1'
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.2.60'
implementation "org.jetbrains.kotlin:kotlin-reflect:1.2.60"
implementation 'com.facebook.stetho:stetho:1.5.0'
testCompile 'junit:junit:4.12'
testCompile 'com.google.truth:truth:0.32'
testCompile 'org.mockito:mockito-core:1.10.19'
testImplementation 'junit:junit:4.12'
testImplementation 'com.google.truth:truth:0.42'
testImplementation 'org.mockito:mockito-core:1.10.19'
}

View File

@ -1,42 +1,18 @@
package android.emu6502.app
import android.emu6502.Display
import android.emu6502.Emulator
import android.emu6502.R
import android.os.Bundle
import android.support.design.widget.CoordinatorLayout
import android.support.design.widget.FloatingActionButton
import android.support.design.widget.Snackbar
import android.support.v7.app.ActionBar
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.Toolbar
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.widget.Button
import android.widget.FrameLayout
import android.widget.TextView
import butterknife.bindView
import androidx.appcompat.app.ActionBar
import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.snackbar.Snackbar
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.toolbar.*
class MainActivity : AppCompatActivity() {
val toolbar: Toolbar by bindView(R.id.toolbar)
val txtA: TextView by bindView(R.id.A)
val txtX: TextView by bindView(R.id.X)
val txtY: TextView by bindView(R.id.Y)
val txtSP: TextView by bindView(R.id.SP)
val txtPC: TextView by bindView(R.id.PC)
val txtFlags: TextView by bindView(R.id.PC)
val displayWrapper: FrameLayout by bindView(R.id.display_wrapper)
val display: Display by bindView(R.id.display)
val txtInstructions: TextView by bindView(R.id.txtInstructions)
val fabRun: FloatingActionButton by bindView(R.id.fabRun)
val layoutContent: CoordinatorLayout by bindView(R.id.layout_content)
val btnLeft: Button by bindView(R.id.arrowLeft)
val btnRight: Button by bindView(R.id.arrowRight)
val btnUp: Button by bindView(R.id.arrowUp)
val btnDown: Button by bindView(R.id.arrowDown)
val btnReset: Button by bindView(R.id.btnReset)
private var emulator: Emulator? = null
override fun onCreate(savedInstanceState: Bundle?) {
@ -47,11 +23,11 @@ class MainActivity : AppCompatActivity() {
ab.setDisplayHomeAsUpEnabled(true)
fabRun.setOnClickListener {
displayWrapper.visibility = View.VISIBLE
display_wrapper.visibility = View.VISIBLE
emulator = Emulator(display)
val emu: Emulator = emulator as Emulator
emu.assembler.assembleCode(txtInstructions.text.toString().split("\n"))
Snackbar.make(layoutContent,
Snackbar.make(layout_content,
"Code assembled successfully, ${emu.assembler.codeLen} bytes.",
Snackbar.LENGTH_SHORT).show()
emu.cpu.run()
@ -68,10 +44,10 @@ class MainActivity : AppCompatActivity() {
emu.cpu.memory.storeKeypress(code)
}
}
btnLeft.setOnClickListener { onClickButton(0x61) }
btnRight.setOnClickListener { onClickButton(0x64) }
btnUp.setOnClickListener { onClickButton(0x77) }
btnDown.setOnClickListener { onClickButton(0x73) }
arrowLeft.setOnClickListener { onClickButton(0x61) }
arrowRight.setOnClickListener { onClickButton(0x64) }
arrowUp.setOnClickListener { onClickButton(0x77) }
arrowDown.setOnClickListener { onClickButton(0x73) }
}
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
@ -85,10 +61,10 @@ class MainActivity : AppCompatActivity() {
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
val id = item!!.itemId
if (id == R.id.action_settings) {
return true
return if (id == R.id.action_settings) {
true
} else {
return super.onOptionsItemSelected(item)
super.onOptionsItemSelected(item)
}
}
}

View File

@ -1,4 +1,4 @@
<android.support.design.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/layout_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
@ -12,7 +12,7 @@
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -20,14 +20,14 @@
<include layout="@layout/toolbar"/>
</android.support.design.widget.AppBarLayout>
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_margin="@dimen/card_margin">
@ -54,7 +54,7 @@
android:layout_height="match_parent"/>
</FrameLayout>
</android.support.v7.widget.CardView>
</androidx.cardview.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
@ -184,7 +184,7 @@
</LinearLayout>
<android.support.design.widget.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabRun"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -193,4 +193,4 @@
android:src="@drawable/ic_play_arrow_white_48dp"
app:borderWidth="0dp"/>
</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,4 +1,4 @@
<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_height="wrap_content"

View File

@ -3,10 +3,11 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.0'
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@ -16,6 +17,7 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
}

View File

@ -15,4 +15,6 @@
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
org.gradle.parallel=true
android.useAndroidX=true
android.enableJetifier=true

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip