commit 9346ea10e5ddf79ca311eba1d890c983bd2decaf Author: Carlos Silva Date: Fri Apr 23 19:04:13 2010 +0100 Initial commit. It's version 1.3.1 Signed-off-by: Carlos Silva diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..207072c --- /dev/null +++ b/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8d94b88 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/gen diff --git a/.project b/.project new file mode 100644 index 0000000..00a4875 --- /dev/null +++ b/.project @@ -0,0 +1,33 @@ + + + DroidUptime + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/AndroidManifest.xml b/AndroidManifest.xml new file mode 100644 index 0000000..3a28a48 --- /dev/null +++ b/AndroidManifest.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bin/DroidUptime.apk b/bin/DroidUptime.apk new file mode 100644 index 0000000..8812124 Binary files /dev/null and b/bin/DroidUptime.apk differ diff --git a/bin/classes.dex b/bin/classes.dex new file mode 100644 index 0000000..16f696f Binary files /dev/null and b/bin/classes.dex differ diff --git a/bin/resources.ap_ b/bin/resources.ap_ new file mode 100644 index 0000000..6583d11 Binary files /dev/null and b/bin/resources.ap_ differ diff --git a/default.properties b/default.properties new file mode 100644 index 0000000..19c9665 --- /dev/null +++ b/default.properties @@ -0,0 +1,13 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "build.properties", and override values to adapt the script to your +# project structure. + +# Indicates whether an apk should be generated for each density. +split.density=false +# Project target. +target=android-4 diff --git a/libs/admob-sdk-android.jar b/libs/admob-sdk-android.jar new file mode 100644 index 0000000..e186671 Binary files /dev/null and b/libs/admob-sdk-android.jar differ diff --git a/res/drawable-mdpi/droiduptime.png b/res/drawable-mdpi/droiduptime.png new file mode 100644 index 0000000..dc9c6d0 Binary files /dev/null and b/res/drawable-mdpi/droiduptime.png differ diff --git a/res/drawable-mdpi/icon.png b/res/drawable-mdpi/icon.png new file mode 100644 index 0000000..7bd8ab8 Binary files /dev/null and b/res/drawable-mdpi/icon.png differ diff --git a/res/layout/about.xml b/res/layout/about.xml new file mode 100644 index 0000000..3b73273 --- /dev/null +++ b/res/layout/about.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/res/layout/main.xml b/res/layout/main.xml new file mode 100644 index 0000000..17a7e59 --- /dev/null +++ b/res/layout/main.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/values-en/strings.xml b/res/values-en/strings.xml new file mode 100644 index 0000000..0d86ba9 --- /dev/null +++ b/res/values-en/strings.xml @@ -0,0 +1,46 @@ + + + DroidUptime + DroidUptime application was developed by Carlos Silva and uses www.uptimeprj.com to commit the uptime information. If you liked this application, and if you want to, feel free to make a donation at www.r3pek.org or the Uptime Project website. Thanks. + Running + Stopped + Start + Stop + About + Setup + OK + Cancel + Service Status: + Uptime: + Last Update: + This application requires you to register at www.uptimeprj.com so you can keep track of your uptime. After you registered, come back here and fill in the username and password on the Setup Menu. + Haven't updated yet + months + days + hours + minutes and + seconds + Authentication + Username + Password + General + + 10 Minutes + 20 Minutes + 30 Minutes + 1 Hour + 2 Hours + + Update Interval + How often it will submit the uptime (requires restart of the service) + + 600 + 1200 + 1800 + 3600 + 7200 + + Please setup Username and Password + Hostname + Hostname to send to the Uptime Project + diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml new file mode 100644 index 0000000..cb2ebca --- /dev/null +++ b/res/values-es/strings.xml @@ -0,0 +1,46 @@ + + + DroidUptime + La aplicación DroidUptime fué desarrollada por Carlos Silva y usa www.uptimeprj.com para recojer la información de uptime. Si te gusta esta aplicación, y si te apetece puede enviar tu donativo para www.r3pek.org o all Uptime Project website. Gracias. + En ejecución + Parado + Empezar + Parar + Sobre + Configuración + Aceptar + Cancelar + Estado: + Tiempo actividad: + Ultima actualización: + Tienes que registrarte en www.uptimeprj.com para que puedas saber tu uptime. Después del registro coloca tus datos en el menu de configuración. + Sin actualizar + Meses + días + horas + minutos y + segundos + Autenticación + Usuário + Contraseña + General + + 10 Minutos + 20 Minutos + 30 Minutos + 1 Hora + 2 Horas + + Intervalo de actualización + A cada cuanto tiempo quieres que se actualice. (necesitas reiniciar el servicio) + + 600 + 1200 + 1800 + 3600 + 7200 + + Por favor configura el usuário y contraseña + Nombre del equipo + Nombre del equipo para Uptime Project + diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml new file mode 100644 index 0000000..5a7a445 --- /dev/null +++ b/res/values-pt/strings.xml @@ -0,0 +1,46 @@ + + + DroidUptime + A aplicação DroidUptime foi desenvolvida por Carlos Silva e usa o site www.uptimeprj.com para guardar a informação relativa ao uptime. Se gostou desta aplicação, e se quiser, faça um donativo em www.r3pek.org ou no site do Uptime Project. Obrigado. + A executar + Parado + Iniciar + Parar + Sobre + Configuração + OK + Cancelar + Estado do Serviço: + Uptime: + Última actualização: + Esta aplicação necessita que se registe em www.uptimeprj.com para que se possa guardar e para controlar o seu uptime. Após o registo, volte a esta aplicação e preencha o Utilizador e a Senha no menu Configuração. + Ainda não actualizado + meses + dias + horas + minutos e + segundos + Autenticação + Utilizador + Senha + Geral + + 10 Minutos + 20 Minutos + 30 Minutos + 1 Hora + 2 Horas + + Frequência das Actualizações + Frequência em que o uptime é submetido ao servidor (requer que se reinicie o serviço) + + 600 + 1200 + 1800 + 3600 + 7200 + + Insira o utilizador e a senha no menu configuração + Hostname + Hostname a reportar para o Uptime Project + diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml new file mode 100644 index 0000000..2268f8e --- /dev/null +++ b/res/values-zh-rCN/strings.xml @@ -0,0 +1,46 @@ + + + DroidUptime + DroidUptime 应用是由 Carlos Silva 根据 www.uptimeprj.com 的正常运行时间数据开发的。如果您喜欢这个应用请到 www.r3pek.org 或 Uptime 项目的主页捐助, 谢谢! + 运行中 + 已停止 + 开始 + 停止 + 关于 + 设置 + 确定 + 取消 + 服务状态: + 正常运行时间: + 最近更新: + 该应用需要注册, www.uptimeprj.com 这样您就可以跟踪您的正常运行时间。 注册完之后请回到这里并在设置菜单中填写用户名和密码。 + 还没有更新 + + + + 分和 + + 验证 + 用户名 + 密码 + 概况General + + 10 分钟 + 20 分钟 + 30 分钟 + 1 小时 + 2 小时 + + 更新间隔 + 多久提交更新 (需重启该服务) + + 600 + 1200 + 1800 + 3600 + 7200 + + 请设定用户名和密码 + 主机名 + 主机名发送到 Uptime 项目 + diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml new file mode 100644 index 0000000..4eb13eb --- /dev/null +++ b/res/values-zh-rTW/strings.xml @@ -0,0 +1,46 @@ + + + DroidUptime + DroidUptime 套用是由 Carlos Silva 依 www.uptimeprj.com 的正常執行時間資料開發的。如果您喜歡這個套用請到 www.r3pek.org 或 Uptime 項目的首頁捐助, 謝謝! + 執行中 + 已停止 + 開始 + 停止 + 關於 + 設定 + 確定 + 取消 + 服務狀態: + 正常執行時間: + 最近更新: + 該套用需要註冊, www.uptimeprj.com 這樣您就可以跟蹤您的正常執行時間。 註冊完之後請回到這裡並在設定功能表中填寫使用者名稱和密碼。 + 還沒有更新 + + + + 分和 + + 驗證 + 使用者名稱 + 密碼 + 概況General + + 10 分鐘 + 20 分鐘 + 30 分鐘 + 1 小時 + 2 小時 + + 更新間隔 + 多久提交更新 (需重啟該服務) + + 600 + 1200 + 1800 + 3600 + 7200 + + 請設定使用者名稱和密碼 + 主機名 + 主機名發送到 Uptime 項目 + diff --git a/res/values/attrs.xml b/res/values/attrs.xml new file mode 100644 index 0000000..406268d --- /dev/null +++ b/res/values/attrs.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml new file mode 100644 index 0000000..09da856 --- /dev/null +++ b/res/xml/preferences.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/src/org/r3pek/droiduptime/Base64.java b/src/org/r3pek/droiduptime/Base64.java new file mode 100644 index 0000000..2ee54a6 --- /dev/null +++ b/src/org/r3pek/droiduptime/Base64.java @@ -0,0 +1,575 @@ +package org.r3pek.droiduptime; + +import java.util.Arrays; + +/** A very fast and memory efficient class to encode and decode to and from BASE64 in full accordance + * with RFC 2045.

+ * On Windows XP sp1 with 1.4.2_04 and later ;), this encoder and decoder is about 10 times faster + * on small arrays (10 - 1000 bytes) and 2-3 times as fast on larger arrays (10000 - 1000000 bytes) + * compared to sun.misc.Encoder()/Decoder().

+ * + * On byte arrays the encoder is about 20% faster than Jakarta Commons Base64 Codec for encode and + * about 50% faster for decoding large arrays. This implementation is about twice as fast on very small + * arrays (< 30 bytes). If source/destination is a String this + * version is about three times as fast due to the fact that the Commons Codec result has to be recoded + * to a String from byte[], which is very expensive.

+ * + * This encode/decode algorithm doesn't create any temporary arrays as many other codecs do, it only + * allocates the resulting array. This produces less garbage and it is possible to handle arrays twice + * as large as algorithms that create a temporary array. (E.g. Jakarta Commons Codec). It is unknown + * whether Sun's sun.misc.Encoder()/Decoder() produce temporary arrays but since performance + * is quite low it probably does.

+ * + * The encoder produces the same output as the Sun one except that the Sun's encoder appends + * a trailing line separator if the last character isn't a pad. Unclear why but it only adds to the + * length and is probably a side effect. Both are in conformance with RFC 2045 though.
+ * Commons codec seem to always att a trailing line separator.

+ * + * Note! + * The encode/decode method pairs (types) come in three versions with the exact same algorithm and + * thus a lot of code redundancy. This is to not create any temporary arrays for transcoding to/from different + * format types. The methods not used can simply be commented out.

+ * + * There is also a "fast" version of all decode methods that works the same way as the normal ones, but + * har a few demands on the decoded input. Normally though, these fast verions should be used if the source if + * the input is known and it hasn't bee tampered with.

+ * + * If you find the code useful or you find a bug, please send me a note at base64 @ miginfocom . com. + * + * Licence (BSD): + * ============== + * + * Copyright (c) 2004, Mikael Grev, MiG InfoCom AB. (base64 @ miginfocom . com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this list + * of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * Neither the name of the MiG InfoCom AB nor the names of its contributors may be + * used to endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * @version 2.2 + * @author Mikael Grev + * Date: 2004-aug-02 + * Time: 11:31:11 + */ + +public class Base64 +{ + private static final char[] CA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray(); + private static final int[] IA = new int[256]; + static { + Arrays.fill(IA, -1); + for (int i = 0, iS = CA.length; i < iS; i++) + IA[CA[i]] = i; + IA['='] = 0; + } + + // **************************************************************************************** + // * char[] version + // **************************************************************************************** + + /** Encodes a raw byte array into a BASE64 char[] representation i accordance with RFC 2045. + * @param sArr The bytes to convert. If null or length 0 an empty array will be returned. + * @param lineSep Optional "\r\n" after 76 characters, unless end of file.
+ * No line separator will be in breach of RFC 2045 which specifies max 76 per line but will be a + * little faster. + * @return A BASE64 encoded array. Never null. + */ + public final static char[] encodeToChar(byte[] sArr, boolean lineSep) + { + // Check special case + int sLen = sArr != null ? sArr.length : 0; + if (sLen == 0) + return new char[0]; + + int eLen = (sLen / 3) * 3; // Length of even 24-bits. + int cCnt = ((sLen - 1) / 3 + 1) << 2; // Returned character count + int dLen = cCnt + (lineSep ? (cCnt - 1) / 76 << 1 : 0); // Length of returned array + char[] dArr = new char[dLen]; + + // Encode even 24-bits + for (int s = 0, d = 0, cc = 0; s < eLen;) { + // Copy next three bytes into lower 24 bits of int, paying attension to sign. + int i = (sArr[s++] & 0xff) << 16 | (sArr[s++] & 0xff) << 8 | (sArr[s++] & 0xff); + + // Encode the int into four chars + dArr[d++] = CA[(i >>> 18) & 0x3f]; + dArr[d++] = CA[(i >>> 12) & 0x3f]; + dArr[d++] = CA[(i >>> 6) & 0x3f]; + dArr[d++] = CA[i & 0x3f]; + + // Add optional line separator + if (lineSep && ++cc == 19 && d < dLen - 2) { + dArr[d++] = '\r'; + dArr[d++] = '\n'; + cc = 0; + } + } + + // Pad and encode last bits if source isn't even 24 bits. + int left = sLen - eLen; // 0 - 2. + if (left > 0) { + // Prepare the int + int i = ((sArr[eLen] & 0xff) << 10) | (left == 2 ? ((sArr[sLen - 1] & 0xff) << 2) : 0); + + // Set last four chars + dArr[dLen - 4] = CA[i >> 12]; + dArr[dLen - 3] = CA[(i >>> 6) & 0x3f]; + dArr[dLen - 2] = left == 2 ? CA[i & 0x3f] : '='; + dArr[dLen - 1] = '='; + } + return dArr; + } + + /** Decodes a BASE64 encoded char array. All illegal characters will be ignored and can handle both arrays with + * and without line separators. + * @param sArr The source array. null or length 0 will return an empty array. + * @return The decoded array of bytes. May be of length 0. Will be null if the legal characters + * (including '=') isn't divideable by 4. (I.e. definitely corrupted). + */ + public final static byte[] decode(char[] sArr) + { + // Check special case + int sLen = sArr != null ? sArr.length : 0; + if (sLen == 0) + return new byte[0]; + + // Count illegal characters (including '\r', '\n') to know what size the returned array will be, + // so we don't have to reallocate & copy it later. + int sepCnt = 0; // Number of separator characters. (Actually illegal characters, but that's a bonus...) + for (int i = 0; i < sLen; i++) // If input is "pure" (I.e. no line separators or illegal chars) base64 this loop can be commented out. + if (IA[sArr[i]] < 0) + sepCnt++; + + // Check so that legal chars (including '=') are evenly divideable by 4 as specified in RFC 2045. + if ((sLen - sepCnt) % 4 != 0) + return null; + + int pad = 0; + for (int i = sLen; i > 1 && IA[sArr[--i]] <= 0;) + if (sArr[i] == '=') + pad++; + + int len = ((sLen - sepCnt) * 6 >> 3) - pad; + + byte[] dArr = new byte[len]; // Preallocate byte[] of exact length + + for (int s = 0, d = 0; d < len;) { + // Assemble three bytes into an int from four "valid" characters. + int i = 0; + for (int j = 0; j < 4; j++) { // j only increased if a valid char was found. + int c = IA[sArr[s++]]; + if (c >= 0) + i |= c << (18 - j * 6); + else + j--; + } + // Add the bytes + dArr[d++] = (byte) (i >> 16); + if (d < len) { + dArr[d++]= (byte) (i >> 8); + if (d < len) + dArr[d++] = (byte) i; + } + } + return dArr; + } + + /** Decodes a BASE64 encoded char array that is known to be resonably well formatted. The method is about twice as + * fast as {@link #decode(char[])}. The preconditions are:
+ * + The array must have a line length of 76 chars OR no line separators at all (one line).
+ * + Line separator must be "\r\n", as specified in RFC 2045 + * + The array must not contain illegal characters within the encoded string
+ * + The array CAN have illegal characters at the beginning and end, those will be dealt with appropriately.
+ * @param sArr The source array. Length 0 will return an empty array. null will throw an exception. + * @return The decoded array of bytes. May be of length 0. + */ + public final static byte[] decodeFast(char[] sArr) + { + // Check special case + int sLen = sArr.length; + if (sLen == 0) + return new byte[0]; + + int sIx = 0, eIx = sLen - 1; // Start and end index after trimming. + + // Trim illegal chars from start + while (sIx < eIx && IA[sArr[sIx]] < 0) + sIx++; + + // Trim illegal chars from end + while (eIx > 0 && IA[sArr[eIx]] < 0) + eIx--; + + // get the padding count (=) (0, 1 or 2) + int pad = sArr[eIx] == '=' ? (sArr[eIx - 1] == '=' ? 2 : 1) : 0; // Count '=' at end. + int cCnt = eIx - sIx + 1; // Content count including possible separators + int sepCnt = sLen > 76 ? (sArr[76] == '\r' ? cCnt / 78 : 0) << 1 : 0; + + int len = ((cCnt - sepCnt) * 6 >> 3) - pad; // The number of decoded bytes + byte[] dArr = new byte[len]; // Preallocate byte[] of exact length + + // Decode all but the last 0 - 2 bytes. + int d = 0; + for (int cc = 0, eLen = (len / 3) * 3; d < eLen;) { + // Assemble three bytes into an int from four "valid" characters. + int i = IA[sArr[sIx++]] << 18 | IA[sArr[sIx++]] << 12 | IA[sArr[sIx++]] << 6 | IA[sArr[sIx++]]; + + // Add the bytes + dArr[d++] = (byte) (i >> 16); + dArr[d++] = (byte) (i >> 8); + dArr[d++] = (byte) i; + + // If line separator, jump over it. + if (sepCnt > 0 && ++cc == 19) { + sIx += 2; + cc = 0; + } + } + + if (d < len) { + // Decode last 1-3 bytes (incl '=') into 1-3 bytes + int i = 0; + for (int j = 0; sIx <= eIx - pad; j++) + i |= IA[sArr[sIx++]] << (18 - j * 6); + + for (int r = 16; d < len; r -= 8) + dArr[d++] = (byte) (i >> r); + } + + return dArr; + } + + // **************************************************************************************** + // * byte[] version + // **************************************************************************************** + + /** Encodes a raw byte array into a BASE64 byte[] representation i accordance with RFC 2045. + * @param sArr The bytes to convert. If null or length 0 an empty array will be returned. + * @param lineSep Optional "\r\n" after 76 characters, unless end of file.
+ * No line separator will be in breach of RFC 2045 which specifies max 76 per line but will be a + * little faster. + * @return A BASE64 encoded array. Never null. + */ + public final static byte[] encodeToByte(byte[] sArr, boolean lineSep) + { + // Check special case + int sLen = sArr != null ? sArr.length : 0; + if (sLen == 0) + return new byte[0]; + + int eLen = (sLen / 3) * 3; // Length of even 24-bits. + int cCnt = ((sLen - 1) / 3 + 1) << 2; // Returned character count + int dLen = cCnt + (lineSep ? (cCnt - 1) / 76 << 1 : 0); // Length of returned array + byte[] dArr = new byte[dLen]; + + // Encode even 24-bits + for (int s = 0, d = 0, cc = 0; s < eLen;) { + // Copy next three bytes into lower 24 bits of int, paying attension to sign. + int i = (sArr[s++] & 0xff) << 16 | (sArr[s++] & 0xff) << 8 | (sArr[s++] & 0xff); + + // Encode the int into four chars + dArr[d++] = (byte) CA[(i >>> 18) & 0x3f]; + dArr[d++] = (byte) CA[(i >>> 12) & 0x3f]; + dArr[d++] = (byte) CA[(i >>> 6) & 0x3f]; + dArr[d++] = (byte) CA[i & 0x3f]; + + // Add optional line separator + if (lineSep && ++cc == 19 && d < dLen - 2) { + dArr[d++] = '\r'; + dArr[d++] = '\n'; + cc = 0; + } + } + + // Pad and encode last bits if source isn't an even 24 bits. + int left = sLen - eLen; // 0 - 2. + if (left > 0) { + // Prepare the int + int i = ((sArr[eLen] & 0xff) << 10) | (left == 2 ? ((sArr[sLen - 1] & 0xff) << 2) : 0); + + // Set last four chars + dArr[dLen - 4] = (byte) CA[i >> 12]; + dArr[dLen - 3] = (byte) CA[(i >>> 6) & 0x3f]; + dArr[dLen - 2] = left == 2 ? (byte) CA[i & 0x3f] : (byte) '='; + dArr[dLen - 1] = '='; + } + return dArr; + } + + /** Decodes a BASE64 encoded byte array. All illegal characters will be ignored and can handle both arrays with + * and without line separators. + * @param sArr The source array. Length 0 will return an empty array. null will throw an exception. + * @return The decoded array of bytes. May be of length 0. Will be null if the legal characters + * (including '=') isn't divideable by 4. (I.e. definitely corrupted). + */ + public final static byte[] decode(byte[] sArr) + { + // Check special case + int sLen = sArr.length; + + // Count illegal characters (including '\r', '\n') to know what size the returned array will be, + // so we don't have to reallocate & copy it later. + int sepCnt = 0; // Number of separator characters. (Actually illegal characters, but that's a bonus...) + for (int i = 0; i < sLen; i++) // If input is "pure" (I.e. no line separators or illegal chars) base64 this loop can be commented out. + if (IA[sArr[i] & 0xff] < 0) + sepCnt++; + + // Check so that legal chars (including '=') are evenly divideable by 4 as specified in RFC 2045. + if ((sLen - sepCnt) % 4 != 0) + return null; + + int pad = 0; + for (int i = sLen; i > 1 && IA[sArr[--i] & 0xff] <= 0;) + if (sArr[i] == '=') + pad++; + + int len = ((sLen - sepCnt) * 6 >> 3) - pad; + + byte[] dArr = new byte[len]; // Preallocate byte[] of exact length + + for (int s = 0, d = 0; d < len;) { + // Assemble three bytes into an int from four "valid" characters. + int i = 0; + for (int j = 0; j < 4; j++) { // j only increased if a valid char was found. + int c = IA[sArr[s++] & 0xff]; + if (c >= 0) + i |= c << (18 - j * 6); + else + j--; + } + + // Add the bytes + dArr[d++] = (byte) (i >> 16); + if (d < len) { + dArr[d++]= (byte) (i >> 8); + if (d < len) + dArr[d++] = (byte) i; + } + } + + return dArr; + } + + + /** Decodes a BASE64 encoded byte array that is known to be resonably well formatted. The method is about twice as + * fast as {@link #decode(byte[])}. The preconditions are:
+ * + The array must have a line length of 76 chars OR no line separators at all (one line).
+ * + Line separator must be "\r\n", as specified in RFC 2045 + * + The array must not contain illegal characters within the encoded string
+ * + The array CAN have illegal characters at the beginning and end, those will be dealt with appropriately.
+ * @param sArr The source array. Length 0 will return an empty array. null will throw an exception. + * @return The decoded array of bytes. May be of length 0. + */ + public final static byte[] decodeFast(byte[] sArr) + { + // Check special case + int sLen = sArr.length; + if (sLen == 0) + return new byte[0]; + + int sIx = 0, eIx = sLen - 1; // Start and end index after trimming. + + // Trim illegal chars from start + while (sIx < eIx && IA[sArr[sIx] & 0xff] < 0) + sIx++; + + // Trim illegal chars from end + while (eIx > 0 && IA[sArr[eIx] & 0xff] < 0) + eIx--; + + // get the padding count (=) (0, 1 or 2) + int pad = sArr[eIx] == '=' ? (sArr[eIx - 1] == '=' ? 2 : 1) : 0; // Count '=' at end. + int cCnt = eIx - sIx + 1; // Content count including possible separators + int sepCnt = sLen > 76 ? (sArr[76] == '\r' ? cCnt / 78 : 0) << 1 : 0; + + int len = ((cCnt - sepCnt) * 6 >> 3) - pad; // The number of decoded bytes + byte[] dArr = new byte[len]; // Preallocate byte[] of exact length + + // Decode all but the last 0 - 2 bytes. + int d = 0; + for (int cc = 0, eLen = (len / 3) * 3; d < eLen;) { + // Assemble three bytes into an int from four "valid" characters. + int i = IA[sArr[sIx++]] << 18 | IA[sArr[sIx++]] << 12 | IA[sArr[sIx++]] << 6 | IA[sArr[sIx++]]; + + // Add the bytes + dArr[d++] = (byte) (i >> 16); + dArr[d++] = (byte) (i >> 8); + dArr[d++] = (byte) i; + + // If line separator, jump over it. + if (sepCnt > 0 && ++cc == 19) { + sIx += 2; + cc = 0; + } + } + + if (d < len) { + // Decode last 1-3 bytes (incl '=') into 1-3 bytes + int i = 0; + for (int j = 0; sIx <= eIx - pad; j++) + i |= IA[sArr[sIx++]] << (18 - j * 6); + + for (int r = 16; d < len; r -= 8) + dArr[d++] = (byte) (i >> r); + } + + return dArr; + } + + // **************************************************************************************** + // * String version + // **************************************************************************************** + + /** Encodes a raw byte array into a BASE64 String representation i accordance with RFC 2045. + * @param sArr The bytes to convert. If null or length 0 an empty array will be returned. + * @param lineSep Optional "\r\n" after 76 characters, unless end of file.
+ * No line separator will be in breach of RFC 2045 which specifies max 76 per line but will be a + * little faster. + * @return A BASE64 encoded array. Never null. + */ + public final static String encodeToString(byte[] sArr, boolean lineSep) + { + // Reuse char[] since we can't create a String incrementally anyway and StringBuffer/Builder would be slower. + return new String(encodeToChar(sArr, lineSep)); + } + + /** Decodes a BASE64 encoded String. All illegal characters will be ignored and can handle both strings with + * and without line separators.
+ * Note! It can be up to about 2x the speed to call decode(str.toCharArray()) instead. That + * will create a temporary array though. This version will use str.charAt(i) to iterate the string. + * @param str The source string. null or length 0 will return an empty array. + * @return The decoded array of bytes. May be of length 0. Will be null if the legal characters + * (including '=') isn't divideable by 4. (I.e. definitely corrupted). + */ + public final static byte[] decode(String str) + { + // Check special case + int sLen = str != null ? str.length() : 0; + if (sLen == 0) + return new byte[0]; + + // Count illegal characters (including '\r', '\n') to know what size the returned array will be, + // so we don't have to reallocate & copy it later. + int sepCnt = 0; // Number of separator characters. (Actually illegal characters, but that's a bonus...) + for (int i = 0; i < sLen; i++) // If input is "pure" (I.e. no line separators or illegal chars) base64 this loop can be commented out. + if (IA[str.charAt(i)] < 0) + sepCnt++; + + // Check so that legal chars (including '=') are evenly divideable by 4 as specified in RFC 2045. + if ((sLen - sepCnt) % 4 != 0) + return null; + + // Count '=' at end + int pad = 0; + for (int i = sLen; i > 1 && IA[str.charAt(--i)] <= 0;) + if (str.charAt(i) == '=') + pad++; + + int len = ((sLen - sepCnt) * 6 >> 3) - pad; + + byte[] dArr = new byte[len]; // Preallocate byte[] of exact length + + for (int s = 0, d = 0; d < len;) { + // Assemble three bytes into an int from four "valid" characters. + int i = 0; + for (int j = 0; j < 4; j++) { // j only increased if a valid char was found. + int c = IA[str.charAt(s++)]; + if (c >= 0) + i |= c << (18 - j * 6); + else + j--; + } + // Add the bytes + dArr[d++] = (byte) (i >> 16); + if (d < len) { + dArr[d++]= (byte) (i >> 8); + if (d < len) + dArr[d++] = (byte) i; + } + } + return dArr; + } + + /** Decodes a BASE64 encoded string that is known to be resonably well formatted. The method is about twice as + * fast as {@link #decode(String)}. The preconditions are:
+ * + The array must have a line length of 76 chars OR no line separators at all (one line).
+ * + Line separator must be "\r\n", as specified in RFC 2045 + * + The array must not contain illegal characters within the encoded string
+ * + The array CAN have illegal characters at the beginning and end, those will be dealt with appropriately.
+ * @param s The source string. Length 0 will return an empty array. null will throw an exception. + * @return The decoded array of bytes. May be of length 0. + */ + public final static byte[] decodeFast(String s) + { + // Check special case + int sLen = s.length(); + if (sLen == 0) + return new byte[0]; + + int sIx = 0, eIx = sLen - 1; // Start and end index after trimming. + + // Trim illegal chars from start + while (sIx < eIx && IA[s.charAt(sIx) & 0xff] < 0) + sIx++; + + // Trim illegal chars from end + while (eIx > 0 && IA[s.charAt(eIx) & 0xff] < 0) + eIx--; + + // get the padding count (=) (0, 1 or 2) + int pad = s.charAt(eIx) == '=' ? (s.charAt(eIx - 1) == '=' ? 2 : 1) : 0; // Count '=' at end. + int cCnt = eIx - sIx + 1; // Content count including possible separators + int sepCnt = sLen > 76 ? (s.charAt(76) == '\r' ? cCnt / 78 : 0) << 1 : 0; + + int len = ((cCnt - sepCnt) * 6 >> 3) - pad; // The number of decoded bytes + byte[] dArr = new byte[len]; // Preallocate byte[] of exact length + + // Decode all but the last 0 - 2 bytes. + int d = 0; + for (int cc = 0, eLen = (len / 3) * 3; d < eLen;) { + // Assemble three bytes into an int from four "valid" characters. + int i = IA[s.charAt(sIx++)] << 18 | IA[s.charAt(sIx++)] << 12 | IA[s.charAt(sIx++)] << 6 | IA[s.charAt(sIx++)]; + + // Add the bytes + dArr[d++] = (byte) (i >> 16); + dArr[d++] = (byte) (i >> 8); + dArr[d++] = (byte) i; + + // If line separator, jump over it. + if (sepCnt > 0 && ++cc == 19) { + sIx += 2; + cc = 0; + } + } + + if (d < len) { + // Decode last 1-3 bytes (incl '=') into 1-3 bytes + int i = 0; + for (int j = 0; sIx <= eIx - pad; j++) + i |= IA[s.charAt(sIx++)] << (18 - j * 6); + + for (int r = 16; d < len; r -= 8) + dArr[d++] = (byte) (i >> r); + } + + return dArr; + } +} \ No newline at end of file diff --git a/src/org/r3pek/droiduptime/ConfigValues.java b/src/org/r3pek/droiduptime/ConfigValues.java new file mode 100644 index 0000000..db3213d --- /dev/null +++ b/src/org/r3pek/droiduptime/ConfigValues.java @@ -0,0 +1,47 @@ +package org.r3pek.droiduptime; + +import android.content.Context; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; +import android.text.format.DateUtils; + +public class ConfigValues { + private SharedPreferences settings; + private Context ctx; + + public ConfigValues(Context ctx) { + this.ctx = ctx; + settings = PreferenceManager.getDefaultSharedPreferences(ctx); + } + + public String getUsername() { + return settings.getString("username", ""); + } + + public String getPassword() { + return settings.getString("password", ""); + } + + public int getUpdateInterval() { + return Integer.parseInt(settings.getString("pref_gen_update_int", "3600")); + } + + public String getHostname() { + return settings.getString("pref_gen_hostname", ""); + } + + public String getLastUpdate() { + long lastUpdate = settings.getLong("lastUpdate", Long.MAX_VALUE); + if (lastUpdate == Long.MAX_VALUE) + return ctx.getString(R.string.notyetupdated).toString(); + else + return DateUtils.getRelativeTimeSpanString(lastUpdate).toString(); + } + + public void setLastUpdate(Long time) { + SharedPreferences.Editor editor = settings.edit(); + editor.putLong("lastUpdate", time); + editor.commit(); + } + +} diff --git a/src/org/r3pek/droiduptime/DroidUptimeService.java b/src/org/r3pek/droiduptime/DroidUptimeService.java new file mode 100644 index 0000000..371c3dd --- /dev/null +++ b/src/org/r3pek/droiduptime/DroidUptimeService.java @@ -0,0 +1,160 @@ +package org.r3pek.droiduptime; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.http.NameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.protocol.HTTP; + +import android.app.Service; +import android.content.Intent; +import android.net.ConnectivityManager; +import android.net.wifi.WifiInfo; +import android.net.wifi.WifiManager; +import android.os.IBinder; +import android.os.SystemClock; + +public class DroidUptimeService extends Service { + private Timer timer; + private ConfigValues cv; + + @Override + public IBinder onBind(Intent arg0) { + return null; + } + + @Override + public void onCreate() { + super.onCreate(); + cv = new ConfigValues(getApplicationContext()); + timer = new Timer(); + timer.scheduleAtFixedRate(new TimerTask() { + + @Override + public void run() { + sendUptime(); + } + }, 60000, cv.getUpdateInterval() * 1000); + } + + @Override + public void onDestroy() { + super.onDestroy(); + if (timer != null) timer.cancel(); + } + + @SuppressWarnings("static-access") + private String getMACAddrMD5() { + WifiManager manager = (WifiManager)getApplicationContext().getSystemService(getApplicationContext().WIFI_SERVICE); + WifiInfo info = manager.getConnectionInfo(); + + try { + return MD5.calculateMD5(info.getMacAddress().toLowerCase().replaceAll(":", "")); + } catch (Exception e) { } + return ""; + } + + private String getFormattedKernelVersion() { + String procVersionStr; + + try { + BufferedReader reader = new BufferedReader(new FileReader("/proc/version"), 256); + try { + procVersionStr = reader.readLine(); + } finally { + reader.close(); + } + final String PROC_VERSION_REGEX = "\\w+\\s+" + /* ignore: Linux */ + "\\w+\\s+" + /* ignore: version */ + "([^\\s]+)\\s+" + /* group 1: 2.6.22-omap1 */ + "\\(([^\\s@]+(?:@[^\\s.]+)?)[^)]*\\)\\s+" + /* group 2: (xxxxxx@xxxxx.constant) */ + "\\([^)]+\\)\\s+" + /* ignore: (gcc ..) */ + "([^\\s]+)\\s+" + /* group 3: #26 */ + "(?:PREEMPT\\s+)?" + /* ignore: PREEMPT (optional) */ + "(.+)"; /* group 4: date */ + Pattern p = Pattern.compile(PROC_VERSION_REGEX); + Matcher m = p.matcher(procVersionStr); + + if (!m.matches()) + return "Unavailable"; + else + return m.group(1); + } catch (IOException e) { + return "Unavailable"; + } + } + + private String getCPUABI() { + String procStr; + + try { + BufferedReader reader = new BufferedReader(new FileReader("/proc/cpuinfo"), 256); + try { + procStr = reader.readLine(); + } finally { + reader.close(); + } + + String[] cpu = procStr.replace("(", "").replace(")", "").split(" "); + return cpu[1] + "-" + cpu[5]; + + } catch (Exception e) { + return ""; + } + } + + @SuppressWarnings("static-access") + public void sendUptime() { + if (cv.getUsername().equals("") || cv.getPassword().equals("")) + return; + ConnectivityManager conMngr = (ConnectivityManager)getSystemService(getApplicationContext().CONNECTIVITY_SERVICE); + boolean isConnected = false || conMngr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnected(); + isConnected |= conMngr.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected(); + if (!isConnected) return; + + long uptime = SystemClock.elapsedRealtime() / 1000; + String agent = "DroidUptime-v1.3"; + String cnb = "1"; + String mac = getMACAddrMD5(); + String hostname = cv.getHostname(); + String machine = hostname.equals("") ? android.os.Build.MODEL : hostname + " (" + android.os.Build.MODEL + ")"; + String os = "Linux+" + getFormattedKernelVersion() + "+(" + getCPUABI() + ")"; + String distrib = "Android"; + String distribContent = "SDK " + android.os.Build.VERSION.RELEASE; + distribContent = Base64.encodeToString(distribContent.getBytes(), false); + + try { + DefaultHttpClient httpclient = new DefaultHttpClient(); + HttpPost post = new HttpPost("http://update.uptimeprj.com/update.php?username=" + cv.getUsername()); + post.addHeader("User-Agent", agent); + + List data = new ArrayList(); + data.add(new BasicNameValuePair("username", cv.getUsername())); + data.add(new BasicNameValuePair("pass", cv.getPassword())); + data.add(new BasicNameValuePair("cnb", cnb)); + data.add(new BasicNameValuePair("mac", mac)); + data.add(new BasicNameValuePair("machine", machine)); + data.add(new BasicNameValuePair("os", os)); + data.add(new BasicNameValuePair("uptime", String.valueOf(uptime))); + data.add(new BasicNameValuePair("distrib", distrib)); + data.add(new BasicNameValuePair("distribcontent", distribContent)); + post.setEntity(new UrlEncodedFormEntity(data, HTTP.UTF_8)); + + httpclient.execute(post); + + cv.setLastUpdate(System.currentTimeMillis()); + } catch (Exception e) { e.printStackTrace(); } + } + +} diff --git a/src/org/r3pek/droiduptime/DroidUptimeServiceManager.java b/src/org/r3pek/droiduptime/DroidUptimeServiceManager.java new file mode 100644 index 0000000..f77dc4f --- /dev/null +++ b/src/org/r3pek/droiduptime/DroidUptimeServiceManager.java @@ -0,0 +1,24 @@ +package org.r3pek.droiduptime; + +import android.content.BroadcastReceiver; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.util.Log; + +public class DroidUptimeServiceManager extends BroadcastReceiver { + + public void onReceive(Context arg0, Intent arg1) { + if (arg1.getAction().equals("android.intent.action.BOOT_COMPLETED")) { + ComponentName comp = new ComponentName(arg0.getPackageName(), DroidUptimeService.class.getName()); + ComponentName service = arg0.startService(new Intent().setComponent(comp)); + if (null == service){ + // something really wrong here + Log.e(getClass().getName(), "Could not start service " + comp.toString()); + } + } else { + Log.e(getClass().getName(), "Received unexpected intent " + arg1.toString()); + } + } + +} diff --git a/src/org/r3pek/droiduptime/MD5.java b/src/org/r3pek/droiduptime/MD5.java new file mode 100644 index 0000000..7f3d6ec --- /dev/null +++ b/src/org/r3pek/droiduptime/MD5.java @@ -0,0 +1,33 @@ +package org.r3pek.droiduptime; + +import java.io.UnsupportedEncodingException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class MD5 { + + private static String convertToHex(byte[] data) { + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < data.length; i++) { + int halfbyte = (data[i] >>> 4) & 0x0F; + int two_halfs = 0; + do { + if ((0 <= halfbyte) && (halfbyte <= 9)) + buf.append((char) ('0' + halfbyte)); + else + buf.append((char) ('a' + (halfbyte - 10))); + halfbyte = data[i] & 0x0F; + } while(two_halfs++ < 1); + } + return buf.toString(); + } + + public static String calculateMD5(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException { + MessageDigest md; + md = MessageDigest.getInstance("MD5"); + byte[] md5hash = new byte[32]; + md.update(text.getBytes("iso-8859-1"), 0, text.length()); + md5hash = md.digest(); + return convertToHex(md5hash); + } +} \ No newline at end of file diff --git a/src/org/r3pek/droiduptime/Main.java b/src/org/r3pek/droiduptime/Main.java new file mode 100644 index 0000000..1d9038b --- /dev/null +++ b/src/org/r3pek/droiduptime/Main.java @@ -0,0 +1,184 @@ +package org.r3pek.droiduptime; + +import java.util.List; + +import android.app.Activity; +import android.app.ActivityManager; +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.ActivityManager.RunningServiceInfo; +import android.app.AlertDialog.Builder; +import android.content.ComponentName; +import android.content.Intent; +import android.os.Bundle; +import android.os.SystemClock; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.view.View.OnClickListener; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.TextView; + +public class Main extends Activity { + private static final int MENU_ABOUT = 0; + private static final int MENU_SETUP = 1; + private static final int DIALOG_ABOUT = 0; + + private Button btnStartStopService; + private TextView tvStatus; + private TextView tvUptime; + private TextView tvLastUpdate; + private Thread uptimeThread; + private ConfigValues cv; + + private volatile boolean stopThread; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.main); + + /*AdManager.setTestDevices( new String[] { + AdManager.TEST_EMULATOR, // Android emulator + "7A352EFBD63EAC6DF4C5F8DFBC661C00", // My Nexus1 + } );*/ + + cv = new ConfigValues(getApplicationContext()); + + btnStartStopService = (Button)findViewById(R.id.btnStartStopService); + tvStatus = (TextView)findViewById(R.id.tvStatus); + tvUptime = (TextView)findViewById(R.id.tvUptime); + tvLastUpdate = (TextView)findViewById(R.id.tvLastUpdate); + + btnStartStopService.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + Intent service = new Intent(getApplicationContext(), DroidUptimeService.class); + if (isServiceRunning()) { + stopService(service); + } else { + startService(service); + } + updateStatus(); + } + }); + } + + private void startThread() { + stopThread = false; + uptimeThread = new Thread(new Runnable() { + @Override + public void run() { + while (!stopThread) { + long secondsRunning = SystemClock.elapsedRealtime() / 1000; + final int months = (int)(secondsRunning / 2592000); + final int days = (int)((secondsRunning - (months * 2592000)) / 86400); + final int hours = (int)((secondsRunning - (months * 2592000) - (days * 86400)) / 3600); + final int minutes = (int)((secondsRunning - (months * 2592000) - (days * 86400) - (hours * 3600)) / 60); + final int seconds = (int)(secondsRunning % 60); + runOnUiThread(new Runnable() { + public void run() { + tvUptime.setText(String.valueOf(months) + " " + getString(R.string.months) + ", " + + String.valueOf(days) + " " + getString(R.string.days) + ", " + + String.valueOf(hours) + " " + getString(R.string.hours) + ", " + + String.valueOf(minutes) + " " + getString(R.string.minutes) + " " + + String.valueOf(seconds) + " " + getString(R.string.seconds)); + if (cv.getUsername().equals("") || cv.getPassword().equals("")) + tvLastUpdate.setText(R.string.no_user_pass); + else + tvLastUpdate.setText(cv.getLastUpdate()); + updateStatus(); + } + }); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { return; } + } + } + }); + uptimeThread.start(); + } + + @Override + public void onPause() { + super.onPause(); + stopThread = true; + uptimeThread = null; + } + + @Override + public void onResume() { + super.onResume(); + if (uptimeThread == null) + startThread(); + updateStatus(); + } + + private boolean isServiceRunning() { + ActivityManager activityManager = (ActivityManager)getSystemService(ACTIVITY_SERVICE); + List serviceList = activityManager.getRunningServices(Integer.MAX_VALUE); + + if (serviceList.size() <= 0) { + return false; + } + for (int i = 0; i < serviceList.size(); i++) { + RunningServiceInfo serviceInfo = serviceList.get(i); + ComponentName serviceName = serviceInfo.service; + if(serviceName.getClassName().equals(DroidUptimeService.class.getName())) { + return true; + } + } + + return false; + } + + private void updateStatus() { + if (isServiceRunning()) { + tvStatus.setText(R.string.status_running); + btnStartStopService.setText(R.string.operation_stop); + } else { + tvStatus.setText(R.string.status_stopped); + btnStartStopService.setText(R.string.operation_start); + } + } + + public boolean onCreateOptionsMenu(Menu menu) { + menu.add(0, MENU_ABOUT, 0, R.string.menu_about).setIcon(android.R.drawable.ic_menu_info_details);; + menu.add(0, MENU_SETUP, 0, R.string.menu_setup).setIcon(android.R.drawable.ic_menu_preferences); + return true; + } + + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case MENU_ABOUT: + showDialog(DIALOG_ABOUT); + return true; + case MENU_SETUP: + Intent i = new Intent(getApplicationContext(), MyPreferences.class); + startActivity(i); + return true; + } + return false; + } + + public Dialog onCreateDialog(int id) { + Dialog d; + switch (id) { + case DIALOG_ABOUT: { + LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE); + View layout = inflater.inflate(R.layout.about, (ViewGroup)findViewById(R.id.aboutRoot)); + ImageView image = (ImageView)layout.findViewById(R.id.ImageView01); + image.setImageResource(R.drawable.icon); + Builder builder = new AlertDialog.Builder(this); + builder.setView(layout); + d = builder.create(); + break; + } + default: d = null; + } + return d; + } +} diff --git a/src/org/r3pek/droiduptime/MyPreferences.java b/src/org/r3pek/droiduptime/MyPreferences.java new file mode 100644 index 0000000..dda5a4a --- /dev/null +++ b/src/org/r3pek/droiduptime/MyPreferences.java @@ -0,0 +1,13 @@ +package org.r3pek.droiduptime; + +import android.os.Bundle; +import android.preference.PreferenceActivity; + +public class MyPreferences extends PreferenceActivity { + + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + addPreferencesFromResource(R.xml.preferences); + } +}