customizing XDA's today screen - MDA, XDA, 1010 General

Is it possible to customize the XDA's today screen (i.e. by using XML) as you can do with the Orange's SPV ?

Download Microsoft's Theme Generator...
http://www.microsoft.com/mobile/pocketpc/downloads/powertoys.asp
There are some other goodies on that page aswell.
Good luck!

Powertoy is not what I am looking for: the idea is not only changing the background image but to organize all the datas on the screen as and where you wish (date, time, numbers of emails received, fonts, etc.) as you can do on smarphone 2002 changing the today screen's script in XML.
For examples what you can do with Smartphone 2002:
http://www.smartphony.org/stories.php?topic=32

It's a bit more complicated with PPC 2002. Unlike smartphone, it is an API to change the contents of 'Today'. Each line is loaded as a type of 'snap in' dll.

Do you I could find some examples of that kind of work ?

It is really a pain in the ass
But this works fine... 8)
#include "stdafx.h"
#include <todaycmn.h>
#define IDI_ICON1 101
HINSTANCE Instance;
BOOL Refresh;
HICON hIcon;
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
PAINTSTRUCT ps;
RECT rect;
switch (msg) {
case WM_TODAYCUSTOM_CLEARCACHE:
break;
case WM_TODAYCUSTOM_QUERYREFRESHCACHE:
if (Refresh) {
Refresh = FALSE;
((TODAYLISTITEM *)(wparam))->cyp = 20;
return TRUE;
} else {
return FALSE;
}
case WM_ERASEBKGND:
{
TODAYDRAWWATERMARKINFO dwi;
dwi.hwnd = hwnd;
dwi.hdc = (HDC)wparam;
GetClientRect(hwnd, &(dwi.rc));
SendMessage(GetParent(hwnd), TODAYM_DRAWWATERMARK, 0, (LPARAM)&dwi);
return 1;
}
case WM_PAINT:
BeginPaint(hwnd, &ps);
GetWindowRect(hwnd, &rect);
SetBkMode(ps.hdc, TRANSPARENT);
hIcon = (HICON)LoadImage(Instance,MAKEINTRESOURCE(IDI_ICON1),IMAGE_ICON,16,16,LR_DEFAULTCOLOR );
DrawIcon(ps.hdc, 2, 0, hIcon);
DestroyIcon(hIcon);
LOGFONT lf;
HFONT hSysFont;
HFONT hFont, hFontOld;
hSysFont = (HFONT) GetStockObject(SYSTEM_FONT);
GetObject(hSysFont, sizeof(LOGFONT), &lf);
lf.lfWeight = FW_BOLD;
lf.lfHeight = (long) -((8.0 * (double)GetDeviceCaps(ps.hdc, LOGPIXELSY) / 72.0)+.5);
hFont = CreateFontIndirect(&lf);
hFontOld = (HFONT) SelectObject(ps.hdc, hFont);
SetTextColor(ps.hdc, SendMessage(GetParent(hwnd), TODAYM_GETCOLOR, (WPARAM)TODAYCOLOR_TEXT, NULL));
GetClientRect(hwnd, &rect);
DrawText(ps.hdc, TEXT("Text you want to enter"), -1, &rect, DT_LEFT | DT_TOP | DT_NOCLIP);
SelectObject(ps.hdc, hFontOld);
DeleteObject(hFont);
EndPaint(hwnd, &ps);
break;
case WM_LBUTTONUP:
// Whatever you want to occur when the button is pressed //
CreateProcess(TEXT("iexplore.exe"), NULL, NULL, NULL, FALSE, 0, NULL, NULL, NULL, NULL);
break;
default:
return DefWindowProc(hwnd, msg, wparam, lparam);
}
return 0;
}
HWND APIENTRY InitializeCustomItem(TODAYLISTITEM *tli, HWND parent)
{
if (!tli->fEnabled) {
return NULL;
}
Instance = tli->hinstDLL;
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = Instance;
wc.hIcon = 0;
wc.hCursor = 0;
wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND + 1;
wc.lpszMenuName = NULL;
wc.lpszClassName = TEXT("RegisterClassName");
UnregisterClass(TEXT("RegisterClassName"), Instance);
RegisterClass(&wc);
Refresh = TRUE;
return CreateWindow(TEXT("RegisterClassName"), TEXT("RegisterClassName"), WS_VISIBLE | WS_CHILD, CW_DEFAULT, CW_DEFAULT, 0, 0, parent, NULL, Instance, NULL);
}

Thank's !
Is there somewhere a technical documentation about that ?

Related

[APP]ReSense - Very small application to restart HTC Sense

Well I really was tired of manually restart HTC Sense when it dissorted the display (Start->Settings->Today->Items....) and here's my 5 minute solution.
Requires .NET 2.0 or above.
Place it anywhere on your Device an run it. A shortcut will be created automatically.
There is no GUI or anything else. It just restarts HTC Sense.
Download it below
If you plan to change or modify anything, just create a new .NET 2.0 console solution in Visual Studio. Here's the code:
Code:
using System;
using System.Text;
using System.Runtime.InteropServices;
using System.Threading;
using Microsoft.Win32;
namespace ReSense
{
class Program
{
[DllImport("coredll.dll")]
private static extern int SendMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
public const int HWND_BROADCAST = 0xffff;
public const int WM_WININICHANGE = 0x001A;
[DllImport("coredll.dll", EntryPoint = "SHCreateShortcut", SetLastError = true)]
public static extern bool SHCreateShortcut(string shortcut, string target);
[DllImport("coredll.dll", SetLastError = true, EntryPoint = "SHGetSpecialFolderPath")]
static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner, StringBuilder lpszPath, Folders nFolder, int fCreate);
const int MAX_PATH = 50;
public enum Folders
{
Programs = 2, // \Windows\Start Menu\Programs
Personal = 5, // \My Documents
Startup = 7, // \Windows\StartUp
Startmenu = 0x0B, // \Windows\Start Menu
Fonts = 0x14, // \Windows\Fonts
Favorites = 0x16, // \Windows\Favorites
Program_Files = 0x26 // \Program Files
}
public static void waitSec(int sec)
{
for (int i = 0; i < sec * 10; i++)
{
Thread.Sleep(100);
}
}
public static string GetFolderPath(Folders folder)
{
StringBuilder sPath = new StringBuilder(' ', MAX_PATH);
bool bRet;
bRet = SHGetSpecialFolderPath(IntPtr.Zero, sPath, folder, 0);
return sPath.ToString();
}
static void Main(string[] args)
{
String appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
String appName = System.IO.Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
String app = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
String lnkPath = GetFolderPath(Folders.Programs);
SHCreateShortcut(lnkPath + "\\ReSense.lnk", "\"" + app + "\"");
// This refreshes the today screen
SendMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
RegistryKey ik = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Today\\Items\\HTC Sense", true);
ik.SetValue("Enabled", 0);
ik.Close();
// This refreshes the today screen
SendMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
waitSec(5);
ik = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Today\\Items\\HTC Sense", true);
ik.SetValue("Enabled", 1);
ik.Close();
// This refreshes the today screen
SendMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
}
}
}
tks man,the app is very useful!
Sense is frozen, does ReSense only work when Sense is working?
Does this work on the HD2? I have installed and tried it but my Sense will not restart. Also, do you know of a way to restart Sense when it is frozen? That is the only reason I needed this app.

[Q] :How to use list view for Map

Hi,
I am developing an android app in which i am using csv file and displaying column contents as listview its displaying as [a,b,c,d] in single row how to display them in individual row in listview.Please any one help me how to achive this.
This is my csv file reading code using hashcode.
Code:
public static Map<String,ArrayList<String>> parseCsv(InputStreamReader reader, String separator, boolean hasHeader) throws IOException {
Map<String,ArrayList<String> > values = new LinkedHashMap<String,ArrayList<String>>();
List<String> columnNames = new LinkedList<String>();
BufferedReader br = null;
br = new BufferedReader(reader);
String line;
int numLines = 0;
while ((line = br.readLine()) != null) {
//if (StringUtils.isNotBlank(line)) {
//if (!line.startsWith("#")) {
String[] tokens = line.split(separator);
if (tokens != null) {
for (int i = 0; i < tokens.length; ++i) {
if (numLines == 0) {
columnNames.add(hasHeader ? tokens[i] : ("row_"+i));
} else {
ArrayList<String> column = values.get(columnNames.get(i));
if (column == null) {
column = new ArrayList<String>();
}
column.add(tokens[i]);
values.put(columnNames.get(i), column);
}
}
}
++numLines;
}
// }//
// }//
return values;
listview code is:
Code:
oslist.add(values);
ListView list = (ListView) findViewById(R.id.studentnames);
String name="name";
// Add it listview
ListAdapter adapter = new SimpleAdapter(this,
oslist, R.layout.student_list, new String[] { name }, new int[] { R.id.name});
list.setAdapter(adapter);

[Q] Draw Objects on Screen

I'm starting to build an app that needs 2D drawing on Android Studio and even after some search I still have some troubles understanding some things. My intention is to draw Balls as objects, so that I can specify its radius and locations to draw. That ball should be a filled circle.
So here are my questions:
1. How to create the ball class in the most organized way? (Its constructors, methods, and stuff like that)​1. Where to call that class to create balls?(what should I do on the onCreate() method? My coding should go in my MainActivity class?)​1. How to draw them by a timer?(create a ball with a random radius and position and draw it on screen)​1. Where to draw them? (container)​
I saw a lot of things using canvas, the mysterious onDraw() method and I didn't get much of it.
I didn't understand how to control when to draw it.
I used this code for leaning and kinda control the drawing of objects , but It seems too messy and dont feel right.
Its a sensor controlled ball.
Bubbleview.java
Code:
public class BubbleView extends View
{
private int diametro;
private int x;
private int y;
private int Xt;
private int Yt;
private ShapeDrawable bubble;
private ShapeDrawable rect;
private boolean isTouch = false;
private int width;
private int height;
private WindowManager wm;
private Display display;
private Point size;
private Point centroBola;
private Point centroRet;
//private Color Retcor;
//private Color Bolacor;
public BubbleView(Context context)
{
super(context);
/*--Instancias--*/
bubble = new ShapeDrawable(new OvalShape());
rect = new ShapeDrawable(new RectShape());
size = new Point();
//Retcor = new Color();
//Bolacor = new Color();
createBubble();
}
private void createBubble()
{
wm = (WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE);
display = wm.getDefaultDisplay();
display.getSize(size);
width = (size.x);
height = (size.y);
x = width/2;
y = height/2;
//centroBola.set(x+(diametro/2),y-(diametro/2));
diametro = 100;
bubble.setBounds(x-diametro,y-diametro, x + diametro, y + diametro);
rect.setBounds(0, 10, size.x-1,80);
bubble.getPaint().setColor(0xff74AC23);
//rect.getPaint().setColor(0xff74AC23);//0xffEE4400
}
protected void move(float f, float g)
{
if (isTouch)
{
x = Xt;
y = Yt;
}
else
{
if (bubble.getBounds().right > width)
{
x=width-diametro-1;
y = (int) (y + g);
}
if (bubble.getBounds().left < 0)
{
x = 0;
y = (int) (y + g);
}
if (bubble.getBounds().top < 0)
{
x = (int) (x - f);
y = 1;
}
if (bubble.getBounds().bottom > height) {
x = (int) (x - f);
y = height - diametro -1;
}
x = (int) (x - f);
y = (int) (y + g);
}
//rect.setBounds(x+40, y+40, x + diametro, y + diametro);
bubble.setBounds(x,y,x +diametro,y+diametro);
}
@Override
public boolean onTouchEvent(MotionEvent event)
{
Xt = (int) event.getX();
Yt = (int) event.getY();
int evento = event.getAction();
switch (evento)
{
case MotionEvent.ACTION_DOWN:
bubble.setBounds(0, 0, Xt + diametro,Yt+ diametro);
//rect.setBounds(Xt, Yt, Xt + diametro,Yt+ diametro);
//coords.setText("X: " + X + ", Y: " + Y);
isTouch = true;
break;
case MotionEvent.ACTION_MOVE:
//coords.setText("X: " + X + ", Y: " + Y);
break;
case MotionEvent.ACTION_UP:
//Toast.makeText(this, "Saiu da tela em: X: " + X + ", Y: " + Y, Toast.LENGTH_SHORT);
isTouch = false;
break;
}
return true;
}
protected void onDraw(Canvas canvas)
{
super.onDraw(canvas);
//rect.draw(canvas);
bubble.draw(canvas);
}
}
So I tried to build my app using this as a reference, but no success.
Wich way should the code becomes more intuitive?
thx in advance

Kernel Sysfs Param Storage function - Get calling parameter

So, I hate to ask because I'm sure this is really simple...
I have this function that is storing a sysfs value. To save space, I have 4 different parameters sharing the function as it's basically the same function for each. I'd like to check which parameter is calling the function so that I can perform some checks depending on the parameter (ie, that each is in a logical order compared to it's neighboring values). How would I get the name of parameter that called it?
https://gist.github.com/yoinx/6a3ff00945f3ec1db230
embedded to avoid the link:
Code:
/* Frequency limit storage */
static int set_freq_limit(const char *val, const struct kernel_param *kp)
{
int ret = 0;
int i, cnt;
int valid = 0;
struct cpufreq_policy *policy;
static struct cpufreq_frequency_table *tbl = NULL;
ret = kstrtouint(val, 10, &i);
if (ret)
return -EINVAL;
policy = cpufreq_cpu_get(0);
tbl = cpufreq_frequency_get_table(0);
for (cnt = 0; (tbl[cnt].frequency != CPUFREQ_TABLE_END); cnt++) {
if (cnt > 0)
if (tbl[cnt].frequency == i)
valid = 1;
}
if (!valid)
return -EINVAL;
ret = param_set_int(val, kp);
return ret;
}
static struct kernel_param_ops freq_limit_ops = {
.set = set_freq_limit,
.get = param_get_int,
};
module_param_cb(freq_hell, &freq_limit_ops, &FREQ_HELL, 0644);
module_param_cb(freq_very_hot, &freq_limit_ops, &FREQ_VERY_HOT, 0644);
module_param_cb(freq_hot, &freq_limit_ops, &FREQ_HOT, 0644);
module_param_cb(freq_warm, &freq_limit_ops, &FREQ_WARM, 0644);
I could go even more sloppy and just duplicate this function repeatedly... But I'd rather not.
I thought kp would hold the kernel parameter... but it's a structure, not a variable... So I'm not positive what value in the structure would hold the name.
Thanks for the help.
Edit:
Would it be kp->name?
Ok, so not sure why it wouldn't work for me the other day... Which is what lead me to this post.
It was indeed kp->name, like I expected it to be. When I was trying to test it in a printk, it was causing a kernel panic though. Whatever, it worked now.
It prints out as module.param, just in case this helps anyone in the future.
*Edit*
Here's how I ended up doing this. Again, in case it helps anyone in the future.
Code:
/* Frequency limit storage */
static int set_freq_limit(const char *val, const struct kernel_param *kp)
{
int ret = 0;
int i, cnt;
int valid = 0;
struct cpufreq_policy *policy;
static struct cpufreq_frequency_table *tbl = NULL;
ret = kstrtouint(val, 10, &i);
if (ret)
return -EINVAL;
policy = cpufreq_cpu_get(0);
tbl = cpufreq_frequency_get_table(0);
for (cnt = 0; (tbl[cnt].frequency != CPUFREQ_TABLE_END); cnt++) {
if (cnt > 0)
if (tbl[cnt].frequency == i)
valid = 1;
}
if (!valid)
return -EINVAL;
/* Perform some sanity checks on the values that we're storing
* to make sure that they're scaling linearly */
if (strcmp( kp->name, "msm_thermal.freq_warm") == 0 && i <= FREQ_HOT)
return -EINVAL;
if ( strcmp( kp->name, "msm_thermal.freq_hot") == 0 && ( i >= FREQ_WARM || i <= FREQ_VERY_HOT ))
return -EINVAL;
if ( strcmp( kp->name, "msm_thermal.freq_very_hot") == 0 && ( i >= FREQ_HOT || i <= FREQ_HELL ))
return -EINVAL;
if ( strcmp( kp->name, "msm_thermal.freq_hell") == 0 && i >= FREQ_VERY_HOT )
return -EINVAL;
/* End Sanity Checks */
ret = param_set_int(val, kp);
return ret;
}
static struct kernel_param_ops freq_limit_ops = {
.set = set_freq_limit,
.get = param_get_int,
};
module_param_cb(freq_hell, &freq_limit_ops, &FREQ_HELL, 0644);
module_param_cb(freq_very_hot, &freq_limit_ops, &FREQ_VERY_HOT, 0644);
module_param_cb(freq_hot, &freq_limit_ops, &FREQ_HOT, 0644);
module_param_cb(freq_warm, &freq_limit_ops, &FREQ_WARM, 0644);

How to support icons in FileDialog

So i found this perfect code to be able to select zip from sd, but the list looks so basic and I would like to add icons (like one common icon for all dirs), however it seems too hard to do on my own, here is the code:
Code:
private void loadFileList(File path) {
this.currentPath = path;
List<String> r = new ArrayList<String>();
if (path.exists()) {
if (path.getParentFile() != null) r.add(PARENT_DIR);
FilenameFilter filter = new FilenameFilter() {
@SuppressLint("DefaultLocale")
public boolean accept(File dir, String filename) {
File sel = new File(dir, filename);
if (!sel.canRead()) return false;
if (selectDirectoryOption) return sel.isDirectory();
else {
boolean endsWith = fileEndsWith != null ? filename.toLowerCase().endsWith(fileEndsWith) : true;
return endsWith || sel.isDirectory();
}
}
};
String[] fileList1 = path.list(filter);
for (String file : fileList1) {
r.add(file);
}
}
fileList = (String[]) r.toArray(new String[]{});
}

Categories

Resources