package com.gordonlu.qr; import android.app.Activity; import android.content.Context; import com.google.appinventor.components.annotations.*; import com.google.appinventor.components.common.ComponentCategory; import com.google.appinventor.components.runtime.AndroidNonvisibleComponent; import com.google.appinventor.components.runtime.ComponentContainer; import com.google.appinventor.components.runtime.EventDispatcher; import java.util.*; @DesignerComponent( version = 2, description = "This extension helps you to generate a valid link for your QR code.", category = ComponentCategory.EXTENSION, nonVisible = true, iconName = "https://docs.google.com/drawings/d/e/2PACX-1vQCI87PHLBF0jb8QWyYmIRQSjjNW3EFXf-qpsWCvBYkUQ9vEgPAB8SpxcMpblxNpbIYrjCjLrRLIU2c/pub?w=16&h=16") @SimpleObject(external = true) //Libraries @UsesLibraries(libraries = "") //Permissions @UsesPermissions(permissionNames = "") public class QR extends AndroidNonvisibleComponent { //Activity and Context private Context context; private Activity activity; public QR(ComponentContainer container){ super(container.$form()); this.activity = container.$context(); this.context = container.$context(); } @SimpleFunction(description = "Returns all available formats of the QR code.") public static List AvailableFormats () { List formats = new ArrayList<>(); formats.add("UTF-8"); formats.add("Shift_JIS"); formats.add("ISO-8859-1"); return formats; } @SimpleFunction(description = "Generates a link for the QR code.") public String GenerateQRLink (String height, String width, String code, String type) { String make = "https://chart.googleapis.com/chart?cht=qr&chs=" + height + "x" + width + "&chl=" + code + "&choe=" + type; return make; } }