unlock the screen lock using UiScroller - android-uiautomator

I am trying to unlock the screen lock by swiping forward and for that I have used UiScroller.
Methiod1:
UiScrollable scrollUnlock = new UiScrollable(new UiSelector().packageName("com.android.systemui").className("android.view.ViewGroup").resourceId("com.android.systemui:id/notification_stack_scroller"));
scrollUnlock.scrollForward();
This method sometimes work and sometimes does not work. Any suggestions please.
Method 2:
UiObject scrollUnlock = device.findObject(new UiSelector().packageName("com.android.systemui").className("android.view.ViewGroup").resourceId("com.android.systemui:id/notification_stack_scroller").enabled(true).index(1).scrollable(true));
scrollUnlock.scrollable();
This method does not work.
Please suggest some ideas.

Have you tried getUiDevice().swipe()
code:-
public void unlockBySwipe() throws UiObjectNotFoundException, Exception {
x1 = getUiDevice().getDisplayWidth()/2;
y1 = getUiDevice().getDisplayHeight()/2;
x2 = getUiDevice().getDisplayWidth()/3;
y2 = getUiDevice().getDisplayHeight()/3;
getUiDevice().swipe(x1,y1,x2,y2, 10);
getUiDevice().waitForIdle()
}

Related

How can you disable the trun off screen mode in Processing 3?

I just want my computer's screen not to turn off while a program is runnig. I know I can set it on my PC settings but I just want this app to do it.
Can anybody help me?
Thanks!
I found the following code here
import java.awt.Robot;
import java.awt.MouseInfo;
long robotLastMove = 0;
Robot robot=null;
setup(){
try{
robot = new Robot();
}catch(Exception e){e.printStackTrace();}
}
draw(){
long now = System.currentTimeMillis();
if(robot!=null && now-robotLastMove>1000*60*15){
//TODO: move back the mouse
int x = MouseInfo.getPointerInfo().getLocation().x;
int y = MouseInfo.getPointerInfo().getLocation().y;
//robot.
robot.mouseMove(x+2, y+2);
robot.mouseMove(x, y);
robotLastMove=now;
}
}
This moves the mouse automatically when your PC tries to sleep, but only a little. If you save the code inside the draw function from the above code into a different function, you can call it in the the draw to make the code look better. Like this:
import java.awt.Robot;
import java.awt.MouseInfo;
long robotLastMove = 0;
Robot robot=null;
setup(){
try{
robot = new Robot();
}catch(Exception e){e.printStackTrace();}
}
void stayAwake(){
long now = System.currentTimeMillis();
if(robot!=null && now-robotLastMove>1000*60*15){
//TODO: move back the mouse
int x = MouseInfo.getPointerInfo().getLocation().x;
int y = MouseInfo.getPointerInfo().getLocation().y;
//robot.
robot.mouseMove(x+2, y+2);
robot.mouseMove(x, y);
robotLastMove=now;
}
}
void draw(){
background(0);
stayAwake();
// the code you want to run without your pc falling asleep.
}
Good luck!

Win10 App - Holding & Releasing the map to manipulate an element on the interface

I working on an UWP (Win10) App with a simple location picker function. The user can drag the map on the wanted location. A basic Pushpin thats always in the center of the Map window acts as the location indicator. It works just like the free location pick in WhatsApp.
To give the user feedback that he is moving the center pin, I want to raise the pin when the user is moving the map and lower it again on release.
Here the simple code to raise the pin (and manipulate the shadow):
private void MyMap_MapHolding(MapControl sender, MapInputEventArgs args)
{
iconSwitch = true;
if(iconSwitch == true) {
centerPin.Margin = new Thickness(0, 0, 0, 60);
centerPinShadow.Opacity = 0.3;
centerPinShadow.Width = 25;
}
But this event doesn't seem to be affected on click & hold or tap & hold. Am I missing something?
FYI: I tried this out with the MyMap_MapTapped(...) method, and it worked just fine, but I need it when the map is dragged not just tapped.
Chees!
I've tested and debugged, MapHolding event can't work by me either. For your purpose, CenterChangedLink event maybe helpful, I've tested it too.
Here is part of my sample code:
RandomAccessStreamReference mapIconStreamReference;
public Maptest()
{
this.InitializeComponent();
myMap.Loaded += MyMap_Loaded;
myMap.MapTapped += MyMap_MapTapped;
myMap.MapHolding += MyMap_MapHolding;
myMap.CenterChanged += MyMap_CenterChanged;
mapIconStreamReference = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/MapPin.png"));
}
private void MyMap_Loaded(object sender, RoutedEventArgs e)
{
myMap.Center =
new Geopoint(new BasicGeoposition()
{
//Geopoint for Seattle
Latitude = 47.604,
Longitude = -122.329
});
myMap.ZoomLevel = 12;
}
private void MyMap_MapTapped(Windows.UI.Xaml.Controls.Maps.MapControl sender, Windows.UI.Xaml.Controls.Maps.MapInputEventArgs args)
{
var tappedGeoPosition = args.Location.Position;
string status = "MapTapped at \nLatitude:" + tappedGeoPosition.Latitude + "\nLongitude: " + tappedGeoPosition.Longitude;
rootPage.NotifyUser( status, NotifyType.StatusMessage);
}
private void MyMap_MapHolding(Windows.UI.Xaml.Controls.Maps.MapControl sender, Windows.UI.Xaml.Controls.Maps.MapInputEventArgs args)
{
var holdingGeoPosition = args.Location.Position;
string status = "MapHolding at \nLatitude:" + holdingGeoPosition.Latitude + "\nLongitude: " + holdingGeoPosition.Longitude;
rootPage.NotifyUser(status, NotifyType.StatusMessage);
}
private void MyMap_CenterChanged(Windows.UI.Xaml.Controls.Maps.MapControl sender, object obj)
{
MapIcon mapIcon = new MapIcon();
mapIcon.Location = myMap.Center;
mapIcon.NormalizedAnchorPoint = new Point(0.5, 1.0);
mapIcon.Title = "Here";
mapIcon.Image = mapIconStreamReference;
mapIcon.ZIndex = 0;
myMap.MapElements.Add(mapIcon);
}
At first I thought, even when the MapHoling event can't work, the Tapped action before holding should handled by MapTapped event, but it is seems this action is ignored. So remember, if a user hold the Map but not move it, nothing will happen.

Iterative MenuLayer Pebble

I am trying to create an app on pebble using MenuLayer. My intention is to create Menu's and then sub-menus using the MenuLayer.
I did some basic implementation using "menu_layer_set_callbacks" method and registering callbacks methods for each submenu layers. However, now I realise its getting too messy.
I want to know if there is any easy way out provided in the framework to meet this requirement.
Thanks.
KK
I don't know what you ended up with, but for my project, I made a set of sub-windows but reuses the same callbacks, you can pass custom data to let each know what type it is. Then just push the required sub-windows as needed
void sub_window_load(Window* parentWindow) {
Layer* window_layer = window_get_root_layer(parentWindow);
const GRect bounds = layer_get_frame(window_layer);
MenuLayer* new_layer = menu_layer_create(bounds);
const int context = *((int*) window_get_user_data(parentWindow));
if (context == ID_A) s_A_layer = new_layer;
else if (context == ID_B) s_B_layer = new_layer;
menu_layer_set_callbacks(new_layer, window_get_user_data(parentWindow), (MenuLayerCallbacks){
.get_num_sections = sub_menu_get_num_sections_callback,
.get_num_rows = sub_menu_get_num_rows_callback
/* etc */
});
menu_layer_set_click_config_onto_window(new_layer, parentWindow);
layer_add_child(window_layer, menu_layer_get_layer(new_layer));
}
void createSubWin(Window** w, int* context) {
*w = window_create();
window_set_user_data(*w, context);
window_set_window_handlers(*w, (WindowHandlers) {
.load = sub_window_load,
.unload = sub_window_unload
});
}

How to populate dynamically created imageview through urls asyncronously...In Android

I am using horizontal pager
https://github.com/ysamlan/horizontalpager/blob/master/src/com/github/ysamlan/horizontalpager/HorizontalPager.java
to make dynamic views,and making dynamic images in it....
And using fedor imageloader to pupulate imageviews from urls...
https://github.com/thest1/LazyList/blob/master/src/com/fedorvlasov/lazylist/ImageLoader.java
but i am getting that annoying stid image....
here is my code...
Any help or suggestion will be highly appropriated
Thanx in advance
public class testing extends Activity {
private HorizontalPager mPager;
ImageView[] image;
String url = "http://icons-search.com/img/icons-land/IconsLandVistaStyleEmoticonsDemo.zip/IconsLandVistaStyleEmoticonsDemo-PNG-256x256-Cool.png-256x256.png";
#Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.testing);
ImageLoader imageLoader = new ImageLoader(this);
mPager = (HorizontalPager) findViewById(R.id.horizontal_pager);
image = new ImageView[2];
for (int i = 0; i < 2; i++) {
image[i] = new ImageView(getApplicationContext());
image[i].setImageResource(R.drawable.logo_background);
RelativeLayout.LayoutParams layoutParams90 = new RelativeLayout.LayoutParams(
225, 250);
layoutParams90.leftMargin = 25;
image[i].setLayoutParams(layoutParams90);
mPager.addView(image[i]);
}
for (int i = 0; i < 2; i++) {
imageLoader.DisplayImage(url, image[i]);
}
}
}
When you create ImageView try to pass your Activity instead of Application context. So replace this
image[i] = new ImageView(getApplicationContext());
with this
image[i] = new ImageView(this);
Please check whether you added external storage and internet permission in your android manifest file?
You need to localize the problem first. Probably there's something wrong with the url you use - try another one. Probably something related to Pager - try without pages, just put all images into LinearLayout. What else may be a problem - just find some clue. Does it work if you just put a single ImageView to the screen?

Detect x & y touch event in WP7 screen

I am really need help with return the coordinates x and y in the WP7 screen.
this code help me to move an rectangle in the screen with showing the start(x&y), delta(x,y) and end(x,y) :
TransformGroup transformG;
TranslateTransform translation;
// Constructor
public MainPage()
{
InitializeComponent();
this.ManipulationDelta += new EventHandler<ManipulationDeltaEventArgs>(MainPage_ManipulationDelta);
transformG = new TransformGroup();
translation = new TranslateTransform();
transformG.Children.Add(translation);
rectangle.RenderTransform = transformG;
}
void MainPage_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
startX.Text =e.ManipulationOrigin.X.ToString();
startY.Text = e.ManipulationOrigin.Y.ToString();
DeltaX.Text = e.DeltaManipulation.Translation.X.ToString();
DeltaY.Text = e.DeltaManipulation.Translation.Y.ToString();
translation.X += e.DeltaManipulation.Translation.X;
translation.Y += e.DeltaManipulation.Translation.Y;
EndX.Text =Convert.ToString(translation.X);
EndY.Text = Convert.ToString(translation.Y);
}
I just want to do something like that but without move anything, just tap in the screen and know the start and the end with delta (difference).
I use silverlight
You Should remove rectangle.RenderTransform = transformG; than the rectangle should stay on the same place.

Resources