[Request] Chinese sort&search in contacts&dial up - Nexus One General

for us use chinese, is there anybody can help to fix to sort&search Chinese in contacts&dial up on Nexus one or Android 2.1 ?
HTC, can search contact when input number in dial up. CM Rom can not .

http://www.androidin.net/bbs/thread-49607-1-1.html

http://www.androidin.net/bbs/viewthread.php?tid=46916&highlight=

yungjoe said:
http://www.androidin.net/bbs/viewthread.php?tid=46916&highlight=
Click to expand...
Click to collapse
thanks a lot. and i made this post, not perfect ^_^
http://www.androidin.net/bbs/thread-49607-1-1.html
but i meet some problem that i can not search chiese name by english alphabet. HTC Hero's contacts is good, any one ported ?

*** link deleted ***

hengsin said:
http://www.tigersw.cn/soft15633.html
Click to expand...
Click to collapse
please remove the link or prepared to be banned

Sorry to go off-topic, but why will he be banned because of the link? Non-English?

by replace the libsqlite.so libcudata.so can display sorted chinese contact .
below is the way to add function search by name, but it is for android 1.6. I found the contacts.db is different from Android 2.1.
no "pepole persons contact_methods" tables
only "contacts name_lookup phone_lookup"
i did not understand the co-relation beside these tables, some guy can help to change below scripts on Android 2.1 ??
Thanks very much.
Android 2.1 contacts2.db
PHP:
sqlite> .tables
.tables
_sync_state status_updates
_sync_state_metadata v1_settings
activities view_contacts
agg_exceptions view_contacts_restricted
android_metadata view_data
calls view_data_restricted
contact_entities_view view_groups
contact_entities_view_restricted view_raw_contacts
contacts view_raw_contacts_restricted
data view_v1_contact_methods
groups view_v1_extensions
mimetypes view_v1_group_membership
name_lookup view_v1_groups
nickname_lookup view_v1_organizations
packages view_v1_people
phone_lookup view_v1_phones
raw_contacts view_v1_photos
settings
sqlite> .schema contacts
.schema contacts
CREATE TABLE contacts (_id INTEGER PRIMARY KEY AUTOINCREMENT,display_name TEXT,p
hoto_id INTEGER REFERENCES data(_id),custom_ringtone TEXT,send_to_voicemail INTE
GER NOT NULL DEFAULT 0,times_contacted INTEGER NOT NULL DEFAULT 0,last_time_cont
acted INTEGER,starred INTEGER NOT NULL DEFAULT 0,in_visible_group INTEGER NOT NU
LL DEFAULT 1,has_phone_number INTEGER NOT NULL DEFAULT 0,lookup TEXT,status_upda
te_id INTEGER REFERENCES data(_id),single_is_restricted INTEGER NOT NULL DEFAULT
0);
CREATE INDEX contacts_has_phone_index ON contacts (has_phone_number);
CREATE INDEX contacts_restricted_index ON contacts (single_is_restricted);
CREATE INDEX contacts_visible_index ON contacts (in_visible_group,display_name C
OLLATE LOCALIZED);
CREATE TRIGGER contacts_times_contacted UPDATE OF last_time_contacted ON contact
s BEGIN UPDATE contacts SET times_contacted = (new.times_contacted + 1) WHERE _i
d = new._id;END;
sqlite> .schema name_lookup
.schema name_lookup
CREATE TABLE name_lookup (data_id INTEGER REFERENCES data(_id) NOT NULL,raw_cont
act_id INTEGER REFERENCES raw_contacts(_id) NOT NULL,normalized_name TEXT NOT NU
LL,name_type INTEGER NOT NULL,PRIMARY KEY (data_id, normalized_name, name_type))
;
CREATE INDEX name_lookup_index ON name_lookup (normalized_name,name_type, raw_co
ntact_id);
CREATE INDEX name_lookup_raw_contact_id_index ON name_lookup (raw_contact_id);
sqlite> .schema phone_lookup
.schema phone_lookup
CREATE TABLE phone_lookup (data_id INTEGER PRIMARY KEY REFERENCES data(_id) NOT
NULL,raw_contact_id INTEGER REFERENCES raw_contacts(_id) NOT NULL,normalized_num
ber TEXT NOT NULL);
CREATE INDEX phone_lookup_index ON phone_lookup (normalized_number,raw_contact_i
d,data_id);
PHP:
echo 'Phase 1: Creating triggers...'
#Replace the offical trigger to index email address
sqlite3 contacts.db "DROP TRIGGER IF EXISTS peopleLookup_update;"
sqlite3 contacts.db \
"CREATE TRIGGER peopleLookup_update \
UPDATE OF name ON people \
BEGIN\
DELETE FROM peopleLookup WHERE source = new._id;\
SELECT _TOKENIZE('peopleLookup', new._id, new.name, ' ');\
SELECT _TOKENIZE('peopleLookup', new._id, data, '')\
FROM contact_methods\
WHERE person=new._id AND kind=1; \
END"
# Trig the peopleLookup_updats trigger
sqlite3 contacts.db "DROP TRIGGER IF EXISTS sunner_email_update;"
sqlite3 contacts.db \
"CREATE TRIGGER IF NOT EXISTS sunner_email_update \
AFTER UPDATE OF data ON contact_methods \
WHEN new.kind=1 \
BEGIN \
UPDATE people SET name=\`name\` WHERE _id=new.person; \
END"
sqlite3 contacts.db \
"CREATE TRIGGER IF NOT EXISTS sunner_email_insert \
AFTER INSERT ON contact_methods \
WHEN new.kind=1 \
BEGIN \
SELECT _TOKENIZE('peopleLookup', new.person, new.data, ''); \
END"

Related

Win32 Mode Failure to set text in static control

I have a problem in setting controls in a Win32 application.
When I use SendMessage to set a text string in a static control I get error number 120 which translated means: "This function is only valid in Win32 mode."
Here's the background:
I'm using Visual Studio 2005, I've installed the Windows Mobile 5 SDK.
The project was created using the New Project Wizard, with the following settings:
Visual C++/Smart Device
Win32 Smart Device Project
Platform SDK is: Windows Mobile 5.0 Pocket PC SDK
Windows application
I've added a dialog template resource and can bring up a dialog based on that resource. It contains a static control that I can read the text from, but attempting to set the text gives me the above error.
The relevent code (within the WM_INITDIALOG message handler) is:
Code:
char buffer[100];
HWND hCtrl = ::GetDlgItem(hDlg, IDC_TITLE);
LRESULT result = ::SendMessage(hCtrl, WM_GETTEXT, (WPARAM)80, (LPARAM)buffer);
This works, I get the correct text (ie the text I have placed into the static control using the dialog template editor) copied into the buffer. What follows is:
Code:
buffer[0] = 'A'; // Just to set up a different string
result = ::SendMessage(hCtrl, WM_SETTEXT, (WPARAM)0, (LPARAM)buffer);
if (result == 0)
{
LPVOID lpMsgBuf;
DWORD error = ::GetLastError();
::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, 0, (LPTSTR)&lpMsgBuf, 0, NULL);
::MessageBox(NULL, (LPCTSTR)lpMsgBuf, (LPCWSTR)"LError", MB_OK | MB_ICONINFORMATION);
::LocalFree(lpMsgBuf);
}
The attempt to set the changed text string fails (ie result == 0), and the last error is 120, which is translated to the error message above.
This works the same in both the Windows Mobile 5 emulator, and if I run it on my Atom.
What does this mean? How could it be anything other than Win32 mode?
Is there a function or something I have to call to put it into Win32 mode?
Or is it a project setting in VS2005 that I haven't been able to find?
I'd very much appreciate any help on this.
Peter
Your build target was a PPC 2003 variant for this project, correct? If so (and I'm assuming that it is so because you mention trying this on the PPC emulator), then you are most certainly not in Win32 mode, rather you are targeting WinCE. To target win32, you need to go into configuration manager and change your target at which point your program will no longer run on PPC.
More to your problem: I don't believe that you can dynamically change dialog static control properties through messaging on WinCE. I may be wrong on this here though too....

Assign a Software to HD2 Hardware Keys

Hey guys this is my first post
I think so long for use HD2 hardkeys and find a way that explain with XDA user "rezaulkabir" And I test that and make a little change to assign voice Speed dialer to send key (Green Button) So do following :
Go to registry: you can ues resco explorer or other soft
HKLM\Software\Microsoft\Shell\
Create a new Key and named that "Keys"
Inside "Keys" create another Key named that "40C6"
Inside "40C6" create following Registry values:
1. String Value : Name= Name , value= Send key(Hold)
2. String Value : Name= Icon , value= \windows\SendKeyIcon.exe, 0
3. DWORD Value : Name= Flags , value= 0
4. String Value : Name= default , value=\windows\sddialer.exe (Or other exe files)
Now restart.
for other software you can find EXE file in windows folder and in 4 step write that.
test it and tel me how it work.

[Q] Databases again

Currently i can create a database with following lines:
Code:
final String MY_DB_NAME = "Test";
final String MY_DB_TABLE = "Autos";
SQLiteDatabase myDB = null;
myDB = this.openOrCreateDatabase(MY_DB_NAME, MODE_PRIVATE, null);
myDB.execSQL("CREATE TABLE IF NOT EXISTS " + MY_DB_TABLE + " (_id integer primary key autoincrement, name varchar(100), pos int(4))");
myDB.execSQL("INSERT INTO " + MY_DB_TABLE + " (name)" + " VALUES ('Audi TT')");
myDB.execSQL("INSERT INTO " + MY_DB_TABLE + " (name)" + " VALUES ('Honda Civic');");
Now this creates only name.
But i need to add a value too, what must i change to make it possible?
The table only has 3 fields..the autoincrement _id field which the database handles.
Then you have name and pos.
Not sure what you want to do, but to insert data to both columns, it's:
insert into autos ("name", "pos") values ("Chevy Camaro", 1);
If you need more information, you'll have to recreate (or alter) the table to add columns.
Currently i can create a database with the following lines:
Code:
private void onCreateDB () {
final String MY_DB_NAME = "settings";
SQLiteDatabase myDB = this.openOrCreateDatabase(MY_DB_NAME, MODE_PRIVATE, null);
Toast.makeText(set.this, "PATH: " + myDB.getPath(), Toast.LENGTH_SHORT).show();
myDB.execSQL("CREATE TABLE IF NOT EXISTS system (_id integer primary key autoincrement, name varchar(100), value int(4))");
myDB.execSQL("INSERT INTO system (name, value)" + " VALUES ('wifi_http_proxy', 'proxy')");
myDB.execSQL("INSERT INTO system (name, value)" + " VALUES ('wifi_http_port', '3128');");
myDB.close();
}
now, i must replace the entry by the name, not by the id. how can i do it?
ilendemli said:
Currently i can create a database with the following lines:
Code:
private void onCreateDB () {
final String MY_DB_NAME = "settings";
SQLiteDatabase myDB = this.openOrCreateDatabase(MY_DB_NAME, MODE_PRIVATE, null);
Toast.makeText(set.this, "PATH: " + myDB.getPath(), Toast.LENGTH_SHORT).show();
myDB.execSQL("CREATE TABLE IF NOT EXISTS system (_id integer primary key autoincrement, name varchar(100), value int(4))");
myDB.execSQL("INSERT INTO system (name, value)" + " VALUES ('wifi_http_proxy', 'proxy')");
myDB.execSQL("INSERT INTO system (name, value)" + " VALUES ('wifi_http_port', '3128');");
myDB.close();
}
now, i must replace the entry by the name, not by the id. how can i do it?
Click to expand...
Click to collapse
UPDATE system SET value = XX WHERE name = 'xxxx'
Do some googling for SQL. There is TONS of help for SQL out there, and it sounds like your problem isn't Android, it's SQL. There's some great learning resources out there.
i already got it, thx anyways.

Single quote in database

Can't get rid of this error:
android.database.sqlite.SQLiteException: near "s": syntax error: , while compiling:
Select correct from answers where correct = 'Between the airplane's climb angle and the horizon.'
Obviously, it's finding the single quote in ( airplane's ) and considering that the end of the statement.
I've tried:
correct.replaceAll(" ' ", " ''' "); //replace 1 with 3
correct.replaceAll(" ' ", " '' "); // replace 1 with 2
correct.replaceAll(" ' ", " "); // replace 1 with space
(NOTE: the spaces are NOT in the code, I just did that to make it readable)
I have no idea what's going on, IMO, it should work. Maybe I need to try:
String single = "'"; // single '
String double = "''" // double ''
correct.replaceAll(single, double); // ????
Everything I"ve read about sqlite3 is to replace one with two....
TIA,
Roots
\'
\ is the escape character for most languages
so airplane's would be airplane\'s
Also, are you binding your queries with the "question mark" bind?
I'll try the escape and post back later. There are 1,000 rows in the database and I"m pulling a random subset of that, so it's not that often I get one of those situations.
I'm not sure what you mean by "binding with ?" Isn't that what you use for bind variable unknown at runtime? I know my bind variables and just use it in my dbquery. Please enlighten me...always happy to learn something new
Sample code...answerOne would contain the single quote that's killing me
Code:
Cursor c;
c = myDataBase.rawQuery("Select correct from answers where correct = '" + answerOne + "'", null);
if(c.moveToFirst())
answer = "1";
c.close();
binding with question marks should take care of escaping for you.
Basically the question mark is a place holder for a variable in the query.
What you are doing is manually creating the query string. This is considered bad practice these days especially with regards to security. Mostly because it opens up the DB to a SQL injection attack.
So instead of using the rawQuery just use query and you can put a ? in and android will substitute the value for you, all properly escaped:
Code:
String tableName = "answers";
String selectArgs = "correct=[COLOR="Red"]?[/COLOR]";
// if answerOne is string dont need String.valueOf
String[] selectVals = { String.valueOf ( answerOne ) };
String[] columnsProjection= new String[] {"correct" };
Cursor c = db.query(tableName, columnsProjection, selectArgs,selectVals,null);
So in that code the OS will replace the ? in selectArgs with the values in selectVals
This may seem like more writing at first but once you get in the habit it will be easy, reliable and more secure. It also allows you to bind multiple variables to mutiple question marks. It just binds then in the order it gets them.
so something like this:
Code:
String answerOne= "one";
String selectArgs = "correct=? AND age=? AND smiling=?";
String[] selectVals = { answerOne, "21", "yes" };
Ok, I'll try it. There are about 50 different queries in this program...for some reason I just decided to do a rawQuery on this one. I'll change it to "db.query(table name, new String[] {}....yada, yada).
Because, it just crashed and I decided to come back here and check for a solution.
Thank you very much!!!
Roots
Glad to be of help, just remember to hit the thanks booton ya Rooster
Still getting the error
Example: column is in table as text. Say it's equal to:
The driver's last name
Error comes back as "syntax error near 's' when compiling select correct from answers where correct = 'The driver's last name'
That single quote in driver's is killing my SQL.

Rpi test jpg image and automatically deleting files from the sd card

HI, I want to use the RPi as part of a home security system, basically to send me email alerts with jpg images triggered by a PIR sensor.
I have 3 questions:
1. I know how to take a test jpg image using
Code:
raspistill -o testshot.jpg
But can you tell me how to view these test images?
2. will the following piece of code delete all jpg images from the RPI sd card?
Code:
rm *.jpg
3. When the PIR triggers an email alert and emails the jpg images, could a line of code be inserted into the following python script to automatically delete the images after they have been emailed, so as to avoid a large accumulation of images on the sd card?
This is the python script, which I think I got from: https://circuitdigest.com/microcontroller-projects/raspberry-pi-iot-intruder-alert-system
Code:
#!/usr/bin/env python3
import RPi.GPIO as gpio
import picamera
import time
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEBase import MIMEBase
from email import encoders
from email.mime.image import MIMEImage
fromaddr = "email_address " # change the email address accordingly
toaddr = "other_email_address " # change the email address accordingly
mail = MIMEMultipart()
mail['From'] = fromaddr
mail['To'] = toaddr
mail['Subject'] = "Attachment"
body = "Please find the attachment"
led=17
pir=18
HIGH=1
LOW=0
gpio.setwarnings(False)
gpio.setmode(gpio.BCM)
gpio.setup(led, gpio.OUT) # initialize GPIO Pin as outputs
gpio.setup(pir, gpio.IN) # initialize GPIO Pin as input
data=""
def sendMail(data):
mail.attach(MIMEText(body, 'plain'))
print data
dat='%s.jpg'%data
print dat
attachment = open(dat, 'rb')
image=MIMEImage(attachment.read())
attachment.close()
mail.attach(image)
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(fromaddr, "*********")
text = mail.as_string()
server.sendmail(fromaddr, toaddr, text)
server.quit()
def capture_image():
data= time.strftime("%d_%b_%Y|%H:%M:%S")
camera.start_preview()
time.sleep(5)
print data
camera.capture('%s.jpg'%data)
camera.stop_preview()
time.sleep(1)
sendMail(data)
gpio.output(led , 0)
camera = picamera.PiCamera()
camera.rotation=180
camera.awb_mode= 'auto'
camera.brightness=55
while 1:
if gpio.input(pir)==1:
gpio.output(led, HIGH)
capture_image()
while(gpio.input(pir)==1):
time.sleep(1)
else:
gpio.output(led, LOW)
time.sleep(0.01)
Thanks

Categories

Resources