Skip to content

Instantly share code, notes, and snippets.

Avatar
🤖

Jake Lee JakeSteam

🤖
View GitHub Profile
@JakeSteam
JakeSteam / build.sh
Created Apr 26, 2020
Posting a Slack message from Travis CI
View build.sh
# Environment variables
REPO=${TRAVIS_REPO_SLUG}
BRANCH=${TRAVIS_BRANCH}
COMMIT_HASH=${TRAVIS_COMMIT}
COMMIT_HASH_SHORT=${COMMIT_HASH:0:7}
COMMIT_MESSAGE=${TRAVIS_COMMIT_MESSAGE}
IS_PULL_REQUEST=${TRAVIS_PULL_REQUEST}
BUILD_DIR=${TRAVIS_BUILD_DIR}
BUILD_NUMBER=${TRAVIS_BUILD_NUMBER}
BUILD_URL=${TRAVIS_BUILD_WEB_URL}
View .travis.yml
# Overall config
dist: xenial
language: android
# Android version config
android:
components:
- build-tools-28.0.3
- android-28
View .travis.yml
# Overall config
dist: xenial
language: android
# Android version config
android:
components:
- build-tools-28.0.3
- android-28
@JakeSteam
JakeSteam / .travis.yml
Last active Jun 16, 2020
Creating app bundles and APKs on Travis CI (for https://wp.me/paoKlI-Gk)
View .travis.yml
# Overall config
dist: xenial
language: android
# Android version config
android:
components:
- build-tools-28.0.3
- android-28
View AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="uk.co.jakelee.updatelistener">
<application
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">
@JakeSteam
JakeSteam / AndroidManifest.xml
Created Apr 28, 2019
"How to programmatically change your Android app icon and name" for http://blog.jakelee.co.uk/programmatically-changing-app-icon
View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="uk.co.jakelee.dynamiciconchanging">
<application
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER"/>
@JakeSteam
JakeSteam / SettingsFragment.kt
Created Mar 18, 2019
Automatically adding build time to your Android app
View SettingsFragment.kt
private fun setupVersionInfo() {
findPreference(getString(R.string.pref_version)).title = "V${BuildConfig.VERSION_NAME}"
findPreference(getString(R.string.pref_version)).summary = String.format(
getString(R.string.version_summary),
BuildConfig.VERSION_CODE,
SimpleDateFormat("dd MMM yyy", Locale.US).format(BuildConfig.BUILD_TIME)
)
}
@JakeSteam
JakeSteam / MainActivity.kt
Created Mar 5, 2019
Creating a SharedPreferences utility
View MainActivity.kt
val prefHelper = PreferenceHelper(this)
val myBoolean = prefHelper.getBooleanPref(PreferenceHelper.BooleanPref.setting1)
prefHelper.setBooleanPref(PreferenceHelper.BooleanPref.setting1, false)
val myString = prefHelper.getStringPref(PreferenceHelper.StringPref.setting1)
prefHelper.setStringPref(PreferenceHelper.StringPref.setting1, "abc")
View MainActivity.kt
class MainActivity: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
this.supportFragmentManager
.beginTransaction()
.replace(R.id.fragment_frame, PrefsFragment())
.commit()
}
View ContentAdapter.kt
class ContentAdapter(private val rows: List<IRow>) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
interface IRow
class HeaderRow(val date: String, val title: String) : IRow
class MessageRow(val message: String) : IRow
class ColourRow(val colour: Int) : IRow
class HeaderViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val dateView: TextView = itemView.findViewById(R.id.date)
val titleView: TextView = itemView.findViewById(R.id.title)
You can’t perform that action at this time.