Skip to content

Commit

Permalink
Remove Butterknife and fix UI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vgaidarji committed Mar 15, 2024
1 parent b8b292b commit ec5e262
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 33 deletions.
8 changes: 5 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildFeatures {
viewBinding = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
Expand All @@ -67,9 +70,8 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:25.0.0'
implementation 'com.jakewharton:butterknife:5.1.1'
implementation 'com.android.support:design:25.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
// todo: firebase app distribution
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-all:2.0.2-beta'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class LoginActivityTest {
@Rule
var activityTestRule = ActivityTestRule(
@get:Rule
val activityTestRule = ActivityTestRule(
LoginActivity::class.java
)

Expand Down
40 changes: 14 additions & 26 deletions app/src/main/java/com/vgaidarji/cimatters/LoginActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,30 @@ package com.vgaidarji.cimatters

import android.content.Intent
import android.os.Bundle
import android.support.design.widget.CoordinatorLayout
import android.support.design.widget.Snackbar
import android.support.v7.app.AppCompatActivity
import android.widget.Button
import android.widget.EditText
import butterknife.ButterKnife
import butterknife.InjectView
import butterknife.OnClick
import com.vgaidarji.cimatters.databinding.ActivityLoginBinding

class LoginActivity : AppCompatActivity(), LoginView {
@InjectView(R.id.coordinator)
var coordinatorLayout: CoordinatorLayout? = null

@InjectView(R.id.edit_text_email)
var editTextEmail: EditText? = null

@InjectView(R.id.edit_text_password)
var editTextPassword: EditText? = null

@InjectView(R.id.button_login)
var buttonLogin: Button? = null
private var presenter: LoginPresenter? = null
private lateinit var binding: ActivityLoginBinding
private lateinit var presenter: LoginPresenter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
binding = ActivityLoginBinding.inflate(layoutInflater);
setContentView(binding.root)
title = getString(R.string.activity_login)
ButterKnife.inject(this)
presenter = LoginPresenter(this)
setupLoginButtonClickListener()
}

@OnClick(R.id.button_login)
fun onLoginClick() {
presenter!!.onLoginClick(
editTextEmail!!.text.toString(),
editTextPassword!!.text.toString()
)
private fun setupLoginButtonClickListener() {
binding.buttonLogin.setOnClickListener {
presenter.onLoginClick(
binding.editTextEmail.text.toString(),
binding.editTextPassword.text.toString()
)
}
}

override fun openNextActivity() {
Expand All @@ -46,6 +34,6 @@ class LoginActivity : AppCompatActivity(), LoginView {
}

override fun showError(message: String?) {
message?.let { Snackbar.make(coordinatorLayout!!, it, Snackbar.LENGTH_LONG).show() }
message?.let { Snackbar.make(binding.coordinator, it, Snackbar.LENGTH_LONG).show() }
}
}
3 changes: 3 additions & 0 deletions app/src/main/java/com/vgaidarji/cimatters/LoginPresenter.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.vgaidarji.cimatters

import android.util.Log

internal class LoginPresenter(private val view: LoginView) {
fun onLoginClick(email: String, password: String) {
Log.d("test123","email + ${email}, password + ${password}, ${email == EMAIL && password == PASSWORD}")
if (email == EMAIL && password == PASSWORD) {
view.openNextActivity()
} else {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.2.0'
classpath 'com.android.tools.build:gradle:8.3.0'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.7.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Sep 19 20:32:35 EEST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

0 comments on commit ec5e262

Please sign in to comment.