Skip to content

Instantly share code, notes, and snippets.

@eclectice
eclectice / AlwaysRunningAndroidService.md
Created February 17, 2023 03:35 — forked from varunon9/AlwaysRunningAndroidService.md
How to create an always running service in Android

Full Source Code: https://github.com/varunon9/DynamicWallpaper/tree/always_running_service

Steps-

  1. Create a Foreground Service (MyService.java)
  2. Create a Manifest registered Broadcast Receiver (MyReceiver.java) which will start your Foreground Service
  3. In onDestroy lifecycle of MyService, send a broadcast intent to MyReceiver
  4. Launch the MyService on app start from MainActivity (see step 8)
  5. With above 4 steps, MyService will always get re-started when killed as long as onDestroy of Service gets called
  6. onDestroy method of Service is not always guaranteed to be called and hence it might not get started again
@eclectice
eclectice / BottomSheetScrollView.kt
Created November 8, 2022 02:52 — forked from AfzalivE/BottomSheetScrollView.kt
BottomSheetScrollView for when you have a ViewPager with RecyclerViews in your BottomSheet
class BottomSheetScrollView(context: Context, attrs: AttributeSet?) : FrameLayout(context, attrs),
NestedScrollingParent2 {
private val TAG = "NestedScroll3"
private val childHelper = NestedScrollingChildHelper(this).apply {
isNestedScrollingEnabled = true
}
private var behavior: BottomSheetBehavior<*>? = null
var started = false
var canScroll = false
@eclectice
eclectice / README.md
Created October 22, 2022 01:53 — forked from aelindeman/README.md
ONC-format OpenVPN client configuration (Chrome OS) for OVPN

Instructions

  1. Download https://files.ovpn.com/ubuntu_cli/ovpn-us.zip
  2. Unzip it
  3. Fill in the template
    • UUID #1 and #2: create two UUIDs either from something like https://www.uuidgenerator.net/ or by running cat /proc/sys/kernel/random/uuid in a terminal, then paste them into the fields (leave in the curly braces)
    • Server CA: ovpn-ca.crt from the download - remove the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- lines, make the rest all one line, then paste it into the X509 field
    • Host: the OVPN server you wish to use - I chose US servers, but if you follow the "Ubuntu CLI" guide and download the zip file, the ovpn.conf file has a remote field where you can find a different host
    • Client key: ovpn-tls.key from the download - run grep -v '#' ovpn-tls.key | perl -p -e 's/\n/\\n/' - and paste the result into the TLSAuthContents field
  • Fill in your OVPN username and password
package me.kalehv.app.myapp;
import android.annotation.TargetApi;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Outline;
import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
package android.support.v7.app;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;