Skip to content

Commit

Permalink
added telegram script (#3)
Browse files Browse the repository at this point in the history
* updated to recent android sdk
updated gradle to 4.6
update kotlin
updated dependencies
compile fix

* update kotlin

* disable hyphenation on line number textview and codeeditor as well

* updated kotlin
updated dependency

* added travis-telegram-bot added missing travis files to git

* use variable for GitHub url and Travis url

* also push messages for master branch

* test

* test

* additional telegram variable

* apk file path now uses absolute path

* fix bot id
  • Loading branch information
markusressel authored Dec 30, 2018
1 parent 0d3fdde commit 3e23f6f
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 12 deletions.
29 changes: 29 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.2.61'
ext.kotlin_version = '1.3.11'

ext {
group = 'com.github.markusressel'

gradle_plugin_version = '3.1.3'
gradle_plugin_version = '3.2.1'

minSdkVersion = 16
versionName = "0.5.0"
versionCode = 1

compileSdkVersion = 28
targetSdkVersion = 28
buildToolsVersion = "27.0.3"
buildToolsVersion = "28.0.3"

// DEPENDENCIES

androidKtxVersion = "0.3"
supportLibVersion = "27.1.1"
supportLibVersion = "28.0.0"

javaxAnnotationVersion = "10.0-b28"
aboutlibrariesVersion = "6.0.9"
materialdrawerVersion = "6.0.8"
iconicsVersion = "3.0.4"
aboutlibrariesVersion = "6.2.0"
materialdrawerVersion = "6.1.1"
iconicsVersion = "3.1.0"

rxKotlinVersion = "2.3.0"
rxBindingVersion = "2.1.1"
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Aug 25 17:52:39 CEST 2018
#Tue Oct 23 14:05:42 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dependencies {
implementation "com.trello.rxlifecycle2:rxlifecycle-android-lifecycle-kotlin:$rxLifecycleVersion"

// Zoom Layout Container
api 'com.otaliastudios:zoomlayout:1.3.0'
api 'com.otaliastudios:zoomlayout:1.4.0'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package de.markusressel.kodeeditor.library.view

import android.content.Context
import android.os.Build
import android.support.v7.widget.AppCompatEditText
import android.text.Layout
import android.util.AttributeSet
import android.util.Log
import com.jakewharton.rxbinding2.widget.RxTextView
Expand Down Expand Up @@ -44,6 +46,10 @@ class CodeEditText : AppCompatEditText {
}

private fun reinit() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
hyphenationFrequency = Layout.HYPHENATION_FREQUENCY_NONE
}

initSyntaxHighlighter()
}

Expand Down Expand Up @@ -98,7 +104,7 @@ class CodeEditText : AppCompatEditText {
}

syntaxHighlighter
?.highlight(text)
?.apply { highlight(text!!) }
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import android.content.Context
import android.content.res.TypedArray
import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.os.Build
import android.support.annotation.AttrRes
import android.support.annotation.ColorInt
import android.support.annotation.StringRes
import android.support.annotation.StyleableRes
import android.support.v4.content.ContextCompat
import android.support.v4.view.ViewCompat
import android.text.Layout
import android.util.AttributeSet
import android.util.Log
import android.util.TypedValue
Expand Down Expand Up @@ -142,6 +144,9 @@ open class CodeEditorView : ZoomLayout {
contentLayout = inflater.inflate(R.layout.view_code_editor__inner_layout, null) as LinearLayout

lineNumberView = contentLayout.findViewById(R.id.codeLinesView) as TextView
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
lineNumberView.hyphenationFrequency = Layout.HYPHENATION_FREQUENCY_NONE
}

dividerView = contentLayout.findViewById(R.id.divider) as View

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
android:inputType="textMultiLine|textNoSuggestions"
android:maxLength="99999999"
android:maxLines="99999999"
android:scrollHorizontally="false"
android:scrollbars="none"
android:scrollHorizontally="false"
android:textSize="12sp"
android:typeface="monospace" />

Expand Down
15 changes: 15 additions & 0 deletions travis/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

echo "Travis Container environment variables:"
env | sort

echo

if [[ "${TRAVIS_BRANCH}" =~ "${TELEGRAM_BRANCHES}" ]]; then
echo "Start compiling and assembling apk..."
./gradlew clean testDebug lintDebug assembleDebug --stacktrace
else
echo "Start compiling WITHOUT assembling apk..."
./gradlew clean testDebug lintDebug --stacktrace
fi

Binary file added travis/debug.keystore
Binary file not shown.
62 changes: 62 additions & 0 deletions travis/distribute_result.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
if [[ "${TRAVIS_BRANCH}" =~ "${TELEGRAM_BRANCHES}" ]]; then
echo "Generating Telegram Messages..."

BASE_URL="https://api.telegram.org/bot${TELEGRAM_TOKEN}"

# prepare telegram message to send as reply to the apk file
if [[ "${TRAVIS_PULL_REQUEST}" != "false" ]]; then
PR_LINK_TEXT=$(cat <<EOF
[Pull Request](${GITHUB_URL}/pull/${TRAVIS_PULL_REQUEST})
EOF
)
fi

if [[ "${TRAVIS_TEST_RESULT}" == "0" ]]; then
RESULT_EMOJI=""
else
RESULT_EMOJI="🔥"
fi

COMMITS_INVOLVED=$(git log --oneline ${TRAVIS_COMMIT_RANGE})

MESSAGE=$(cat <<EOF
${RESULT_EMOJI} *Travis Build* [#${TRAVIS_BUILD_NUMBER}](https://travis-ci.org/${TRAVIS_URL}/builds/${TRAVIS_BUILD_ID}) *(${TRAVIS_EVENT_TYPE})*
Commits:
\`${COMMITS_INVOLVED}\`
${PR_LINK_TEXT}
EOF
)

if [[ "${TRAVIS_TEST_RESULT}" == "0" ]]; then
# find compiled .apk file
APK_FILE=$(find "${TRAVIS_BUILD_DIR}/app/build/outputs/apk/debug" -type f -name "*.apk")

echo "Sending apk file..."

# send apk file via telegram bot
MESSAGE_ID=$(curl \
--silent \
--form chat_id="${CHAT_ID}" \
--form document=@"${APK_FILE}" \
"${BASE_URL}/sendDocument" \
| jq 'if (.ok == true) then .result.message_id else empty end')
fi

echo "Sending info message..."
# send telegram chat message
curl \
--silent \
-X POST \
"${BASE_URL}/sendMessage" \
-d "chat_id=${CHAT_ID}" \
-d "text=${MESSAGE}" \
-d "reply_to_message_id=${MESSAGE_ID}" \
-d "parse_mode=markdown" \
-d "disable_web_page_preview=true" \
>/dev/null

fi

0 comments on commit 3e23f6f

Please sign in to comment.