use of android.widget.TableLayout in project smoke by textbrowser.
the class Chat method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
m_databaseHelper = Database.getInstance(getApplicationContext());
m_receiver = new ChatBroadcastReceiver();
setContentView(R.layout.activity_chat);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
try {
getSupportActionBar().setSubtitle(Smoke.networkStatusString());
getSupportActionBar().setTitle("Smoke | Chat");
} catch (Exception exception) {
}
Button button1 = (Button) findViewById(R.id.clear_chat_messages);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Chat.this.isFinishing())
return;
State.getInstance().clearChatLog();
TextView textView1 = (TextView) findViewById(R.id.chat_messages);
textView1.setText("");
}
});
button1 = (Button) findViewById(R.id.send_chat_message);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Chat.this.isFinishing())
return;
final TextView textView1 = (TextView) findViewById(R.id.chat_message);
if (textView1.getText().toString().trim().isEmpty())
return;
String str = textView1.getText().toString().trim();
StringBuilder stringBuilder = new StringBuilder();
TableLayout tableLayout = (TableLayout) findViewById(R.id.participants);
TextView textView2 = (TextView) findViewById(R.id.chat_messages);
textView2.append("[");
textView2.append(m_simpleDateFormat.format(new Date()));
textView2.append("] ");
{
SpannableStringBuilder spannable = new SpannableStringBuilder("me");
spannable.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textView2.append(spannable);
}
stringBuilder.append(": ");
stringBuilder.append(str);
stringBuilder.append("\n\n");
textView2.append(stringBuilder);
textView1.setText("");
int size = CHAT_MESSAGE_PREFERRED_SIZE * (int) Math.ceil((1.0 * str.length()) / (1.0 * CHAT_MESSAGE_PREFERRED_SIZE));
if (size > str.length()) {
char[] a = new char[size - str.length()];
Arrays.fill(a, ' ');
str += new String(a);
} else if (str.length() > 0) {
char[] a = new char[1024 + str.length() % 2];
Arrays.fill(a, ' ');
str += new String(a);
}
int count = tableLayout.getChildCount();
for (int i = 0; i < count; i++) {
TableRow row = (TableRow) tableLayout.getChildAt(i);
if (row == null)
continue;
Switch switch1 = (Switch) row.getChildAt(0);
if (switch1 == null || switch1.getTag() == null || !switch1.isChecked())
continue;
String sipHashId = switch1.getTag().toString();
byte[] keyStream = m_databaseHelper.participantKeyStream(s_cryptography, sipHashId);
if (keyStream == null || keyStream.length != Cryptography.CIPHER_HASH_KEYS_LENGTH)
continue;
Kernel.getInstance().enqueueChatMessage(str, sipHashId, null, keyStream);
}
scrollMessagesView();
textView1.post(new Runnable() {
@Override
public void run() {
textView1.requestFocus();
}
});
}
});
TextView textView1 = (TextView) findViewById(R.id.chat_message);
textView1.requestFocus();
try {
textView1 = (TextView) findViewById(R.id.chat_message);
textView1.setText(State.getInstance().getCharSequence("chat.message"));
textView1 = (TextView) findViewById(R.id.chat_messages);
textView1.setText(State.getInstance().getCharSequence("chat.messages"));
} catch (Exception exception) {
}
populateChat();
if (State.getInstance().isAuthenticated())
populateParticipants();
prepareListeners();
}
use of android.widget.TableLayout in project Slide by ccrama.
the class CommentOverflow method setViews.
/**
* Set the text for the corresponding views.
*
* @param blocks list of all blocks to be set
* @param subreddit
*/
public void setViews(List<String> blocks, String subreddit, OnClickListener click, OnLongClickListener longClick) {
Context context = getContext();
int type = new FontPreferences(context).getFontTypeComment().getTypeface();
if (type >= 0) {
typeface = RobotoTypefaces.obtainTypeface(context, type);
} else {
typeface = Typeface.DEFAULT;
}
TypedValue typedValue = new TypedValue();
Resources.Theme theme = context.getTheme();
theme.resolveAttribute(R.attr.fontColor, typedValue, true);
textColor = typedValue.data;
TypedValue fontSizeTypedValue = new TypedValue();
theme.resolveAttribute(R.attr.font_commentbody, fontSizeTypedValue, true);
TypedArray a = context.obtainStyledAttributes(null, new int[] { R.attr.font_commentbody }, R.attr.font_commentbody, new FontPreferences(context).getCommentFontStyle().getResId());
fontSize = a.getDimensionPixelSize(0, -1);
a.recycle();
removeAllViews();
if (!blocks.isEmpty()) {
setVisibility(View.VISIBLE);
}
for (String block : blocks) {
if (block.startsWith("<table>")) {
HorizontalScrollView scrollView = new HorizontalScrollView(context);
scrollView.setScrollbarFadingEnabled(false);
TableLayout table = formatTable(block, subreddit, click, longClick);
scrollView.setLayoutParams(MARGIN_PARAMS);
table.setPaddingRelative(0, 0, 0, DisplayUtil.dpToPxVertical(10));
scrollView.addView(table);
addView(scrollView);
} else if (block.equals("<hr/>")) {
View line = new View(context);
line.setLayoutParams(HR_PARAMS);
line.setBackgroundColor(textColor);
line.setAlpha(0.6f);
addView(line);
} else if (block.startsWith("<pre>")) {
HorizontalScrollView scrollView = new HorizontalScrollView(context);
scrollView.setScrollbarFadingEnabled(false);
SpoilerRobotoTextView newTextView = new SpoilerRobotoTextView(context);
newTextView.setTextHtml(block, subreddit);
setStyle(newTextView, subreddit);
scrollView.setLayoutParams(MARGIN_PARAMS);
newTextView.setPaddingRelative(0, 0, 0, DisplayUtil.dpToPxVertical(10));
scrollView.addView(newTextView);
if (click != null)
newTextView.setOnClickListener(click);
if (longClick != null)
newTextView.setOnLongClickListener(longClick);
addView(scrollView);
} else {
SpoilerRobotoTextView newTextView = new SpoilerRobotoTextView(context);
newTextView.setTextHtml(block, subreddit);
setStyle(newTextView, subreddit);
newTextView.setLayoutParams(MARGIN_PARAMS);
if (click != null)
newTextView.setOnClickListener(click);
if (longClick != null)
newTextView.setOnLongClickListener(longClick);
addView(newTextView);
}
}
}
use of android.widget.TableLayout in project satstat by mvglasow.
the class RadioSectionFragment method addWifiResult.
private final void addWifiResult(ScanResult result) {
// needed to pass a persistent reference to the OnClickListener
final ScanResult r = result;
android.view.View.OnClickListener clis = new android.view.View.OnClickListener() {
@Override
public void onClick(View v) {
onWifiEntryClick(r.BSSID);
}
};
LinearLayout wifiLayout = new LinearLayout(wifiAps.getContext());
wifiLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
wifiLayout.setOrientation(LinearLayout.HORIZONTAL);
wifiLayout.setWeightSum(22);
wifiLayout.setMeasureWithLargestChildEnabled(false);
ImageView wifiType = new ImageView(wifiAps.getContext());
wifiType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.MATCH_PARENT, 3));
if (WifiCapabilities.isAdhoc(result)) {
wifiType.setImageResource(R.drawable.ic_content_wifi_adhoc);
} else if ((WifiCapabilities.isEnterprise(result)) || (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.EAP)) {
wifiType.setImageResource(R.drawable.ic_content_wifi_eap);
} else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.PSK) {
wifiType.setImageResource(R.drawable.ic_content_wifi_psk);
} else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.WEP) {
wifiType.setImageResource(R.drawable.ic_content_wifi_wep);
} else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.OPEN) {
wifiType.setImageResource(R.drawable.ic_content_wifi_open);
} else {
wifiType.setImageResource(R.drawable.ic_content_wifi_unknown);
}
wifiType.setScaleType(ScaleType.CENTER);
wifiLayout.addView(wifiType);
TableLayout wifiDetails = new TableLayout(wifiAps.getContext());
wifiDetails.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19));
TableRow innerRow1 = new TableRow(wifiAps.getContext());
TextView newMac = new TextView(wifiAps.getContext());
newMac.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 14));
newMac.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
newMac.setText(result.BSSID);
innerRow1.addView(newMac);
TextView newCh = new TextView(wifiAps.getContext());
newCh.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
newCh.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
newCh.setText(getChannelFromFrequency(result.frequency));
innerRow1.addView(newCh);
TextView newLevel = new TextView(wifiAps.getContext());
newLevel.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
newLevel.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
newLevel.setText(String.valueOf(result.level));
innerRow1.addView(newLevel);
innerRow1.setOnClickListener(clis);
wifiDetails.addView(innerRow1, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
TableRow innerRow2 = new TableRow(wifiAps.getContext());
TextView newSSID = new TextView(wifiAps.getContext());
newSSID.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19));
newSSID.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Small);
newSSID.setText(result.SSID);
innerRow2.addView(newSSID);
innerRow2.setOnClickListener(clis);
wifiDetails.addView(innerRow2, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
wifiLayout.addView(wifiDetails);
wifiLayout.setOnClickListener(clis);
wifiAps.addView(wifiLayout);
}
Aggregations