Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to set a password on a ToggleButton

 
L Vasquez
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a single ToggleButton. How would I make it so that onToggle, the user must create a password if there isn't one / type in the password if one's already been set?

Thanks
 
Brian Tkatch
Bartender
Posts: 567
25
Linux Notepad Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouldn't that be a simple if() statement?
 
L Vasquez
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about the whole password thing? I've never made a password prompt before. Do I need to create a layout for it? Where does the password store? etc
 
Brian Tkatch
Bartender
Posts: 567
25
Linux Notepad Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you want to prompt on the same Activity, or jump to another? There are plenty of choices.
 
L Vasquez
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now that I think about it, I'd like the password set to occur from a button in activity1. In activity2 when I hit the togglebutton in question, it prompts me for that password. How would I go about this?

Thanks for your help.
 
Brian Tkatch
Bartender
Posts: 567
25
Linux Notepad Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need to be more specific. I am not sure exactly what the difficulty is.
 
L Vasquez
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Difficulty for me is just where to start.
 
Dave Tolls
Ranch Hand
Posts: 2091
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start with the first bit.
Add a button that sticks up a prompt for a password.

Can you achieve that?

Then the next part is storing that password somewhere.
 
Brian Tkatch
Bartender
Posts: 567
25
Linux Notepad Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, he said he wants two Activities, not a prompt. (Unless that is what he meant.)

My preference is to work from the outside in. And that would be by creating the two Activities, add a button for one to open the other. Once the flow is there, populate the individual Activities with other buttons and fields, and only at the end decide how to store the password.

So many choices.
 
L Vasquez
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry, I should have been more specific from the start:

My app is basically finished. There are 2+ activities all ready to go with function buttons, editTexts, etc. I'm just having trouble understand how it is that I go about setting a password lock on a ToggleButton in one of my activities, let's call that activity activity1.

In activity1 there is a ToggleButton I need to be "password-protected". In other words, when the user attempts to toggle the button, they must type a password to do so.
  

In activity2 there is a button called ResetPassword. When this button is clicked, the password should be able to be changed.


I'd like help to understand how to go about setting, and more specifically storing the password throughout my app the way I've outlined above. I don't feel like I've found any straightforward explanation online.

Please ask any more questions you need.

Thanks again.
 
Brian Tkatch
Bartender
Posts: 567
25
Linux Notepad Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
L Vasquez wrote:I'm sorry, I should have been more specific from the start:

That always helps. Context is everything.

L Vasquez wrote:I'd like help to understand how to go about setting, and more specifically storing the password throughout my app the way I've outlined above.

How secure do you want the password to be? (Well, how secure does it need to be?) It can be stored simply, like in a file, or more securely with SmartLock.
 
L Vasquez
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doesn't have to be secure at all. Simply any string that user would like. You mentioned storing it in a file, could this be done via SharedPreferences considering my lack of need for actual security?
 
Brian Tkatch
Bartender
Posts: 567
25
Linux Notepad Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not? If it's just a simple password to make breaking not simple, i would say go for it. If or when things need to be secure, you can implement a secure method.
 
L Vasquez
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So theoretically that's helpful, thank you. But what does it look like implemented, would it be using editText? Do I have to create some kind of layout for the password prompt? etc.
 
Dave Tolls
Ranch Hand
Posts: 2091
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the Android design page for dialogs.

This is the sort of thing you probably want.
See the Creating Custom Layout section, which is probably close to your needs?
 
Brian Tkatch
Bartender
Posts: 567
25
Linux Notepad Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
L Vasquez wrote:would it be using editText? Do I have to create some kind of layout for the password prompt? etc.

Yes, an editText with an inputType of textPassword would be the basic implementation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic