这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
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
6 changes: 6 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id "com.android.application"
}
apply plugin: 'kotlin-android'

android {
compileSdkVersion 28
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -146,3 +149,6 @@ afterEvaluate {
variant.javaCompileProvider.get().dependsOn(downloadBootstraps)
}
}
repositories {
mavenCentral()
}
63 changes: 0 additions & 63 deletions app/src/main/java/com/termux/app/BellUtil.java

This file was deleted.

61 changes: 61 additions & 0 deletions app/src/main/java/com/termux/app/BellUtil.kt
Original file line number Diff line number Diff line change
@@ -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) }
}
}
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
buildscript {
ext.kotlin_version = '1.3.72'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.android.tools.build:gradle:4.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

Expand Down
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions terminal-emulator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

ext {
bintrayName = 'terminal-emulator'
Expand Down Expand Up @@ -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()
}
6 changes: 6 additions & 0 deletions terminal-view/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

ext {
bintrayName = 'terminal-view'
Expand Down Expand Up @@ -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()
}