Skip to content

Instantly share code, notes, and snippets.

View addOn.gs
function createHomeCard() {
const imgLogoUri = "http://your.home.page.image.link";
const imgLogo = CardService.newImage()
.setImageUrl(imgLogoUri)
.setAltText("Digit-Atoms");
const footer = CardService.newFixedFooter().setPrimaryButton(
CardService.newTextButton()
.setTextButtonStyle(CardService.TextButtonStyle.FILLED)
View code.gs
const txtInsertId =
CardService.newTextParagraph().setText("<b>Bold text</b><br/> -Can you read this?");
const textInput = CardService.newTextInput()
.setFieldName("txt_input_id_to_process")
.setTitle("Write something here...");
const ico = CardService.newIconImage().setIconUrl(
"ico link"
);
View gist:2bec486fc2255e08ac0cc5c8530f21a8
/**
* Callback for rendering the homepage card.
* @return The card to show to the user.
*/
function onHomepage(e) {
return createHomeCard();
}
/**
* Build the home card
View appscript.json
{
"timeZone": "America/New_York",
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"addOns": {
"common": {
"name": "MY COOL APP",
"logoUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/9/97/Wikipedia-logo-gv_%281%29.png/196px-Wikipedia-logo-gv_%281%29.png",
"useLocaleFromApp": true,
"homepageTrigger": {
@Xiryl
Xiryl / YourFragment.kt
Created Aug 29, 2021
fragmentcallback-3
View YourFragment.kt
class YourCustomFRagment(
var backPressedListener: OnFragmentCallback
) : Fragment(R.layout.xyz) {
override fun onCreateView() {}
// trigger the event!
override fun onDestroy() {
backPressedListener.onFragmentBackPressed()
}
@Xiryl
Xiryl / YourActivity.kt
Created Aug 29, 2021
fragmentcallback-2
View YourActivity.kt
override fun onCreate(savedInstanceState: Bundle?) {
showFragment()
}
// callback listener
private val fragmentBackPressedListener = object : OnFragmentCallback {
override fun onFragmentBackPressed() {
foo()
}
}
View OnFragmentCallbackListener.kt
interface OnFragmentCallbackListener.kt {
fun onFragmentBackPressed()
}
@Xiryl
Xiryl / BluetoothSDKService.kt
Created Aug 12, 2021
BluetoothSDK-Service3
View BluetoothSDKService.kt
private inner class ConnectedThread(private val mmSocket: BluetoothSocket) : Thread() {
private val mmInStream: InputStream = mmSocket.inputStream
private val mmOutStream: OutputStream = mmSocket.outputStream
private val mmBuffer: ByteArray = ByteArray(1024) // mmBuffer store for the stream
override fun run() {
var numBytes: Int // bytes returned from read()
// Keep listening to the InputStream until an exception occurs.
@Xiryl
Xiryl / BluetoothSDKService.kt
Created Aug 12, 2021
BluetoothSDK-Service2
View BluetoothSDKService.kt
/**
* Class used for the client Binder.
*/
inner class LocalBinder : Binder() {
/**
* Enable the discovery, registering a broadcastreceiver {@link discoveryBroadcastReceiver}
* The discovery filter by LABELER_SERVER_TOKEN_NAME
*/
public fun startDiscovery(context: Context) {
@Xiryl
Xiryl / BluetoothSDKService.kt
Created Aug 12, 2021
BluetoothSDK-Service1
View BluetoothSDKService.kt
class BluetoothSDKService : Service() {
// Service Binder
private val binder = LocalBinder()
// Bluetooth stuff
private lateinit var bluetoothAdapter: BluetoothAdapter
private lateinit var pairedDevices: MutableSet<BluetoothDevice>
private var connectedDevice: BluetoothDevice? = null