Skip to content

Instantly share code, notes, and snippets.

View JakeSteam's full-sized avatar
🤖

Jake Lee JakeSteam

🤖
View GitHub Profile
@JakeSteam
JakeSteam / AndroidManifest.xml
Last active December 17, 2018 18:57
"Sharing internal / cache images (with text) to other Android apps" (tutorial at https://blog.jakelee.co.uk/sharing-internal-cache-images-with-text-to-other-android-apps)
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>
@JakeSteam
JakeSteam / AndroidManifest.xml
Last active December 3, 2018 18:19
Repeating background tasks on Android using Kotlin and JobDispatcher
<service
android:name=".JobScheduler"
android:exported="false">
<intent-filter>
<action android:name="com.firebase.jobdispatcher.ACTION_EXECUTE" />
</intent-filter>
</service>
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".develop.mlkit.MLKitFragment"
android:fadeScrollbars="false">
<LinearLayout
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
TrackingUtil(requireActivity()).track(TrackingUtil.Screens.Login)
return inflater.inflate(R.layout.fragment_login, container, false)
}
@JakeSteam
JakeSteam / ActionHandler.kt
Last active October 22, 2018 21:18
"Adding Callbacks From Fragment To Activity Or Activity To Application In Android" @ http://blog.jakelee.co.uk/2018/10/22/adding-callbacks-from-fragment-to-activity-or-activity-to-application-in-android
interface ActionHandler {
fun handleAction(actionCode: String)
}
@JakeSteam
JakeSteam / DrawableModifier.kt
Created September 13, 2018 22:27
"Recolouring / modifying multi-layer drawables dynamically in Android" for blog.jakelee.co.uk
// Changing colour
val layerDrawable = (ImageView)findViewById(R.id.my_drawable).drawable as LayerDrawable
val backgroundDrawable = layerDrawable.findDrawableByLayerId(R.id.background_circle) as GradientDrawable
backgroundDrawable.setColor(ContextCompat.getColor(context, R.color.my_colour))
// Changing drawable
layerDrawable.setDrawableByLayerId(R.id.foreground_icon, ContextCompat.getDrawable(context, R.drawable.new_foreground_icon))
@JakeSteam
JakeSteam / styles.xml
Created September 10, 2018 18:30
"Using multi-weighted custom fonts on Android" for blog.jakelee.co.uk
<style name="Font_Regular" tools:keep="@style/Font_Regular">
<item name="android:fontFamily">@font/the_sans_c4s</item>
</style>
<style name="Font_Regular_Italic" parent="Font_Regular" tools:keep="@style/Font_Regular_Italic">
<item name="android:textStyle">italic</item>
</style>
<style name="Font_Bold" parent="Font_Regular" tools:keep="@style/Font_Bold">
<item name="android:textStyle">bold</item>
@JakeSteam
JakeSteam / LockableViewPager.kt
Last active September 7, 2018 17:25
"Dynamically preventing scrolling on selected ViewPager pages" for blog.jakelee.co.uk
import android.content.Context
import android.support.v4.view.ViewPager
import android.util.AttributeSet
import android.view.MotionEvent
enum class SwipeDirection { BOTH, LEFT, RIGHT, NONE }
// https://stackoverflow.com/a/34076649/608312
class LockableViewPager(context: Context, attrs: AttributeSet) : ViewPager(context, attrs) {
@JakeSteam
JakeSteam / AndroidManifest.xml
Last active February 23, 2023 14:42
"Generic SharedPreferences Utility Class" for blog.jakelee.co.uk
<application
android:allowBackup="true"
android:fullBackupContent="@xml/backup_rules"
@JakeSteam
JakeSteam / AndroidManifest.xml
Created July 7, 2017 11:29
"Getting Started with Sugar ORM" for GameDevAlgorithms.com
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourpackagename">
<application
android:name=".MainApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name">
<meta-data
android:name="DATABASE"