use of android.widget.RelativeLayout in project wifilibrary by LiShiHui24740.
the class WifiFragment method initViews.
private void initViews() {
TextView mTitle = (TextView) mContentView.findViewById(R.id.id_tv_wifi_header);
LinearLayout rl_title_top_bg = (LinearLayout) mContentView.findViewById(R.id.id_rl_title_top_bg);
LinearLayout ll_wifi_footer;
if (layout_type == TYPE1_NONE) {
ll_wifi_footer = (LinearLayout) mContentView.findViewById(R.id.id_ll_wifi_footer1);
ll_wifi_footer.setVisibility(View.GONE);
} else if (layout_type == TYPE2_NONE) {
ll_wifi_footer = (LinearLayout) mContentView.findViewById(R.id.id_ll_wifi_footer2);
ll_wifi_footer.setVisibility(View.GONE);
}
mWifiToggle = (CheckBox) mContentView.findViewById(R.id.id_cb_toggle);
back = (ImageView) mContentView.findViewById(R.id.id_tv_wifi_back);
id_iv_wifi = (ImageView) mContentView.findViewById(R.id.id_iv_wifi);
if (top_wifi_visible) {
if (top_wifi != -1) {
id_iv_wifi.setImageResource(top_wifi);
}
} else {
id_iv_wifi.setVisibility(View.GONE);
}
if (backDrawableId > 0) {
back.setImageResource(backDrawableId);
}
if (backIsVisible) {
back.setVisibility(View.VISIBLE);
} else {
back.setVisibility(View.GONE);
}
mWifiToggle.setOnCheckedChangeListener(this);
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (onBackClickListener != null) {
onBackClickListener.onClick();
}
}
});
if (top_title_size != 0) {
mTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, top_title_size);
}
if (top_title_color != 0) {
mTitle.setTextColor(top_title_color);
}
if (top_bg_drawable != 0) {
rl_title_top_bg.setBackgroundResource(top_bg_drawable);
} else if (top_bg_color != 0) {
rl_title_top_bg.setBackgroundColor(top_bg_color);
}
RelativeLayout type1_bg_color_rl;
if (layout_type == StyleConfig.TYPE1_1 || layout_type == StyleConfig.TYPE1_2 || layout_type == StyleConfig.TYPE1_NONE) {
mTip = (TextView) mContentView.findViewById(R.id.id_tv_wifi_toggle_tip);
mListView = (ListView) mContentView.findViewById(R.id.id_lv_wifi_list);
type1_bg_color_rl = (RelativeLayout) mContentView.findViewById(R.id.id_rl1_bg);
if (bg_drawable != 0) {
type1_bg_color_rl.setBackgroundResource(bg_drawable);
} else if (bg_color != 0) {
type1_bg_color_rl.setBackgroundColor(bg_color);
}
} else if (layout_type == StyleConfig.TYPE2_1 || layout_type == StyleConfig.TYPE2_2 || layout_type == StyleConfig.TYPE2_NONE) {
mTip = (TextView) mContentView.findViewById(R.id.id_tv_wifi_toggle2_tip);
mGridview = (GridView) mContentView.findViewById(R.id.id_gv_wifi2_list);
RelativeLayout type2_bg_color_rl = (RelativeLayout) mContentView.findViewById(R.id.id_rl2_bg);
if (bg_drawable != 0) {
type2_bg_color_rl.setBackgroundResource(bg_drawable);
} else if (bg_color != 0) {
type2_bg_color_rl.setBackgroundColor(bg_color);
}
} else {
mTip = (TextView) mContentView.findViewById(R.id.id_tv_wifi_toggle_tip);
mListView = (ListView) mContentView.findViewById(R.id.id_lv_wifi_list);
type1_bg_color_rl = (RelativeLayout) mContentView.findViewById(R.id.id_rl1_bg);
if (bg_drawable != 0) {
type1_bg_color_rl.setBackgroundResource(bg_drawable);
} else if (bg_color != 0) {
type1_bg_color_rl.setBackgroundColor(bg_color);
}
}
if (tip_size != 0) {
mTip.setTextSize(tip_size);
}
if (tip_color != 0) {
mTip.setTextColor(tip_color);
}
add_wifi = (LinearLayout) mContentView.findViewById(R.id.id_ll_wifi_add);
search_wifi = (LinearLayout) mContentView.findViewById(R.id.id_ll_wifi_search);
}
use of android.widget.RelativeLayout in project WhatsappExtensions by suraj0208.
the class ExtModule method hookMethodsForHighLight.
private void hookMethodsForHighLight(final XC_LoadPackage.LoadPackageParam loadPackageParam) {
XposedHelpers.findAndHookMethod("com.whatsapp.HomeActivity", loadPackageParam.classLoader, "onCreate", Bundle.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
initPrefs();
TypedValue a = new TypedValue();
AndroidAppHelper.currentApplication().getApplicationContext().getTheme().resolveAttribute(android.R.attr.textColor, a, true);
originalColor = a.data;
((Activity) param.thisObject).registerReceiver(unlockReceiver, new IntentFilter(ExtModule.UNLOCK_INTENT));
}
});
XposedHelpers.findAndHookMethod("android.view.View", loadPackageParam.classLoader, "setTag", Object.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
if (!(param.args[0] instanceof String))
return;
String tag = param.args[0].toString();
boolean localIsGroup = tag.contains("@g.us");
View parent = processedViewsHashMap.get(param.thisObject);
RelativeLayout rl = null;
String contact = null;
if (!localIsGroup) {
// XposedBridge.log("not a group");
if (tagToContactHashMap.get(tag) == null) {
try {
if (!tag.contains(":"))
return;
contact = tag.split(":")[1];
contact = contact.split("_")[0];
contact = contact.replace("+", "");
tagToContactHashMap.put(tag, contact);
} catch (ArrayIndexOutOfBoundsException ex) {
return;
}
} else
contact = tagToContactHashMap.get(tag);
} else {
contact = tag.split("@")[0];
}
if (parent == null) {
View contactPictureViewBackground = (View) ((View) param.thisObject).getParent();
if (contactPictureViewBackground == null)
return;
parent = (View) contactPictureViewBackground.getParent();
if (parent == null)
return;
processedViewsHashMap.put((View) param.thisObject, parent);
try {
rl = (RelativeLayout) parent;
} catch (ClassCastException e) {
// XposedBridge.log("ClassCastException in hookMethodsForHighLight");
}
if (rl != null) {
zerothChildrenHashMap.put(parent, rl.getChildAt(0));
firstChildrenHashMap.put(parent, rl.getChildAt(1));
}
}
View zerothChild = zerothChildrenHashMap.get(parent);
View firstChild = firstChildrenHashMap.get(parent);
// hide previews for locked contacts
try {
if (lockedContacts.contains(contact)) {
View v = getPreviewView(firstChild);
if (v != null)
v.setVisibility(View.GONE);
} else {
View v = getPreviewView(firstChild);
if (v != null)
v.setVisibility(View.VISIBLE);
}
} catch (Exception ex) {
// who cares
}
if (!enableHighlight && highlightedChats.size() == 0)
return;
if (localIsGroup && enableHighlight) {
firstChild.setBackgroundColor(highlightColor);
zerothChild.setBackgroundColor(highlightColor);
firstChild.setPadding(0, 37, 30, 0);
((RelativeLayout.LayoutParams) firstChild.getLayoutParams()).height = -1;
} else {
if (contact != null && highlightedChats.contains(contact)) {
firstChild.setBackgroundColor(individualHighlightColor);
zerothChild.setBackgroundColor(individualHighlightColor);
firstChild.setPadding(0, 37, 30, 0);
((RelativeLayout.LayoutParams) firstChild.getLayoutParams()).height = -1;
return;
}
firstChild.setBackgroundColor(originalColor);
zerothChild.setBackgroundColor(originalColor);
firstChild.setPadding(0, 0, 30, 0);
((RelativeLayout.LayoutParams) firstChild.getLayoutParams()).height = -2;
}
}
});
}
use of android.widget.RelativeLayout in project CodenameOne by codenameone.
the class AndroidImplementation method showNativePicker.
@Override
public Object showNativePicker(final int type, final Component source, final Object currentValue, final Object data) {
if (getActivity() == null) {
return null;
}
final boolean[] canceled = new boolean[1];
final boolean[] dismissed = new boolean[1];
if (editInProgress()) {
stopEditing(true);
}
if (type == Display.PICKER_TYPE_TIME) {
class TimePick implements TimePickerDialog.OnTimeSetListener, TimePickerDialog.OnCancelListener, Runnable {
int result = ((Integer) currentValue).intValue();
public void onTimeSet(TimePicker tp, int hour, int minute) {
result = hour * 60 + minute;
dismissed[0] = true;
synchronized (this) {
notify();
}
}
public void run() {
while (!dismissed[0]) {
synchronized (this) {
try {
wait(50);
} catch (InterruptedException er) {
}
}
}
}
@Override
public void onCancel(DialogInterface di) {
dismissed[0] = true;
canceled[0] = true;
synchronized (this) {
notify();
}
}
}
final TimePick pickInstance = new TimePick();
getActivity().runOnUiThread(new Runnable() {
public void run() {
int hour = ((Integer) currentValue).intValue() / 60;
int minute = ((Integer) currentValue).intValue() % 60;
TimePickerDialog tp = new TimePickerDialog(getActivity(), pickInstance, hour, minute, true) {
@Override
public void cancel() {
super.cancel();
dismissed[0] = true;
canceled[0] = true;
}
@Override
public void dismiss() {
super.dismiss();
dismissed[0] = true;
}
};
tp.setOnCancelListener(pickInstance);
// DateFormat.is24HourFormat(activity));
tp.show();
}
});
Display.getInstance().invokeAndBlock(pickInstance);
if (canceled[0]) {
return null;
}
return new Integer(pickInstance.result);
}
if (type == Display.PICKER_TYPE_DATE) {
final java.util.Calendar cl = java.util.Calendar.getInstance();
cl.setTime((Date) currentValue);
class DatePick implements DatePickerDialog.OnDateSetListener, DatePickerDialog.OnCancelListener, Runnable {
Date result = (Date) currentValue;
public void onDateSet(DatePicker dp, int year, int month, int day) {
java.util.Calendar c = java.util.Calendar.getInstance();
c.set(java.util.Calendar.YEAR, year);
c.set(java.util.Calendar.MONTH, month);
c.set(java.util.Calendar.DAY_OF_MONTH, day);
result = c.getTime();
dismissed[0] = true;
synchronized (this) {
notify();
}
}
public void run() {
while (!dismissed[0]) {
synchronized (this) {
try {
wait(50);
} catch (InterruptedException er) {
}
}
}
}
public void onCancel(DialogInterface di) {
result = null;
dismissed[0] = true;
canceled[0] = true;
synchronized (this) {
notify();
}
}
}
final DatePick pickInstance = new DatePick();
getActivity().runOnUiThread(new Runnable() {
public void run() {
DatePickerDialog tp = new DatePickerDialog(getActivity(), pickInstance, cl.get(java.util.Calendar.YEAR), cl.get(java.util.Calendar.MONTH), cl.get(java.util.Calendar.DAY_OF_MONTH)) {
@Override
public void cancel() {
super.cancel();
dismissed[0] = true;
canceled[0] = true;
}
@Override
public void dismiss() {
super.dismiss();
dismissed[0] = true;
}
};
tp.setOnCancelListener(pickInstance);
tp.show();
}
});
Display.getInstance().invokeAndBlock(pickInstance);
return pickInstance.result;
}
if (type == Display.PICKER_TYPE_STRINGS) {
final String[] values = (String[]) data;
class StringPick implements Runnable, NumberPicker.OnValueChangeListener {
int result = -1;
StringPick() {
}
public void run() {
while (!dismissed[0]) {
synchronized (this) {
try {
wait(50);
} catch (InterruptedException er) {
}
}
}
}
public void cancel() {
dismissed[0] = true;
canceled[0] = true;
synchronized (this) {
notify();
}
}
public void ok() {
canceled[0] = false;
dismissed[0] = true;
synchronized (this) {
notify();
}
}
@Override
public void onValueChange(NumberPicker np, int oldVal, int newVal) {
result = newVal;
}
}
final StringPick pickInstance = new StringPick();
for (int iter = 0; iter < values.length; iter++) {
if (values[iter].equals(currentValue)) {
pickInstance.result = iter;
break;
}
}
if (pickInstance.result == -1 && values.length > 0) {
// The picker will default to showing the first element anyways
// If we don't set the result to 0, then the user has to first
// scroll to a different number, then back to the first option
// to pick the first option.
pickInstance.result = 0;
}
getActivity().runOnUiThread(new Runnable() {
public void run() {
NumberPicker picker = new NumberPicker(getActivity());
if (source.getClientProperty("showKeyboard") == null) {
picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
}
picker.setMinValue(0);
picker.setMaxValue(values.length - 1);
picker.setDisplayedValues(values);
picker.setOnValueChangedListener(pickInstance);
if (pickInstance.result > -1) {
picker.setValue(pickInstance.result);
}
RelativeLayout linearLayout = new RelativeLayout(getActivity());
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(50, 50);
RelativeLayout.LayoutParams numPicerParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
numPicerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
linearLayout.setLayoutParams(params);
linearLayout.addView(picker, numPicerParams);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
alertDialogBuilder.setView(linearLayout);
alertDialogBuilder.setCancelable(false).setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
pickInstance.ok();
}
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
pickInstance.cancel();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
});
Display.getInstance().invokeAndBlock(pickInstance);
if (canceled[0]) {
return null;
}
if (pickInstance.result < 0) {
return null;
}
return values[pickInstance.result];
}
return null;
}
use of android.widget.RelativeLayout in project CCIP-Android by CCIP-App.
the class CountdownActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_countdown);
final TextView attrText = (TextView) findViewById(R.id.attr);
final TextView countdownText = (TextView) findViewById(R.id.countdown);
final TextView currentTimeText = (TextView) findViewById(R.id.current_time);
final RelativeLayout countdownLayot = (RelativeLayout) findViewById(R.id.countdown_layout);
final Button button = (Button) findViewById(R.id.button);
final Scenario scenario = JsonUtil.fromJson(getIntent().getStringExtra(INTENT_EXTRA_SCENARIO), Scenario.class);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
JsonObject attr = scenario.getAttr().getAsJsonObject();
JsonElement elemDiet = attr.get("diet");
if (elemDiet != null) {
String diet = elemDiet.getAsString();
if (diet.equals("meat")) {
countdownLayot.setBackgroundColor(getResources().getColor(R.color.colorDietMeat));
attrText.setText(R.string.meal);
} else {
countdownLayot.setBackgroundColor(getResources().getColor(R.color.colorDietVegetarian));
attrText.setText(R.string.vegan);
}
} else {
Set<Map.Entry<String, JsonElement>> entries = attr.entrySet();
for (Map.Entry<String, JsonElement> entry : entries) {
attrText.append(entry.getValue() + "\n");
}
}
long countdown;
if (scenario.getUsed() == null) {
countdown = scenario.getCountdown() * 1000L;
} else {
countdown = (scenario.getUsed() + scenario.getCountdown()) * 1000L - new Date().getTime();
}
new CountDownTimer(countdown, 1000L) {
@Override
public void onTick(long l) {
countdownText.setText(l / 1000 + "");
currentTimeText.setText(SDF.format(new Date().getTime()));
}
@Override
public void onFinish() {
countdownText.setText("0");
currentTimeText.setVisibility(View.GONE);
countdownLayot.setBackgroundColor(Color.RED);
}
}.start();
}
use of android.widget.RelativeLayout in project Roblu by wdavies973.
the class MetricEditor method getConfigField.
/**
* Generates a configuration field for the layout with the specified settings.
* The config field will detect the instance type of RMetric metric above and decide
* what to update. Acceptable names:
* -"title"
* -"min"
* -"max"
* -"increment"
* -"comma"
*/
private TextInputLayout getConfigField(final String name, RelativeLayout layout, int position) {
TextInputLayout inputLayout = new TextInputLayout(this);
inputLayout.setHint(name);
inputLayout.setId(Utils.generateViewId());
AppCompatEditText nameInput = new AppCompatEditText(this);
Utils.setInputTextLayoutColor(rui.getAccent(), inputLayout, nameInput);
nameInput.setTextColor(rui.getText());
nameInput.setHighlightColor(rui.getAccent());
nameInput.setId(Utils.generateViewId());
if (name.equalsIgnoreCase("minimum")) {
nameInput.setInputType(InputType.TYPE_CLASS_NUMBER);
if (metric instanceof RSlider)
nameInput.setText(String.valueOf(((RSlider) metric).getMin()));
} else if (name.equalsIgnoreCase("maximum")) {
nameInput.setInputType(InputType.TYPE_CLASS_NUMBER);
if (metric instanceof RSlider)
nameInput.setText(String.valueOf(((RSlider) metric).getMax()));
} else if (name.equalsIgnoreCase("increment")) {
nameInput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
if (metric instanceof RCounter)
nameInput.setText(String.valueOf(((RCounter) metric).getIncrement()));
} else if (name.equalsIgnoreCase("calculation")) {
if (metric instanceof RCalculation)
nameInput.setText(((RCalculation) metric).getCalculation());
} else if (name.startsWith("Comma separated list")) {
if (metric instanceof RCheckbox) {
StringBuilder text = new StringBuilder();
RCheckbox checkbox = ((RCheckbox) metric);
if (checkbox.getValues() != null) {
for (Object o : checkbox.getValues().keySet()) {
text.append(o).append(",");
}
}
if (text.toString().length() > 0)
nameInput.setText(text.toString().substring(0, text.toString().length() - 1));
} else if (metric instanceof RChooser) {
StringBuilder text = new StringBuilder();
RChooser chooser = ((RChooser) metric);
if (chooser.getValues() != null) {
for (String s : chooser.getValues()) text.append(s).append(",");
}
if (text.toString().length() > 0)
nameInput.setText(text.toString().substring(0, text.toString().length() - 1));
}
} else
nameInput.setText(metric.getTitle());
nameInput.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if (name.equalsIgnoreCase("title")) {
metric.setTitle(charSequence.toString());
} else if (name.equalsIgnoreCase("minimum") && metric instanceof RSlider) {
((RSlider) metric).setMin((int) processTextAsNumber(charSequence, 0));
} else if (name.equalsIgnoreCase("maximum") && metric instanceof RSlider) {
((RSlider) metric).setMax((int) processTextAsNumber(charSequence, 100));
} else if (name.equalsIgnoreCase("increment") && metric instanceof RCounter) {
((RCounter) metric).setIncrement(processTextAsNumber(charSequence, 1));
} else if (name.startsWith("Comma")) {
if (metric instanceof RCheckbox) {
String[] tokens = charSequence.toString().split(",");
LinkedHashMap<String, Boolean> hash = new LinkedHashMap<>();
for (String s : tokens) hash.put(s, false);
((RCheckbox) metric).setValues(hash);
} else if (metric instanceof RChooser) {
String[] tokens = charSequence.toString().split(",");
((RChooser) metric).setValues(tokens);
}
} else if (name.equalsIgnoreCase("calculation")) {
((RCalculation) metric).setCalculation(charSequence.toString());
}
addMetricPreviewToToolbar();
/*Toolbar tl = findViewById(R.id.toolbar);
ViewGroup view = (ViewGroup) tl.getChildAt(0);
RelativeLayout t = (RelativeLayout) view.getChildAt(0);
TextView text = (TextView) t.getChildAt(0);
text.setText(charSequence);
metric.setTitle(charSequence.toString());*/
}
@Override
public void afterTextChanged(Editable editable) {
}
});
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
if (position > 0)
params.addRule(RelativeLayout.BELOW, layout.getChildAt(position - 1).getId());
inputLayout.setLayoutParams(params);
inputLayout.addView(nameInput);
inputLayout.requestFocus();
return inputLayout;
}
Aggregations