├── .gitignore
├── AndroidManifest.xml
├── LICENSE.txt
├── README.md
├── ant.properties
├── build.xml
├── proguard.cfg
├── project.properties
├── res
├── drawable
│ └── icon.png
├── layout
│ ├── main.xml
│ └── part_list_item.xml
├── values-de
│ └── strings.xml
├── values-pt-rBR
│ └── strings.xml
├── values-tr
│ └── strings.xml
└── values
│ └── strings.xml
└── src
└── hu
└── vsza
├── adsapi
├── Part.java
└── Search.java
└── adsdroid
├── PartList.java
└── SearchPanel.java
/.gitignore:
--------------------------------------------------------------------------------
1 | # built application files
2 | *.apk
3 | *.ap_
4 |
5 | # files for the dex VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # generated files
12 | bin/
13 | gen/
14 |
15 | # Local configuration file (sdk path, etc)
16 | local.properties
17 |
--------------------------------------------------------------------------------
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2012 Andras Veres-Szentkiralyi
2 |
3 | Permission is hereby granted, free of charge, to any person
4 | obtaining a copy of this software and associated documentation
5 | files (the "Software"), to deal in the Software without
6 | restriction, including without limitation the rights to use,
7 | copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the
9 | Software is furnished to do so, subject to the following
10 | conditions:
11 |
12 | The above copyright notice and this permission notice shall be
13 | included in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Unofficial Android application for alldatasheet.com
2 | ===================================================
3 |
4 | Building
5 | --------
6 |
7 | - Download and unpack the Android SDK to any directory (if you haven't done so already).
8 | - Create the `local.properties` with a single line like `sdk.dir=/path/to/android/sdk` with the correct path.
9 | - Download the latest version of jsoup from http://jsoup.org/download and put the JAR in the `libs` directory.
10 | - Run `ant debug` to build the project and sign it with a debug key.
11 |
12 | License
13 | -------
14 |
15 | The whole project is licensed under MIT license.
16 |
--------------------------------------------------------------------------------
/ant.properties:
--------------------------------------------------------------------------------
1 | # This file is used to override default values used by the Ant build system.
2 | #
3 | # This file must be checked in Version Control Systems, as it is
4 | # integral to the build system of your project.
5 |
6 | # This file is only used by the Ant script.
7 |
8 | # You can use this to override default values such as
9 | # 'source.dir' for the location of your java source folder and
10 | # 'out.dir' for the location of your output folder.
11 |
12 | # You can also use it define how the release builds are signed by declaring
13 | # the following properties:
14 | # 'key.store' for the location of your keystore and
15 | # 'key.alias' for the name of the key to use.
16 | # The password will be asked during the build when you use the 'release' target.
17 |
18 |
--------------------------------------------------------------------------------
/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
29 |
30 |
31 |
40 |
41 |
42 |
43 |
47 |
48 |
49 |
51 |
63 |
64 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/proguard.cfg:
--------------------------------------------------------------------------------
1 | -optimizationpasses 5
2 | -dontusemixedcaseclassnames
3 | -dontskipnonpubliclibraryclasses
4 | -dontpreverify
5 | -verbose
6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
7 |
8 | -keep public class * extends android.app.Activity
9 | -keep public class * extends android.app.Application
10 | -keep public class * extends android.app.Service
11 | -keep public class * extends android.content.BroadcastReceiver
12 | -keep public class * extends android.content.ContentProvider
13 | -keep public class * extends android.app.backup.BackupAgentHelper
14 | -keep public class * extends android.preference.Preference
15 | -keep public class com.android.vending.licensing.ILicensingService
16 |
17 | -keepclasseswithmembernames class * {
18 | native ;
19 | }
20 |
21 | -keepclasseswithmembers class * {
22 | public (android.content.Context, android.util.AttributeSet);
23 | }
24 |
25 | -keepclasseswithmembers class * {
26 | public (android.content.Context, android.util.AttributeSet, int);
27 | }
28 |
29 | -keepclassmembers class * extends android.app.Activity {
30 | public void *(android.view.View);
31 | }
32 |
33 | -keepclassmembers enum * {
34 | public static **[] values();
35 | public static ** valueOf(java.lang.String);
36 | }
37 |
38 | -keep class * implements android.os.Parcelable {
39 | public static final android.os.Parcelable$Creator *;
40 | }
41 |
--------------------------------------------------------------------------------
/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-9
12 |
13 | # ProGuard config.
14 | proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard.cfg
15 |
--------------------------------------------------------------------------------
/res/drawable/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dnet/adsdroid/2cd6c7eafb10ec77f90e699b7f0d91b8a9c965b5/res/drawable/icon.png
--------------------------------------------------------------------------------
/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
19 |
26 |
31 |
32 |
--------------------------------------------------------------------------------
/res/layout/part_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
15 |
21 |
22 |
--------------------------------------------------------------------------------
/res/values-de/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Verbinde zu PDF-Server
4 | Datenblatt als %s gespeichert
5 | Fehler beim Download
6 | Downloade Datenblatt... (%d bytes bereits heruntergeladen)
7 | Fehler beim Bekommen der Resultate
8 | Lade PDF URL herunter...
9 | Keine Ergebnisse gefunden
10 | Suche in Resultaten
11 | Name des Teils:
12 | Konnte PDF-Betrachter nicht öffnen. Haben Sie einen installiert?
13 | Suche Nach Name des Bauteils
14 | Suchmodus
15 | Suche...
16 | Beginne Download...
17 |
18 |
--------------------------------------------------------------------------------
/res/values-pt-rBR/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | ADSdroid
4 | Modo de busca
5 | Resultados da busca
6 | Buscando...
7 | Nenhum resultado encontrado.
8 | Erro ao obter resultados.
9 | Começando a baixar...
10 | Obtendo URL do PDF...
11 | Conectando ao servidor de PDF...
12 | Baixando datasheet... (obtidos %d bytes até agora)
13 | Erro ocorreu durante o download
14 | Datasheet salvo como %s
15 | Falha ao abrir o visualizador PDF, você tem algum instalado?
16 | Nome da peça:
17 | Procurar pelo nome da peça
18 |
--------------------------------------------------------------------------------
/res/values-tr/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | ADSdroid
4 | Arama modu
5 | Arama sonuçları
6 | Aranıyor ...
7 | Sonuç bulunamadı.
8 | Sonuçlar getirilirken hata oluştu.
9 | İndirme başlatılıyor ...
10 | PDF URL alınıyor ...
11 | PDF sunucusuna bağlanıyor ...
12 | Datasheet indiriliyor ... (şu ana kadar %d bayt indirildi)
13 | İndirme sırasında hata oluştu
14 | Datasheet %s olarak kaydedildi
15 | PDF görüntüleyici açılamadı, yüklü bir uygulama var mı?
16 | Bölüm adı:
17 | Parça adına göre ara
18 |
19 |
--------------------------------------------------------------------------------
/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | ADSdroid
4 | Search mode
5 | Search results
6 | Searching...
7 | No results found.
8 | Error fetching results.
9 | Starting download...
10 | Fetching PDF URL...
11 | Connecting to PDF server...
12 | Downloading datasheet... (fetched %d bytes so far)
13 | Error happened during download
14 | Datasheet saved as %s
15 | Failed to open PDF viewer, do you have one installed?
16 | Part name:
17 | Search by part name
18 |
19 |
--------------------------------------------------------------------------------
/src/hu/vsza/adsapi/Part.java:
--------------------------------------------------------------------------------
1 | package hu.vsza.adsapi;
2 |
3 | import java.io.IOException;
4 | import java.net.URL;
5 | import java.net.URLConnection;
6 | import java.util.HashMap;
7 | import java.util.List;
8 | import java.util.Map;
9 | import org.jsoup.Jsoup;
10 | import org.jsoup.Connection;
11 | import org.jsoup.nodes.Document;
12 | import org.jsoup.nodes.Element;
13 | import org.jsoup.select.Elements;
14 |
15 | public class Part extends HashMap {
16 |
17 | public final static String NAME = "NAME", DESCRIPTION = "DESCRIPTION", HREF = "HREF";
18 | public final static String UA = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1088.0 Safari/536.6";
19 |
20 | public Part(Map extends String, ? extends String> map) {
21 | super(map);
22 | }
23 |
24 | public Part(String name, String description, String href) {
25 | super(3);
26 | put(NAME, name);
27 | put(DESCRIPTION, description);
28 | put(HREF, href);
29 | }
30 |
31 | public URLConnection getPdfConnection() throws IOException {
32 | String href = get(HREF);
33 |
34 | Document doc = Jsoup.connect(href).timeout(0).get();
35 | Element viewPageLink = doc.select("td.blue a").get(0);
36 | String viewPageUrl = viewPageLink.absUrl("href");
37 |
38 | Connection.Response resp = Jsoup.connect(viewPageUrl).referrer(href)
39 | .timeout(0).userAgent(UA).header("Accept-Language", "en").execute();
40 | StringBuilder cookies = new StringBuilder();
41 | for (Map.Entry e : resp.cookies().entrySet()) {
42 | if (cookies.length() != 0) cookies.append("; ");
43 | cookies.append(e.getKey()).append('=').append(e.getValue());
44 | }
45 | Element pdfIframe = getDatasheetIframe(resp.parse());
46 | String pdfUrl = pdfIframe.absUrl("src");
47 |
48 | URLConnection pdfConnection = new URL(pdfUrl).openConnection();
49 | pdfConnection.setRequestProperty("Cookie", cookies.toString());
50 | pdfConnection.setRequestProperty("Referer", viewPageUrl);
51 | pdfConnection.setRequestProperty("User-Agent", UA);
52 | return pdfConnection;
53 | }
54 |
55 | protected static Element getDatasheetIframe(Element doc) {
56 | List iframes = doc.select("iframe");
57 | for (Element iframe : iframes) {
58 | String src = iframe.attr("src");
59 | if (!src.startsWith("http") && !src.startsWith("//")) return iframe;
60 | }
61 | return iframes.get(0);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/hu/vsza/adsapi/Search.java:
--------------------------------------------------------------------------------
1 | package hu.vsza.adsapi;
2 |
3 | import java.io.IOException;
4 | import java.util.ArrayList;
5 | import org.jsoup.Jsoup;
6 | import org.jsoup.nodes.Document;
7 | import org.jsoup.nodes.Element;
8 | import org.jsoup.select.Elements;
9 |
10 | public class Search {
11 | public enum Mode {
12 | INCLUDED(1), START_WITH(2), END(3), MATCH(4);
13 |
14 | private byte value;
15 |
16 | private Mode(int value) {
17 | this.value = (byte)value;
18 | }
19 |
20 | public byte getValue() {
21 | return value;
22 | }
23 |
24 | @Override
25 | public String toString() {
26 | return super.toString().toLowerCase().replace("_", " ");
27 | }
28 | }
29 |
30 | public static ArrayList searchByPartName(String partName, Mode searchMode) throws IOException {
31 | Document doc = Jsoup.connect("https://www.alldatasheet.com/view.jsp")
32 | .data("sField", Byte.toString(searchMode.getValue()))
33 | .data("sSearchword", partName)
34 | .header("Accept-Language", "en")
35 | .timeout(0)
36 | .post();
37 | Elements tableRows = doc.select("tr.nv_td");
38 |
39 | ArrayList partList = new ArrayList(tableRows.size());
40 |
41 | for (Element tableRow : tableRows) {
42 | Elements rowCells = tableRow.getElementsByTag("td");
43 | if (rowCells.size() < 3) continue;
44 | Element firstCol = rowCells.get(0);
45 | Elements links = firstCol.getElementsByTag("a");
46 | if (links.size() == 0) continue;
47 | String foundPartName = firstCol.text();
48 | String foundPartDesc = rowCells.get(2).text();
49 | String foundPartHref = links.get(0).absUrl("href");
50 | partList.add(new Part(foundPartName, foundPartDesc, foundPartHref));
51 | }
52 |
53 | return partList;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/hu/vsza/adsdroid/PartList.java:
--------------------------------------------------------------------------------
1 | package hu.vsza.adsdroid;
2 |
3 | import java.util.Date;
4 | import java.util.List;
5 | import java.util.Map;
6 | import java.io.*;
7 | import java.net.URLConnection;
8 | import hu.vsza.adsapi.Part;
9 | import android.app.ListActivity;
10 | import android.app.ProgressDialog;
11 | import android.content.Intent;
12 | import android.content.ActivityNotFoundException;
13 | import android.net.Uri;
14 | import android.os.Bundle;
15 | import android.os.AsyncTask;
16 | import android.os.Environment;
17 | import android.text.format.DateFormat;
18 | import android.view.View;
19 | import android.widget.ListView;
20 | import android.widget.SimpleAdapter;
21 | import android.widget.Toast;
22 |
23 | public class PartList extends ListActivity
24 | {
25 | public final static String PARTS = "hu.vsza.adsdroid.PartList.PARTS";
26 | ProgressDialog mProgressDialog;
27 |
28 | /** Called when the activity is first created. */
29 | @Override
30 | public void onCreate(Bundle savedInstanceState)
31 | {
32 | super.onCreate(savedInstanceState);
33 | List