Methods Summary |
---|
public java.lang.String | closeDialog(int closingType)
return null;
|
void | displayAsLink(android.widget.Button button)Display a button as an HTML link. Remove the background, set the
text color to R.color.dialog_link and draw an underline
if (button == null) {
return;
}
CharSequence text = button.getText();
button.setBackgroundDrawable(null);
int color = getResources().getColor(R.color.dialog_link);
button.setTextColor(color);
SpannableString str = new SpannableString(text);
str.setSpan(new UnderlineSpan(), 0, str.length(),
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
button.setText(str);
button.setFocusable(false);
|
void | downloadIcon(java.lang.String url)Utility method to download an icon from a url and set
it to the GUI element R.id.origin_icon.
It is used both in the shortcut dialog and the
permission dialog.
The actual download is done in the background via
IconDownload; once the icon is downlowded the UI is updated
via updateIcon().
The icon size is included in the layout with the choosen
size, although not displayed, to limit text reflow once
the icon is received.
if (url == null) {
return;
}
View view = findViewById(R.id.origin_icon);
if (view != null) {
view.setMinimumWidth(mChoosenIconSize);
view.setMinimumHeight(mChoosenIconSize);
view.setVisibility(View.INVISIBLE);
}
Thread thread = new Thread(new IconDownload(url));
thread.start();
|
android.view.View | findViewById(int id)
return mActivity.findViewById(id);
|
android.content.res.Resources | getResources()
return mActivity.getResources();
|
private java.lang.String | getString(int id)
return mActivity.getString(id);
|
java.lang.Object | getSystemService(java.lang.String name)
return mActivity.getSystemService(name);
|
public boolean | handleBackButton()Method called when the back button is pressed,
allowing the dialog to intercept the default behaviour.
return false;
|
void | hideView(android.view.View v, int rsc)Utility method to hide a view.
if (rsc == 0) {
return;
}
View view;
if (v == null) {
view = findViewById(rsc);
} else {
view = v.findViewById(rsc);
}
if (view != null) {
view.setVisibility(View.GONE);
}
|
void | inflate(int layout, int viewID)Inflate a given layout in a view (which has to be
a ViewGroup, e.g. LinearLayout).
This is used to share the basic dialog outline among
the different dialog types.
LayoutInflater inflater = (LayoutInflater) getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
View view = findViewById(viewID);
if (view != null) {
try {
ViewGroup viewGroup = (ViewGroup) view;
inflater.inflate(layout, viewGroup);
} catch (ClassCastException e) {
String msg = "exception, the view (" + view + ")";
msg += " is not a ViewGroup";
Log.e(TAG, msg, e);
} catch (InflateException e) {
Log.e(TAG, "exception while inflating the layout", e);
}
} else {
String msg = "problem, trying to inflate a non-existent view";
msg += " (" + viewID + ")";
Log.e(TAG, msg);
}
|
public int | notification()Returns the resource string of the notification displayed
after the dialog. By default, does not return one.
return 0;
|
public android.app.Dialog | onCreateDialog(int id)If a secondary dialog (e.g. a confirmation dialog) is created,
GearsNativeDialog will call this method.
// This should be redefined by subclasses as needed.
return null;
|
public void | setDebug(boolean debug)
mDebug = debug;
|
public void | setGearsVersion(java.lang.String version)
mGearsVersion = version;
|
void | setLabel(org.json.JSONObject json, java.lang.String name, int rsc)Utility method to set elements' text indicated in
the dialogs' arguments.
try {
if (json.has(name)) {
String text = json.getString(name);
View view = findViewById(rsc);
if (view != null && text != null) {
TextView textView = (TextView) view;
textView.setText(text);
textView.setVisibility(View.VISIBLE);
}
}
} catch (JSONException e) {
Log.e(TAG, "json exception", e);
}
|
void | setText(android.view.View v, int rsc, java.lang.CharSequence text)Utility method to set a text.
if (rsc == 0) {
return;
}
View view = v.findViewById(rsc);
if (view != null) {
TextView textView = (TextView) view;
textView.setText(text);
textView.setVisibility(View.VISIBLE);
}
|
void | setText(android.view.View v, int rsc, int txtRsc)Utility method to set a text.
if (rsc == 0) {
return;
}
View view = v.findViewById(rsc);
if (view != null) {
TextView textView = (TextView) view;
if (txtRsc == 0) {
textView.setVisibility(View.GONE);
} else {
CharSequence text = getString(txtRsc);
textView.setText(text);
textView.setVisibility(View.VISIBLE);
}
}
|
public void | setup()Setup the dialog
By default, just display a simple message.
setupButtons(0, 0, R.string.default_button);
setupDialog();
|
void | setupButton(int buttonRscID, int rscString, View.OnClickListener listener, boolean isLink, boolean requestFocus)Button setup.
Set the button's text and its listener. If the text resource's id
is 0, makes the button invisible.
View view = findViewById(buttonRscID);
if (view == null) {
return;
}
Button button = (Button) view;
if (rscString == 0) {
button.setVisibility(View.GONE);
} else {
CharSequence text = getString(rscString);
button.setText(text);
button.setOnClickListener(listener);
if (isLink) {
displayAsLink(button);
}
if (requestFocus) {
button.requestFocus();
}
}
|
void | setupButton(int buttonRsc, int rsc, View.OnClickListener listener)Button setup: as the above method, except that 'isLink' and
'requestFocus' default to false.
setupButton(buttonRsc, rsc, listener, false, false);
|
void | setupButtons(int alwaysDenyRsc, int allowRsc, int denyRsc)Utility method to setup the three dialog buttons.
setupButton(R.id.button_alwaysdeny, alwaysDenyRsc,
new Button.OnClickListener() {
public void onClick(View v) {
mHandler.sendEmptyMessage(ALWAYS_DENY);
}
});
setupButton(R.id.button_allow, allowRsc,
new Button.OnClickListener() {
public void onClick(View v) {
mHandler.sendEmptyMessage(ALLOW);
}
});
setupButton(R.id.button_deny, denyRsc,
new Button.OnClickListener() {
public void onClick(View v) {
mHandler.sendEmptyMessage(DENY);
}
});
|
public void | setupDialog()Utility method that get the dialogMessage
and icon and ask the setupDialog(message,icon)
method to set the values.
TextView dialogMessage = null;
ImageView icon = null;
View view = findViewById(R.id.dialog_message);
if (view != null) {
dialogMessage = (TextView) view;
}
View iconView = findViewById(R.id.icon);
if (iconView != null) {
icon = (ImageView) iconView;
}
if ((dialogMessage != null) && (icon != null)) {
setupDialog(dialogMessage, icon);
dialogMessage.setVisibility(View.VISIBLE);
}
|
public void | setupDialog(android.widget.TextView message, android.widget.ImageView icon)
message.setText(R.string.unrecognized_dialog_message);
icon.setImageResource(R.drawable.ic_dialog_menu_generic);
message.setVisibility(View.VISIBLE);
|
void | showView(android.view.View v, int rsc)Utility method to show a view.
if (rsc == 0) {
return;
}
View view;
if (v == null) {
view = findViewById(rsc);
} else {
view = v.findViewById(rsc);
}
if (view != null) {
view.setVisibility(View.VISIBLE);
}
|
public void | updateIcon()Utility method to update the icon.
Called on the UI thread.
if (mIcon == null) {
return;
}
View view = findViewById(R.id.origin_icon);
if (view != null) {
ImageView imageView = (ImageView) view;
imageView.setMaxHeight(MAX_ICON_SIZE);
imageView.setMaxWidth(MAX_ICON_SIZE);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setImageBitmap(mIcon);
imageView.setVisibility(View.VISIBLE);
}
|