From a020e89ecef84f9d22aad3051b22e9301110933b Mon Sep 17 00:00:00 2001 From: sriramsv Date: Mon, 29 Aug 2022 20:21:57 -0700 Subject: [PATCH] Add Google Fit Workout Shortcut --- community/google-fit.lua | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 community/google-fit.lua diff --git a/community/google-fit.lua b/community/google-fit.lua new file mode 100644 index 0000000..a2c73a9 --- /dev/null +++ b/community/google-fit.lua @@ -0,0 +1,39 @@ +-- name = "Google Fit" +-- description = "Start/Stop tracking workouts in google fit" +-- data_source = "internal" +-- type = "search" +-- author = "Sriram SV" +-- version = "1.0" +-- prefix = "fit|track" + +fit_intent_action = "vnd.google.fitness.TRACK" +fit_intent_mime_type = "vnd.google.fitness.activity/other" +fit_intent_category = "android.intent.category.DEFAULT" +fit_package_name = "com.google.android.apps.fitness" + +local md_color = require "md_colors" +local blue = md_colors.light_blue_800 +local red = md_colors.red_800 +function on_search(input) + search:show({"Start Tracking", "Stop Tracking"},{blue,red}) +end + +function on_click(idx) + local status = "" + if idx == 1 then + status = "ActiveActionStatus" + elseif idx ==2 then + status = "CompletedActionStatus" + end + intent:start_activity{ + action = fit_intent_action, + category = fit_intent_category, + package = fit_package_name, + type = fit_intent_mime_type, + extras = { + actionStatus=status + } + } +end + +