From 76615c5cdbce67c547519f2d679dd511754ffa38 Mon Sep 17 00:00:00 2001 From: Larson Carter Date: Mon, 15 Jun 2020 10:49:48 -0500 Subject: [PATCH 1/3] Bump Gradle Version I simply bumped the gradle version to 4.0.0 --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index bc822d6bcd..8fc918b490 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.6.3' + classpath 'com.android.tools.build:gradle:4.0.0' } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a2bf1313b8..6bea9fe5a4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Mon Jun 15 10:18:25 CDT 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip From fdcf5adae10fd1bdf126673cd03ef239e14c1fff Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Mon, 15 Jun 2020 18:14:50 +0200 Subject: [PATCH 2/3] configured Kotlin --- app/build.gradle | 6 ++++++ build.gradle | 2 ++ terminal-emulator/build.gradle | 6 ++++++ terminal-view/build.gradle | 6 ++++++ 4 files changed, 20 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index 63278dc0d8..f927b574e1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,7 @@ plugins { id "com.android.application" } +apply plugin: 'kotlin-android' android { compileSdkVersion 28 @@ -74,6 +75,8 @@ android { dependencies { testImplementation 'junit:junit:4.13' testImplementation 'org.robolectric:robolectric:4.3.1' + implementation "androidx.core:core-ktx:1.3.0" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" } task versionName { @@ -146,3 +149,6 @@ afterEvaluate { variant.javaCompileProvider.get().dependsOn(downloadBootstraps) } } +repositories { + mavenCentral() +} diff --git a/build.gradle b/build.gradle index 8fc918b490..a06548fb0f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,12 @@ buildscript { + ext.kotlin_version = '1.3.72' repositories { jcenter() google() } dependencies { classpath 'com.android.tools.build:gradle:4.0.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/terminal-emulator/build.gradle b/terminal-emulator/build.gradle index a69359dcfd..1fa342c5fd 100644 --- a/terminal-emulator/build.gradle +++ b/terminal-emulator/build.gradle @@ -4,6 +4,7 @@ plugins { } apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' ext { bintrayName = 'terminal-emulator' @@ -62,6 +63,11 @@ tasks.withType(Test) { dependencies { testImplementation 'junit:junit:4.13' + implementation "androidx.core:core-ktx:+" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" } apply from: '../scripts/bintray-publish.gradle' +repositories { + mavenCentral() +} diff --git a/terminal-view/build.gradle b/terminal-view/build.gradle index 3aad164402..292fa0b73c 100644 --- a/terminal-view/build.gradle +++ b/terminal-view/build.gradle @@ -4,6 +4,7 @@ plugins { } apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' ext { bintrayName = 'terminal-view' @@ -45,6 +46,11 @@ android { dependencies { testImplementation 'junit:junit:4.13' + implementation "androidx.core:core-ktx:1.3.0" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" } apply from: '../scripts/bintray-publish.gradle' +repositories { + mavenCentral() +} From 67bb48b59fac6a848cf4e21bce92c79f96272de9 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Mon, 15 Jun 2020 18:15:20 +0200 Subject: [PATCH 3/3] converted BellUtil to Kotlin --- .../main/java/com/termux/app/BellUtil.java | 63 ------------------- app/src/main/java/com/termux/app/BellUtil.kt | 61 ++++++++++++++++++ 2 files changed, 61 insertions(+), 63 deletions(-) delete mode 100644 app/src/main/java/com/termux/app/BellUtil.java create mode 100644 app/src/main/java/com/termux/app/BellUtil.kt diff --git a/app/src/main/java/com/termux/app/BellUtil.java b/app/src/main/java/com/termux/app/BellUtil.java deleted file mode 100644 index 666124ceb7..0000000000 --- a/app/src/main/java/com/termux/app/BellUtil.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.termux.app; - -import android.content.Context; -import android.os.Handler; -import android.os.Looper; -import android.os.SystemClock; -import android.os.Vibrator; - -public class BellUtil { - private static BellUtil instance = null; - private static final Object lock = new Object(); - - public static BellUtil getInstance(Context context) { - if (instance == null) { - synchronized (lock) { - if (instance == null) { - instance = new BellUtil((Vibrator) context.getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE)); - } - } - } - - return instance; - } - - private static final long DURATION = 50; - private static final long MIN_PAUSE = 3 * DURATION; - - private final Handler handler = new Handler(Looper.getMainLooper()); - private long lastBell = 0; - private final Runnable bellRunnable; - - private BellUtil(final Vibrator vibrator) { - bellRunnable = new Runnable() { - @Override - public void run() { - if (vibrator != null) { - vibrator.vibrate(DURATION); - } - } - }; - } - - public synchronized void doBell() { - long now = now(); - long timeSinceLastBell = now - lastBell; - - if (timeSinceLastBell < 0) { - // there is a next bell pending; don't schedule another one - } else if (timeSinceLastBell < MIN_PAUSE) { - // there was a bell recently, scheudle the next one - handler.postDelayed(bellRunnable, MIN_PAUSE - timeSinceLastBell); - lastBell = lastBell + MIN_PAUSE; - } else { - // the last bell was long ago, do it now - bellRunnable.run(); - lastBell = now; - } - } - - private long now() { - return SystemClock.uptimeMillis(); - } -} diff --git a/app/src/main/java/com/termux/app/BellUtil.kt b/app/src/main/java/com/termux/app/BellUtil.kt new file mode 100644 index 0000000000..6fce12d368 --- /dev/null +++ b/app/src/main/java/com/termux/app/BellUtil.kt @@ -0,0 +1,61 @@ +package com.termux.app + +import android.content.Context +import android.os.Handler +import android.os.Looper +import android.os.SystemClock +import android.os.Vibrator + +class BellUtil private constructor(vibrator: Vibrator?) { + private val handler = Handler(Looper.getMainLooper()) + private var lastBell: Long = 0 + private val bellRunnable: Runnable + + @Synchronized + fun doBell() { + val now = now() + val timeSinceLastBell = now - lastBell + if (timeSinceLastBell < 0) { + // there is a next bell pending; don't schedule another one + } else if (timeSinceLastBell < MIN_PAUSE) { + // there was a bell recently, scheudle the next one + handler.postDelayed(bellRunnable, MIN_PAUSE - timeSinceLastBell) + lastBell += MIN_PAUSE + } else { + // the last bell was long ago, do it now + bellRunnable.run() + lastBell = now + } + } + + private fun now(): Long { + return SystemClock.uptimeMillis() + } + + companion object { + private var instance: BellUtil? = null + private val lock = Any() + + @JvmStatic + fun getInstance(context: Context): BellUtil? { + if (instance == null) { + synchronized(lock) { + if (instance == null) { + instance = BellUtil( + context.applicationContext + .getSystemService(Context.VIBRATOR_SERVICE) as Vibrator + ) + } + } + } + return instance + } + + private const val DURATION: Long = 50 + private const val MIN_PAUSE = 3 * DURATION + } + + init { + bellRunnable = Runnable { vibrator?.vibrate(DURATION) } + } +}