Android scratch View 2 Layers - imageview

I'm using Android-WScratchView to implement a scratch effect in my app.
What my app does is a "cleaning" effect. I have a picture of a clean t-shirt and another picture of the same t-shirt but dirty (with some mud).
Android-WScratchView works great for the normal case, a background Image (clean t-shirt) and an overlay Image (dirty t-shirt).
The problem is now, I need to add a second overlay Image, which is a "less" dirty t-shirt so the user has to "clean" the t-shirt in 2 steps.
Once the first layer has been erased, I need to be able to erase the second layer but only where it is visible.
I've implemented it using 2 WScratchView objects, one behind another, like this:
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/shirt_clean" />
<com.winsontan520.WScratchView
xmlns:wsv="http://schemas.android.com/apk/res-auto"
android:id="#+id/scratch_view_layer_1"
android:layout_width="300dp"
android:layout_height="300dp"
wsv:antiAlias="true"
wsv:revealSize="20dp"
wsv:scratchDrawable="#drawable/shirt_less_dirty"
wsv:scratchable="true" />
<com.winsontan520.WScratchView
xmlns:wsv="http://schemas.android.com/apk/res-auto"
android:id="#+id/scratch_view_layer_2"
android:layout_width="300dp"
android:layout_height="300dp"
wsv:antiAlias="true"
wsv:revealSize="20dp"
wsv:scratchDrawable="#drawable/shirt_dirty"
wsv:scratchable="true" />
The problem is that after the "most dirty" layer is "erased" (it gets transparent) I cannot delete the "less dirty" layer because the second layer is getting the onTouch event.
My idea is parsing somehow the onTouch event through the second WScratchView to the first one. But still would have the problem that I don't know which area has already been deleted and which not.
I would appreciate any help, also a different way to implement it will be accepted.

Related

Force the screen reader to read a label

I am developing an application using accessibility properties. I have some buttons that increment and decrement some values showed in labels. Is it possible somehow force the screen reader to read a label when a blind user changes the values?
Support for aria-live is spotty.
Seeing a code example would be handy, but if you are always putting focus on the field then perhaps you want to use aria-label with some good messaging instead as this is better supported and will be spoken when the field gets focus.
<label for="foo">Field Label</label>
<input type="text" id="foo" aria-label="Field Label. Note: If you are using a screen reader…">
Note: The screen reader reads the value when ever there is focus so after clicking the button check where your focus resides.
1. Probably worth a read: https://developer.paciellogroup.com/blog/2014/03/screen-reader-support-aria-live-regions/
2. An example from JAWS: ARIA https://www.freedomscientific.com/SurfsUp/AriaLiveRegions.htm
OR
Accessibility - live region in Xamarin.Forms
<TextView
android:id="#+id/feedback_text_view"
android:accessibilityLiveRegion="polite" />
Please follow for more help = https://codelabs.developers.google.com/codelabs/basic-android-accessibility/#6
Hope will help you

Activity or Fragment or?

I have the the following Activity LinearLayout.
<!-- Main LinearLayout -->
<LinearLayout
...
android:orientation="vertical"
tools:context=".MainActivity">
<!-- Inner LinearLayout -->
<LinearLayout... />
<!-- Fragment holding Google Map Fragment -->
<fragment android:name=".MainMapFragment"
android:id="#+id/map_fragment"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="match_parent" />
<!-- Inner LinearLayout -->
<LinearLayout... />
</LinearLayout/>
I have some Google Map Markers displayed in the MainMapFragment showing that around that location there are some specific related business to look into.
Once a User clicks on any of those Markers on the Map... I need to display a LIST of all those Business associated to that MARKER and allow the User to Tag/Mark the business as FAVORITE or NOT.
I have everything done in relation to the Google Map, Markers, InfoWindow, etc... however... I would like to know what should be a good way/design/layout to DISPLAY the Business List (ListView is ok) detail information and allow the User to MARK AS FAVORITE any of the business in the list using a REGULAR BUTTON (or TOGGLE BUTTON) display within the Business Information Details.
Although I already thought on some choices (see below), I am not sure which one to go for it.
Launch a new Activity, once back (new activity finished) update the information within the Map, Markers, etc.
Add a new Fragment to the current Layout and SWITCH (hide/show) between the one with the Map and the one with the Business Information.
A Modal Dialog (DialogInterface, AlertDialog, etc)
Once again I am not sure where to go and so my question... what will be a good design/model to approach this request?
Sorry for my english, i think that you should use an activity, If I understood correctly on click event you should display details of the related place, a good habit of mobile programming is to display details in other activity with the back button in the action bar.
I ended up extending DialogFragment, not only works OK but also allowed me to work with anything in a custom/complex layout inside the Dialog.

Sometimes willHideViewController from UISplitViewControllerDelegate is not called

I have a problem.
My app is a tab bar controller and its first view controller is a split view controller.
This seems to be not ok for Apple because documents say a split voew controller must be the root, so perhaps that is the reason of my problems.
The problem is that sometimes, willHideViewController from UISplitViewControllerDelegate is not called, so, for this reason, the upper/left button sometimes is not created, which is anoying.
I realised, to reproduce this error, try several times this:
-Landscape mode.
-Select a tab different to split view controller tap.
-Move the iPad to portrait in that tab.
-Go to the split view controller tab, and sometimes, willHideViewController is not called so you will not see the upper button. However if I rotate my iPad to landscape and after that to portrait, it's fixed.
I tried to force manually several rotations to work around this problem, but no luck.
I still have to try any split view controller clone class from github or similar.
Do you have idea what's going on or any work around?
Here I show you two examples working properly.
Thanks a lot for your help.
Where do you set the splitViewControllers delegate? Perhaps you can set the delegate when you load the tab. It sounds like you set it only when you have rotated once?
Otherwise, see this example
Here they have the TableViewController be the delegate of the splitviewcontroller. Perhaps you could do the same with the TabBarController?
I've concluded that this can't be done in any way that I consider 'sufficiently' legitimate. It's possible to get frustratingly close, but the issue of having the willShow..., willHide disseminated to the split view controllers under each tab remains.
The solution that seems most likely to work is,
https://github.com/grgcombs/IntelligentSplitViewController/blob/master/IntelligentSplitViewController.m
Though this code is undoubtedly clever, it's a bit too 'side door' for me. I suspect (but don't know) that just invoking the delegate methods is not sufficient. Surely the UISplitViewController itself needs to change it's internal state as well as calling the delegate methods? This method 'just' invokes the delegate methods when there's an orientation change.
So... I've decided on a more legitimate solution, which is to use the new method introduced in iOS 5.
- (BOOL) splitViewController:(UISplitViewController *)svc
shouldHideViewController:(UIViewController *)vc
inOrientation:(UIInterfaceOrientation)orientation
{
return NO;
}
So, the master menu is never hidden, and therefore the problem of managing the popover doesn't arise.
Of course, this is still not totally 'legit' as it still includes UISplitViewControllers that are not at the top level (the UITabViewController is at the top level, and the split views are on each tab)
Good luck with whichever solution you choose.
I'll update this reply when I've confirmed Apple will approve an app using this solution.

XUL button looks like disabled and is not "pushable" (but onclick function is invoked)

I'm developing a Firefox extension. I'm familiar with JS, CSS, XML but new to XUL.
I want to override Downloads in the way that adds a button next to each downloaded file to rename it. I've already done it (placing a button and handling rename logic).
The thing that left is UI. The button looks like disabled, but apparently is not, because I can click it and the popup appears.
Here it is how it looks now:
and the corresponding code:
<xul:button label="Rename" tabindex="1" onclick="foo()"/>
Adding disabled="false" doesn't help. I can add style="color:black; text-shadow:0 0;" and this makes it look like intended, but there are several problems (and I guess disabled-like look might be the cause):
The button I added is not "pushable" in the manner like the native "Clear list" button (pushing it doesn't change its look, i.e. it doesn't "go down"). However, foo() is invoked.
I can't navigate to the button with Tab from keyboard.
I've read one should prefer command / oncommand instead of onclick (because of Tab navigation for instance), but in my example, only onclick invokes foo(). The two other don't work.
In case more detailed code is needed (I borrowed it entirely from some other extension):
<binding id="download-done" extends="chrome://mozapps/content/downloads/download.xml#download-base">
<content>
<xul:hbox flex="1">
...
<xul:vbox pack="start" flex="1">
...
<xul:hbox align="center" flex="1">
<xul:label xbl:inherits="value=status,tooltiptext=statusTip" crop="end" flex="1" class="status"/>
<xul:button label="Rename" tabindex="1" onclick="foo()"/>
</xul:hbox>
</xul:vbox>
</xul:hbox>
</content>
</binding>
Help greatly appreciated.
Edit 1
The code I presented above was taken from original Firefox download.xml (<binding id="download-done">) and changed only by adding my <xul:button>.
For the things to be even more weird, I've taken, from the same file, two another bindings ( <binding id="download-paused"> and <binding id="download-downloading">) and added exactly the same <xul:button> to them, and in both cases, the button is both "pushable" and black (in short, normal, as it should be). It is also navigable from keyboard with Tab, even without setting tabindex explicitly.

Android Layout: Consistent visible Button Bar

In my main Activity I have created a bar with buttons on it. Now , I would like the "Button Bar" to always show regardless of what Activity I'm showing. Basically I need the handle the Button events from the "Button Bar" across all Activities. Is this possible, and what best practice to achieve this?
Use includes inside a Merge. The includes can be re used inside any view.
<com.testmerge.TitleBar
id="#+id/titlebar"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_gravity="top"
android:paddingTop="0dip"
android:background="#drawable/title_bar"
/>
<com.testmerge.OkCancelBar
android:layout_width="fill_parent"
android:layout_height="60dip"
android:layout_gravity="bottom"
android:paddingTop="0dip"
android:background="#drawable/header_bkgrnd"
/>
<!--"#AA000000"-->

Resources