Skip to content
This repository
Browse code

cleanup, upgrate to android 2.1 agin + adding getPods() as a AsyncTask

  • Loading branch information...
commit 9d4d2657ab13ba9ce366e3cd5774b5be81b43049 1 parent f766774
Voidcode authored

Showing 37 changed files with 403 additions and 54 deletions. Show diff stats Hide diff stats

  1. +2 2 AndroidManifest.xml
  2. BIN  bin/Diaspora-Webclient.apk
  3. BIN  bin/classes.dex
  4. BIN  bin/classes/com/voidcode/diasporawebclient/MainActivity$2.class
  5. BIN  bin/classes/com/voidcode/diasporawebclient/MainActivity.class
  6. BIN  bin/classes/com/voidcode/diasporawebclient/PodSettingsActivity$1.class
  7. BIN  bin/classes/com/voidcode/diasporawebclient/PodSettingsActivity$2.class
  8. BIN  bin/classes/com/voidcode/diasporawebclient/PodSettingsActivity$3.class
  9. BIN  bin/classes/com/voidcode/diasporawebclient/PodSettingsActivity.class
  10. BIN  bin/classes/com/voidcode/diasporawebclient/R$drawable.class
  11. BIN  bin/classes/com/voidcode/diasporawebclient/R$id.class
  12. BIN  bin/classes/com/voidcode/diasporawebclient/R$layout.class
  13. BIN  bin/classes/com/voidcode/diasporawebclient/R$string.class
  14. BIN  bin/classes/com/voidcode/diasporawebclient/R$style.class
  15. BIN  bin/classes/com/voidcode/diasporawebclient/R$xml.class
  16. BIN  bin/classes/com/voidcode/diasporawebclient/ShareActivity.class
  17. BIN  bin/classes/com/voidcode/diasporawebclient/getPodlistTask.class
  18. BIN  bin/res/drawable-hdpi/ic_menu_podsettings.png
  19. BIN  bin/res/drawable-ldpi/ic_menu_podsettings.png
  20. BIN  bin/res/drawable-mdpi/ic_menu_podsettings.png
  21. BIN  bin/res/drawable-xhdpi/ic_menu_podsettings.png
  22. BIN  bin/resources.ap_
  23. +30 28 gen/com/voidcode/diasporawebclient/R.java
  24. +1 1  project.properties
  25. BIN  res/drawable-hdpi/ic_menu_podsettings.png
  26. BIN  res/drawable-ldpi/ic_menu_podsettings.png
  27. BIN  res/drawable-mdpi/ic_menu_podsettings.png
  28. BIN  res/drawable-xhdpi/ic_menu_podsettings.png
  29. +44 0 res/layout/podsettings.xml
  30. +1 1  res/layout/setupinternet.xml
  31. +1 1  res/menu/main_menu.xml
  32. +10 7 res/values/strings.xml
  33. +1 1  src/com/voidcode/diasporawebclient/JSInterface.java
  34. +8 8 src/com/voidcode/diasporawebclient/MainActivity.java
  35. +205 0 src/com/voidcode/diasporawebclient/PodSettingsActivity.java
  36. +5 5 src/com/voidcode/diasporawebclient/ShareActivity.java
  37. +95 0 src/com/voidcode/diasporawebclient/getPodlistTask.java
4 AndroidManifest.xml
@@ -4,7 +4,7 @@
4 4 android:versionCode="7"
5 5 android:versionName="1.6">
6 6
7   - <uses-sdk android:minSdkVersion="4" />
  7 + <uses-sdk android:minSdkVersion="7" />
8 8 <uses-permission android:name="android.permission.INTERNET"/>
9 9 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
10 10
@@ -34,7 +34,7 @@
34 34 </activity>
35 35 <activity
36 36 android:theme="@android:style/Theme.NoTitleBar"
37   - android:name=".SettingsActivity"
  37 + android:name=".PodSettingsActivity"
38 38 android:configChanges="orientation">
39 39 </activity>
40 40 <activity
BIN  bin/Diaspora-Webclient.apk
Binary file not shown
BIN  bin/classes.dex
Binary file not shown
BIN  bin/classes/com/voidcode/diasporawebclient/MainActivity$2.class
Binary file not shown
BIN  bin/classes/com/voidcode/diasporawebclient/MainActivity.class
Binary file not shown
BIN  bin/classes/com/voidcode/diasporawebclient/PodSettingsActivity$1.class
Binary file not shown
BIN  bin/classes/com/voidcode/diasporawebclient/PodSettingsActivity$2.class
Binary file not shown
BIN  bin/classes/com/voidcode/diasporawebclient/PodSettingsActivity$3.class
Binary file not shown
BIN  bin/classes/com/voidcode/diasporawebclient/PodSettingsActivity.class
Binary file not shown
BIN  bin/classes/com/voidcode/diasporawebclient/R$drawable.class
Binary file not shown
BIN  bin/classes/com/voidcode/diasporawebclient/R$id.class
Binary file not shown
BIN  bin/classes/com/voidcode/diasporawebclient/R$layout.class
Binary file not shown
BIN  bin/classes/com/voidcode/diasporawebclient/R$string.class
Binary file not shown
BIN  bin/classes/com/voidcode/diasporawebclient/R$style.class
Binary file not shown
BIN  bin/classes/com/voidcode/diasporawebclient/R$xml.class
Binary file not shown
BIN  bin/classes/com/voidcode/diasporawebclient/ShareActivity.class
Binary file not shown
BIN  bin/classes/com/voidcode/diasporawebclient/getPodlistTask.class
Binary file not shown
BIN  bin/res/drawable-hdpi/ic_menu_podsettings.png
BIN  bin/res/drawable-ldpi/ic_menu_podsettings.png
BIN  bin/res/drawable-mdpi/ic_menu_podsettings.png
BIN  bin/res/drawable-xhdpi/ic_menu_podsettings.png
BIN  bin/resources.ap_
Binary file not shown
58 gen/com/voidcode/diasporawebclient/R.java
@@ -21,9 +21,9 @@
21 21 public static final int ic_menu_invite=0x7f020007;
22 22 public static final int ic_menu_messages=0x7f020008;
23 23 public static final int ic_menu_notifications=0x7f020009;
24   - public static final int ic_menu_profile=0x7f02000a;
25   - public static final int ic_menu_search=0x7f02000b;
26   - public static final int ic_menu_settings=0x7f02000c;
  24 + public static final int ic_menu_podsettings=0x7f02000a;
  25 + public static final int ic_menu_profile=0x7f02000b;
  26 + public static final int ic_menu_search=0x7f02000c;
27 27 public static final int ic_menu_share=0x7f02000d;
28 28 public static final int ic_menu_tips=0x7f02000e;
29 29 public static final int ic_menu_translate=0x7f02000f;
@@ -43,7 +43,7 @@
43 43 public static final int listView_poduptime=0x7f08000b;
44 44 public static final int mainmenu_donation=0x7f08001f;
45 45 public static final int mainmenu_exit=0x7f080020;
46   - public static final int mainmenu_settings=0x7f08001d;
  46 + public static final int mainmenu_podsettings=0x7f08001d;
47 47 public static final int mainmenu_share=0x7f08001b;
48 48 public static final int mainmenu_tips=0x7f08001e;
49 49 public static final int mainmenu_translate=0x7f08001c;
@@ -67,7 +67,7 @@
67 67 }
68 68 public static final class layout {
69 69 public static final int main=0x7f030000;
70   - public static final int settings=0x7f030001;
  70 + public static final int podsettings=0x7f030001;
71 71 public static final int setupinternet=0x7f030002;
72 72 public static final int translate=0x7f030003;
73 73 public static final int widget=0x7f030004;
@@ -77,12 +77,12 @@
77 77 }
78 78 public static final class string {
79 79 public static final int app_name=0x7f050000;
80   - public static final int findtag=0x7f05001d;
81   - public static final int findtag_alert_title=0x7f05001b;
82   - public static final int findtag_alert_validate_needsomedata=0x7f05001c;
83   - public static final int findtag_button=0x7f05001a;
84   - public static final int findtag_h1=0x7f050018;
85   - public static final int findtag_p=0x7f050019;
  80 + public static final int findtag=0x7f05001f;
  81 + public static final int findtag_alert_title=0x7f05001d;
  82 + public static final int findtag_alert_validate_needsomedata=0x7f05001e;
  83 + public static final int findtag_button=0x7f05001c;
  84 + public static final int findtag_h1=0x7f05001a;
  85 + public static final int findtag_p=0x7f05001b;
86 86 public static final int menu_aspects=0x7f05000c;
87 87 public static final int menu_contacts=0x7f050008;
88 88 public static final int menu_donation=0x7f050006;
@@ -92,27 +92,29 @@
92 92 public static final int menu_invite=0x7f05000d;
93 93 public static final int menu_messages=0x7f05000a;
94 94 public static final int menu_notifications=0x7f050009;
  95 + public static final int menu_podsettings=0x7f050004;
95 96 public static final int menu_profile=0x7f05000b;
96   - public static final int menu_settings=0x7f050004;
97 97 public static final int menu_share=0x7f050002;
98 98 public static final int menu_tips=0x7f050005;
99 99 public static final int menu_translate=0x7f050007;
100   - public static final int settings_button_close=0x7f05001e;
101   - public static final int settings_button_save=0x7f050013;
102   - public static final int settings_currentpod=0x7f050011;
103   - public static final int settings_h1=0x7f05000f;
104   - public static final int settings_text_currentpod=0x7f050010;
105   - public static final int setupinternet_button=0x7f050017;
106   - public static final int setupinternet_button_wirelesssettings=0x7f050016;
107   - public static final int setupinternet_h1=0x7f050014;
108   - public static final int setupinternet_text=0x7f050015;
109   - public static final int translate_button_howto_obtain_googletranslatekey=0x7f050024;
110   - public static final int translate_button_linkto_googleapiconsole=0x7f050022;
111   - public static final int translate_button_text=0x7f050021;
112   - public static final int translate_chooselanguage_h1=0x7f05001f;
113   - public static final int translate_googlekey_h1=0x7f050020;
114   - public static final int translate_howto_text=0x7f050023;
115   - public static final int widget_button_share=0x7f050012;
  100 + public static final int podsettings_button_close=0x7f050020;
  101 + public static final int podsettings_button_save=0x7f050015;
  102 + public static final int podsettings_currentpod=0x7f050011;
  103 + public static final int podsettings_dialog_text=0x7f050013;
  104 + public static final int podsettings_dialog_title=0x7f050012;
  105 + public static final int podsettings_h1=0x7f05000f;
  106 + public static final int podsettings_text_currentpod=0x7f050010;
  107 + public static final int setupinternet_button=0x7f050019;
  108 + public static final int setupinternet_button_wirelesssettings=0x7f050018;
  109 + public static final int setupinternet_h1=0x7f050016;
  110 + public static final int setupinternet_text=0x7f050017;
  111 + public static final int translate_button_howto_obtain_googletranslatekey=0x7f050026;
  112 + public static final int translate_button_linkto_googleapiconsole=0x7f050024;
  113 + public static final int translate_button_text=0x7f050023;
  114 + public static final int translate_chooselanguage_h1=0x7f050021;
  115 + public static final int translate_googlekey_h1=0x7f050022;
  116 + public static final int translate_howto_text=0x7f050025;
  117 + public static final int widget_button_share=0x7f050014;
116 118 }
117 119 public static final class style {
118 120 public static final int widgetimagesbutton=0x7f060000;
2  project.properties
@@ -8,4 +8,4 @@
8 8 # project structure.
9 9
10 10 # Project target.
11   -target=android-4
  11 +target=android-7
BIN  res/drawable-hdpi/ic_menu_podsettings.png
BIN  res/drawable-ldpi/ic_menu_podsettings.png
BIN  res/drawable-mdpi/ic_menu_podsettings.png
BIN  res/drawable-xhdpi/ic_menu_podsettings.png
44 res/layout/podsettings.xml
... ... @@ -0,0 +1,44 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="fill_parent"
  4 + android:layout_height="fill_parent"
  5 + android:orientation="vertical" >
  6 + <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  7 + android:layout_width="fill_parent"
  8 + android:layout_height="wrap_content"
  9 + android:orientation="vertical"
  10 + android:background="@drawable/topmenu_repeat" >
  11 + <ImageView
  12 + android:id="@+id/imageView1"
  13 + android:layout_width="wrap_content"
  14 + android:layout_height="wrap_content"
  15 + android:src="@drawable/topmenu" />
  16 + </LinearLayout>
  17 + <TextView
  18 + android:id="@+id/textView1"
  19 + android:layout_width="fill_parent"
  20 + android:layout_height="wrap_content"
  21 + android:text="@string/podsettings_text_currentpod"
  22 + android:textAppearance="?android:attr/textAppearanceMedium" />
  23 +
  24 + <EditText
  25 + android:id="@+id/editText_currentpod"
  26 + android:layout_width="fill_parent"
  27 + android:layout_height="wrap_content"
  28 + android:text="@string/podsettings_currentpod">
  29 + </EditText>
  30 + <Button
  31 + android:id="@+id/settings_button_save"
  32 + android:layout_width="fill_parent"
  33 + android:layout_height="wrap_content"
  34 + android:onClick="Onclick_SaveSettings"
  35 + android:text="@string/podsettings_button_save" />
  36 +
  37 + <ListView
  38 + android:id="@+id/listView_poduptime"
  39 + android:layout_width="fill_parent"
  40 + android:layout_height="wrap_content" >
  41 +
  42 + </ListView>
  43 +
  44 +</LinearLayout>
2  res/layout/setupinternet.xml
@@ -50,7 +50,7 @@
50 50 android:id="@+id/settings_button_close"
51 51 android:layout_width="wrap_content"
52 52 android:layout_height="wrap_content"
53   - android:text="@string/settings_button_close" />
  53 + android:text="@string/podsettings_button_close" />
54 54
55 55 </TableLayout>
56 56
2  res/menu/main_menu.xml
@@ -2,7 +2,7 @@
2 2 <menu xmlns:android="http://schemas.android.com/apk/res/android" >
3 3 <item android:id="@+id/mainmenu_share" android:icon="@drawable/ic_menu_share" android:title="@string/menu_share" />
4 4 <item android:id="@+id/mainmenu_translate" android:icon="@drawable/ic_menu_translate" android:title="@string/menu_translate" />
5   - <item android:id="@+id/mainmenu_settings" android:icon="@drawable/ic_menu_settings" android:title="@string/menu_settings" />
  5 + <item android:id="@+id/mainmenu_podsettings" android:icon="@drawable/ic_menu_podsettings" android:title="@string/menu_podsettings" />
6 6 <item android:id="@+id/mainmenu_tips" android:icon="@drawable/ic_menu_tips" android:title="@string/menu_tips" />
7 7 <item android:id="@+id/mainmenu_donation" android:icon="@drawable/ic_menu_donation" android:title="@string/menu_donation" />
8 8 <item android:id="@+id/mainmenu_exit" android:icon="@drawable/ic_menu_exit" android:title="@string/menu_exit" />
17 res/values/strings.xml
@@ -5,7 +5,7 @@
5 5 <string name="menu_home">Stream</string>
6 6 <string name="menu_share">Share</string>
7 7 <string name="menu_findtag">Find tag</string>
8   - <string name="menu_settings">Settings</string>
  8 + <string name="menu_podsettings">PodSettings</string>
9 9 <string name="menu_tips">Tips</string>
10 10 <string name="menu_donation">Donation</string>
11 11 <string name="menu_translate">Translate</string>
@@ -19,13 +19,16 @@
19 19 <string name="menu_invite">Invite</string>
20 20 <string name="menu_exit">Exit</string>
21 21
22   - <string name="settings_h1">Settings.</string>
23   - <string name="settings_text_currentpod">Find your pod.</string>
24   - <string name="settings_currentpod"></string>
25   -
  22 + <string name="podsettings_h1">Settings.</string>
  23 + <string name="podsettings_text_currentpod">Find your pod.</string>
  24 + <string name="podsettings_currentpod"></string>
  25 +
  26 + <string name="podsettings_dialog_title">PodSettings</string>
  27 + <string name="podsettings_dialog_text">You have to choose a pod before you can logon Diaspora.\nWith this client you wil only be enable to logon pods there uses https.\nAll pods showing in the list is from podupti.me and uses https.</string>
  28 +
26 29 <string name="widget_button_share">Share on diaspora</string>
27 30
28   - <string name="settings_button_save">Use this pod</string>
  31 + <string name="podsettings_button_save">Use this pod</string>
29 32
30 33 <string name="setupinternet_h1">Setup internet</string>
31 34 <string name="setupinternet_text">This app require a internet connection!</string>
@@ -39,7 +42,7 @@
39 42 <string name="findtag" >findtag</string>
40 43
41 44
42   - <string name="settings_button_close">Ok</string>
  45 + <string name="podsettings_button_close">Ok</string>
43 46
44 47 <string name="translate_chooselanguage_h1">Translate post to this language.</string>
45 48 <string name="translate_googlekey_h1">Add your translate api-key here.</string>
2  src/com/voidcode/diasporawebclient/JSInterface.java
@@ -14,7 +14,7 @@ public String Translate(String main_domain, String googleapikey, String defaultl
14 14 String decodetext = URLDecoder.decode(text);
15 15 String rawtext = decodetext.replaceAll("\\<.*?\\>", "");//remove all htmltags
16 16 //TODO: find out if google is tacking money for 'none' translate word(HEX23...the..word),
17   - //if, then make it so all tag is remove form the 'rawtext' and then add it back to the 'translatePost'(after: Translate.DEFAULT.execute)
  17 + //if, then make it so all tag is remove form the 'rawtext' anded then add it back to the 'translatePost'(after: Translate.DEFAULT.execute)
18 18 rawtext = rawtext.replaceAll("#", "HEX23");//format all #tags so google-translate don�t translate the #tag
19 19 rawtext = rawtext.trim();//remove end-spaces
20 20 // Set the HTTP referrer to your website address.
16 src/com/voidcode/diasporawebclient/MainActivity.java
@@ -52,11 +52,11 @@ public void onCreate(Bundle savedInstanceState) {
52 52
53 53 //set cache size to 8mb by default.
54 54 settings.setCacheMode(1);
55   - // settings.setAppCacheMaxSize(1024*1024*8);
56   - // settings.setDomStorageEnabled(true);
57   - // settings.setAppCachePath("/data/data/com.voidcode.diasporawebclient/cache");
58   - // settings.setAllowFileAccess(true);
59   - // settings.setAppCacheEnabled(true);
  55 + settings.setAppCacheMaxSize(1024*1024*8);
  56 + settings.setDomStorageEnabled(true);
  57 + settings.setAppCachePath("/data/data/com.voidcode.diasporawebclient/cache");
  58 + settings.setAllowFileAccess(true);
  59 + settings.setAppCacheEnabled(true);
60 60
61 61 //settings.setBuiltInZoomControls(true);
62 62
@@ -82,7 +82,7 @@ public boolean onJsAlert(WebView view, String url, String message, JsResult resu
82 82 //then open SettingsActivity
83 83 if(this.main_domain.equals(""))
84 84 {
85   - startActivity(new Intent(this, SettingsActivity.class));
  85 + startActivity(new Intent(this, PodSettingsActivity.class));
86 86 }
87 87 else
88 88 {
@@ -256,9 +256,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
256 256 this.finish();
257 257 startActivity(new Intent(this, TranslateActivity.class));
258 258 return true;
259   - case R.id.mainmenu_settings:
  259 + case R.id.mainmenu_podsettings:
260 260 this.finish();
261   - startActivity(new Intent(this, SettingsActivity.class));
  261 + startActivity(new Intent(this, PodSettingsActivity.class));
262 262 return true;
263 263 case R.id.mainmenu_tips:
264 264 mWeb.loadUrl("file:///android_asset/tips.html");
205 src/com/voidcode/diasporawebclient/PodSettingsActivity.java
... ... @@ -0,0 +1,205 @@
  1 +package com.voidcode.diasporawebclient;
  2 +
  3 +import java.io.BufferedReader;
  4 +import java.io.IOException;
  5 +import java.io.InputStream;
  6 +import java.io.InputStreamReader;
  7 +import java.util.ArrayList;
  8 +import java.util.List;
  9 +import java.util.concurrent.ExecutionException;
  10 +
  11 +import org.apache.http.HttpEntity;
  12 +import org.apache.http.HttpResponse;
  13 +import org.apache.http.StatusLine;
  14 +import org.apache.http.client.ClientProtocolException;
  15 +import org.apache.http.client.HttpClient;
  16 +import org.apache.http.client.methods.HttpGet;
  17 +import org.apache.http.impl.client.DefaultHttpClient;
  18 +import org.json.JSONArray;
  19 +import org.json.JSONObject;
  20 +import android.app.Activity;
  21 +import android.app.AlertDialog;
  22 +import android.app.ProgressDialog;
  23 +import android.content.Context;
  24 +import android.content.DialogInterface;
  25 +import android.content.Intent;
  26 +import android.content.SharedPreferences;
  27 +import android.content.res.Configuration;
  28 +import android.net.ConnectivityManager;
  29 +import android.net.NetworkInfo;
  30 +import android.os.Bundle;
  31 +import android.text.Editable;
  32 +import android.text.TextWatcher;
  33 +import android.util.Log;
  34 +import android.view.KeyEvent;
  35 +import android.view.View;
  36 +import android.widget.AdapterView;
  37 +import android.widget.ArrayAdapter;
  38 +import android.widget.EditText;
  39 +import android.widget.ListView;
  40 +import android.widget.AdapterView.OnItemClickListener;
  41 +import android.widget.Toast;
  42 +
  43 +public class PodSettingsActivity extends Activity {
  44 + public static final String SETTINGS_FILENAME="settings";
  45 + public ListView lvPods;
  46 + public String lvPods_arr[];
  47 + private EditText editTextCurrentpod;
  48 + JSONArray jsonArray;
  49 + @Override
  50 + public void onCreate(Bundle savedInstanceState) {
  51 + if(isNetworkAvailable())
  52 + {
  53 +
  54 +
  55 +
  56 + try {
  57 + //load pods from poduptime.me as a AsyncTask
  58 +
  59 + lvPods_arr = new getPodlistTask(this).execute().get();
  60 +
  61 + Log.i("lvPods_arr", String.valueOf(lvPods_arr.length) );
  62 +
  63 + super.onCreate(savedInstanceState);
  64 + setContentView(R.layout.podsettings);
  65 +
  66 + //load elements from layout file podsettings.xml
  67 + editTextCurrentpod = (EditText) findViewById(R.id.editText_currentpod);
  68 + lvPods = (ListView) findViewById(R.id.listView_poduptime);
  69 +
  70 + //show the currentpod to user
  71 + SharedPreferences preferences = getSharedPreferences(SETTINGS_FILENAME, MODE_PRIVATE);
  72 + editTextCurrentpod.setText(preferences.getString("currentpod", "You need to choose a pod"));
  73 + editTextCurrentpod.selectAll();
  74 +
  75 + //check if user have be get the dialog info box
  76 + if(preferences.getBoolean("has_show_dialog", false) == false)
  77 + {
  78 + final AlertDialog.Builder alert = new AlertDialog.Builder(this);
  79 + alert.setTitle(R.string.podsettings_dialog_title);
  80 + alert.setMessage(R.string.podsettings_dialog_text);
  81 + alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
  82 + public void onClick(DialogInterface dialog, int whichButton) {
  83 + }
  84 + });
  85 + alert.show();
  86 + //this ensure the user only see the dialogbox ones
  87 + SharedPreferences.Editor editor = preferences.edit();
  88 + editor.putBoolean("has_show_dialog", true);
  89 + editor.commit();
  90 + }
  91 +
  92 + //fill listview with pods form http://podupti.me
  93 + fillListview(this.lvPods_arr);
  94 +
  95 + //podsearch, A fast find search on editTextCurrentpod, So user don�t have to scholl the podlist to finde a pod
  96 + editTextCurrentpod.addTextChangedListener(new TextWatcher()
  97 + {
  98 + List<String> filter_podurl_list = null;
  99 + public void beforeTextChanged(CharSequence s, int start, int count, int after)
  100 + {
  101 + }
  102 + public void onTextChanged(CharSequence s, int start, int before, int count)
  103 + {
  104 + filter_podurl_list=new ArrayList<String>();
  105 + for(String podurl:lvPods_arr)
  106 + {
  107 + if(podurl.startsWith(s.toString()))
  108 + {
  109 + filter_podurl_list.add(podurl);
  110 + }
  111 + }
  112 + }
  113 + public void afterTextChanged(Editable s)
  114 + {
  115 + ///add reslut to listview
  116 + if(!filter_podurl_list.equals(null))
  117 + fillListview(filter_podurl_list.toArray(new String[filter_podurl_list.size()]));
  118 + }
  119 + });
  120 +
  121 + } catch (InterruptedException e) {
  122 + // TODO Auto-generated catch block
  123 + e.printStackTrace();
  124 + } catch (ExecutionException e) {
  125 + // TODO Auto-generated catch block
  126 + e.printStackTrace();
  127 + }
  128 +
  129 +
  130 +
  131 +
  132 +
  133 + }
  134 + else //user have NO internet
  135 + {
  136 + this.finish();
  137 + startActivity(new Intent(this, SetupInternetActivity.class));
  138 + }
  139 + }
  140 + public void fillListview(String _lvPods_arr[])
  141 + {
  142 + lvPods.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, _lvPods_arr));
  143 + lvPods.setOnItemClickListener(new OnItemClickListener(){
  144 + public void onItemClick(AdapterView<?> a, View v, int position, long id) {
  145 + //onclick put select pod to editTextCurrentpod
  146 + editTextCurrentpod.setText(lvPods.getItemAtPosition(position).toString());
  147 + }
  148 + });
  149 + }
  150 + //Screen orientation crashes app fix
  151 + //http://jamesgiang.wordpress.com/2010/06/05/screen-orientation-crashes-my-app/
  152 + @Override
  153 + public void onConfigurationChanged(Configuration newConfig)
  154 + {
  155 + super.onConfigurationChanged(newConfig);
  156 + }
  157 + // Handle the Back button
  158 + @Override
  159 + public boolean onKeyDown(int keyCode, KeyEvent msg){
  160 + if((keyCode == KeyEvent.KEYCODE_BACK))
  161 + {
  162 + this.finish();
  163 + startActivity(new Intent(this, MainActivity.class));
  164 + return false;
  165 + }
  166 + else
  167 + return true;
  168 + }
  169 + public void Onclick_SaveSettings(View v) throws IOException
  170 + {
  171 + //get userinput
  172 + String new_currentpod = editTextCurrentpod.getText().toString();
  173 + //if user has added a pod
  174 + if(!new_currentpod.equals(""))
  175 + {
  176 + // Save the new currentpod
  177 + SharedPreferences preferences = getSharedPreferences(SETTINGS_FILENAME, MODE_PRIVATE);
  178 + SharedPreferences.Editor editor = preferences.edit();
  179 + editor.putString("currentpod", new_currentpod);
  180 + editor.commit();
  181 + //goto MainActivity
  182 + this.finish();
  183 + startActivity(new Intent(this, MainActivity.class));
  184 + }
  185 + else
  186 + Toast.makeText(getApplicationContext(), "You need to choose a pod", Toast.LENGTH_SHORT).show();
  187 + }
  188 + //simple json parsing, to retrieve list of pods from podupti.me
  189 + //https://github.com/voidcode/Diaspora-Webclient/pull/4
  190 + //by: https://github.com/vipulnsward
  191 +
  192 + private boolean isNetworkAvailable()
  193 + {
  194 + ConnectivityManager connec = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
  195 + NetworkInfo mobileInfo = connec.getNetworkInfo(0);
  196 + NetworkInfo wifiInfo = connec.getNetworkInfo(1);
  197 + NetworkInfo wimaxInfo = connec.getNetworkInfo(6);
  198 + if (wimaxInfo!=null) {
  199 + return mobileInfo.isConnected() || wifiInfo.isConnected()|| wimaxInfo.isConnected();
  200 + }
  201 + else {
  202 + return mobileInfo.isConnected() || wifiInfo.isConnected();
  203 + }
  204 + }
  205 +}
10 src/com/voidcode/diasporawebclient/ShareActivity.java
@@ -23,11 +23,11 @@ public void onCreate(Bundle savedInstanceState) {
23 23
24 24 //set cache size to 8mb by default.
25 25 settings.setCacheMode(1);
26   - //settings.setAppCacheMaxSize(1024*1024*8);
27   - // settings.setDomStorageEnabled(true);
28   - //settings.setAppCachePath("/data/data/com.voidcode.diasporawebclient/cache");
29   - //settings.setAllowFileAccess(true);
30   - //settings.setAppCacheEnabled(true);
  26 + settings.setAppCacheMaxSize(1024*1024*8);
  27 + settings.setDomStorageEnabled(true);
  28 + settings.setAppCachePath("/data/data/com.voidcode.diasporawebclient/cache");
  29 + settings.setAllowFileAccess(true);
  30 + settings.setAppCacheEnabled(true);
31 31
32 32 //settings.setBuiltInZoomControls(true);
33 33 // load: open new messages
95 src/com/voidcode/diasporawebclient/getPodlistTask.java
... ... @@ -0,0 +1,95 @@
  1 +package com.voidcode.diasporawebclient;
  2 +
  3 +import java.io.BufferedReader;
  4 +import java.io.IOException;
  5 +import java.io.InputStream;
  6 +import java.io.InputStreamReader;
  7 +import java.util.ArrayList;
  8 +import java.util.List;
  9 +
  10 +import org.apache.http.HttpEntity;
  11 +import org.apache.http.HttpResponse;
  12 +import org.apache.http.StatusLine;
  13 +import org.apache.http.client.ClientProtocolException;
  14 +import org.apache.http.client.HttpClient;
  15 +import org.apache.http.client.methods.HttpGet;
  16 +import org.apache.http.impl.client.DefaultHttpClient;
  17 +import org.json.JSONArray;
  18 +import org.json.JSONObject;
  19 +
  20 +import android.content.Context;
  21 +import android.app.ProgressDialog;
  22 +import android.os.AsyncTask;
  23 +
  24 +public class getPodlistTask extends AsyncTask<Void, Void, String[]> {
  25 + protected Context context;
  26 + private ProgressDialog dialog;
  27 +
  28 + public getPodlistTask(Context c)
  29 + {
  30 + context = c;
  31 + }
  32 + @Override
  33 + protected void onPreExecute() {
  34 + super.onPreExecute();
  35 + dialog = new ProgressDialog(context);
  36 + dialog.setMessage("Downloading podlist from poduptime.me");
  37 + dialog.setIndeterminate(true);
  38 + dialog.setCancelable(false);
  39 + dialog.show();
  40 + }
  41 + protected void onPostExecute(String[] pods) {
  42 + dialog.dismiss();
  43 + }
  44 + @Override
  45 + protected String[] doInBackground(Void... params) {
  46 + StringBuilder builder = new StringBuilder();
  47 + HttpClient client = new DefaultHttpClient();
  48 + List<String> list = null;
  49 + try {
  50 + HttpGet httpGet = new HttpGet("http://podupti.me/api.php?key=4r45tg&format=json");
  51 + HttpResponse response = client.execute(httpGet);
  52 + StatusLine statusLine = response.getStatusLine();
  53 + int statusCode = statusLine.getStatusCode();
  54 + if (statusCode == 200) {
  55 + HttpEntity entity = response.getEntity();
  56 + InputStream content = entity.getContent();
  57 + BufferedReader reader = new BufferedReader(
  58 + new InputStreamReader(content));
  59 + String line;
  60 + while ((line = reader.readLine()) != null) {
  61 + builder.append(line);
  62 + }
  63 + } else {
  64 + //TODO Notify User about failure
  65 + //Log.e("Diaspora-WebClient", "Failed to download file");
  66 + }
  67 + } catch (ClientProtocolException e) {
  68 + //TODO handle network unreachable exception here
  69 + e.printStackTrace();
  70 + } catch (IOException e) {
  71 + //TODO handle json buggy feed
  72 + e.printStackTrace();
  73 + }
  74 + //Parse the JSON Data
  75 + try {
  76 + JSONObject j=new JSONObject(builder.toString());
  77 + JSONArray jr=j.getJSONArray("pods");
  78 + //Log.i("Diaspora-WebClient","Number of entries " + jr.length());
  79 + list=new ArrayList<String>();
  80 + for (int i = 0; i < jr.length(); i++) {
  81 + JSONObject jo = jr.getJSONObject(i);
  82 + //Log.i("Diaspora-WebClient", jo.getString("domain"));
  83 + String secure=jo.getString("secure");
  84 + if(secure.equals("true"))
  85 + list.add(jo.getString("domain"));
  86 + }
  87 +
  88 + }catch (Exception e) {
  89 + //TODO Handle Parsing errors here
  90 + e.printStackTrace();
  91 + }
  92 + return list.toArray(new String[list.size()]);
  93 + }
  94 +
  95 +}

0 comments on commit 9d4d265

Please sign in to comment.
Something went wrong with that request. Please try again.