[Source] Variable Size Pattern Lockscreen - Android Software Development

For those who don't know, my pattern lockscreen modification has been merged into CyanogenMod 10.
This thread is designed to explain this modification so it can be enjoyed on more roms and devices.
I will also consider other lockscreen modification sugestions.
This addition is now in any CM10 based rom built after 09/01/2012 2:22
If you want to read about how or why I created this mod - continue reading post 1
If you want to implement this feature in your rom - skip to post 2
If you want to admire some screenshots - skip to post 3
Basic design process:
I finally learned how to compile android from source, so I figured I might as well start editing the source some.
Looking at my phone's lockscreen I thought, "Wouldn't it be cool if it was 5x5, it should be as easy as changing some 3s to 5s..."
I began with a lot of searches in the framworks/base folder.
I searched for the incorect pattern error message, found the localization file,
searched for the key, found the PatternUnlockScreen
and finally ended up with LockPatternView.java.
Any time I found 3 (or its variations) I replaced it with the variable PATTERN_SIZE.
3->PATTERN_SIZE, 2->PATTERN_SIZE-1, 9->PatternSize^2, etc
This allowed me to change the patterns appearance at compile time; however, it would only store a 3x3 pattern and could not be changed by a user.
These problems had me digging through LockPatternUtils and the android settings implementation.
Eventually I had a simi working setting (required restart) http://forum.xda-developers.com/showthread.php?t=1267420.
Later, school kept me busy and CM9 came out removing my changes.
With the release of CM10 I decided to recreate the modification from scratch, this time with everything working correctly.

Summary of required changes:
There are two modified projects
frameworks/base - http://review.cyanogenmod.com/#/c/20613/
packages/apps/Settings - http://review.cyanogenmod.com/#/c/20614/
Code:
Frameworks:
LockPatternView.java:
Replace '3' and its variations with a private static int 'PATTERN_SIZE' (must be static to be called from static functions). (This is the only modification required for a static sized pattern, everything else is for the settings implementation)
Add functions to get and set 'PATTERN_SIZE' (changing size requires recreating a few variables).
Update 'Cell' class to alow size changes (recreate and initialize 'sCells' to the new size).
Recreate '// Check for gaps in existing pattern' to support any size patterns and gaps. (This was a challenge to create my own optimized method to achieve this, if you have any improvements please let me know)
LockPatternUtils.java:
Replace '3' with a static int 'PATTERN_SIZE'
Add functions to get, set, and update 'PATTERN_SIZE'
Add get and set Integer functions to interface with the android settings
ILockSettings.aidl:
Add protypes for the get and set Integer functions
LockSettingsService.java:
Add functions to read and write Integers to the settings database
Settings.java:
Add keys for 'LOCK_PATTERN_SIZE' to the settings database
PatternUnlockScreen.java:
Read lockPatternSize from the utils and change the view's size to reflect it
Update the utils PATTERN_SIZE before checking a pattern
Settings:
AndroidManifest.xml:
Add activity to choose the pattern size
strings.xml:
Add entries for the various sizes. (These could be localized; add more keys if you want to expand the size past 6x6)
security_settings_pattern_size.xml: (New File)
Add buttons for the various sizes (Can add more buttons for more sizes)
ConfirmLockPatternSize:
Make mLockPatternView's size respect the saved size
ChooseLockGeneric.java:
Go strait to 'ChooseLockPatternSize.class'. It will forward to the tutorial or pattern choosing activities.
ChooseLockPatternSize.java: (New File)
Inflate the menu with new xml file
Check which button was clicked. (This is what actually determines the 'PATTERN_SIZE' that will later be saved)
Forward 'PATTERN_SIZE' in the intent to the next activity.
ChooseLockPatternTutorial.java:
Set the tutorial's mPatternView size to the one passed in the intent.
Forward 'PATTERN_SIZE' to the next activity.
ChooseLockPattern.java:
Set mLockPatternView's size to the one passed in the intent (Don't save it until they have actually confirmed a pattern of the new size)
Save the new PATTERN_SIZE with LockPatternUtils
All of the required code is contained in the two gerrit commits above.
Simply obtain the source for your rom and make the changes as needed.
Feel free to improve the source, add more sizes (fyi, 10x10 is almost unusable), or anything else (however, it would be nice to give me some credit if you use this code).
Post if you have any questions, I am also up for suggestions.

Screenshots: http://androtransfer.com/development/smasher816/media
See attached photos (larger inline photos coming soon)

I saw this in the latest CM10 release for the Nexus 7. Loved it and am now hoping other CM10 derived ROMs will also implement this!
Sent from my Nexus 7

Only for jb???
Sent from my GT-S7500 using xda premium

Pattern unlock coordinates in log
Hi, I just found out, that coordinates of unlock pattern are printed out to logcat.
Like that:
Code:
V/SMASHER816( 1656): (0, 0)
V/SMASHER816( 1656): (1, 0)
V/SMASHER816( 1656): (2, 0)
V/SMASHER816( 1656): (3, 0)
V/SMASHER816( 1656): (3, 1)
V/SMASHER816( 1656): (3, 2)
V/SMASHER816( 1656): (3, 3)
I think, it is not secure, so, it's better to remove logging of this stuff.

nonsleepr said:
Hi, I just found out, that coordinates of unlock pattern are printed out to logcat.
Like that:
Code:
V/SMASHER816( 1656): (0, 0)
V/SMASHER816( 1656): (1, 0)
V/SMASHER816( 1656): (2, 0)
V/SMASHER816( 1656): (3, 0)
V/SMASHER816( 1656): (3, 1)
V/SMASHER816( 1656): (3, 2)
V/SMASHER816( 1656): (3, 3)
I think, it is not secure, so, it's better to remove logging of this stuff.
Click to expand...
Click to collapse
Looks like the line that was logging this has been removed in cm10. Not sure what the OP's logic was on adding this in the first place?

Flashable zip possible?
I love this, but not every dev incorporates it.
Is it possible to make this code change into a flashable zip with 3, 4, or 5 as the options?
TIA

ccbeam said:
I love this, but not every dev incorporates it.
Is it possible to make this code change into a flashable zip with 3, 4, or 5 as the options?
TIA
Click to expand...
Click to collapse
Sorry if this has been already answered but I'd also like to know the outcome. A flashable zip would be perfect.
Seems like a great way to add more security. I have searched for this and cant find any other usable info on how to do it without compiling it into a rom which I have no idea about

Great Idea
I wonder now why something so simple yet effective in means of improving the pattern locks level of security wouldnt have occurred to google in the first place. I suppose they figure the average end user lacks the memory recall to move beyond a max 3x3 grid pattern.Idk but I love it and am looking forward to incorporating into my own TW ROM.

This would like be perfect as an Xposed module
Envoyé depuis mon GT-I9505 avec Tapatalk 4

+1 as an xposed module! I have been trying to find a way to do this since switching to the Moto X. Also, will this work on 4.4?
Sent from my XT1056 using Tapatalk

fstorm said:
This would like be perfect as an Xposed module
Envoyé depuis mon GT-I9505 avec Tapatalk 4
Click to expand...
Click to collapse
zgroten said:
+1 as an xposed module! I have been trying to find a way to do this since switching to the Moto X. Also, will this work on 4.4?
Sent from my XT1056 using Tapatalk
Click to expand...
Click to collapse
+1 !
Enviado desde mi Nexus 4 mediante Tapatalk

Is a kitkat compatible mod in the works? I'm crossing my fingers hoping it is

I really want this in dummie mode.. At flashable zip!
Enviado desde mi Nexus 4 mediante Tapatalk

Related

event handling in dynamically created control

Hi all,
I am using eVC++ 4.0, and i've dynamically created a CListView like this:
Code:
lv.Create(0,_T(""),WS_CHILD|WS_VISIBLE,r,this,5);
but I dont know how to handle the events of this control... any ideas??
Mohammad
To get events from a listview (win32) I normally subclass it. I use the subclassing routine to post a message back to the parent when the user is doing something like tapping on it, then the windows routine can check whats selected etc and act on it. Is subclassing possible in mfc ?( I don't use it).
Thank u
but can anybody post some code??
thnx
Ok, I am a bit lazy to look up code at the moment, but here's something:
Yes, subclassing is possible in MFC. You just derive your class from the basic class provided like this:
Code:
class MyListView : pubic CListView
Then you add message handlers in the normal matter.
EDIT: The following passage is incorrect:
But I think subclassing may not be necessary in you case. List box controls send WM_COMMAND messages with notifications of major events like selection change to the parent window. All you have to do is to create a WM_COMMAND handler in your parent class.
Sorry I was thinking of ListBox not list view when I wrote it.
To manually add message handlers you need to put macros like ON_MESAGE or ON_COMMAND in the DECLARE_MESSAGE_MAP section of the class cpp file. All the detaisl are available on MSDN.
Are you saying that a listview will send the same WM_COMMAND as a list box in mfc? Dose this also happen in win32 made listviews. I have always thought it was a bit too tedious to find out when the user taps an item in the listview.
After reading your post levenum I had a quick look and it says that a WM_NOTIFY gets sent to the parent with a LVN_ITEMCHANGED for example. I had not used the LVN_**** because when I looked at them there was none that seem to deal with selections. I would guess that LVN_ITEMACTIVATE or LVN_ODSTATECHANGED would be usefull for this but then a second tap would not be picked up still leaving me wanting subclassing in many situations to get the users tap.
Ok, I have read what u wrote guys and my problem is almost solved, I used the OnNotify() method to handle messages sent from child controls like this:
Code:
BOOL CTest2Dlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
// TODO: Add your specialized code here and/or call the base class
if(wParam ==5 ) //5 is control ID
{
NMHDR *ph =(NMHDR*)lParam;
if(ph->code==NM_CLICK)
MessageBox("Click");
else if(ph->code==HDN_ITEMCLICK)
MessageBox("Item Click");
else
{
CString str;
str.Format("%d",ph->code);
MessageBox(str);
}
}
return CDialog::OnNotify(wParam, lParam, pResult);
}
Now there still a very small prolem: what messages should I handle for 'Selected Item Changed' event ?? I know its easy but I couldnt find it
Regards
mohgdeisat: I am sorry, I made a mistake about WM_COMMAND.
OdeeanRDeathshead is right, I was thinking of a list box not list view.
To make up for this, here is some sample code from a win32 dialog app that uses list view control. I hope it will be of some help:
Code:
//this is from the dialog window function:
case WM_NOTIFY: //handle events:
nmhdr = (LPNMHDR)lParam;
switch (nmhdr->idFrom)
{
case IDC_LEDLIST: //list control ID.
return OnLEDListEvent(hwndDlg, (LPNMLISTVIEW)lParam);
break;
}
break;
BOOL OnLEDListEvent(HWND hwndDlg, LPNMLISTVIEW nmlv)
{
/////
// Handles list view control notification messages
switch (nmlv->hdr.code)
{
case LVN_ITEMCHANGED:
return OnLEDListItemChanged(hwndDlg, nmlv);
break;
}
return 0;
}
BOOL OnLEDListItemChanged(HWND hwndDlg, LPNMLISTVIEW nmlv)
{
if (ListView_GetSelectionMark(nmlv->hdr.hwndFrom) != nmlv->iItem) return 0;
/* do what you need here */
return 0;
}
Don't mind the fact that I used 3 different functions. This is part of a bigger program and I am trying to keep things well organized without resorting to classes.
As I understand it, LVN_ITEMCHANGE is received for different reasons so I try to handle only the one coming from selected item. LVN_ITEMACTIVATE is only sent when you double click the item so if you just want to catch selection change you need to use LVN_ITEMCHANGE.
Once again, sorry for confusing you before.
thanx pals, good job!!!
I think my problem is now solved with ur help :wink:
Mohammad
Ok guys, I said that my problem was solved, yet, another problem arises...
When the list view is in the report mode, how can I determine when a header button is clicked, and determine which one was clicked???????
thanx in advance
To identify a header column click, you need to handle the WM_NOTIFY/HDN_ITEMCLICK message. Normally this message will be received by the header's parent control (i.e. the listview) -- some frameworks may redirect the message to the header control itself. I haven't worked with MFC in 10 years so I can't really if it reflects notification messages back to the control.
If you're trying to implement column sort, do yourself a favor and check out the Windows Template Library (WTL) at sourceforge.net. It's a set of C++ template classes that provide a thin yet useful wrapper around the standard Windows UI components. One of the classes is a sortable listview control. I've been using WTL with big Windows for more than 5 years -- you couldn't pay me to go back to MFC.
hi,
I have seen the WTL library and it seems very useful and time-saver, but I have a couple of questions about it:
1. can WTL 8.0 be installed with VC++ 6.0, specifically the appwizard stuff??how?? I see only javascript files of vc7.0 and 7.1 and 8.0!!
2. is there a good documentation about those classes??
Mohammad
I don't know about WTL 8; I'm still using WTL 7.5 with VS .Net 2003 for all my Win32 development. My guess is that it wouldn't work too well, as WTL is based on ATL, which has substantially changed between VC 6 and 7.
Good references for WTL include www.codeproject.com/wtl, and the WTL group over at Yahoo groups (reflected at www.gmane.org).

[proof of concept app]Gesture recognition

I recently saw this tread:
http://forum.xda-developers.com/showthread.php?t=370632
i liked the idea, and when i thought about it, gesture recognition didn't seem to hard. And guess what - it really wasn't hard
I made a simple application recognizing gestures defined in an external configuration file. It was supposed to be a gesture launcher, but i didn't find out how to launch an app from a winCE program yet. Also, it turned out to be a bit to slow for that because of the way i draw gesture trails - i'd have to rewrite it almost from scratch to make it really useful and i don't have time for that now.
So i decided to share the idea and the source code, just to demonstrate how easy it is to include gesture recognition in your software.
My demo app is written in C, using XFlib for graphics and compiled using CeGCC so you'll need both of them to compile it (download and install instructions are on the Xflib homepage: www.xflib.net)
The demo program is just an exe file - extract it anywhere on your device, no installation needed. You'll also need to extract the gestureConfig.ini to the root directory of your device, or the program won't run.
Try some of the gestures defined in the ini (like 'M' letter - 8392, a rectangle - 6248, a triangle - 934), or define some of your own to see how the recognition works. Make sure that you have a string consisting of numbers, then space of a tabulator (or more of them) and some text - anything will do, just make sure that there's more than just the numbers in each line. Below you can set the side sensitivity to tweak recognition (see the rest of the post for description on how it works). Better leave the other parameter as it is - seems to work best with this value.
Now, what the demo app does:
It recognizes direction of drawn strokes, and prints them on the bottom of the screen as a string of numbers representing them (described bellow). If a drawn gesture matches one of the patterns in the config file, the entire drawn gesture gets highlited. It works the best with stylus, but is usable with finger as well.
Clicking the large rectangle closes the app.
And how it does it:
The algorithm i used is capable of recognizing strokes drawn in eight directions - horizontally, vertically and diagonally. Directions are described with numbers from 1 to 9, arranged like on a PC numerical keyboard:
Code:
7 8 9
4 6
1 2 3
So a gesture defined in config as 6248 is right-down-left-up - a ractangle.
All that is needed to do the gesture recognition is last few positions of the stylus. In my program i recorded the entire path for drawing if, but used only 5 last positions. The entire trick is to determine which way the stylus is moving, and if it moves one way long enough, store this direction as a stroke.
The easiest way would be to subtract previous stylus position from current one, like
Code:
vectorX=stylusX[i]-stylusX[i-1];
vectorY=stylusY[i]-stylusY[i-1];
[code]
But this method would be highly inaccurate due to niose generated by some digitizers, especially with screen protectors, or when using a finger (try drawing a straight line with your finger in some drawing program)
That's why i decided to calculate an average vector instead:
[code]
averageVectorX=((stylusHistoryX[n]-stylusHistoryX[n-5])+
(stylusHistoryX[n-1]-stylusHistoryX[n-5])
(stylusHistoryX[n-2]-stylusHistoryX[n-5])
(stylusHistoryX[n-3]-stylusHistoryX[n-5])
(stylusHistoryX[n-4]-stylusHistoryX[n-5]))/5;
//Y coordinate is calculated the same way
where stylusHistoryX[n] is the current X position of stylus, and stylusHistoryX[n-1] is the previous position, etc.
Such averaging filters out the noise, without sacrificing too much responsiveness, and uses only a small number of samples. It also has another useful effect - when the stylus changes movement direction, the vector gets shorter.
Now, that we have the direction of motion, we'll have to check how fast the stylus is moving (how long the vector is):
Code:
if(sqrt(averageVectorX*averageVectorX+averageVectorY*averageVectorY)>25)
(...)
If the vector is long enough, we'll have to determine which direction it's facing. Since usually horizontal and vertical lines are easier to draw than diagonal, it's nice to be able to adjust the angle at which the line is considered diagonal or vertical. I used the sideSensitivity parameter for that (can be set in the ini file - range its is from 0 to 100). See the attached image to see how it works.
The green area on the images is the angle where the vector is considered horizontal or vertical. Blue means angles where the vector is considered diagonal. sideSensitivity for those pictures are: left one - 10, middle - 42 (default value, works fine for me ), right - 90. Using o or 100 would mean that horizontal or vertical stroke would be almost impossible to draw.
to make this parameter useful, there are some calculations needed:
Code:
sideSensitivity=tan((sideSensitivity*45/100)*M_PI/180);
First, the range of the parameter is changed from (0-100) to (0-22), meaning angle in degrees of the line dividing right section (green) and top-right (blue). hat angle is then converted to radians, and tangent of this angle (in radians) is being calculated, giving slope of this line.
Having the slope, it's easy to check if the vector is turned sideways or diagonal. here's a part of source code that does the check, it is executed only if the vector is long enough (condition written above):
Code:
if( abs(averageVectorY)<sideSensitivity*abs(averageVectorX) ||
abs(averageVectorX)<sideSensitivity*abs(averageVectorY)) //Vector is turned sideways (horizontal or vertical)
{
/*Now that we know that it's facing sideways, we'll check which side it's actually facing*/
if( abs(averageVectorY)<sideSensitivity*averageVectorX) //Right Gesture
gestureStroke='6'; //storing the direction of vector for later processing
if( abs(averageVectorY)<sideSensitivity*(-averageVectorX)) //Left Gesture
gestureStroke='4';
if( abs(averageVectorX)<sideSensitivity*(averageVectorY)) //Down gesture
gestureStroke='2';
if( abs(averageVectorX)<sideSensitivity*(-averageVectorY)) //Up gesture
gestureStroke='8';
}
else
{ //Vector is diagonal
/*If the vector is not facing isdeways, then it's diagonal. Checking which way it's actually facing
and storing it for later use*/
if(averageVectorX>0 && averageVectorY>0) //Down-Right gesture
gestureStroke='3';
if(averageVectorX>0 && averageVectorY<0) //Up-Right gesture
gestureStroke='9';
if(averageVectorX<0 && averageVectorY>0) //Down-Left gesture
gestureStroke='1';
if(averageVectorX<0 && averageVectorY<0) //Up-Left gesture
gestureStroke='7';
}
Now, we have a character (i used char type, so i can use character strings for string gestures - they can be easily loaded from file and compared with strcmp() ) telling which way the stylus is moving. To avoid errors, we'll have to make sure that the stylus moves in the same direction for a few cycles before storing it as a gesture stroke by increasing a counter as long as it keeps moving in one direction, and resetting it if it changes the direction. If the counter value is bigger than some threshold (pathSensitivity variable is used as this threshold in my program), we can store the gestureStroke value into a string, but only if it's different from previous one - who needs a gesture like "44444" when dragging the stylus left?
After the stylus is released, you'll have to compare generated gesture string to some patterns (eg. loaded from a configuration file), and if it matches, do an appropriate acton.
See the source if you want to see how it can be done, this post already is quite long
If you have any questions, post them and i'll do my best to answer.
Feel free to use this method, parts of, or the entire source in your apps. I'm really looking forward to seeing some gesture-enabled programs
Very nice work. Reading your post was very insightful, and I hope this can provide the basis for some new and exciting apps!
great app... and well done for not just thinking that seems easy... but actually doing it...
ive been a victim of that myself
very nice work man.. one question in which tool did you write code.. i mean it looks like C but how you test and all..
Great app, i see that it is just proof of concept at this stage, but i see that it can be used in future applications control
Continiue with your great work
nik_for_you said:
very nice work man.. one question in which tool did you write code.. i mean it looks like C but how you test and all..
Click to expand...
Click to collapse
It is C, (no "++", no "#", no ".NET", just god old C ) compiled with opensource compiler CeGCC (works under linux, or under windows using cygwin - a unix emulator), developed in opensource IDE Vham (but even a notepad, or better notepad++ would do), tested directly on my Wizard (without emulator). I used XFlib which simplifies graphics and input handling to a level where anyone who ever programed anything at all should be able to handle it - it providea an additional layer between the programmer and the OS. You talk to Xflib, and Xflib talks to the OS. I decided to use this library, because i wanted to try it out anyway.
If i decide to rewrite it and make an actual launcher or anything else out of it, i'll have to use something with a bit faster and more direct screen access (probably SDL, since i already done some programing for desktop PC with it) - XFlib concentrates on usage of sprites - like 2D console games. every single "blob" of the gesture trail is a separate sprite , which has to be drawn each time the screen is refreshed - that is what slows down the app so much. The gesture recognition itself is really fast.
Very good program i just test it and it works very well some combinaison are pretty hard to realize but i like this blue point turning red with command2 and 934. Goond luck , i'll continue to see your job maybe you'll code a very interesting soft.
Interesting work.... would like to see this implemented in an app, could be very useful.
If you want I have some code I did for NDS coding, and which I ported on PocketPC for XFlib.
It works perfectly well and I use it in Skinz Sudoku to recognize the drawn numbers.
The method is pretty simple : when the stylus is pressed, enter the stylus coordinates in a big array. And when it's released, it takes 16 points (could be changed depending on what you need) at the same distance from each other, checks the angle, and gives you the corresponding 'char'.
To add new shapes, it's just a 15 character string which you link to any char (like, link right movement to 'r', or 'a', or a number, or whatever ^^). It works for pretty much any simple shape, and I even used it to do a graffitti-like thing on NDS which worked really well
Hey!
How do you get the last Stylus Positions?
and how often do you read them out
I want to realice such a code under vb.net, but I don't know how i should read out the last stylus positions, to get them perfectly for such calculations
Code:
Private Sub frmGesture_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
If StylusJump = 1 Then
StylusJump += 1
If (CurrentStylusPosition.X <> frmGesture.MousePosition.X) Or (CurrentStylusPosition.Y <> frmGesture.MousePosition.Y) Then
LastStylusPosition(9).X = LastStylusPosition(8).X
LastStylusPosition(9).Y = LastStylusPosition(8).Y
LastStylusPosition(8).X = LastStylusPosition(7).X
LastStylusPosition(8).Y = LastStylusPosition(7).Y
LastStylusPosition(7).X = LastStylusPosition(6).X
LastStylusPosition(7).Y = LastStylusPosition(6).Y
LastStylusPosition(6).X = LastStylusPosition(5).X
LastStylusPosition(6).Y = LastStylusPosition(5).Y
LastStylusPosition(5).X = LastStylusPosition(4).X
LastStylusPosition(5).Y = LastStylusPosition(4).Y
LastStylusPosition(4).X = LastStylusPosition(3).X
LastStylusPosition(4).Y = LastStylusPosition(3).Y
LastStylusPosition(3).X = LastStylusPosition(2).X
LastStylusPosition(3).Y = LastStylusPosition(2).Y
LastStylusPosition(2).X = LastStylusPosition(1).X
LastStylusPosition(2).Y = LastStylusPosition(1).Y
LastStylusPosition(1).X = CurrentStylusPosition.X
LastStylusPosition(1).Y = CurrentStylusPosition.Y
CurrentStylusPosition.X = frmGesture.MousePosition.X
CurrentStylusPosition.Y = frmGesture.MousePosition.Y
End If
Dim LabelString As String
Dim iCount As Integer
LabelString = "C(" & CurrentStylusPosition.X & "\" & CurrentStylusPosition.Y & ")"
For iCount = 1 To 9
LabelString = LabelString & " " & iCount & "(" & LastStylusPosition(iCount).X & "\" & LastStylusPosition(iCount).Y & ")"
Next
lblGesture.Text = LabelString
ElseIf StylusJump <= 3 Then
StylusJump += 1
Else
StylusJump = 1
End If
End Sub
Sorry, i didn't notice your post before. I guess that you have the problem solved now, that you released a beta of gesture launcher?
Anyway, you don't really need 10 last positions, in my code i used only 5 for calculations and it still worked fine.
Nice thread, thanks for sharing.
Human-,achine interface has always been an interesting subject to me, and the release of ultimatelaunch has sparked an idea. I am trying to acheive a certain look-and-feel interface - entirely using components that are today screen and ultimatelaunch compatible. Basically a clock strip with a few status buttons at the top, and an ultimatelaunch cube for the main lower portion of the screen - gesture left/right to spin the cube, and each face should have lists of info / icons scrolled by vertical gesture. I'm talking big chunky buttons here - tasks, calendar appts, (quick) contacts, music/video playlists - all vertical lists, one item per row, scrolling in various faces of the cube.
Done the top bit using rlToday for now. Set it to type 5 so scrollbars never show for the top section. All good. Cobbling together bits for the faces, but few of the apps are exactly what I want, some (like that new face contacts one) are pretty close, and being a bit of an armchair coder, I thought now would be a good opportunity to check out WM programming and see if I can't at least come up with a mockup of what I want if not a working app.
I was wondering if anyone could advise me on whether I should bother recognising gestures in such a way as this. Does WM not provide gesture detection for the basic up, down, left, right? Actually, all the stuff I have in mind would just require up/down scrolling of a pane - I was thinking that I may well not need to code gesture support at all, just draw a vertical stack of items, let it overflow to create a scrollbar and then just use the normal WM drag-to-scroll feature (if it exists) to handle the vertical scrolling by gesture in the face of the cube. I would rather keep the requirements to a minimum (eg touchflo), both for dependancy and compatibility reasons, so maybe doing the detection manually would be the "way to go", I dunno.
Did you release source with the app launcher? A library maybe? I intend to go open source with anything I do, so if you are doing the same then I would love to have access to your working code
Nice work man.
Impressive.

Need some help with app I'm making

I'm making an app for my church and a few surrounding churches. I want to use one app for all of them. I want the user to be able to open the app, go to setting. Then in the setting I have 2 spinners. One or cities and spinner 2 for churches. Once the church is selected the user is then taken to that churches page. I want that page to now be set as the main screen seen when opening the app every time. I want each user to be able to select their own church as the main screen when opening the app. I don't know how to set that tho. Can someone help me? Is there a better way to accomplish this than what I'm doing? I also want to be able to go into settings and allow user to visit other church pages. I was thinking he way I'm going and having 2 buttons. One for setting as home and one for visiting. Like I said tho. I can't figure out how to set it as the new main activity like I want to do.
Sent from my LG-LS995 using XDA Free mobile app
jeb192004 said:
I'm making an app for my church and a few surrounding churches. I want to use one app for all of them. I want the user to be able to open the app, go to setting. Then in the setting I have 2 spinners. One or cities and spinner 2 for churches. Once the church is selected the user is then taken to that churches page. I want that page to now be set as the main screen seen when opening the app every time. I want each user to be able to select their own church as the main screen when opening the app. I don't know how to set that tho. Can someone help me? Is there a better way to accomplish this than what I'm doing? I also want to be able to go into settings and allow user to visit other church pages. I was thinking he way I'm going and having 2 buttons. One for setting as home and one for visiting. Like I said tho. I can't figure out how to set it as the new main activity like I want to do.
Sent from my LG-LS995 using XDA Free mobile app
Click to expand...
Click to collapse
I'm assuming you've tried using an if statement inside your spinner declaration?
My approach would be the following:
Make a settings activity for your app, details on how to do this and also how to create the xml menu resource, can be found here: http://developer.android.com/guide/topics/ui/settings.html
Concerning the selection of church and city, you should have a look at the ListPreference item mentioned in the guide.
When this is done, and the user has selected something inside the settings, this value is automatucally saved in a dedicated settings sharedprefs file. Now in your onCreate of the main activity you should do this:
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this); //this lets you get access to the settings sharedprefs
Then do this:
String church = pref.getString(KEY_FOR_CHURCH_VALUE, "");
if (church.contentEquals("")) startActivity(this, SettingsActivity.class) //if there is no saved value for the church, automatically open the settings
if (church == "foo1") {
//do something, for example setContentView(R.layout.foo1_layout)
}
... And so on
---------------------------------
Phone : Nexus 4
OS :
- KitKat 4.4.4 stock
- Xposed: 58(app_process); 54(bridge)
- SU: SuperSU
- no custom recovery
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk
Masrepus said:
My approach would be the following:
Make a settings activity for your app, details on how to do this and also how to create the xml menu resource, can be found here: http://developer.android.com/guide/topics/ui/settings.html
Concerning the selection of church and city, you should have a look at the ListPreference item mentioned in the guide.
When this is done, and the user has selected something inside the settings, this value is automatucally saved in a dedicated settings sharedprefs file. Now in your onCreate of the main activity you should do this:
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this); //this lets you get access to the settings sharedprefs
Then do this:
String church = pref.getString(KEY_FOR_CHURCH_VALUE, "");
if (church.contentEquals("")) startActivity(this, SettingsActivity.class) //if there is no saved value for the church, automatically open the settings
if (church == "foo1") {
//do something, for example setContentView(R.layout.foo1_layout)
}
... And so on
---------------------------------
Phone : Nexus 4
OS :
- KitKat 4.4.4 stock
- Xposed: 58(app_process); 54(bridge)
- SU: SuperSU
- no custom recovery
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk
Click to expand...
Click to collapse
Thanks. I'll try to give that a try sometime this week if I get time.
Also, what would be the best way to update textviews on a monthly basis. I'll prob have a quite a few of them that get updated every month. I'm thinking of putting txt files into the assets folder and and then each month I just replace them with a new update txt file. but searching google I'm seeing mixed responses on doing this. Is it possible to link a folder in my app with dropbox or drive so I can replace the old txt file on there and see the results in my app? I'm thinking this would be better than pushing an update every month...
jeb192004 said:
I'm making an app for my church and a few surrounding churches. I want to use one app for all of them. I want the user to be able to open the app, go to setting. Then in the setting I have 2 spinners. One or cities and spinner 2 for churches. Once the church is selected the user is then taken to that churches page. I want that page to now be set as the main screen seen when opening the app every time. I want each user to be able to select their own church as the main screen when opening the app. I don't know how to set that tho. Can someone help me? Is there a better way to accomplish this than what I'm doing? I also want to be able to go into settings and allow user to visit other church pages. I was thinking he way I'm going and having 2 buttons. One for setting as home and one for visiting. Like I said tho. I can't figure out how to set it as the new main activity like I want to do.
Sent from my LG-LS995 using XDA Free mobile app
Click to expand...
Click to collapse
Masrepus had a good solution.
You may also want to consider the following:
Make a new XML file with 2 (or more) spinners, that give you the desired options. Using a dialog box, you can load this XML file and dynamically fill the option list. In this way, the app can see what pages you have made and provide them as options to the user automatically.
If you like, you can save the last user selection (e.g. to file) and give that as a starting value.
I suggest using 2 buttons (also part of the same XML) form where the user can cancel or apply his selection. Using an OnListerner event, you can detect the user choice and perform the appropriate action.
The actual pages can be created as a seperate activity (intent) or can be loaded dynamically into the main window.
Hope this helps.
I've finally gotten a chance to start working on this again. I got my spinners to work. Adding different list to sp2 based on what is selected in sp1. But I like the idea of using pref list. Can I do this with pref list. Can I add different lists to my second pref list like I do with the spinners?
Sent from my LG-LS995 using XDA Free mobile app
Android Application Development Request
I am in need of some help I have a great idea for a new app that may change the face of advanced research. This will allow for the user to search all day and all night. While they are handling everyday life issues and events with family and what not. Yet still, allowing them to locate what they are looking for. Also will allow people with artifacts in there home. That the user may think is not worth anything yet it may be a goldmine. So instead of the user having to do research trying to locate these specific artifacts to see if they are worth money. This app will allow them to do advanced research all day with a touch of a button my idea is revolutionary when it comes to the advanced research that needs to be done. Please, I am looking for somebody to help me develop this app and bring it to life. So that I may present this idea to google for a possible sale. Thank you for your consideration ahead of time on helping me with this application.

[Q] Beginner: Issues with canvas bitmaps, buttons, and layouts

[Q] Beginner: Issues with canvas bitmaps, buttons, and layouts
Hi, I'm hoping people might help me with this more open-ended question. I'm fairly new to programming with little scripting experience.
My problem is that I'm cobbling code together from various separate examples, but trying to implement them into my tests, they don't seem to work together.
Let me show you what my goals are for this experiment:
1) Create Button
2) Generate Images with Button click
3) Drag Images around
So far, I've been able to do create images with drawing bitmaps using canvas and create a working button with the easy drag and drop.
My specific problem is that I can't use the Design tool to create buttons if I use the canvas method of drawing bitmaps because setContentView() needs to be on the canvas.
Here's my onCreate():
Code:
GenerateItem ourView;
Button genButton;
LinearLayout myLinearLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ourView = new GenerateItem(this);
setContentView(ourView);
myLinearLayout = (LinearLayout)findViewById(R.id.linearLayout1);
genButton = new Button(this);
genButton.setText("Generate");
myLinearLayout.addView(genButton);
}
And related XML code from my AndroidManifest:
Code:
<LinearLayout xmlns:android="somelink"
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</LinearLayout>
Now I have two questions:
1) Am I going about this problem the correct way using a mix of Design layout tools and code created images (canvas bitmaps)?
2) Can I use canvas bitmaps with an onTouchListener as a button?
Whoaness said:
2) Can I use canvas bitmaps with an onTouchListener as a button?
Click to expand...
Click to collapse
You should use an ImageView instead. Canvas aren't Views, so they aren't managed by the Android System when an event occurs. Canvas are used, for example, to draw anything in a low-level-way (custom views, for example).
I didn't understand the first question..
Sent from my Vodafone 875
Andre1299 said:
You should use an ImageView instead. Canvas aren't Views, so they aren't managed by the Android System when an event occurs. Canvas are used, for example, to draw anything in a low-level-way (custom views, for example).
I didn't understand the first question..
Sent from my Vodafone 875
Click to expand...
Click to collapse
You might have answered my first question. I'm not sure.
I was asking whether I should stick with canvas methods and, from my limited scripting knowledge, draw a hitbox for the onTouch method to detect so I can redraw the object to the fingers position.
I can easily drag imageviews/imagebuttons around. I guess I have to figure out how to create Imageviews, though I think I seen a way to cast bitmaps into an imageview, but it never worked out for me.
Whoaness said:
You might have answered my first question. I'm not sure.
I was asking whether I should stick with canvas methods and, from my limited scripting knowledge, draw a hitbox for the onTouch method to detect so I can redraw the object to the fingers position.
I can easily drag imageviews/imagebuttons around. I guess I have to figure out how to create Imageviews, though I think I seen a way to cast bitmaps into an imageview, but it never worked out for me.
Click to expand...
Click to collapse
Uhm... so, let me know wheter I understood.
In your project you have a button that renders an image (a bitmap) wich is drawn with a canvas. But you want that this image is draggable.
Am I right?
Andre1299 said:
Uhm... so, let me know wheter I understood.
In your project you have a button that renders an image (a bitmap) wich is drawn with a canvas. But you want that this image is draggable.
Am I right?
Click to expand...
Click to collapse
Yes, draggable image button. Although I'm not sure if it needs to be a button, but I thought button properties would be appropriate for touch and dragging.
Sorry for the late reply. I was on a hiatus.

Issue with setColorFilter on button background (Android 5)

Hi guys,
Teaching myself Android JAVA but am struggling with an issue that's affecting only one major version of Android, which appears to be all of 5.
I have an app using SupportFragments with the v4 support library (also tried it with framework fragments using v13 support library). On two of the fragments I have a ScrollView containing a large set of custom buttons. Both of these screen have an issue where the setColorFilter is being ignored when the scroll position is at the very top of the ScrollView. Oddly, if I scroll even 1 pixel the setColorFilter is working. Baffling.
Note, this only affects Android 5. Android 4, and Android 6 work perfectly. Only the various flavors of 5 I've tested with so far have this problem (5.1.1 - Cyanogen S4, and 5.0.2 - Galaxy Tab S2). The Nexus 9 (6.0), Galaxy Tab 2 (4.2.2) and Galaxy Tab 3 (4.4.2) all work fine.
Below is the example of the the scroll being at the top of the scrollview, and then scrolling by just a tiny margin showing the color filter applied.
******* won't let me post the images yet ****************
The buttons are initially added in the populate method called from the Fragments onCreateView using:
Code:
PasswordButton<Password> btn = (PasswordButton<Password>)inflater.inflate(R.layout.password_button, viewGroup, false);
btn.setObject(password);
The setObject(password) actually sets a password object to the button, and applies the color filter that it inherits from it's password group to the background using the following code (again all from the onCreateView):
Code:
public void setColour() {
int colour = ((ButtonInterface)this.object).getColour();
Drawable background = ContextCompat.getDrawable(getContext(), R.drawable.password_button_selector);
background.setColorFilter(new PorterDuffColorFilter(colour, PorterDuff.Mode.MULTIPLY));
this.setBackground(background);
}
The button's style is a made up of a 9patch background (which is where I'm applying the color filter), a small arrow image, and the text.
I've made a workaround by overriding the onDraw completely for Android 5, and all other variants simply calling super(canvas), but it would be nice to not have to do this as if I start skinning the buttons my custom onDraw will need constant updating.
The searching I've done found allot of issues the other way (i.e. 5 working, but 4 not), and the ones I've found that had issues with 5 I'm already using the methods they say got it working.
Any help would be appreciated

Categories

Resources