Skip to content

Commit

Permalink
Merge pull request #17 from open-tool/custom_clicks_to_different_plac…
Browse files Browse the repository at this point in the history
…es_of_view/#10

clicks in different places within view
  • Loading branch information
alex-tiurin authored May 12, 2022
2 parents 3455622 + 6909b18 commit ffdd908
Show file tree
Hide file tree
Showing 15 changed files with 593 additions and 161 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ kotlin.code.style=official
android.useAndroidX=true
GROUP=com.atiurin
POM_ARTIFACT_ID=ultron
VERSION_NAME=1.0.17
VERSION_NAME=1.0.18

POM_NAME=ultron
POM_PACKAGING=aar
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.atiurin.sampleapp.tests.espresso

import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.matcher.ViewMatchers.withId
import com.atiurin.sampleapp.R
import com.atiurin.sampleapp.activity.CustomClicksActivity
import com.atiurin.sampleapp.tests.BaseTest
import com.atiurin.ultron.extensions.*
import com.atiurin.ultron.testlifecycle.setupteardown.SetUpRule
import org.junit.Test

class CustomClicksTest : BaseTest() {

private val startActivity = SetUpRule().add {
ActivityScenario.launch(CustomClicksActivity::class.java)
}

init {
ruleSequence.addLast(startActivity)
}

@Test
fun clickTopLeft() {
withId(R.id.imageView).clickTopLeft(offsetX = 30, offsetY = 30)
withId(R.id.rB_top_left).isChecked()
}

@Test
fun clickTopCenter() {
withId(R.id.imageView).clickTopCenter(offsetY = 30)
withId(R.id.rB_top_center).isChecked()
}

@Test
fun clickTopRight() {
withId(R.id.imageView).clickTopRight(offsetX = -30, offsetY = 30)
withId(R.id.rB_top_right).isChecked()
}

@Test
fun clickCenterRight() {
withId(R.id.imageView).clickCenterRight(offsetX = -30)
withId(R.id.rB_center_right).isChecked()
}

@Test
fun clickBottomRight() {
withId(R.id.imageView).clickBottomRight(offsetX = -30, offsetY = -30)
withId(R.id.rB_bottom_right).isChecked()
}

@Test
fun clickBottomCenter() {
withId(R.id.imageView).clickBottomCenter(offsetY = -30)
withId(R.id.rB_bottom_center).isChecked()
}

@Test
fun clickBottomLeft() {
withId(R.id.imageView).clickBottomLeft(offsetX = 30, offsetY = -30)
withId(R.id.rB_bottom_left).isChecked()
}

@Test
fun clickCenterLeft() {
withId(R.id.imageView).clickCenterLeft(offsetX = 30)
withId(R.id.rB_center_left).isChecked()
}
}
59 changes: 28 additions & 31 deletions sample-app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,52 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.atiurin.sampleapp">
package="com.atiurin.sampleapp">

<uses-permission android:name="android.permission.INTERNET" />
<application
android:requestLegacyExternalStorage="true"
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:usesCleartextTraffic="true"
>
<activity
android:name="com.atiurin.sampleapp.activity.SplashActivity"
android:theme="@style/SplashTheme">
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity
android:name="com.atiurin.sampleapp.activity.SplashActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.atiurin.sampleapp.activity.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
</activity>
android:name="com.atiurin.sampleapp.activity.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" />

<activity
android:name="com.atiurin.sampleapp.activity.ChatActivity"
android:theme="@style/AppTheme.NoActionBar">
</activity>
android:name="com.atiurin.sampleapp.activity.ChatActivity"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name="com.atiurin.sampleapp.activity.LoginActivity"
android:theme="@style/AppTheme">
</activity>
android:name="com.atiurin.sampleapp.activity.LoginActivity"
android:theme="@style/AppTheme" />
<activity
android:name="com.atiurin.sampleapp.activity.ProfileActivity"
android:theme="@style/AppTheme.NoActionBar">
</activity>
android:name="com.atiurin.sampleapp.activity.ProfileActivity"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name="com.atiurin.sampleapp.activity.UiElementsActivity"
android:theme="@style/AppTheme.NoActionBar">
</activity>
android:name="com.atiurin.sampleapp.activity.UiElementsActivity"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name="com.atiurin.sampleapp.activity.WebViewActivity"
android:theme="@style/AppTheme.NoActionBar">
</activity>
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name="com.atiurin.sampleapp.activity.CustomClicksActivity"
android:theme="@style/AppTheme.NoActionBar" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.atiurin.sampleapp.activity

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.atiurin.sampleapp.R

class CustomClicksActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_custom_clicks)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
val intent = Intent(applicationContext, WebViewActivity::class.java)
startActivity(intent)
}
R.id.custom_clicks_nav_item -> {
val intent = Intent(applicationContext, CustomClicksActivity::class.java)
startActivity(intent)
}
}
val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout)
drawerLayout.closeDrawer(GravityCompat.START)
Expand Down
124 changes: 124 additions & 0 deletions sample-app/src/main/res/layout/activity_custom_clicks.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#123FE3"
tools:context=".activity.CustomClicksActivity">

<ImageView
android:id="@+id/imageView"
android:layout_width="264dp"
android:layout_height="285dp"
android:layout_marginStart="72dp"
android:layout_marginTop="128dp"
android:adjustViewBounds="false"
android:background="#FFFFFF"
android:contentDescription="picture"
android:visibility="visible"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/background_splash"
tools:srcCompat="@drawable/background_splash" />

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="161dp"
android:layout_marginTop="58dp"
android:text="Button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView" />

<RadioButton
android:id="@+id/rB_top_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="72dp"
android:layout_marginTop="128dp"
android:backgroundTint="#DA1414"
android:minWidth="48dp"
android:minHeight="48dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<RadioButton
android:id="@+id/rB_center_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="216dp"
android:layout_marginBottom="120dp"
android:backgroundTint="#DA1414"
android:minWidth="48dp"
android:minHeight="48dp"
app:layout_constraintBottom_toBottomOf="@+id/imageView"
app:layout_constraintEnd_toEndOf="@+id/imageView" />

<RadioButton
android:id="@+id/rB_bottom_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#DA1414"
android:minWidth="48dp"
android:minHeight="48dp"
app:layout_constraintBottom_toBottomOf="@+id/imageView"
app:layout_constraintStart_toStartOf="@+id/imageView" />

<RadioButton
android:id="@+id/rB_top_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#DA1414"
android:minWidth="48dp"
android:minHeight="48dp"
app:layout_constraintEnd_toEndOf="@+id/imageView"
app:layout_constraintTop_toTopOf="@+id/imageView" />

<RadioButton
android:id="@+id/rB_center_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="117dp"
android:backgroundTint="#DA1414"
android:minWidth="48dp"
android:minHeight="48dp"
app:layout_constraintEnd_toEndOf="@+id/imageView"
app:layout_constraintTop_toTopOf="@+id/imageView" />

<RadioButton
android:id="@+id/rB_bottom_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#DA1414"
android:minWidth="48dp"
android:minHeight="48dp"
app:layout_constraintBottom_toBottomOf="@+id/imageView"
app:layout_constraintEnd_toEndOf="@+id/imageView" />

<RadioButton
android:id="@+id/rB_top_center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="104dp"
android:backgroundTint="#DA1414"
android:minWidth="48dp"
android:minHeight="48dp"
app:layout_constraintEnd_toEndOf="@+id/imageView"
app:layout_constraintTop_toTopOf="@+id/imageView" />

<RadioButton
android:id="@+id/rB_bottom_center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="237dp"
android:layout_marginEnd="104dp"
android:backgroundTint="#DA1414"
android:minWidth="48dp"
android:minHeight="48dp"
app:layout_constraintEnd_toEndOf="@+id/imageView"
app:layout_constraintTop_toTopOf="@+id/imageView" />

</androidx.constraintlayout.widget.ConstraintLayout>
6 changes: 5 additions & 1 deletion sample-app/src/main/res/menu/activity_main_drawer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
<item
android:id="@+id/web_view_nav_item"
android:icon="@drawable/ic_menu_slideshow"
android:title="@string/menu_web_view"/>
android:title="@string/menu_web_view" />
<item
android:id="@+id/custom_clicks_nav_item"
android:icon="@android:drawable/ic_dialog_dialer"
android:title="@string/menu_custom_clicks" />
</group>

<!--<item android:title="Communicate">-->
Expand Down
1 change: 1 addition & 0 deletions sample-app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@
<string name="button_event_double_click">Double Click</string>

<string name="app_compat_text">Default AppCompatTextView</string>
<string name="menu_custom_clicks">Custom Clicks</string>

</resources>
Loading

0 comments on commit ffdd908

Please sign in to comment.