I am working on an android app where I am saving the a lock pattern.
While the user enters a pattern while powering on the screen, I am checking if it is the same as the saved pattern.
I am saving the pattern in the application using: https://github.com/haibison/android-lockpattern/
The problem is that both are in different formats:
1) lockpattern Object captured while powering on the screen:
[(row=1,clmn=0), (row=0,clmn=1), (row=1,clmn=1), (row=2,clmn=1), (row=1,clmn=2)]
2) And this one i am capturing using haibison's method:
char[] pattern = data.getCharArrayExtra(LockPatternActivity.EXTRA_PATTERN);
String lockpattern = new String(pattern);
Can you please provide some examples/links.
Should I not use haibison's method?
You have to set an Encrypter before starting the Lockpattern-Intent in order to get a proper representation from haibison's char-array , e.g. LPEncrypter (https://bitbucket.org/haibison/android-lockpattern/wiki/Encryption):
AlpSettings.Security.setEncrypterClass(context, LPEncrypter.class);
E.g. a simple representation for this pattern:
Simple Pattern
Habisons char array without the Encrypter is like this:
[3,9,7,7,c,9,3,7,e,c,e,a,5,6,2,4,0,e,a,7,3,9,3,4,b,8,e,9,a,c,9,7,6,6,e,8,e,8,d,0]
using the Example-Encrypter with
String[] ids = new String(pattern).split("[^0-9]");
you'll get [1,-,2,-,3,-,6] which should be easy to convert into your lockpattern-representation.
Related
I am using a QR code scan library zxing.
Is there a way to use multiple bar code formats at the same time?
EXAMPLE)
ONE_D_CODE_TYPES And DATA_MATRIX
ScanOptions options = new ScanOptions();
//like this
options.setDesiredBarcodeFormats(ScanOptions.ONE_D_CODE_TYPES);
options.setDesiredBarcodeFormats(ScanOptions.DATA_MATRIX);
options.setPrompt("Scan a barcode");
options.setCameraId(0); // Use a specific camera of the device
options.setBeepEnabled(false);
options.setBarcodeImageEnabled(true);
You can use both of them using | character. Try this to use both of them:
options.setBarcodeFormats(ScanOptions.ONE_D_CODE_TYPES | ScanOptions.DATA_MATRIX);
private static final String Accept = "Accept & continue";
public void acceptWorkspaceCreation() {
//Wait for Set up a Work Profile Screen for Android 9 Pixel
waitUtilByText(180, Accept);
assertTrue("Couldn't click on Accept & continue.",
findElementByIdAndClick("com.android.managedprovisioning", "next_button"));
}
public boolean waitUtilByText(int seconds, String text){
String textStr = "//*[#text='" + text + "//*[#id='";
return !new WebDriverWait(this.driver, seconds).until(ExpectedConditions.presenceOfAllElementsLocatedBy(By
.xpath(textStr))).isEmpty();
}
For some cases Accept value comes in caps 'ACCEPT & CONTINUE', How to validate both the strings in selenium.
The condition you are waiting for only checks for one thing:
ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath(textStr))
So, presumably (as I am not familiar with Selenium), you can use the ExpectedConditions.or method to check a number of conditions, and wait for just one to be true:
ExpectedConditions.or(
ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath(textStr)),
ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath(textStr2)))
where textStr2 is the alternative text you are looking for.
I'd suggest using native Android UiSelector's textMatches method where You'd write matcher for both upper and lower case texts. If you want to stick to the Xpath anyways - it also has a text matcher. But first of all, investigate why the text changes - that's not a good practice.
I would like to show tooltip on clicking on any word of Android Hi-chart Word-Cloud like 1,000 , currently it is showing like 1 000.
I had conversation with Hi-chart support team.
They suggested with this URL.
But unable to understand how to implement the same. I tried as below:
HILang hiLang = new HILang();
hiLang.setThousandsSep("3");
But setThousandsSep method accepts String type parameter only.
The default is a single space character which is why it is being shown as 3 100; a space after "3"
Try
hiLang.setThousandsSep(",");
I am writing an Android application which gets string to parse using regex. Let's say it gets
'Tis an example image of a beaver {[beaver.jpg]} having an afternoon tea.
And what I want to get is TextView with 'Tis an example image of a beaver, ImageView beaver.jpg and an another TextView having an afternoon tea..
How (if possible) is creating objects possible after reading such string and parsing with regex?
Your custom view class should have a constructor that takes three String parameters, one for the path of the image, one for text to be displayed before the image and one for the text to display afterwards.
class YourView {
public YourView(String imgPath, String beforeImg, String afterImg){
//add TextView for text before image
//add ImageView for image
//add TextView for text after image
}
}
If your image will always be enclosed in a {[ ]}, the regex (.+)\\{\\[(.+)\\]\\}(.+) will capture everything before the {[ in capturing group 0, everything between {[ and }] (i.e. the image path) in group 1, and everything after }] in group 2.
If you use a Java Matcher You can then achieve your desired result like:
String pre, path, post;
while (matcher.find()){
pre = matcher.group(0);
path = matcher.group(1);
post = matcher.group(2);
YourView view = new YourView(path, pre, post);
//add view
}
Note that, if the image is at the end or beginning of the text, you'll simply be passing empty strings as the third/first parameters here, which will result in the creation of empty TextViews, which should be harmless (or you can do a check and not create one for empty strings).
That said, also note that above code is untested (but should give you the general idea), and that I'm a Java programmer with little experience in Android - so let me know if there's an Android-specific reason this wouldn't work
In my Android app I use Picasso to load images. This normally works perfectly well.
Today I tried loading a static image from the google maps api, but this doesn't seem to work. When I open the example link as provided on their info page, I get to see the static map image perfectly well. When I load it in my Android app using the line below, I get nothing at all.
Picasso.with(getContext()).load("http://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=370x250&maptype=roadmap%20&markers=color:blue|label:S|40.702147,-74.015794&markers=color:green|label:G|40.711614,-74.012318%20&markers=color:red|color:red|label:C|40.718217,-73.998284&sensor=false").into(mapView);
I also tried to download the image and uploading it to my personal webspace, from which it loads perfectly well, but somehow, it doesn't seem to load directly from the direct google API url.
Does anybody know why this is so, and how I can solve it?
The only programmatic point-of-failure that comes to mind is in parsing the URI. Looking at the current Picasso code (https://github.com/square/picasso/blob/master/picasso/src/main/java/com/squareup/picasso/Picasso.java) I see the following:
public RequestCreator load(String path) {
if (path == null) {
return new RequestCreator(this, null, 0);
}
if (path.trim().length() == 0) {
throw new IllegalArgumentException("Path must not be empty.");
}
return load(Uri.parse(path));
}
So I'd first debug
Uri.parse("http://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=370x250&maptype=roadmap%20&markers=color:blue|label:S|40.702147,-74.015794&markers=color:green|label:G|40.711614,-74.012318%20&markers=color:red|color:red|label:C|40.718217,-73.998284&sensor=false")
and see what that Object looks like. Does it drop or confuse any of your parameters?
If that doesn't lead you anwhere, try downloading the file manually using a HttpClient [or similar]. Then at least you can fully debug the request/response.
Also, I know Google maps has some limits -- are you sure you haven't reached them?
replace http with https
replace | with %7C
add api key
The .loadMap() function has many declared variables. This is the heart of the whole process.
So what is required for the static maps API to give us an image is that we make an http request with a given url, for which an image response (URL) is received. Let us run through the meaning and utility of these variables. Yes, all of them have a completely different meaning!
The mapUrlInitial variable is always the same while making an API call. It has a query of center ( ?center ) which specifies that we want the location to be centered in the map.
The mapUrlProperties variable contains a string where you control the actual zooming of the image response you will get, the size ofthe image and the color of the marker which will point out our place.
The mapUrlMapType variable is a string where you can actually determine the marker size you want and the type of the map. We are using a roadtype map in the app.
Finally latLong is a string which concatenates the latitude and the longitude of the place we want to pinpoint!
We then concatenate all of these strings to form a feasible Url. The Url is then loaded as we have seen above, in the Picasso code. One thing we can notice is that an event object is always required for all of this to happen, because we are able to fetch the position details using the event object! Final Code:-
fun loadMap(event: Event): String{
//location handling
val mapUrlInitial = “https://maps.googleapis.com/maps/api/staticmap?center=”
val mapUrlProperties = “&zoom=12&size=1200×390&markers=color:red%7C”
val mapUrlMapType = “&markers=size:mid&maptype=roadmap”
val latLong: String = “” +event.latitude + “,” + event.longitude
return mapUrlInitial + latLong + mapUrlProperties + latLong + mapUrlMapType
}
//load image
Picasso.get()
.load(loadMap(event))
.placeholder(R.drawable.ic_map_black_24dp)
.into(rootView.image_map)