Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'


android {
compileSdkVersion 28
Expand All @@ -22,9 +25,15 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

implementation 'com.hover:android-sdk:1.5.1'
implementation 'com.hover:android-sdk:1.5.2'
implementation "androidx.core:core-ktx:1.2.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
mavenCentral()
}
59 changes: 0 additions & 59 deletions app/src/main/java/com/usehover/hoverstarter/MainActivity.java

This file was deleted.

55 changes: 55 additions & 0 deletions app/src/main/java/com/usehover/hoverstarter/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.usehover.hoverstarter

import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Button
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.hover.sdk.actions.HoverAction
import com.hover.sdk.api.Hover
import com.hover.sdk.api.HoverParameters
import com.hover.sdk.permissions.PermissionActivity
import java.util.*

class MainActivity : AppCompatActivity(), Hover.DownloadListener {

private val TAG = "MainActivity"
private lateinit var permissionButton: Button
private lateinit var buttonAction: Button

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

Hover.initialize(applicationContext, this)

permissionButton = findViewById(R.id.permissions_button)
permissionButton.setOnClickListener {
val i = Intent(applicationContext, PermissionActivity::class.java)
startActivityForResult(i, 0)
}

buttonAction = findViewById<View>(R.id.action_button) as Button
buttonAction.isEnabled = true
buttonAction.setOnClickListener {
val i = HoverParameters.Builder(this@MainActivity)
.request("YOUR_ACTION_ID") // Add your action ID here
.extra("YOUR_VARIABLE_NAME", "TEST_VALUE") // Uncomment and add your variables if any
.buildIntent()
startActivityForResult(i, 0)
}

}

override fun onError(message: String) {
Toast.makeText(this, "Error while attempting to download actions, see logcat for error", Toast.LENGTH_LONG).show()
Log.e(TAG, "Error: $message")
}

override fun onSuccess(actions: ArrayList<HoverAction>) {
Toast.makeText(this, "Successfully downloaded " + actions.size + " actions", Toast.LENGTH_LONG).show()
Log.d(TAG, "Successfully downloaded " + actions.size + " actions")
}
}
5 changes: 2 additions & 3 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
Expand Down Expand Up @@ -33,6 +32,6 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:enabled="true"/>
android:enabled="true" />

</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

ext.kotlin_version = '1.3.72'

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

Expand Down