Commit 08b0801cd96eeabfbf47abfb6e3dad2685fc1588

Authored by Imanol-Mikel Barba Sabariego
0 parents

Initial Import - Versió Marc Siquier: Funciona Descàrrega

Showing 46 changed files with 370 additions and 0 deletions
.classpath 0 → 100644
  1 +++ a/.classpath
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<classpath>
  3 + <classpathentry kind="src" path="src"/>
  4 + <classpathentry kind="src" path="gen"/>
  5 + <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
  6 + <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
  7 + <classpathentry kind="output" path="bin/classes"/>
  8 +</classpath>
... ...
.project 0 → 100644
  1 +++ a/.project
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<projectDescription>
  3 + <name>UPC_NEWS_v0</name>
  4 + <comment></comment>
  5 + <projects>
  6 + </projects>
  7 + <buildSpec>
  8 + <buildCommand>
  9 + <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
  10 + <arguments>
  11 + </arguments>
  12 + </buildCommand>
  13 + <buildCommand>
  14 + <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
  15 + <arguments>
  16 + </arguments>
  17 + </buildCommand>
  18 + <buildCommand>
  19 + <name>org.eclipse.jdt.core.javabuilder</name>
  20 + <arguments>
  21 + </arguments>
  22 + </buildCommand>
  23 + <buildCommand>
  24 + <name>com.android.ide.eclipse.adt.ApkBuilder</name>
  25 + <arguments>
  26 + </arguments>
  27 + </buildCommand>
  28 + </buildSpec>
  29 + <natures>
  30 + <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
  31 + <nature>org.eclipse.jdt.core.javanature</nature>
  32 + </natures>
  33 +</projectDescription>
... ...
.settings/org.eclipse.jdt.core.prefs 0 → 100644
  1 +++ a/.settings/org.eclipse.jdt.core.prefs
  1 +eclipse.preferences.version=1
  2 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
  3 +org.eclipse.jdt.core.compiler.compliance=1.5
  4 +org.eclipse.jdt.core.compiler.source=1.5
... ...
AndroidManifest.xml 0 → 100644
  1 +++ a/AndroidManifest.xml
  1 +<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  2 + package="com.upc.pbe.upcnews"
  3 + android:versionCode="1"
  4 + android:versionName="1.0" >
  5 +
  6 + <uses-sdk
  7 + android:minSdkVersion="8"
  8 + android:targetSdkVersion="15" />
  9 + <uses-permission android:name="android.permission.INTERNET"/>
  10 + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  11 +
  12 + <application
  13 + android:icon="@drawable/ic_launcher"
  14 + android:label="@string/app_name"
  15 + android:theme="@style/AppTheme" >
  16 + <activity
  17 + android:name=".MainActivity"
  18 + android:label="@string/title_activity_main" >
  19 + <intent-filter>
  20 + <action android:name="android.intent.action.MAIN" />
  21 +
  22 + <category android:name="android.intent.category.LAUNCHER" />
  23 + </intent-filter>
  24 + </activity>
  25 + <activity android:name=".Descarrega"></activity>
  26 + </application>
  27 +
  28 +</manifest>
0 29 \ No newline at end of file
... ...
bin/AndroidManifest.xml 0 → 100644
  1 +++ a/bin/AndroidManifest.xml
  1 +<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  2 + package="com.upc.pbe.upcnews"
  3 + android:versionCode="1"
  4 + android:versionName="1.0" >
  5 +
  6 + <uses-sdk
  7 + android:minSdkVersion="8"
  8 + android:targetSdkVersion="15" />
  9 + <uses-permission android:name="android.permission.INTERNET"/>
  10 + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  11 +
  12 + <application
  13 + android:icon="@drawable/ic_launcher"
  14 + android:label="@string/app_name"
  15 + android:theme="@style/AppTheme" >
  16 + <activity
  17 + android:name=".MainActivity"
  18 + android:label="@string/title_activity_main" >
  19 + <intent-filter>
  20 + <action android:name="android.intent.action.MAIN" />
  21 +
  22 + <category android:name="android.intent.category.LAUNCHER" />
  23 + </intent-filter>
  24 + </activity>
  25 + <activity android:name=".Descarrega"></activity>
  26 + </application>
  27 +
  28 +</manifest>
0 29 \ No newline at end of file
... ...
bin/UPC_NEWS_v0.apk 0 → 100644
No preview for this file type
bin/classes.dex 0 → 100644
No preview for this file type
bin/classes/com/upc/pbe/upcnews/BuildConfig.class 0 → 100644
No preview for this file type
bin/classes/com/upc/pbe/upcnews/Descarrega.class 0 → 100644
No preview for this file type
bin/classes/com/upc/pbe/upcnews/MainActivity.class 0 → 100644
No preview for this file type
bin/classes/com/upc/pbe/upcnews/R$attr.class 0 → 100644
No preview for this file type
bin/classes/com/upc/pbe/upcnews/R$drawable.class 0 → 100644
No preview for this file type
bin/classes/com/upc/pbe/upcnews/R$id.class 0 → 100644
No preview for this file type
bin/classes/com/upc/pbe/upcnews/R$layout.class 0 → 100644
No preview for this file type
bin/classes/com/upc/pbe/upcnews/R$menu.class 0 → 100644
No preview for this file type
bin/classes/com/upc/pbe/upcnews/R$string.class 0 → 100644
No preview for this file type
bin/classes/com/upc/pbe/upcnews/R$style.class 0 → 100644
No preview for this file type
bin/classes/com/upc/pbe/upcnews/R.class 0 → 100644
No preview for this file type
bin/res/drawable-hdpi/ic_action_search.png 0 → 100644

409 Bytes

bin/res/drawable-hdpi/ic_launcher.png 0 → 100644

8.33 KB

bin/res/drawable-ldpi/ic_launcher.png 0 → 100644

3.07 KB

bin/res/drawable-mdpi/ic_action_search.png 0 → 100644

311 Bytes

bin/res/drawable-mdpi/ic_launcher.png 0 → 100644

4.54 KB

bin/res/drawable-xhdpi/ic_action_search.png 0 → 100644

491 Bytes

bin/res/drawable-xhdpi/ic_launcher.png 0 → 100644

12.7 KB

bin/resources.ap_ 0 → 100644
No preview for this file type
gen/com/upc/pbe/upcnews/BuildConfig.java 0 → 100644
  1 +++ a/gen/com/upc/pbe/upcnews/BuildConfig.java
  1 +/** Automatically generated file. DO NOT MODIFY */
  2 +package com.upc.pbe.upcnews;
  3 +
  4 +public final class BuildConfig {
  5 + public final static boolean DEBUG = true;
  6 +}
0 7 \ No newline at end of file
... ...
gen/com/upc/pbe/upcnews/R.java 0 → 100644
  1 +++ a/gen/com/upc/pbe/upcnews/R.java
  1 +/* AUTO-GENERATED FILE. DO NOT MODIFY.
  2 + *
  3 + * This class was automatically generated by the
  4 + * aapt tool from the resource data it found. It
  5 + * should not be modified by hand.
  6 + */
  7 +
  8 +package com.upc.pbe.upcnews;
  9 +
  10 +public final class R {
  11 + public static final class attr {
  12 + }
  13 + public static final class drawable {
  14 + public static final int ic_action_search=0x7f020000;
  15 + public static final int ic_launcher=0x7f020001;
  16 + }
  17 + public static final class id {
  18 + public static final int button=0x7f070000;
  19 + public static final int menu_settings=0x7f070002;
  20 + public static final int textView1=0x7f070001;
  21 + }
  22 + public static final class layout {
  23 + public static final int main_activity=0x7f030000;
  24 + }
  25 + public static final class menu {
  26 + public static final int activity_main=0x7f060000;
  27 + }
  28 + public static final class string {
  29 + public static final int app_name=0x7f040000;
  30 + public static final int descarregar=0x7f040004;
  31 + public static final int hello_world=0x7f040001;
  32 + public static final int hint=0x7f040005;
  33 + public static final int menu_settings=0x7f040002;
  34 + public static final int title_activity_main=0x7f040003;
  35 + }
  36 + public static final class style {
  37 + public static final int AppTheme=0x7f050000;
  38 + }
  39 +}
... ...
ic_launcher-web.png 0 → 100644

189 KB

libs/android-support-v4.jar 0 → 100644
No preview for this file type
lint.xml 0 → 100644
  1 +++ a/lint.xml
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<lint>
  3 +</lint>
0 4 \ No newline at end of file
... ...
proguard-project.txt 0 → 100644
  1 +++ a/proguard-project.txt
  1 +# To enable ProGuard in your project, edit project.properties
  2 +# to define the proguard.config property as described in that file.
  3 +#
  4 +# Add project specific ProGuard rules here.
  5 +# By default, the flags in this file are appended to flags specified
  6 +# in ${sdk.dir}/tools/proguard/proguard-android.txt
  7 +# You can edit the include path and order by changing the ProGuard
  8 +# include property in project.properties.
  9 +#
  10 +# For more details, see
  11 +# http://developer.android.com/guide/developing/tools/proguard.html
  12 +
  13 +# Add any project specific keep options here:
  14 +
  15 +# If your project uses WebView with JS, uncomment the following
  16 +# and specify the fully qualified class name to the JavaScript interface
  17 +# class:
  18 +#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
  19 +# public *;
  20 +#}
... ...
project.properties 0 → 100644
  1 +++ a/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 edit
  7 +# "ant.properties", and override values to adapt the script to your
  8 +# project structure.
  9 +#
  10 +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
  11 +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
  12 +
  13 +# Project target.
  14 +target=android-10
... ...
res/drawable-hdpi/ic_action_search.png 0 → 100644

3.05 KB

res/drawable-hdpi/ic_launcher.png 0 → 100644

8.7 KB

res/drawable-ldpi/ic_launcher.png 0 → 100644

3.12 KB

res/drawable-mdpi/ic_action_search.png 0 → 100644

2.96 KB

res/drawable-mdpi/ic_launcher.png 0 → 100644

4.69 KB

res/drawable-xhdpi/ic_action_search.png 0 → 100644

3.12 KB

res/drawable-xhdpi/ic_launcher.png 0 → 100644

13.1 KB

res/layout/main_activity.xml 0 → 100644
  1 +++ a/res/layout/main_activity.xml
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout android:layout_width="match_parent"
  3 + android:layout_height="match_parent"
  4 + android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">
  5 +
  6 + <Button
  7 + android:id="@+id/button"
  8 + android:layout_width="match_parent"
  9 + android:layout_height="wrap_content"
  10 + android:text="@string/descarregar" />
  11 +
  12 + <TextView
  13 + android:id="@+id/textView1"
  14 + android:layout_width="match_parent"
  15 + android:layout_height="match_parent"
  16 + android:hint="@string/hint" />
  17 +
  18 +</LinearLayout>
0 19 \ No newline at end of file
... ...
res/menu/activity_main.xml 0 → 100644
  1 +++ a/res/menu/activity_main.xml
  1 +<menu xmlns:android="http://schemas.android.com/apk/res/android">
  2 + <item android:id="@+id/menu_settings"
  3 + android:title="@string/menu_settings"
  4 + android:orderInCategory="100" />
  5 +</menu>
... ...
res/values/strings.xml 0 → 100644
  1 +++ a/res/values/strings.xml
  1 +<resources>
  2 +
  3 + <string name="app_name">UPC_NEWS_v0</string>
  4 + <string name="hello_world">Hello world!</string>
  5 + <string name="menu_settings">Settings</string>
  6 + <string name="title_activity_main">MainActivity</string>
  7 + <string name="descarregar">Descarrega</string>
  8 + <string name="hint">Esperant contingut...</string>
  9 +
  10 +</resources>
0 11 \ No newline at end of file
... ...
res/values/styles.xml 0 → 100644
  1 +++ a/res/values/styles.xml
  1 +<resources>
  2 +
  3 + <style name="AppTheme" parent="android:Theme.Light" />
  4 +
  5 +</resources>
0 6 \ No newline at end of file
... ...
src/com/upc/pbe/upcnews/Descarrega.java 0 → 100644
  1 +++ a/src/com/upc/pbe/upcnews/Descarrega.java
  1 +package com.upc.pbe.upcnews;
  2 +
  3 +import java.io.BufferedReader;
  4 +import java.io.File;
  5 +import java.io.FileOutputStream;
  6 +import java.io.IOException;
  7 +import java.io.InputStream;
  8 +import java.io.InputStreamReader;
  9 +import java.io.OutputStream;
  10 +import java.net.MalformedURLException;
  11 +import java.net.URL;
  12 +import java.net.URLConnection;
  13 +
  14 +import android.os.AsyncTask;
  15 +import android.util.Log;
  16 +
  17 +public class Descarrega extends AsyncTask<Object, Object, Object>{
  18 + final static String TAG = "Descarrega";
  19 + private String url;
  20 + private String nomarxiu;
  21 + private String carpeta;
  22 + private String html;
  23 + private File arxiu;
  24 +
  25 + public Descarrega(String url, String nomarxiu, String carpeta) {
  26 + this.url = url;
  27 + this.nomarxiu = nomarxiu;
  28 + this.carpeta = carpeta;
  29 + this.html = null;
  30 + this.arxiu = null;
  31 + }
  32 +
  33 + public void descarregarguardar() {
  34 + // Creem el directori
  35 + File dir = new File(carpeta);
  36 + if (!dir.exists()) {
  37 + if (!dir.mkdir()) {
  38 + return; // No s'ha pogut crear (ja existeix)
  39 + }
  40 + }
  41 +
  42 + // Creem l'arxiu
  43 + arxiu = new File(carpeta + nomarxiu);
  44 +
  45 + // Iniciem la descàrrega
  46 + try {
  47 + URLConnection conn = new URL(url).openConnection();
  48 + conn.connect();
  49 + Log.d(TAG, "\nDescarregant: \n");
  50 + Log.d(TAG, ">> URL: " + url + " >> Nom: " + nomarxiu
  51 + + " >> Tamany: " + conn.getContentLength() + " bytes");
  52 +
  53 + // Llegeix cada byte i l'escriu en un arxiu fins que arriba a -1
  54 + InputStream in = conn.getInputStream();
  55 + OutputStream out = new FileOutputStream(arxiu);
  56 + int b = 0;
  57 + while (b != -1) {
  58 + b = in.read();
  59 + if (b != -1) {
  60 + out.write(b);
  61 + }
  62 + }
  63 + out.close();
  64 + in.close();
  65 +
  66 + } catch (MalformedURLException e) {
  67 + e.printStackTrace();
  68 + } catch (IOException e) {
  69 + e.printStackTrace();
  70 + }
  71 + }
  72 +
  73 +
  74 +
  75 + protected Object doInBackground() {
  76 + try {
  77 + URLConnection conn = new URL(url).openConnection();
  78 + BufferedReader in = new BufferedReader(new InputStreamReader(
  79 + conn.getInputStream()));
  80 + Log.d(TAG, "\nDescarregant: \n");
  81 + Log.d(TAG, ">> URL: " + url + " >> Nom: " + nomarxiu
  82 + + " >> Tamany: " + conn.getContentLength() + " bytes");
  83 + String inputLine;
  84 + while ((inputLine = in.readLine()) != null) {
  85 + Log.d(TAG, inputLine);
  86 + html = html + "\n" + inputLine;
  87 + }
  88 + Log.d(TAG, "Descarrega finalitzada");
  89 + in.close();
  90 + } catch (MalformedURLException e) {
  91 + Log.d(TAG, "excepcio 1");
  92 + e.printStackTrace();
  93 + } catch (IOException e) {
  94 + Log.d(TAG, "excepcio 2");
  95 + e.printStackTrace();
  96 + }
  97 +
  98 + return html;
  99 +
  100 +
  101 + }
  102 +
  103 + @Override
  104 + protected Object doInBackground(Object... arg0) {
  105 +
  106 + return null;
  107 + }
  108 +}
... ...
src/com/upc/pbe/upcnews/MainActivity.java 0 → 100644
  1 +++ a/src/com/upc/pbe/upcnews/MainActivity.java
  1 +package com.upc.pbe.upcnews;
  2 +
  3 +import com.upc.pbe.upcnews.R;
  4 +
  5 +import android.app.Activity;
  6 +import android.os.Bundle;
  7 +import android.util.Log;
  8 +import android.view.View;
  9 +import android.view.View.OnClickListener;
  10 +import android.widget.Button;
  11 +import android.widget.TextView;
  12 +
  13 +public class MainActivity extends Activity implements OnClickListener {
  14 + final static String TAG = "Main";
  15 + Button buttonDescarrega;
  16 + String url = "http://10.0.2.100";
  17 + String file = "example.m3u8";
  18 + String folder = "C:\\Users\\Usuario\\Downloads\\";
  19 + TextView show;
  20 +
  21 + @Override
  22 + public void onCreate(Bundle savedInstanceState) {
  23 + super.onCreate(savedInstanceState);
  24 + setContentView(R.layout.main_activity);
  25 + Log.d(TAG, "onCreated");
  26 + buttonDescarrega = (Button) findViewById(R.id.button);
  27 + buttonDescarrega.setOnClickListener(this);
  28 + show = (TextView) findViewById(R.id.textView1);
  29 +
  30 + }
  31 +
  32 + public void onClick(View v) {
  33 + Log.d(TAG, "onClicked");
  34 + Descarrega d = new Descarrega(url, file, folder);
  35 + CharSequence html = (CharSequence) d.doInBackground();
  36 + show.setText(html);
  37 +
  38 +
  39 + }
  40 +
  41 +}
0 42 \ No newline at end of file
... ...