toggle button isnt being set correctly - sharedpreferences

I think i can simplify the problem domain. Basically i have set the preference activity to have button set to on. The problem arises when i click off and then come back to the preference and its still on i tried to create a boolean switch but form some reason it doesnt work. The code is posted below.
solution
I think the solution is to fix the problem of when the user clicks on the toggle button and turns it off since I have set clickable to true in the public void Oncreate method. Every time the user goes back to the preference activity the value is set to on. I think a condition which overrides that parameter would fix my problem.
prefs = getSharedPreferences(prefName, 0 );
SharedPreferences.Editor editor = prefs.edit();
if (twitter.isChecked() == true)
{
onoffTwitter = true;
editor.putBoolean(TWITTER_KEY, true);
onoffTwitter = true;
}
if (twitter.isChecked() == false)
{
onoffTwitter = false;
editor.putBoolean(TWITTER_KEY, false);
onoffTwitter = false;
}
Toast.makeText(getBaseContext(),
"was the twitter checked" + twitter.isChecked(),
Toast.LENGTH_SHORT).show();
editor.commit();
And this code is from another activity which hides the button.
SharedPreferences prefs = getSharedPreferences(prefName, 0);
buttonStatus = prefs.getBoolean(TWITTER_KEY, false);
Log.e(LOGS, "What is the value for the twitter feed" + buttonStatus);
Toast.makeText(AndroidGUIActivity.this,
" What is the value for the twitter feed" + buttonStatus,
Toast.LENGTH_SHORT).show();
if (buttonStatus==false) twitter.setVisibility(View.GONE);
I believe I can fix this by setting the initial value of the togglebutton in the xml file.

The problem was I was not passing the preference value to the twitter but so it wasn't storing the value.
prefs = getSharedPreferences(prefName, 0 );
buttonStatus = prefs.getBoolean(TWITTER_KEY, true);
Log.e(LOGS, "What is the value for the timer feed" + buttonStatus);
twitter.setChecked(buttonStatus);

Related

Auto choose, populate and click

I want to load the page https://game.ultimate-bridge.com/table/ in PhantomJS, choose tournament or 4-hand, populate table and board and then click the load hand.
I have mainly tried to click the button "Load Hand" but not even that is going well.
if ("complete" === readyState) {
console.log("if " + readyState);
var x = document.getElementById("root").querySelectorAll(".jss7.jss46.jss51");
x.click();
console.log("klick");
} // if-statement
The button do not get clicked
page.evaluate(function() {
var ev = document.createEvent("MouseEvents");
ev.initEvent("click", true, true);
document.querySelector("div.jss7.jss46.jss51 button[type='submit']").dispatchEvent(ev);
});

how to add arcgis button in a windows form

I am new in ArcGis. I came across a requirement that I need a command on the ArcGis Toolbar. On click the command, a Windows Form will open and there one region selector button is there. upon clicking on the button, the current Form UI must be minimized and the user will be allowed to draw a polygon. Can you please help on how to do that. Here is the code. I took normal windows button and wrote the below code in the click event.
_application = ((IApplication)_hookHelper.Hook);
IMxDocument pMxDoc = (IMxDocument)_application.Document;
IMap pMap = (IMap)pMxDoc.FocusMap;
IActiveView pActiveView = (IActiveView)pMap;
if (pActiveView == null)
{
return;
}
//// Changing the state of the Window.
if (this.WindowState == FormWindowState.Normal || this.WindowState == FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Minimized;
// this.Hide();
}
ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = pActiveView.ScreenDisplay;
// Constant
screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast
ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();
rgbColor.Blue = 111;
ESRI.ArcGIS.Display.IColor color = rgbColor; // Implicit Cast
ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
simpleFillSymbol.Color = color;
ESRI.ArcGIS.Display.ISymbol symbol = simpleFillSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic Cast
ESRI.ArcGIS.Display.IRubberBand rubberBand = new ESRI.ArcGIS.Display.RubberRectangularPolygonClass();
// ESRI.ArcGIS.Display.IRubberBand rubberBand = new ESRI.ArcGIS.Display.RubberPolygonClass();
ESRI.ArcGIS.Geometry.IGeometry geometry = rubberBand.TrackNew(screenDisplay, symbol);
screenDisplay.SetSymbol(symbol);
screenDisplay.DrawPolygon(geometry);
screenDisplay.FinishDrawing();
I am also not getting any mouse event and the UI is not minimized while starting drawing the polygon. Can anyone please help.
Have we check the white paper for ArcGIS runtime SDK for .Net?
http://resources.arcgis.com/en/help/runtime-wpf/concepts/index.html#/Essential_vocabulary/01700000004z000000/

Windows 10 Mobile height of soft keyboard

Does anybody know how to move content of the page (maybe set relative margins or something like that) when soft keyboard is shown.
Here is the example page from my application.
So I want when the user starts typing a phone number in the text box the bottom button will be shown above the soft keyboard. As a result I want something like that:
P.S: Sorry about Russian language on the screens.
It's kind of tricky, but as I've tried should work. I've used InputPane's showing and hiding events to change the translate transform of the button. In page's constructor I've added such code:
Windows.UI.ViewManagement.InputPane.GetForCurrentView().Showing += (s, args) =>
{
GeneralTransform gt = loginButton.TransformToVisual(this);
Point buttonPoint = gt.TransformPoint(new Point(0, loginButton.RenderSize.Height - 1));
var trans = new TranslateTransform { Y = -(buttonPoint.Y - args.OccludedRect.Top) };
loginButton.RenderTransform = trans;
args.EnsuredFocusedElementInView = true;
};
Windows.UI.ViewManagement.InputPane.GetForCurrentView().Hiding += (s, args) =>
{
var trans = new TranslateTransform { Y = 0 };
loginButton.RenderTransform = trans;
args.EnsuredFocusedElementInView = false;
};
You only have to remember that InputPane is for the whole app - once you leave the page, you will probably have to unsubscribe from those events, otherwise you will likely get exceptions.

Dynamically setting passwordMask in Titanium

Since Titanium doesn't allow you to manually change the hintText colour of a textfield, I have to set hintText manually. Because of this, I have to dynamically change the passwordMask setting on one of fields I'm using.
However, I'm getting weird behaviour and I can't tell if I'm doing something wrong, or if it's a bug in Titanium.
So, here's my markup:
<TextField id="password" onFocus="passwordFocusEvent" onReturn="passwordReturnEvent" onBlur="passwordBlurEvent" value="password"></TextField>
And some of my controller code:
function passwordFocusEvent(e) {
slideViewUp();
if (e.value === 'password') {
e.source.setPasswordMask(true);
e.source.value = '';
}
}
function passwordBlurEvent(e) {
if (!e.value) {
e.source.setPasswordMask(false);
e.source.value = 'password';
}
}
function passwordReturnEvent(e) {
slideViewDown();
passwordBlurEvent(e);
}
What happens is bizarre. When I focus on the password field, it remains plain text. I enter some text, then click off to another field, stays as plain text.
I click back to the password field, it's STILL plain text.
Now here's the weirdness. Up to this point, I would just assume it's not working. However, when I click off this second time, the passwordMask is set.
Major WTF.
I even tried targeting the field directly using $.password.passwordMask = true; but same thing.
Unfortunately, you cant do this. According to the docs on Ti.UI.TextField in the fine print;
Note: on iOS, passwordMask must be specified when this text field is created.
Its not all bad news though, there are a couple ways you can approach this, one option is to make the password mask yourself, by listening to the change event:
var theStoredPassword = '';
$.password.addEventListener('change', function(e) {
var newpass = e.source.value;
if(newpass.length < theStoredPassword.length) {
// Character deleted from end
theStoredPassword = theStoredPassword.substring(0, theStoredPassword.length-1);
} else {
// Character added to end
theStoredPassword += newpass.substring(newpass.length-1);
}
// Mask the text with unicode ● BLACK CIRCLE, 25CF
$.password.value = new Array(newpass.length + 1).join('●');
});
Another option, would be to have two text fields and swap them out whenever the user focuses the password field, the top one would have the custom hinttext, the bottom one would be passwordMasked. In fact thats probably way easier than what I just coded up. :-)

How to detect a click on a form reset button from QtWebKit?

Looking at the signals in the QtWebKit API, I failed to find anything that would seem to me to be what I am looking for.
QWebView
linkClicked() seems to be the closest, but a reset button is no link, and definitely does not point to an URL.
QWebPage
I considered the following signals (judging by their name), but according to their description none of them match my purpose either: contentsChanged(), contentsChanged(), contentsChanged(), selectionChanged().
QWebFrame
None of its signals matches my purpose.
QWebElement
Here I can see how to get an object representing the button(s), but it has no signals whatsoever.
I want to catch a click in a reset button in order to store the data in the form before it gets cleared, so it can be restored later.
For now, I did manage to retrieve the buttons as a QWebElementCollection of QWebElement objects, and I can modify them, but I do not know how to get them to send a signal upon click, or something similar.
// Get reset buttons.
QWebElementCollection inputResets = mainFrame()->documentElement().findAll("input[type=reset]");
inputResets += mainFrame()->documentElement().findAll("button[type=reset]");
// Change their text (just a test).
foreach(QWebElement element, inputResets)
{
element.setPlainText("Worked!");
}
Well, I got it working with this, although I do not think it is the best approach:
bool EventFilter::eventFilter(QObject* object, QEvent* event)
{
if (event->type() == QEvent::MouseButtonRelease)
{
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
if (mouseEvent->button() == Qt::LeftButton)
{
QWebView *view = dynamic_cast<QWebView*>(object);
QPoint pos = view->mapFromGlobal(mouseEvent->globalPos());
QWebFrame *frame = view->page()->frameAt(mouseEvent->pos());
if (frame != NULL)
{
// Get the existing reset buttons.
QWebElementCollection inputResets = frame->documentElement().findAll("input[type=reset]");
inputResets += frame->documentElement().findAll("button[type=reset]");
// Check if any of them is at the clicked position.
foreach(QWebElement element, inputResets)
{
if (element.geometry().contains(pos))
{
qDebug() << "Clicked element tag:" << element.localName();
return QObject::eventFilter(object, event);
}
}
}
}
}
return QObject::eventFilter(object, event);
}
You can probably accomplish this with Qt WebKit Bridge.