diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..77eb23f --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*.log +*.iml +*.gradle +*.bat +gradlew +gradle.properties +local.properties +build/ +gradle/ diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..b16652c --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /home/me/Android/SDK/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/app/src/androidTest/java/apps4ics/com/wkdnb/ApplicationTest.java b/app/src/androidTest/java/apps4ics/com/wkdnb/ApplicationTest.java new file mode 100644 index 0000000..b3c8bd9 --- /dev/null +++ b/app/src/androidTest/java/apps4ics/com/wkdnb/ApplicationTest.java @@ -0,0 +1,13 @@ +package apps4ics.com.wkdnb; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase { + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..50adea0 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + diff --git a/app/src/main/java/apps4ics/com/wkdnb/Downloader.java b/app/src/main/java/apps4ics/com/wkdnb/Downloader.java new file mode 100644 index 0000000..6ca2515 --- /dev/null +++ b/app/src/main/java/apps4ics/com/wkdnb/Downloader.java @@ -0,0 +1,65 @@ +package apps4ics.com.wkdnb; + +import android.os.AsyncTask; +import android.util.Log; + +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.DefaultHttpClient; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +/** + * Created by me on 05.03.15. + */ +public class Downloader extends AsyncTask { + @Override + protected String doInBackground(String... urls){ + String response = ""; + for(String url : urls){ + response += downloadWebPage(url); + } + return response; + } + + private String downloadWebPage(String url){ + try { + HttpClient client = new DefaultHttpClient(); + HttpGet get = new HttpGet(url); + HttpResponse response = client.execute(get); + InputStream in = response.getEntity().getContent(); + + BufferedReader reader = new BufferedReader( + new InputStreamReader(in)); + String source = ""; + String tmp; + while ((tmp = reader.readLine()) != null) { + source += tmp; + } + return source; + } catch (IOException io){ + Log.e("Downloader", "Couldn't download " + url); + io.printStackTrace(); + return "Error when downloading Webpage " + url; + } + } + + public interface DownloadCompleteListener { + void onDownloadComplete(String result); + } + + private DownloadCompleteListener dc = null; + + public Downloader(DownloadCompleteListener dc){ + this.dc = dc; + } + + @Override + protected void onPostExecute(String result){ + dc.onDownloadComplete(result); + } +} diff --git a/app/src/main/java/apps4ics/com/wkdnb/MainActivity.java b/app/src/main/java/apps4ics/com/wkdnb/MainActivity.java new file mode 100644 index 0000000..f0ded96 --- /dev/null +++ b/app/src/main/java/apps4ics/com/wkdnb/MainActivity.java @@ -0,0 +1,62 @@ +package apps4ics.com.wkdnb; + +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + + +public class MainActivity extends ActionBarActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + Button download = (Button) findViewById(R.id.button); + download.setOnClickListener(new View.OnClickListener(){ + @Override + public void onClick(View v){ + startDownload(); + } + }); + } + + private void startDownload(){ + Downloader.DownloadCompleteListener dcl = new + Downloader.DownloadCompleteListener(){ + @Override + public void onDownloadComplete(String result){ + TextView tv = (TextView) findViewById(R.id.text); + tv.setText(result); + } + }; + Downloader downloader = new Downloader(dcl); + downloader.execute("http://wannkommtdernaechstebusnachunten.getenv.net/?script=1"); + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } +} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..8cef67d --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + +