Spaces being converted to %20 in Android output - android

We have this Android code that is sending text to a collector:
public void sendHello() {
s.link = "None";
s.track("App Home Page - Hello all");
}
The output, though, contains %20 instead of spaces so we are ending up with something like this:
App%20Home%20Page%20-%20Helloall
Does anyone know how to prevent the spaces being converted or what is causing it?

As others have said, it'd be nice to know the type of s. But, as a shot in the dark, you could use URLDecoder's decode method.

Related

Zendesk Android SDK localization issue

I have a problem with localizing Zendesk to french. You can see in the below screenshot the word Contacteznous which is not the correct one.
This is not the only word that is incorrect, there are some english words which are not translated at all.
I think that based on the language, the appropriate words should be taken from values-fr file in Zendesk library package. The correct word sits there but is not used as you can see from the screenshot.
The code I use for setting up Zendesk is:
public void initZenDesk() {
ZendeskConfig.INSTANCE.setDeviceLocale(Locale.FRANCE);
ZendeskConfig.INSTANCE.init(getActivity(), Constant.ZenDesk_Support_Site, Constant.ZenDesk_ApplicationId, Constant.ZenDesk_Auth_CLientId,
new ZendeskCallback<String>() {
#Override
public void onSuccess(String s) {
Identity identity = new AnonymousIdentity.Builder()
.withNameIdentifier(globals.getUserDetails().get(Constant.MM_UserName))
.withEmailIdentifier(globals.getUserDetails().get(Constant.MM_Email))
.withExternalIdentifier(globals.getUserDetails().get(Constant.MM_UserId))
.build();
ZendeskConfig.INSTANCE.setIdentity(identity);
ZendeskConfig.INSTANCE.setContactConfiguration(new BaseZendeskFeedbackConfiguration() {
#Override
public String getRequestSubject() {
return "Support request";
}
});
new SupportActivity.Builder().show(getActivity());
}
#Override
public void onError(ErrorResponse errorResponse) {
Toast.makeText(getActivity(), errorResponse.getReason() + errorResponse.getResponseBody(), Toast.LENGTH_SHORT).show();
}
});
}
I cannot understand what I am doing wrong, I followed the steps from the official Zendesk webpage. Everything is properly set in the admin back office as well. What am I missing guys?
The missing hyphen is a subtle bug in our translation file, thanks for pointing it out! It will be fixed in our next release.
The hyphen you see in the strings.xml file is a soft hyphen, U+00AD (see https://en.wikipedia.org/wiki/Soft_hyphen), instead of a regular hyphen, U+2010. As such, it is not displaying in this case, because the text is not being broken over multiple lines.
As a workaround in the meantime, you can override the contact_fragment_title in your app, making sure to use a real hyphen character (or a space, or whatever you prefer).
I think you have a ticket open with us at the moment. We'll be looking at the issue tomorrow and we'll get back to you on that channel. We can post the result back here too.
Thanks,
Barry.

JavaFX ScrollPane on Android - Too Slow

I have just coded a simple example of using a scrolling pane in JavaFX. Just one ScrollPane placed in the Scene, and the ScrollPane holds a Label component with a large text. Using gradle I have uploaded the app on a Nexus 4 android device. As you can see from the video I have uploaded, the scrolling is way too slow. I am sure others have experienced this. Any suggestion of how this can be changed to the native speed scroll is really much appreciated.
Source code of the app can be downloaded from here.
AndroidFX.java
public class AndroidFX extends Application{
public static void main(String[] args) {
launch(args);
}
#Override
public void start(Stage primaryStage) throws Exception {
Parent mySearchListFXML = getFXMLPane("/fxml/ScrollPaneWithLabel.fxml");
primaryStage.setScene(new Scene(mySearchListFXML));
primaryStage.setWidth(Screen.getPrimary().getVisualBounds().getWidth()); primaryStage.setHeight(Screen.getPrimary().getVisualBounds().getHeight());
primaryStage.show();
}
public static Parent getFXMLPane(String url) throws IOException {
URL location = AndroidFX.class.getResource(url);
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(location);
Parent pane = fxmlLoader.load();
return pane;
}
}
ScrollPaneWithLabel.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<ScrollPane fx:id="scrollPane" fitToWidth="true" hbarPolicy="NEVER" pannable="true" style="-fx-background: white;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<content>
<Label text="<VERY LARGE TEXT HERE>" wrapText="true" />
</content>
</ScrollPane>
Faced similar issues. The problem is worse on hidpi devices, disabling the hipdpi setting in the properties file helps but you will have to do any scaling your self for hidpi screens.
Another thing that might help is caching the fonts. I believe the end result of a javafx ported application is more like a big image with hot spots. Scrolling I think is just telling the application to redraw the whole image every time. Just a theory really. Caching does help but can make your text look kinda fuzzy. Although I had some success in scaling the font large, setting the cache to true and then scale down, normally x2 and .5 gives pretty good results. Using em for the fonts helps the fuzzy text too.
If you need to show a huge amount of text and it must be scrolled, you will probably get much better results displaying it through a webview. I haven't ever really used it to be honest, but I would imagine that it is replaced when ported with the native browser window so performance should be pretty good I think. I guess it is possible they wrote a html renderer in javafx and then you would run into the same pitfalls.
http://www.gluonhq.com is offering something called the charm, down, and connect package that is supposed to mimic native apps. It sounds promising and I am currently trying to get more info to see if they have solutions to these types of issues. I will add to the post if I receive any more info about charm.

How to find a WebView element in Android using Calabash using TextContent

I have a webview in an ios app that basically has no id or class. (I know, right?)
But it does have a textContent field that I would like to use to select elements.
This is the element I want to find:
{"rect"=>
{"center_x"=>307.5,
"left"=>295,
"bottom"=>136,
"right"=>320,
"top"=>93,
"width"=>25,
"height"=>43,
"center_y"=>178.5},
"nodeName"=>"LI",
"id"=>"",
"textContent"=>"!!! I WANT TO FIND IT BY THIS !!!",
"center"=>{"X"=>307.5, "Y"=>178.5},
"nodeType"=>"ELEMENT_NODE",
"webView"=>
"<UIWebView: 0xe2e1400; frame = (0 0; 320 504); clipsToBounds = YES; autoresize = W+H
"class"=>"arrow",
"html"=>"<div class=\"arrow\"></div>"}
So I was able to find this using css pseudo-selectors alá
query("webView css:'el:first-child'")
I can find it by using the hashes in the results array alá
query("webView css:'li'").select {|element| element["textContent"] == "!!! I WANT TO FIND IT BY THIS !!!}
And I can refactor it a bit to use a regex alá
query("webView css:'li'").select {|element| element["textContent"] =~ /I WANT/}
But all this feels really dirty. Very un-Calabashy. Is there a better way to write this?
I have not tried your exact setup. But I do often use queries with the LIKE comparison on label.
Would that solve your problem?
ex.
element_exists("label {text LIKE 'I WANT TO FIND'}")
I wound up going with this:
query("webView css:'TITLE'{textContent CONTAINS ’I WANT’}")
It tends to work more consistently with these particular webviews (given a lack of accessibility labels in the code).

Robotium for Android - solo.searchText () not working

I'm having a problem with searchText() function used with Robotium.
I'm searching for this string:
<string name="provisioning_wizard_title_2">Service Activation Wizard (Step 2)</string>
I defined it in string xml, and I'm searching it this way:
Activity act=solo.getCurrentActivity();
String string = solo.getString(act.getResources().getIdentifier("provisioning_wizard_title_2", "string", act.getPackageName()));
It fails when I call
assertTrue(solo.searchText(string));
and it fails also if i call:
assertTrue(solo.searchText("Service Activation Wizard (Step 2)"));
even if that is the string I'm seeing in the focused screen activity.
The strange thing is that it works if I use the same string without last character:
assertTrue(solo.searchText("Service Activation Wizard (Step 2"));
and it works if I use
assertTrue(solo.searchText(string.substring(0, string.length()-1)));
I hope someone could help me.
Sorry for my english!
Thank you.
PROBLEM SOLVED
I solved problem thanks to Renas Reda (Founder and maintainer of Robotium).
The problem is due to regex support in searchText(); some characters will trigger it.
Use Pattern.quote(string)
Example: Pattern.qoute("provisioning_wizard_title_2") and eveything works good!
I usually use Solo#waitForText(...) so I make sure I'm not losing some race condition.
Try this:
assertTrue(solo.waitForText( solo.getString(R.string. provisioning_wizard_title_2) );
Make sure you are importing the correct R.java file from your production project (not the test project).
I'm not sure, what string you are fetching. Try to log it:
Log.d("Debug", "String is: " + string);
you should rather call, here may be another issue related to package as activity may be in another package than main package of application:
String string = solo.getString(act.getResources().getIdentifier(act.getPackageName()+":string/provisioning_wizard_title_2"), null, null));
You can also get all visible texts, to make sure, what is on the screen:
for(TextView textView : solo.getCurrentViews(TextView.class)) {
Log.d("DEBUG", "Text on the screen: " + textView.getText().toString());
}

Observe very long String content in Eclipse

Since LogCat truncates long strings, I work around this using FileOutputStream to inspect the contents of very long strings.
It works but it forces me to 'adb pull' that file, which is not very convenient, compare to watching it on LogCat.
Is there any other way in Eclipse to watch very long strings?
For the record, the answer was found here.
when you stop in debug on the variable
do the following and past it to a text file
I think it will be easier to use the eclipse debugging view.
Set a break point at the line where you call Log.* and run your app in debug mode.
When execution reaches the break point the app will ... yes, it will halt.
In the Variables window you may now browse your data and display whatever you need. Copy and paste it at a safe place as well and don't forget to smile :)
What I do, is in "Variables->Change value".
That will show you a Windows with the full text. Then just Copy&paste to notepad.
try this:
public void logLargeString(String str) {
if(str.length() > 3000) {
Log.i(TAG, str.substring(0, 3000));
logLargeString(str.substring(3000));
} else
Log.i(TAG, str);
}
}

Categories

Resources