Bean Bird in Circle

QCircleActivity

This activity shows UIs in the Quick Circle window when it is launched while the cover is closed.

Create and Show a Template

A Quick Circle layout with no sub-area is created.

template = new QCircleTemplate(this, TemplateType.CIRCLE_EMPTY);

 

setContentView() shows the created template.

setContentView(template.getView());

 

Add a Title

mTitle is a QCircleTitle instance and it is added to the QCircle template.

mTitle = new QCircleTitle(this, "Bean Bird In Circle");
template.addElement(mTitle);

 

Add a Back Button

mBackButton is a QCircleBackButton instance and added to the template.

setTheme() decides the background color of the mBackButton. The default is ButtonTheme.LIGHT.

mBackButton = new QCircleBackButton(this);
mBackButton.setTheme(ButtonTheme.DARK);
template.addElement(mBackButton);

 

Connect to Full Screen Activity

Intent shows a webpage of the specified URL. Intent is sent when the cover is opened.

String url = "http://developer.lge.com/main/Intro.dev";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
template.setFullscreenIntent(intent);
template.registerIntentReceiver();

 

Since registeredIntentReceiver() is used, unregisterReceiver() is used.

protected void onDestroy() {
  ...
template.unregisterReceiver();
}

 

Activate Number Badge

numberIntent is an intent for the number badge. activateNumberBadge() returns a created intent for the number badge with a specified count. Here, a number badge with one is created.

Context broadcast the intent to actually show the number badge on the icon.

final Intent numberIntent  = QCircleFeature.activateNumberBadge(activity, 1);
mContext.sendBroadcast(numberIntent);

 

Set background

mypic is a drawable for the circle background. setBackgroundDrawable() sets a drawable object as the background.

mypic = getResources().getDrawable(R.drawable.background1);
template.setBackgroundDrawable(mypic);

 

Add Button

btn switches a background drawable when it is clicked. notiBtn increases the number on the number badge when it is clicked.

Button btn = new Button(mContext); ①

btn.setBackgroundResource(R.drawable.button);
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
params.topMargin = QCircleFeature.getRelativePixelValue(this,300);
btn.setLayoutParams(params); ② 

btn.setOnClickListener(new OnClickListener() { ③

public void onClick(View v) {
if(mSwitched == false)
{
       template.setBackgroundDrawable(mypic2);
       mSwitched = true;
}
else
{
       template.setBackgroundDrawable(mypic);
       mSwitched = false;
}
}
});

Button notiBtn = new Button(mContext);  ④
notiBtn.setText("Number Badge");
params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_LEFT, btn.getId());
params.topMargin = QCircleFeature.getRelativePixelValue(this,270);
params.leftMargin = QCircleFeature.getRelativePixelValue(this,50);

notiBtn.setLayoutParams(params);  ⑤
 
notiBtn.setOnClickListener(new OnClickListener() { 
   int count = 1;
   public void onClick(View v) {
        count++;
        QCircleFeature.setNumberBadge(activity, numberIntent, count);  ⑥
        mContext.sendBroadcast(numberIntent); ⑦
    }
});

① Creates a button instance.

② Sets layout parameters of btn. getRelativePixelValue() method gets a pixel value appropriate for the current running model.

③ Sets onClickListener to switch a background drawable when btn is clicked.

④ Creates a button instance.

⑤ Sets layout parameters of notiBtn.

⑥ Changes the number in the number badge to the count; the count is increased when notiBtn is clicked.

⑦ The activity broadcasts numberIntent to change.

 

Navigation