Related
Hello devs
Im developing an application for Windows Mobile in Visual Basic.NET.
Now I would like to make some kind of PopUp with all the stuff seen in background "dimmed". This can be seen on all newer Manila-Style applications and of course HTC is making those popups.
But, how do I create such popups? I know that it has something to do with AlphaBlending, but I don't really understand how to make it.
Does anyone of you probably have a working sample solution in VB.NET?
Many thanks in advance for any help...
raftbone
Here you go. http://blogs.msdn.com/priozersk/archive/2009/03/31/dimming-the-background.aspx
This guys blog is great. All kinds of tips and tricks to make mobile apps work and look better.
Many thanks for the link. I'll try to get this code changed to VB.NET.
Seems to lock pretty easy and it's exactly what I was looking for
OK, I've managed to change the code into VB. This is the code:
Code:
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim dimBackground As Bitmap = New Bitmap(Me.Width, Me.Height)
Dim gxTemp As Graphics = Graphics.FromImage(dimBackground)
gxTemp.Clear(Color.Black)
e.Graphics.drawalpha(dimBackground, 100, 0, 0)
gxTemp.Dispose()
dimBackground.Dispose()
End Sub
The code is working execpt "DrawAlpha". DrawAlpha seems to be unknown in VisualBasic.NET with .NET CF 3.5.
Can anyone help me how to get the DrawAlpha method working?
Code:
Public Module opacity
Public Structure BlendFunction
Public BlendOp As Byte
Public BlendFlags As Byte
Public SourceConstantAlpha As Byte
Public AlphaFormat As Byte
End Structure
Public Declare Function AlphaBlendCE Lib "Coredll.dll" Alias "AlphaBlend" (ByVal hdcDest As IntPtr, _
ByVal xDest As Int32, ByVal yDest As Int32, ByVal cxDest As Int32, _
ByVal cyDest As Int32, ByVal hdcSrc As IntPtr, ByVal xSrc As Int32, _
ByVal ySrc As Int32, ByVal cxSrc As Int32, ByVal cySrc As Int32, _
ByVal blendFunction As BlendFunction) As Int32
Public Enum BlendOperation As Byte
AC_SRC_OVER = &H0
End Enum
Public Enum BlendFlags As Byte
Zero = &H0
End Enum
Public Enum SourceConstantAlpha As Byte
Transparent = &H0
Opaque = &HFF
End Enum
Public Enum AlphaFormat As Byte
AC_SRC_ALPHA = &H0
End Enum
Public Sub DrawAlpha(ByVal gx As Graphics, ByVal image As Bitmap, _
ByVal transp As Byte, ByVal x As Integer, ByVal y As Integer)
Try
Using gxSrc As Graphics = Graphics.FromImage(image)
Dim hdcDst As IntPtr = gx.GetHdc()
Dim hdcSrc As IntPtr = gxSrc.GetHdc()
Dim bf As New BlendFunction()
bf.BlendOp = CByte(BlendOperation.AC_SRC_OVER)
bf.BlendFlags = CByte(BlendFlags.Zero)
bf.SourceConstantAlpha = transp
bf.AlphaFormat = CByte(AlphaFormat.AC_SRC_ALPHA)
AlphaBlendCE(hdcDst, x, y, image.Width, image.Height, hdcSrc, _
0, 0, image.Width, image.Height, bf)
gx.ReleaseHdc(hdcDst)
gxSrc.ReleaseHdc(hdcSrc)
End Using
Catch ex As Exception
Logger.log("Device dont support alphablending.", Logger.logLevel.NOTICE)
Logger.log(ex, Logger.logLevel.NOTICE)
End Try
End Sub
End Module
usage:
Code:
opacity.DrawAlpha(e.graphics, bmp, 128), 0, 0) 'draw your bmp with 50% opacity
Hope it help it's the quicker method that I found. I have cutted out some specific code from my app, so you ca find error, I've not test the code. Let me know if you have trouble.
If you are intrested there is an other way to make opacity bitmap that work pixel per pixel but is too slow.
If you found better method please post it.
Ciao
Hi
Many thanks for your code. It seems to work pretty using the code I have posted initally. There I was using a new form with WindowState = Maximized etc.
But now I don't really understand on how to exactly use your code in my project.
I have one form and multiple controls on it. The controls are normally invisible and set to Visible = True if I need to show them.
How can I now dim the background with your code, before setting a specific control to Visible = True?
I tried something like this:
Code:
Private Sub ShowPanel()
Dim dimBackground As Bitmap = New Bitmap(Me.Width, Me.Height)
Dim gxTemp As Graphics = Graphics.FromImage(dimBackground)
gxTemp.Clear(Color.Black)
modOpacity.DrawAlpha(gxTemp, dimBackground, 128, 0, 0)
gxTemp.Dispose()
dimBackground.Dispose()
Me.Panel2.Visible = True
End Sub
But if I do this code, I get an error in your code at the line:
Code:
Dim hdcSrc As IntPtr = gxSrc.GetHdc()
It seems, that the object gxSrc does not have a method GetHdc(), but I simply don't understand why...
Could you probably get me into the right direction?
raftbone
As explained in the blog I've created a form 'BackgroundForm'
Code:
using System;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.Drawing;
namespace UI
{
public partial class BackgroundForm : Form
{
public BackgroundForm()
{
InitializeComponent();
}
protected override void OnPaint(PaintEventArgs e)
{
using (Bitmap dimBackGround = new Bitmap(this.Width, this.Height))
using (Graphics gxTemp = Graphics.FromImage(dimBackGround))
{
gxTemp.Clear(Color.Black);
opacity.DrawAlpha(e.Graphics, dimBackGround, 100, 0, 0);
}
}
protected override void OnPaintBackground(PaintEventArgs e)
{
}
}
}
and changed it to be fullscreen (in the designer):
Code:
FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
WindowState = System.Windows.Forms.FormWindowState.Maximized;
Then I've created a static helper class
Code:
using System;
using System.Windows.Forms;
namespace UI
{
public static class FormHelper
{
public static DialogResult ShowMessageBox(string text)
{
return ShowMessageBox(text, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None);
}
public static DialogResult ShowMessageBox(string text, string caption)
{
return ShowMessageBox(text, caption, MessageBoxButtons.OK, MessageBoxIcon.None);
}
public static DialogResult ShowMessageBox(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
{
BackgroundForm form = new BackgroundForm();
form.Show();
DialogResult result = MessageBox.Show(text, caption, buttons, icon, MessageBoxDefaultButton.Button1);
form.Close();
return result;
}
}
}
And now you can simply use one of the three methods to show a message box with dimmed background e.g.
Code:
FormHelper.ShowMessageBox("Text", "Caption", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
To convert from C# to VB.net use for example convert csharp to vb.
Hi
Thanks for your answer. Meanwhile I was already able to get it working with your blog info about using a new form.
Thanks to everyone helping me
raftbone
Hi all,
i want to lock the screen orientation in portrait mode.
how can i do it in programming??
Thank you
try this, is not too clean sorry:
Code:
Public Class display
'DEVICEMODE
<Runtime.InteropServices.DllImport("coredll.dll")> _
Friend Shared Function ChangeDisplaySettingsEx(ByVal lpszDeviceName As String, ByVal lpDevMode As Byte(), ByVal hwnd As IntPtr, ByVal dwflags As CDSFlags, ByVal lParam As IntPtr) As CDSRet
End Function
'Declare Function ChangeDisplaySettingsEx Lib "coredll.dll" (ByVal lpszDeviceName As String, ByVal lpDevMode As Byte(), ByVal hwnd As IntPtr, ByVal dwflags As CDSFlags, ByVal lParam As IntPtr) As CDSRet
Public Shared Function ChangeDisplayOrientation(ByVal degree As Integer) As String
Dim devMode As New devicemodeW()
devMode.dmFields = DM_Fields.DM_DISPLAYORIENTATION
If degree = 0 Then
devMode.dmDisplayOrientation = DMD.DMDO_0
ElseIf degree = 90 Then
devMode.dmDisplayOrientation = DMD.DMDO_90
ElseIf degree = 180 Then
devMode.dmDisplayOrientation = DMD.DMDO_180
ElseIf degree = 270 Then
devMode.dmDisplayOrientation = DMD.DMDO_270
End If
Dim ret As CDSRet = ChangeDisplaySettingsEx(Nothing, devMode.Data, IntPtr.Zero, 0, IntPtr.Zero)
Return (ret.ToString())
End Function
' from pinvoke.net
Public Enum DMD
DMDO_0 = 0
DMDO_90 = 1
DMDO_180 = 2
DMDO_270 = 4
End Enum
Public Enum DM_Fields
DM_DISPLAYORIENTATION = 8388608
DM_DISPLAYQUERYORIENTATION = 16777216
End Enum
Public Enum DM_Orient
DMORIENT_PORTRAIT = 1
DMORIENT_LANDSCAPE = 2
End Enum
' Flags for ChangeDisplaySettings
Enum CDSFlags
CDS_VIDEOPARAMETERS = &H20
CDS_RESET = &H40000000
End Enum
' Return values for ChangeDisplaySettings
Enum CDSRet
DISP_CHANGE_SUCCESSFUL = 0
DISP_CHANGE_RESTART = 1
DISP_CHANGE_FAILED = -1
DISP_CHANGE_BADMODE = -2
DISP_CHANGE_NOTUPDATED = -3
DISP_CHANGE_BADFLAGS = -4
DISP_CHANGE_BADPARAM = -5
End Enum
Public Class devicemodeW
Inherits SelfMarshalledStruct
Private _DM_Orient As DM_Orient
Private _DM_Fields As DM_Fields
Private _DMD As DMD
Public Sub New()
MyBase.New(192)
dmSize = CUShort(Data.Length)
End Sub
Public Property dmDeviceName() As String
Get
Return GetStringUni(0, 64)
End Get
Set(ByVal value As String)
SetStringUni(value, 0, 64)
End Set
End Property
Public Property dmSpecVersion() As UShort
Get
Return GetUInt16(64)
End Get
Set(ByVal value As UShort)
SetUInt16(64, value)
End Set
End Property
Public Property dmDriverVersion() As UShort
Get
Return GetUInt16(66)
End Get
Set(ByVal value As UShort)
SetUInt16(66, value)
End Set
End Property
Public Property dmSize() As UShort
Get
Return GetUInt16(68)
End Get
Set(ByVal value As UShort)
SetUInt16(68, value)
End Set
End Property
Public Property dmDriverExtra() As UShort
Get
Return GetUInt16(70)
End Get
Set(ByVal value As UShort)
SetUInt16(70, value)
End Set
End Property
Public Property dmFields() As DM_Fields
Get
'Return DirectCast(GetUInt32(72), DM_Fields)
Return _DM_Fields
End Get
Set(ByVal value As DM_Fields)
_DM_Fields = value
SetUInt32(72, CInt(value))
End Set
End Property
Public Property dmOrientation() As DM_Orient
Get
'Return DirectCast(GetInt16(76), DM_Orient)
Return _DM_Orient
End Get
Set(ByVal value As DM_Orient)
SetInt16(76, CShort(value))
End Set
End Property
Public Property dmPaperSize() As Short
Get
Return GetInt16(78)
End Get
Set(ByVal value As Short)
SetInt16(78, value)
End Set
End Property
Public Property dmPaperLength() As Short
Get
Return GetInt16(80)
End Get
Set(ByVal value As Short)
SetInt16(80, value)
End Set
End Property
Public Property dmPaperWidth() As Short
Get
Return GetInt16(82)
End Get
Set(ByVal value As Short)
SetInt16(82, value)
End Set
End Property
Public Property dmScale() As Short
Get
Return GetInt16(84)
End Get
Set(ByVal value As Short)
SetInt16(84, value)
End Set
End Property
Public Property dmCopies() As Short
Get
Return GetInt16(86)
End Get
Set(ByVal value As Short)
SetInt16(86, value)
End Set
End Property
Public Property dmDefaultSource() As Short
Get
Return GetInt16(88)
End Get
Set(ByVal value As Short)
SetInt16(88, value)
End Set
End Property
Public Property dmPrintQuality() As Short
Get
Return GetInt16(90)
End Get
Set(ByVal value As Short)
SetInt16(90, value)
End Set
End Property
Public Property dmColor() As Short
Get
Return GetInt16(92)
End Get
Set(ByVal value As Short)
SetInt16(92, value)
End Set
End Property
Public Property dmDuplex() As Short
Get
Return GetInt16(94)
End Get
Set(ByVal value As Short)
SetInt16(94, value)
End Set
End Property
Public Property dmYResolution() As Short
Get
Return GetInt16(96)
End Get
Set(ByVal value As Short)
SetInt16(96, value)
End Set
End Property
Public Property dmTTOption() As Short
Get
Return GetInt16(98)
End Get
Set(ByVal value As Short)
SetInt16(98, value)
End Set
End Property
Public Property dmCollate() As Short
Get
Return GetInt16(100)
End Get
Set(ByVal value As Short)
SetInt16(100, value)
End Set
End Property
Public Property dmFormName() As String
Get
Return GetStringUni(102, 64)
End Get
Set(ByVal value As String)
SetStringUni(value, 102, 64)
End Set
End Property
Public Property dmLogPixels() As UShort
Get
Return GetUInt16(166)
End Get
Set(ByVal value As UShort)
SetUInt16(166, value)
End Set
End Property
Public Property dmBitsPerPel() As UInteger
Get
Return GetUInt32(168)
End Get
Set(ByVal value As UInteger)
SetUInt32(168, value)
End Set
End Property
Public Property dmPelsWidth() As UInteger
Get
Return GetUInt32(172)
End Get
Set(ByVal value As UInteger)
SetUInt32(172, value)
End Set
End Property
Public Property dmPelsHeight() As UInteger
Get
Return GetUInt32(176)
End Get
Set(ByVal value As UInteger)
SetUInt32(176, value)
End Set
End Property
Public Property dmDisplayFlags() As UInteger
Get
Return GetUInt32(180)
End Get
Set(ByVal value As UInteger)
SetUInt32(180, value)
End Set
End Property
Public Property dmDisplayFrequency() As UInteger
Get
Return GetUInt32(184)
End Get
Set(ByVal value As UInteger)
SetUInt32(184, value)
End Set
End Property
Public Property dmDisplayOrientation() As DMD
Get
'Return DirectCast(GetUInt32(188), DMD)
Return _DMD
End Get
Set(ByVal value As DMD)
_DMD = value
SetUInt32(188, CInt(value))
End Set
End Property
End Class
Public Class ScreenMode
'DEVICEMODE
<Runtime.InteropServices.DllImport("coredll.dll")> _
Friend Shared Function ChangeDisplaySettingsEx(ByVal lpszDeviceName As String, ByVal lpDevMode As Byte(), ByVal hwnd As IntPtr, ByVal dwflags As CDSFlags, ByVal lParam As IntPtr) As CDSRet
End Function
'Declare Function ChangeDisplaySettingsEx Lib "coredll.dll" (ByVal lpszDeviceName As String, ByVal lpDevMode As Byte(), ByVal hwnd As IntPtr, ByVal dwflags As CDSFlags, ByVal lParam As IntPtr) As CDSRet
Public Function ChangeMode(ByVal degree As Integer) As String
Dim devMode As New devicemodeW()
devMode.dmFields = DM_Fields.DM_DISPLAYORIENTATION
If degree = 0 Then
devMode.dmDisplayOrientation = DMD.DMDO_0
ElseIf degree = 90 Then
devMode.dmDisplayOrientation = DMD.DMDO_90
ElseIf degree = 180 Then
devMode.dmDisplayOrientation = DMD.DMDO_180
ElseIf degree = 270 Then
devMode.dmDisplayOrientation = DMD.DMDO_270
End If
Dim ret As CDSRet = ChangeDisplaySettingsEx(Nothing, devMode.Data, IntPtr.Zero, 0, IntPtr.Zero)
Return (ret.ToString())
End Function
Public Sub SetLandscape()
Try
ChangeMode(90)
Catch ex As Exception
'MsgBox(ex.ToString)
End Try
End Sub
Public Sub SetPortrait()
Try
ChangeMode(0)
Catch ex As Exception
'MsgBox(ex.ToString)
End Try
End Sub
End Class
End Class
usage:
Code:
display.ChangeMode(angle)
i use Win32API to write my app. But , your code is VB.
i will try my best to understand it.
Thank alessandroame so much =]
Is there a way to easily remove the facebook tags on contacts in outlook? it's the stuff that says :
<HTCData><!-- Please do not modify -->
<Facebook>id:xxxxxx/friendof:xxxxxxxxxxx</Facebook>
</HTCData>
Thanks!
Yes PLEASE? I don't use a Sense ROM anymore and this is annoying!
I don't even have this phone anymore. Maybe I will write something to do this for us.
HTC tag removal in contact notes!
I just sat down on my break and created this code to strip out the HTC tags from the contact notes:
Code:
Sub HTCbGone()
Dim objContactsFolder As Outlook.MAPIFolder
Dim objContacts As Outlook.Items
Dim objContact As Object
Dim StartPos As Integer
Dim EndPos As Integer
Dim iCount As Integer
' Specify with which contact folder to work
Set objContactsFolder = _
Session.GetDefaultFolder(olFolderContacts)
Set objContacts = objContactsFolder.Items
iCount = 0
' Process the changes
For Each objContact In objContacts
If TypeName(objContact) = "ContactItem" Then
StartPos = InStr(objContact.Body, "<HTCData>")
EndPos = InStr(objContact.Body, "</HTCData>") + 10
If StartPos > 0 Then
If StartPos = 1 Then
If Len(EndPos) > EndPos + 1 Then
objContact.Body = Mid(objContact.Body, EndPos + 1)
Else
objContact.Body = ""
End If
Else
If Len(EndPos) > EndPos + 1 Then
objContact.Body = Left(objContact.Body, StartPos = 1)
Else
objContact.Body = Left(objContact.Body, StartPos - 1) & Mid(objContact.Body, EndPos + 1)
End If
End If
iCount = iCount + 1
objContact.Save
End If
End If
Next
' Display the results
MsgBox "Number of contacts updated:" & Str$(iCount), , _
"HTCbGone Finished"
' Clean up
Set objContact = Nothing
Set objContacts = Nothing
Set objContactsFolder = Nothing
End Sub
To run this, I opened Outlook. Selected Macro(s) from the Tools pull-down menu (or press [ALT+F8]). Created a new Macro called HTCbGone and pasted this code over everything. Then I just ran it.
Use at your own risk.
Happy scripting,
GinoRP
THANK YOU!!!! (I only type in all caps 2 or 3 times a year) If HTC was a person I would kick him in the teeth because of what they have done to my 500+ contacts in my Microsoft Exchange account.
How could the people at HTC justify code that puts notes on contacts only invisible to a HTC device and visible everywhere else?? How could they think that would annoy no one? Blows my effing mind.
Kinda thanks but for me it did not work.
I made and run the macro.
Then I noticed some things got lost though!
Before I began I made a copy of the contacts folder in Outlook (recommended!).
I used the "modified" tab to see what contacts where changed when.
There was an extra URL in the note position for a contact which I put there earlier today.
After running the macro the Facebook data was gone but so was the URL.
Because it changed many contacts I did not bother to look further if other things gotten lost but rather just emptied the folder and restored from backup folder.
I am do work with DB and such but did not find anything special in the script which could explain my output.
Sorry to bring up a dead thread, but is there a way to do this without outlook?
i am still interested as well- can anyone come up with a better way not using outlook?
Remove HTC Notes Using CSV
DeMiNe0 said:
Sorry to bring up a dead thread, but is there a way to do this without outlook?
Click to expand...
Click to collapse
I was trying to figure out this very same thing and came across this thread in my searching. I also don't look Outlook, but I found a really simple, quick, and effective way to manually get rid of all those pesky HTC notes in under five minutes, for those that don't use Outlook:
1) Go into the contacts view in Gmail
2) Click the "More" dropdown box and select "Export"
3) Ensure that the "All Contacts" option is selected, choose the "Outlook CSV format," and export
4) After the file downloads, open it up in Excel (or your choice spreadsheet program)
5) Find the column labeled "Notes," and then just scroll down and clear all the cells with HTC data in them
6) Save the file, ensuring it is still in CSV format
7) Back in your Google Contact Manager, delete all your contacts
NOTE: Before deleting your contacts you will want to export a Google CSV file of all your contacts for backup. You can also the "More > Restore" feature to go back to a previous point in time if something goes wrong.8) Import the CSV file you saved in step 6
That's it! Your contact book should be restored to the exact way it was, minus the obnoxious HTC data. With 1,000+ contacts, I was able to do this in about two minutes. Again, be sure you have backups of your contacts or know how to use Google's Restore contacts feature in case something goes wrong, but this should work simply enough. Also, I just selected all the cells in the Notes column and cleared all their data, but if you have any notes saved for any of your contacts, you'll want to scroll through the spreadsheet file and be sure you only delete cells with HTC data.
I hope this helps!
---------- Post added at 01:09 AM ---------- Previous post was at 12:52 AM ----------
You should also be aware that this method may cause you to lose your contacts photos, as well as any joined contacts you have in your Android address book. However, if you want to attach your contacts Facebook photos permanently to their Google contact entry (something HTC's method did not do), you should check out this tool; in just a couple clicks, you can have all those photos matched up again and restored:
[I can't post links yet, but just Google "Facebook Google Contact Sync" and click on the first return. It is a great little tool made by a dev called "Heart of Angel."]
mredmond2012 said:
I was trying to figure out this very same thing and came across this thread in my searching. I also don't look Outlook, but I found a really simple, quick, and effective way to manually get rid of all those pesky HTC notes in under five minutes, for those that don't use Outlook:
1) Go into the contacts view in Gmail
2) Click the "More" dropdown box and select "Export"
3) Ensure that the "All Contacts" option is selected, choose the "Outlook CSV format," and export
4) After the file downloads, open it up in Excel (or your choice spreadsheet program)
5) Find the column labeled "Notes," and then just scroll down and clear all the cells with HTC data in them
6) Save the file, ensuring it is still in CSV format
7) Back in your Google Contact Manager, delete all your contacts
NOTE: Before deleting your contacts you will want to export a Google CSV file of all your contacts for backup. You can also the "More > Restore" feature to go back to a previous point in time if something goes wrong.8) Import the CSV file you saved in step 6
That's it! Your contact book should be restored to the exact way it was, minus the obnoxious HTC data. With 1,000+ contacts, I was able to do this in about two minutes. Again, be sure you have backups of your contacts or know how to use Google's Restore contacts feature in case something goes wrong, but this should work simply enough. Also, I just selected all the cells in the Notes column and cleared all their data, but if you have any notes saved for any of your contacts, you'll want to scroll through the spreadsheet file and be sure you only delete cells with HTC data.
I hope this helps!
---------- Post added at 01:09 AM ---------- Previous post was at 12:52 AM ----------
You should also be aware that this method may cause you to lose your contacts photos, as well as any joined contacts you have in your Android address book. However, if you want to attach your contacts Facebook photos permanently to their Google contact entry (something HTC's method did not do), you should check out this tool; in just a couple clicks, you can have all those photos matched up again and restored:
[I can't post links yet, but just Google "Facebook Google Contact Sync" and click on the first return. It is a great little tool made by a dev called "Heart of Angel."]
Click to expand...
Click to collapse
In addition to the thanks button, I think you deserve a "thanks" post. This was so useful and in addition to removing that HTC garbage, I removed all the other data I found unnecessary.
Remove With a Simple Java Program, If you know Java
Ozark_8125 said:
Is there a way to easily remove the facebook tags on contacts in outlook? it's the stuff that says :
<HTCData><!-- Please do not modify -->
<Facebook>id:xxxxxx/friendof:xxxxxxxxxxx</Facebook>
</HTCData>
Thanks!
Click to expand...
Click to collapse
I know I am too late to reply this post but I actually searched a solution today and found this post where some one also had same issue.
Using gdata java api I wrote a small program to remove notes from all of your contacts. Maximum 800 (Congifurable) Here is the Java Program :
Code:
import java.net.URL;
import com.google.gdata.client.Query;
import com.google.gdata.client.contacts.ContactsService;
import com.google.gdata.data.PlainTextConstruct;
import com.google.gdata.data.TextContent;
import com.google.gdata.data.contacts.ContactEntry;
import com.google.gdata.data.contacts.ContactFeed;
/**
* This is a test template
*/
public class ContactNotesCleaner {
public static String feedUrlString = "https COLON SLASH SLASH www DOT google DOT com SLASH m8 SLASH feeds SLASH contacts SLASH default SLASH full";
public static void main(String[] args) throws Exception {
// Create a new Contacts service
ContactsService myService = new ContactsService(<Any App Name>);
myService.setUserCredentials(<Your Gmail Id>, <Your Password>);
updateAllContacts(myService);
}
public static void updateAllContacts(ContactsService myService) throws Exception {
URL feedUrl = new URL(feedUrlString);
Query myQuery = new Query(feedUrl);
myQuery.setMaxResults(800);
ContactFeed resultFeed = myService.query(myQuery, ContactFeed.class);
// Print the results
System.out.println(resultFeed.getTitle().getPlainText());
for (ContactEntry entry : resultFeed.getEntries()) {
if (entry.getContent() != null) {
updateNotesContent(myService, entry);
}
}
}
private static void updateNotesContent(ContactsService myService, ContactEntry entry) throws Exception {
TextContent textContent = (TextContent) entry.getContent();
if (textContent.getContent() != null) {
String plainText = textContent.getContent().getPlainText();
if (plainText != null && plainText.startsWith("<HTCData>")) {
String newPlainText = "";
textContent.setContent(new PlainTextConstruct(newPlainText.trim()));
entry.setContent(textContent);
URL editUrl = new URL(entry.getEditLink().getHref());
ContactEntry contactEntry = myService.update(editUrl, entry);
System.out.println(entry.getName().getFullName().getValue() + " " + "Updated: " + contactEntry.getUpdated().toString());
}
}
}
}
I have executed the above program and tested it. You need gdata lib files:
gdata-media-1.0.jar
gdata-client-meta-1.0.jar
gdata-contacts-3.0.jar
gdata-client-1.0.jar
gdata-contacts-meta-3.0.jar
gdata-core-1.0.jar
guava-14.0.1.jar
gdataplugin.jar -- I am not sure what this jar does, even if it is required or not.
This is a bit complex for some users to run a java program, this way you will not loose the chat invites and other important information of your contact.
Note: Even if I have tested above program 10 times, I would not give any guaranty it will work for you.
- CAM
cmehta82 said:
I know I am too late to reply this post but I actually searched a solution today and found this post where some one also had same issue.
Using gdata java api I wrote a small program to remove notes from all of your contacts. Maximum 800 (Congifurable) Here is the Java Program
Click to expand...
Click to collapse
Your Java program worked!
I attached all the required libraries in a .zip-file. Include them in your Java project and copy the code from cmehta82 post above.
Replace <Your Gmail Id> with your emailadress:
Replace <Your Password> with your application specific password, generated at https://accounts.google.com/b/0/IssuedAuthSubTokens#accesscodes
Replace the feed URL string with https://www.google.com/m8/feeds/contacts/default/full
Can't JOIN contacts if HTCData exists in notes field
I wrote up my solution to this problem a little bit here thanks to the this forum thread above.
http://androidforums.com/samsung-ga...tcdata-exists-in-notes-field.html#post5968115
Python script to remove HTCData
Used to be a HTC phone user and it really messed up my contacts with the XML data. I am using a Mac and have written a Python script to get rid of the HTCData tag.
I posted the script here: http://kongjinjie.wordpress.com/2013/10/29/remove-htcdata-from-apple-contacts/
I don't know if this works on other OS, only tested on my Mac. I hope it helps!
EDIT:
Do not use this for those who setup Sync to Google. After running this script, it doesn't seeem to initiate a sync to Google. Anyone knows how to force a sync to Google? Is there a timestamp I can change to identify the latest version?
cmehta82 said:
I know I am too late to reply this post but I actually searched a solution today and found this post where some one also had same issue.
Using gdata java api I wrote a small program to remove notes from all of your contacts. Maximum 800 (Congifurable) Here is the Java Program :
Code:
import java.net.URL;
import com.google.gdata.client.Query;
import com.google.gdata.client.contacts.ContactsService;
import com.google.gdata.data.PlainTextConstruct;
import com.google.gdata.data.TextContent;
import com.google.gdata.data.contacts.ContactEntry;
import com.google.gdata.data.contacts.ContactFeed;
/**
* This is a test template
*/
public class ContactNotesCleaner {
public static String feedUrlString = "https COLON SLASH SLASH www DOT google DOT com SLASH m8 SLASH feeds SLASH contacts SLASH default SLASH full";
public static void main(String[] args) throws Exception {
// Create a new Contacts service
ContactsService myService = new ContactsService(<Any App Name>);
myService.setUserCredentials(<Your Gmail Id>, <Your Password>);
updateAllContacts(myService);
}
public static void updateAllContacts(ContactsService myService) throws Exception {
URL feedUrl = new URL(feedUrlString);
Query myQuery = new Query(feedUrl);
myQuery.setMaxResults(800);
ContactFeed resultFeed = myService.query(myQuery, ContactFeed.class);
// Print the results
System.out.println(resultFeed.getTitle().getPlainText());
for (ContactEntry entry : resultFeed.getEntries()) {
if (entry.getContent() != null) {
updateNotesContent(myService, entry);
}
}
}
private static void updateNotesContent(ContactsService myService, ContactEntry entry) throws Exception {
TextContent textContent = (TextContent) entry.getContent();
if (textContent.getContent() != null) {
String plainText = textContent.getContent().getPlainText();
if (plainText != null && plainText.startsWith("<HTCData>")) {
String newPlainText = "";
textContent.setContent(new PlainTextConstruct(newPlainText.trim()));
entry.setContent(textContent);
URL editUrl = new URL(entry.getEditLink().getHref());
ContactEntry contactEntry = myService.update(editUrl, entry);
System.out.println(entry.getName().getFullName().getValue() + " " + "Updated: " + contactEntry.getUpdated().toString());
}
}
}
}
I have executed the above program and tested it. You need gdata lib files:
gdata-media-1.0.jar
gdata-client-meta-1.0.jar
gdata-contacts-3.0.jar
gdata-client-1.0.jar
gdata-contacts-meta-3.0.jar
gdata-core-1.0.jar
guava-14.0.1.jar
gdataplugin.jar -- I am not sure what this jar does, even if it is required or not.
This is a bit complex for some users to run a java program, this way you will not loose the chat invites and other important information of your contact.
Note: Even if I have tested above program 10 times, I would not give any guaranty it will work for you.
- CAM
Click to expand...
Click to collapse
P1nGu1n_ said:
Your Java program worked!
I attached all the required libraries in a .zip-file. Include them in your Java project and copy the code from cmehta82 post above.
Replace <Your Gmail Id> with your emailadress:
Replace <Your Password> with your application specific password, generated at https://accounts.google.com/b/0/IssuedAuthSubTokens#accesscodes
Replace the feed URL string with https://www.google.com/m8/feeds/contacts/default/full
Click to expand...
Click to collapse
Where do you configure the app name and password?>
ginorp said:
I just sat down on my break and created this code to strip out the HTC tags from the contact notes:
Code:
Sub HTCbGone()
Dim objContactsFolder As Outlook.MAPIFolder
Dim objContacts As Outlook.Items
Dim objContact As Object
Dim StartPos As Integer
Dim EndPos As Integer
Dim iCount As Integer
' Specify with which contact folder to work
Set objContactsFolder = _
Session.GetDefaultFolder(olFolderContacts)
Set objContacts = objContactsFolder.Items
iCount = 0
' Process the changes
For Each objContact In objContacts
If TypeName(objContact) = "ContactItem" Then
StartPos = InStr(objContact.Body, "<HTCData>")
EndPos = InStr(objContact.Body, "</HTCData>") + 10
If StartPos > 0 Then
If StartPos = 1 Then
If Len(EndPos) > EndPos + 1 Then
objContact.Body = Mid(objContact.Body, EndPos + 1)
Else
objContact.Body = ""
End If
Else
If Len(EndPos) > EndPos + 1 Then
objContact.Body = Left(objContact.Body, StartPos = 1)
Else
objContact.Body = Left(objContact.Body, StartPos - 1) & Mid(objContact.Body, EndPos + 1)
End If
End If
iCount = iCount + 1
objContact.Save
End If
End If
Next
' Display the results
MsgBox "Number of contacts updated:" & Str$(iCount), , _
"HTCbGone Finished"
' Clean up
Set objContact = Nothing
Set objContacts = Nothing
Set objContactsFolder = Nothing
End Sub
To run this, I opened Outlook. Selected Macro(s) from the Tools pull-down menu (or press [ALT+F8]). Created a new Macro called HTCbGone and pasted this code over everything. Then I just ran it.
Use at your own risk.
Happy scripting,
GinoRP
Click to expand...
Click to collapse
Sorry for this reply in this old thread, but you might lose data running the VBA code from GinoRP. I found a lot of small mistakes.
Here is the corrected code. You can run it multiple times if there is more than one <HTCData> tag in a specific contact.
Code:
Sub HTCbGone()
Dim objContactsFolder As Outlook.MAPIFolder
Dim objContacts As Outlook.Items
Dim objContact As Object
Dim StartPos As Integer
Dim EndPos As Integer
Dim iCount As Integer
' Specify with which contact folder to work
Set objContactsFolder = _
Session.GetDefaultFolder(olFolderContacts)
Set objContacts = objContactsFolder.Items
iCount = 0
' Process the changes
For Each objContact In objContacts
If TypeName(objContact) = "ContactItem" Then
StartPos = InStr(objContact.Body, "<HTCData>")
EndPos = InStr(objContact.Body, "</HTCData>") + 10
If StartPos > 0 Then
If StartPos = 1 Then
If Len(objContact.Body) > EndPos + 1 Then
objContact.Body = Mid(objContact.Body, EndPos)
Else
objContact.Body = ""
End If
Else
If Len(objContact.Body) = EndPos - 1 Then
objContact.Body = Left(objContact.Body, StartPos - 1)
Else
objContact.Body = Left(objContact.Body, StartPos - 1) & Mid(objContact.Body, EndPos)
End If
End If
iCount = iCount + 1
objContact.Save
End If
End If
Next
' Display the results
MsgBox "Number of contacts updated:" & Str$(iCount), , _
"HTCbGone Finished"
' Clean up
Set objContact = Nothing
Set objContacts = Nothing
Set objContactsFolder = Nothing
End Sub
I have developped 2 Android applications. The first one, to write into an NFC tag, and the second to read the contents I have written .
This is what i did in the first application (WriteNFC)
private NdefRecord createRecord1(String data)
{
byte[] payload = data.getBytes(Charset.forName("UTF-8"));
byte[] empty = new byte[] {};
return new NdefRecord(NdefRecord.TNF_ABSOLUTE_URI, empty, empty, payload);
}
private NdefRecord createRecord2(String data)
{
byte[] payload = data.getBytes(Charset.forName("UTF-8"));
byte[] empty = new byte[] {};
return new NdefRecord(NdefRecord.TNF_ABSOLUTE_URI, payload, empty, empty);
}
And for in the second application (ReadNFC)
NdefRecord cardRecord = msg.getRecords()[1];//Extract the second Record
String url_data = new String(cardRecord.getType());//Read data type
Result:
When I read with my own application (ReadNFC), of course I had on screen only the payload of the second Record, which I stored through "Record Type". But with a third-party application, especially that natively installed ("tag"), It display correctly the first record, and for the second it's an empty field. How can I hide this field. Otherwise, how can I force the other third-party applications to not read the second record?
Hi! I wanna run some tests and i need some registry values under
HKEY_LOCAL_MACHINE\System\Touch\Buttons
What i need is the keys and the values(better if the device is 4.7" or more)
Thanks
content of "Buttons" from 950XL
"0" key
String = Name, Value = Back
Integer = VKey, Value = 27
"1" key
String = Name, Value = Start
Integer = VKey, Value = 113
"2" key
String = Name, Value = Search
Integer = VKey, Value = 114
Integer = Count, Value = 3
Integer = Duration, Value = 20
Integer = Intensity, Value = 100
Integer = Vibrate, Value = 1
For 640xl.,
All the values are same...except,
Duration(value=41)
Intensity(value=99)
previously i disabled vibration for navigation keys under touch and gestures settings so,
Vibrate(value=0)
dxdy said:
content of "Buttons" from 950XL
"0" key
String = Name, Value = Back
Integer = VKey, Value = 27
"1" key
String = Name, Value = Start
Integer = VKey, Value = 113
"2" key
String = Name, Value = Search
Integer = VKey, Value = 114
Integer = Count, Value = 3
Integer = Duration, Value = 20
Integer = Intensity, Value = 100
Integer = Vibrate, Value = 1
Click to expand...
Click to collapse
Sai Chrisna said:
For 640xl.,
All the values are same...except,
Duration(value=41)
Intensity(value=99)
previously i disabled vibration for navigation keys under touch and gestures settings so,
Vibrate(value=0)
Click to expand...
Click to collapse
Intensity around 50 saves some battery