I was just creating a new extension, and it compiled successfully, but when I imported it and dragged it, App Inventor said "An internal bug has occurred. Report a bug?".
This is the code.
package com.gordonlu.linearprogressbar;
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 android.widget.FrameLayout;
import android.view.View;
import android.widget.ProgressBar;
import com.google.appinventor.components.runtime.AndroidViewComponent;
import com.google.appinventor.components.common.PropertyTypeConstants;
import android.content.res.ColorStateList;
@DesignerComponent(
version = 1,
description = "An extension that indicates the progress of an operation using an animated linear bar.",
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 LinearProgressBar extends AndroidNonvisibleComponent {
//Activity and Context
private Context context;
private Activity activity;
public int color;
public ProgressBar progressBar;
public LinearProgressBar(ComponentContainer container){
super(container.$form());
this.activity = container.$context();
this.context = container.$context();
}
@SimpleFunction(description = "Creates a progress bar in the given arrangement.")
public void CreateProgressBar(AndroidViewComponent layout) {
View view = layout.getView();
FrameLayout fl = (FrameLayout) view;
fl.addView(progressBar);
}
@SimpleProperty(category = PropertyCategory.APPEARANCE, description = "This property specifies the progress color of the progress bar.")
public int ProgressColor() {
return color;
}
@DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_COLOR, defaultValue = "")
@SimpleProperty (description = "This property specifies the progress color of the progress bar.")
public void ProgressColor(int argb) {
this.color = argb;
progressBar.setProgressTintList(ColorStateList.valueOf(argb));
}
}