webDialog "CURRENT GOALS" header but no button to authorize or cancel - facebook

I am new to Facebook SDK. I am adding the Facebook login in my Android app using Facebook SDK 3.0.1. A Facebook webDialog pop-up for login. Today I found a strange behaviour that is different from that yesterday.
After entering an account name and password and press Login button in the webDialog, it finally shows "CURRENT GOALS" in the header requesting add friends, enter locations, etc. The body shows "(YOUR_APP) would like to access your public profile and friend list". But there is no more button to authorize or cancel. From the Eclipse LogCat, the current session state from Session.StatusCallback() is OPENING. As a result, user cannot complete the login process.
So how do I pass the dialog to complete the login process successfully? If I press the upper-left corner close button or back button, the dialog closes. The session state would become CLOSED_LOGIN_FAILED.
Yesterday, when the same account login, the webDalog finally show "You have already authorized (YOURAPP)" and a Cancel and OK buttons exist. If user press OK, the dialog closes, and Session.StatusCallback() calls out session state becomes OPENED. Thus user complete the login process successfully.

I just found and posted a workaround at: current goals hides facebook ok button during Facebook authorization in a web view
In the FaceBookSDK I modified com/facebook/widget/WebDialog.java, so that once the web dialog was loaded it would look for the block that contains "Current Goals" and hide it (if it exists). Once you do that, the buttons are visible again (at least they were for me).
In com/facebook/widget/WebDialog.java:
private class DialogWebViewClient extends WebViewClient {
// ... other methods ...
#Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
if (!isDetached) {
spinner.dismiss();
}
/*
* Once web view is fully loaded, set the contentFrameLayout background to be transparent
* and make visible the 'x' image.
*/
contentFrameLayout.setBackgroundColor(Color.TRANSPARENT);
webView.setVisibility(View.VISIBLE);
crossImageView.setVisibility(View.VISIBLE);
// I don't know how to highlight in the code block
// So I just add this extra long comment to make it obvious
// Add a javascript call to hide that element, if it exists
webView.loadUrl("javascript:try{ document.getElementById('nux-missions-bar').style.display='none'; } catch (e) {}");
// End changes
}

Related

Ionic sidemenu not working after login, goes back to the login page instead

I have a login page where I disable the sidemenu with:
ionViewWillEnter() {
this.menuCtrl.enable(false);
}
ionViewDidLeave() {
this.menuCtrl.enable(true);
}
After logging in, I navigate to / which goes to /welcome:
this.router.navigate(['/']);
In /welcome, I have the menu turned on:
ionViewWillEnter() {
this.menuCtrl.enable(true);
}
Using Edge/Chrome, when I try to use the side-menu after logging in, it instead tries to "Go Back" to the login page:
Added: If I refresh the page after on /welcome, it reloads the page and fixes the sidemenu. So whatever is happening it seems like it must be left over from the login screen's functionality. Also, I thought adding ion-header fixed it, worked for about 2 logins then suddenly went back to it's previous behavior.
I've also noticed that if I sign out, the Angular authguard sends it back to /login, but if I try to swipe while on the login page, it tries to take me back to the app as though I was authenticated.. Then when I click on a link the Auth guard does it's job and sends be back to login again.
This time, I can still swipe left but a blank page tries to appear from the left instead - and this happens in desktop mode too.
Can anyone help me with this please?
I thought adding ion-header fixed it, it did at first, then suddenly started doing it again.
I finally ended up disabling Swipe within Ionic with:
IonicModule.forRoot({ swipeBackEnabled: false})
If anyone has any info it'd be appreciated.

GWT Forward Button

I'm having an issue handling the forward button.
Basically, when a user is on a page and has made changes without saving then presses the backwards or forwards button they are presented with a prompt and two options: Leave or Stay.
I have implemented the backwards button fine, and choosing to stay on the page works well using History.newItem(currentToken) - the back button is still clickable.
However with the forwards button, if I use History.newItem(currentToken), it brings this to the front of the history stack and the forward button can no longer be clicked.
History.replaceItem(currentToken) causes the same issue.
How do I handle the cancelling of a forwards action so that I stay on my current page, but the forwards button is still enabled?
#Override
public void onValueChange(ValueChangeEvent<String> event) {
logger.info("back button pressed: " + event.getValue());
String evenVal = event.getValue();
String token = History.getToken();
AbstractPresenter presenter = sessionKiosk.getCurrentlyShowingPresenter();
if (presenter instanceof NSRCommonWorksheetPresenter && sessionKiosk.isDirty()) {
((NSRCommonWorksheetPresenter)presenter).setHistoryToken(event.getValue());
((NSRCommonWorksheetPresenter)presenter).showUnsavedChangesLeavingPageDialog();
}
else {
handleHistoryEvent(event.getValue());
}
}
The dialog is shown and when I click on stay on page the following is called.
public void stayOnCurrentPage() {
if (eventMap.get(prevPage) != null) {
History.newItem(prevPage, false);
}
}
Update: Basically history.newItem(value) removes the use of the forward button. Is there another way to cancel the event? If I just do nothing, th page stays where i want but the url still updates
None of the 3 options in the else statement seem to work.
Thanks.
You can simply cancel the event without touching History or tokens.
UPDATE:
It appears from your code that you are not intercepting the event (back/forward button), but let it go through, get the new token, and then force a return to the previous state under certain circumstances.
I suggest using Activities and Places pattern where every "place" within your app has a corresponding "activity". Each activity in your app will implement GWT Activity interface which includes mayStop() method. This method is called before a user navigates away from a specific place in your app, giving you an opportunity to warn a user and cancel the navigation if necessary.
In general, this pattern offers a very robust support for the History mechanism, covering many use cases.
If you want to support History mechanism yourself, take a look at PlaceChangeRequestEvent - it allows you to warn a user who tries to navigate away from a place in your app.

JScript setText() in email and password not being read

Hello StackOverflow -
My issue is a strange one and hopefully someone has seen something like it before.
I'm using TestComplete to do front-end functional testing with a REST API.
We have a Login button that drops a modal to enter email and password.
My script:
function modalCheck()
{
var emailBox, mainPage, unexpWnd;
//Browsers.Item(btFirefox).Run("http://[redacted]");
var mainPage = Sys.Browser("firefox").Page("http://[redacted]/");
var loginModalButton = Sys.Browser("firefox").Page("http://[redacted]/").Panel(0).Header(0).Panel(0).Nav(0).Panel(0).Panel(1).Button("login");
//click login button to drop modal
if(loginModalButton.Exists)
{
loginModalButton.Click();
Log.Message("This button exists and I clicked it.");
}
//modal now visible = assign text and click login submit button
var emailBox = Sys.Browser("firefox").Page("http://[redacted]/").Panel(4).Panel(0).Panel(0).Panel(1).Form(0).Panel(0).Panel(0).Panel(0).Panel(0).Textbox("email");
var passwordBox = Sys.Browser("firefox").Page("http://[redacted]/").Panel(4).Panel(0).Panel(0).Panel(1).Form(0).Panel(0).Panel(0).Panel(0).Panel(0).PasswordBox("password");
var loginSubmitButton = Sys.Browser("firefox").Page("http://[redacted]/").Panel(4).Panel(0).Panel(0).Panel(1).Form(0).Panel(1).Panel(0).Panel(0).SubmitButton("login_submit");
emailBox.setText("[redacted]");
passwordBox.setText("[redacted]");
Delay(5000);
loginSubmitButton.Click();
//need to logout - now the button will show "Logout" instead of "Sign Up"
var logoutButton = Sys.Browser("firefox").Page("http://[redacted]/").Panel(0).Header(0).Panel(0).Nav(0).Panel(0).Panel(1).Button("logout");
if(logoutButton.Exists)
{
logoutButton.Click();
Log.Message("This button exists and I clicked it.");
}
}
I can drop the modal, enter my email and password, and click the login button successfully with this script. The problem is - my credentials aren't recognized and/or are flagged as incorrect if they're entered via my script or if the browser autofills them. They work if entered manually (so I know they're correct and I'm not locked out).
As a tester, this is pretty black-box for me. I can pass along some HTML but I'm not involved in the creation. I can also ask the front-end guys more specific questions if it would help solve my issue.
What does it look like my problem is?!
Use the Keys method instead of SetText. The later puts the text directly to the control and this does not fire the required events.
emailBox.Keys("[redacted]");
passwordBox.Keys("[redacted]");

Link home page rather then current when user clicks 'Add to Home Screen' on iPad/iPhone

I'm developing a web page built for iPad's.
If the user is on a product page and they click on 'Add to Home Screen' button.
Is it possible to have the index.html page rather then current(product.html)?
OR ALTERNATIVELY
Would it be possible to have your own link that could be used on all a site pages.
When clicked use javascript to simulate the 'Add to Home Screen' button and have your 'index.html' page added?
You can't control anything about the Add to Home Screen button, not even "press" it using javascript, that is why sites like youtube have a little popover above the button, asking users to press it.
However you may be able to do something like this:
On each page on your website add javascript code like:
//Maybe check if the user is on an iPad???
if (window.location.href != "your home page url" && navigator.standalone) {
if (!document.referrer) {
window.location.href = "your home page url";
}
}
All that does is check if the user has added the webpage to the home screen navigator.referrer == true, and then checks what webpage was visited previously, if it's nothing then the web app must have been started on a page that isn't the homepage, and so it should be sent to the homepage.
I've just typed that into the answer directly, so it may need some correction.

What events can I catch when the user leaves a GXT grid?

I have a web app that uses GXT (version 1.2.2) grids extensively. I'd like to warn the user if they make changes but don't save.
When I use the grid in a popup dialog, the only way for the user to leave is via a button (either Close or OK). If I add a SelectionListener to the Close button, I can do my "isDirty()" check and warn the user.
If I am not using a dialog, the restriction for leaving the page isn't there. The user can click on a side menu, select a different tab, hit a refresh or next page button that we have on each page. I could listen for an event on everyone of those, but is there an easier way? Something like a "before unload" event that gets fired?
Window.addCloseListener
Or in GWT 1.6:
Window.addCloseHandler
You cannot prevent the window from closing, but you can prompt the user to click cancel which will leave the page open. You can also perform a last-chance save operation after the user chooses to confirm the window close, but before your page is unloaded.
Try this:
Window.addListener(Events.Close,
new Listener<ComponentEvent>() {
public void handleEvent(ComponentEvent be) {
//Do something
}
});
or
Window.addListener(Events.Detach,
new Listener<ComponentEvent>() {
public void handleEvent(ComponentEvent be) {
//Do something
}
});