Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 9d4d2657ab13ba9ce366e3cd5774b5be81b43049 1 parent f766774
@voidcode authored
Showing with 403 additions and 54 deletions.
  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
View
4 AndroidManifest.xml
@@ -4,7 +4,7 @@
android:versionCode="7"
android:versionName="1.6">
- <uses-sdk android:minSdkVersion="4" />
+ <uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
@@ -34,7 +34,7 @@
</activity>
<activity
android:theme="@android:style/Theme.NoTitleBar"
- android:name=".SettingsActivity"
+ android:name=".PodSettingsActivity"
android:configChanges="orientation">
</activity>
<activity
View
BIN  bin/Diaspora-Webclient.apk
Binary file not shown
View
BIN  bin/classes.dex
Binary file not shown
View
BIN  bin/classes/com/voidcode/diasporawebclient/MainActivity$2.class
Binary file not shown
View
BIN  bin/classes/com/voidcode/diasporawebclient/MainActivity.class
Binary file not shown
View
BIN  bin/classes/com/voidcode/diasporawebclient/PodSettingsActivity$1.class
Binary file not shown
View
BIN  bin/classes/com/voidcode/diasporawebclient/PodSettingsActivity$2.class
Binary file not shown
View
BIN  bin/classes/com/voidcode/diasporawebclient/PodSettingsActivity$3.class
Binary file not shown
View
BIN  bin/classes/com/voidcode/diasporawebclient/PodSettingsActivity.class
Binary file not shown
View
BIN  bin/classes/com/voidcode/diasporawebclient/R$drawable.class
Binary file not shown
View
BIN  bin/classes/com/voidcode/diasporawebclient/R$id.class
Binary file not shown
View
BIN  bin/classes/com/voidcode/diasporawebclient/R$layout.class
Binary file not shown
View
BIN  bin/classes/com/voidcode/diasporawebclient/R$string.class
Binary file not shown
View
BIN  bin/classes/com/voidcode/diasporawebclient/R$style.class
Binary file not shown
View
BIN  bin/classes/com/voidcode/diasporawebclient/R$xml.class
Binary file not shown
View
BIN  bin/classes/com/voidcode/diasporawebclient/ShareActivity.class
Binary file not shown
View
BIN  bin/classes/com/voidcode/diasporawebclient/getPodlistTask.class
Binary file not shown
View
BIN  bin/res/drawable-hdpi/ic_menu_podsettings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  bin/res/drawable-ldpi/ic_menu_podsettings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  bin/res/drawable-mdpi/ic_menu_podsettings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  bin/res/drawable-xhdpi/ic_menu_podsettings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  bin/resources.ap_
Binary file not shown
View
58 gen/com/voidcode/diasporawebclient/R.java
@@ -21,9 +21,9 @@
public static final int ic_menu_invite=0x7f020007;
public static final int ic_menu_messages=0x7f020008;
public static final int ic_menu_notifications=0x7f020009;
- public static final int ic_menu_profile=0x7f02000a;
- public static final int ic_menu_search=0x7f02000b;
- public static final int ic_menu_settings=0x7f02000c;
+ public static final int ic_menu_podsettings=0x7f02000a;
+ public static final int ic_menu_profile=0x7f02000b;
+ public static final int ic_menu_search=0x7f02000c;
public static final int ic_menu_share=0x7f02000d;
public static final int ic_menu_tips=0x7f02000e;
public static final int ic_menu_translate=0x7f02000f;
@@ -43,7 +43,7 @@
public static final int listView_poduptime=0x7f08000b;
public static final int mainmenu_donation=0x7f08001f;
public static final int mainmenu_exit=0x7f080020;
- public static final int mainmenu_settings=0x7f08001d;
+ public static final int mainmenu_podsettings=0x7f08001d;
public static final int mainmenu_share=0x7f08001b;
public static final int mainmenu_tips=0x7f08001e;
public static final int mainmenu_translate=0x7f08001c;
@@ -67,7 +67,7 @@
}
public static final class layout {
public static final int main=0x7f030000;
- public static final int settings=0x7f030001;
+ public static final int podsettings=0x7f030001;
public static final int setupinternet=0x7f030002;
public static final int translate=0x7f030003;
public static final int widget=0x7f030004;
@@ -77,12 +77,12 @@
}
public static final class string {
public static final int app_name=0x7f050000;
- public static final int findtag=0x7f05001d;
- public static final int findtag_alert_title=0x7f05001b;
- public static final int findtag_alert_validate_needsomedata=0x7f05001c;
- public static final int findtag_button=0x7f05001a;
- public static final int findtag_h1=0x7f050018;
- public static final int findtag_p=0x7f050019;
+ public static final int findtag=0x7f05001f;
+ public static final int findtag_alert_title=0x7f05001d;
+ public static final int findtag_alert_validate_needsomedata=0x7f05001e;
+ public static final int findtag_button=0x7f05001c;
+ public static final int findtag_h1=0x7f05001a;
+ public static final int findtag_p=0x7f05001b;
public static final int menu_aspects=0x7f05000c;
public static final int menu_contacts=0x7f050008;
public static final int menu_donation=0x7f050006;
@@ -92,27 +92,29 @@
public static final int menu_invite=0x7f05000d;
public static final int menu_messages=0x7f05000a;
public static final int menu_notifications=0x7f050009;
+ public static final int menu_podsettings=0x7f050004;
public static final int menu_profile=0x7f05000b;
- public static final int menu_settings=0x7f050004;
public static final int menu_share=0x7f050002;
public static final int menu_tips=0x7f050005;
public static final int menu_translate=0x7f050007;
- public static final int settings_button_close=0x7f05001e;
- public static final int settings_button_save=0x7f050013;
- public static final int settings_currentpod=0x7f050011;
- public static final int settings_h1=0x7f05000f;
- public static final int settings_text_currentpod=0x7f050010;
- public static final int setupinternet_button=0x7f050017;
- public static final int setupinternet_button_wirelesssettings=0x7f050016;
- public static final int setupinternet_h1=0x7f050014;
- public static final int setupinternet_text=0x7f050015;
- public static final int translate_button_howto_obtain_googletranslatekey=0x7f050024;
- public static final int translate_button_linkto_googleapiconsole=0x7f050022;
- public static final int translate_button_text=0x7f050021;
- public static final int translate_chooselanguage_h1=0x7f05001f;
- public static final int translate_googlekey_h1=0x7f050020;
- public static final int translate_howto_text=0x7f050023;
- public static final int widget_button_share=0x7f050012;
+ public static final int podsettings_button_close=0x7f050020;
+ public static final int podsettings_button_save=0x7f050015;
+ public static final int podsettings_currentpod=0x7f050011;
+ public static final int podsettings_dialog_text=0x7f050013;
+ public static final int podsettings_dialog_title=0x7f050012;
+ public static final int podsettings_h1=0x7f05000f;
+ public static final int podsettings_text_currentpod=0x7f050010;
+ public static final int setupinternet_button=0x7f050019;
+ public static final int setupinternet_button_wirelesssettings=0x7f050018;
+ public static final int setupinternet_h1=0x7f050016;
+ public static final int setupinternet_text=0x7f050017;
+ public static final int translate_button_howto_obtain_googletranslatekey=0x7f050026;
+ public static final int translate_button_linkto_googleapiconsole=0x7f050024;
+ public static final int translate_button_text=0x7f050023;
+ public static final int translate_chooselanguage_h1=0x7f050021;
+ public static final int translate_googlekey_h1=0x7f050022;
+ public static final int translate_howto_text=0x7f050025;
+ public static final int widget_button_share=0x7f050014;
}
public static final class style {
public static final int widgetimagesbutton=0x7f060000;
View
2  project.properties
@@ -8,4 +8,4 @@
# project structure.
# Project target.
-target=android-4
+target=android-7
View
BIN  res/drawable-hdpi/ic_menu_podsettings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  res/drawable-ldpi/ic_menu_podsettings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  res/drawable-mdpi/ic_menu_podsettings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  res/drawable-xhdpi/ic_menu_podsettings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
44 res/layout/podsettings.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical" >
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:background="@drawable/topmenu_repeat" >
+ <ImageView
+ android:id="@+id/imageView1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/topmenu" />
+ </LinearLayout>
+
+ <TextView
+ android:id="@+id/textView1"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/podsettings_text_currentpod"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <EditText
+ android:id="@+id/editText_currentpod"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/podsettings_currentpod">
+ </EditText>
+
+ <Button
+ android:id="@+id/settings_button_save"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:onClick="Onclick_SaveSettings"
+ android:text="@string/podsettings_button_save" />
+
+
+
+ <ListView
+ android:id="@+id/listView_poduptime"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
View
2  res/layout/setupinternet.xml
@@ -50,7 +50,7 @@
android:layout_height="wrap_content"
android:text="@string/setupinternet_button_wirelesssettings" />
- <Button
+ <Button
android:onClick="onclick_button_close"
android:id="@+id/settings_button_close"
android:layout_width="wrap_content"
View
2  res/menu/main_menu.xml
@@ -2,7 +2,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/mainmenu_share" android:icon="@drawable/ic_menu_share" android:title="@string/menu_share" />
<item android:id="@+id/mainmenu_translate" android:icon="@drawable/ic_menu_translate" android:title="@string/menu_translate" />
- <item android:id="@+id/mainmenu_settings" android:icon="@drawable/ic_menu_settings" android:title="@string/menu_settings" />
+ <item android:id="@+id/mainmenu_podsettings" android:icon="@drawable/ic_menu_podsettings" android:title="@string/menu_podsettings" />
<item android:id="@+id/mainmenu_tips" android:icon="@drawable/ic_menu_tips" android:title="@string/menu_tips" />
<item android:id="@+id/mainmenu_donation" android:icon="@drawable/ic_menu_donation" android:title="@string/menu_donation" />
<item android:id="@+id/mainmenu_exit" android:icon="@drawable/ic_menu_exit" android:title="@string/menu_exit" />
View
17 res/values/strings.xml
@@ -5,7 +5,7 @@
<string name="menu_home">Stream</string>
<string name="menu_share">Share</string>
<string name="menu_findtag">Find tag</string>
- <string name="menu_settings">Settings</string>
+ <string name="menu_podsettings">PodSettings</string>
<string name="menu_tips">Tips</string>
<string name="menu_donation">Donation</string>
<string name="menu_translate">Translate</string>
@@ -19,13 +19,16 @@
<string name="menu_invite">Invite</string>
<string name="menu_exit">Exit</string>
- <string name="settings_h1">Settings.</string>
- <string name="settings_text_currentpod">Find your pod.</string>
- <string name="settings_currentpod"></string>
-
+ <string name="podsettings_h1">Settings.</string>
+ <string name="podsettings_text_currentpod">Find your pod.</string>
+ <string name="podsettings_currentpod"></string>
+
+ <string name="podsettings_dialog_title">PodSettings</string>
+ <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>
+
<string name="widget_button_share">Share on diaspora</string>
- <string name="settings_button_save">Use this pod</string>
+ <string name="podsettings_button_save">Use this pod</string>
<string name="setupinternet_h1">Setup internet</string>
<string name="setupinternet_text">This app require a internet connection!</string>
@@ -39,7 +42,7 @@
<string name="findtag" >findtag</string>
- <string name="settings_button_close">Ok</string>
+ <string name="podsettings_button_close">Ok</string>
<string name="translate_chooselanguage_h1">Translate post to this language.</string>
<string name="translate_googlekey_h1">Add your translate api-key here.</string>
View
2  src/com/voidcode/diasporawebclient/JSInterface.java
@@ -14,7 +14,7 @@ public String Translate(String main_domain, String googleapikey, String defaultl
String decodetext = URLDecoder.decode(text);
String rawtext = decodetext.replaceAll("\\<.*?\\>", "");//remove all htmltags
//TODO: find out if google is tacking money for 'none' translate word(HEX23...the..word),
- //if, then make it so all tag is remove form the 'rawtext' and then add it back to the 'translatePost'(after: Translate.DEFAULT.execute)
+ //if, then make it so all tag is remove form the 'rawtext' anded then add it back to the 'translatePost'(after: Translate.DEFAULT.execute)
rawtext = rawtext.replaceAll("#", "HEX23");//format all #tags so google-translate don´t translate the #tag
rawtext = rawtext.trim();//remove end-spaces
// Set the HTTP referrer to your website address.
View
16 src/com/voidcode/diasporawebclient/MainActivity.java
@@ -52,11 +52,11 @@ public void onCreate(Bundle savedInstanceState) {
//set cache size to 8mb by default.
settings.setCacheMode(1);
- // settings.setAppCacheMaxSize(1024*1024*8);
- // settings.setDomStorageEnabled(true);
- // settings.setAppCachePath("/data/data/com.voidcode.diasporawebclient/cache");
- // settings.setAllowFileAccess(true);
- // settings.setAppCacheEnabled(true);
+ settings.setAppCacheMaxSize(1024*1024*8);
+ settings.setDomStorageEnabled(true);
+ settings.setAppCachePath("/data/data/com.voidcode.diasporawebclient/cache");
+ settings.setAllowFileAccess(true);
+ settings.setAppCacheEnabled(true);
//settings.setBuiltInZoomControls(true);
@@ -82,7 +82,7 @@ public boolean onJsAlert(WebView view, String url, String message, JsResult resu
//then open SettingsActivity
if(this.main_domain.equals(""))
{
- startActivity(new Intent(this, SettingsActivity.class));
+ startActivity(new Intent(this, PodSettingsActivity.class));
}
else
{
@@ -256,9 +256,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
this.finish();
startActivity(new Intent(this, TranslateActivity.class));
return true;
- case R.id.mainmenu_settings:
+ case R.id.mainmenu_podsettings:
this.finish();
- startActivity(new Intent(this, SettingsActivity.class));
+ startActivity(new Intent(this, PodSettingsActivity.class));
return true;
case R.id.mainmenu_tips:
mWeb.loadUrl("file:///android_asset/tips.html");
View
205 src/com/voidcode/diasporawebclient/PodSettingsActivity.java
@@ -0,0 +1,205 @@
+package com.voidcode.diasporawebclient;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.StatusLine;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.res.Configuration;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.os.Bundle;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.EditText;
+import android.widget.ListView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.Toast;
+
+public class PodSettingsActivity extends Activity {
+ public static final String SETTINGS_FILENAME="settings";
+ public ListView lvPods;
+ public String lvPods_arr[];
+ private EditText editTextCurrentpod;
+ JSONArray jsonArray;
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ if(isNetworkAvailable())
+ {
+
+
+
+ try {
+ //load pods from poduptime.me as a AsyncTask
+
+ lvPods_arr = new getPodlistTask(this).execute().get();
+
+ Log.i("lvPods_arr", String.valueOf(lvPods_arr.length) );
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.podsettings);
+
+ //load elements from layout file podsettings.xml
+ editTextCurrentpod = (EditText) findViewById(R.id.editText_currentpod);
+ lvPods = (ListView) findViewById(R.id.listView_poduptime);
+
+ //show the currentpod to user
+ SharedPreferences preferences = getSharedPreferences(SETTINGS_FILENAME, MODE_PRIVATE);
+ editTextCurrentpod.setText(preferences.getString("currentpod", "You need to choose a pod"));
+ editTextCurrentpod.selectAll();
+
+ //check if user have be get the dialog info box
+ if(preferences.getBoolean("has_show_dialog", false) == false)
+ {
+ final AlertDialog.Builder alert = new AlertDialog.Builder(this);
+ alert.setTitle(R.string.podsettings_dialog_title);
+ alert.setMessage(R.string.podsettings_dialog_text);
+ alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ }
+ });
+ alert.show();
+ //this ensure the user only see the dialogbox ones
+ SharedPreferences.Editor editor = preferences.edit();
+ editor.putBoolean("has_show_dialog", true);
+ editor.commit();
+ }
+
+ //fill listview with pods form http://podupti.me
+ fillListview(this.lvPods_arr);
+
+ //podsearch, A fast find search on editTextCurrentpod, So user don´t have to scholl the podlist to finde a pod
+ editTextCurrentpod.addTextChangedListener(new TextWatcher()
+ {
+ List<String> filter_podurl_list = null;
+ public void beforeTextChanged(CharSequence s, int start, int count, int after)
+ {
+ }
+ public void onTextChanged(CharSequence s, int start, int before, int count)
+ {
+ filter_podurl_list=new ArrayList<String>();
+ for(String podurl:lvPods_arr)
+ {
+ if(podurl.startsWith(s.toString()))
+ {
+ filter_podurl_list.add(podurl);
+ }
+ }
+ }
+ public void afterTextChanged(Editable s)
+ {
+ ///add reslut to listview
+ if(!filter_podurl_list.equals(null))
+ fillListview(filter_podurl_list.toArray(new String[filter_podurl_list.size()]));
+ }
+ });
+
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ExecutionException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+
+
+
+ }
+ else //user have NO internet
+ {
+ this.finish();
+ startActivity(new Intent(this, SetupInternetActivity.class));
+ }
+ }
+ public void fillListview(String _lvPods_arr[])
+ {
+ lvPods.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, _lvPods_arr));
+ lvPods.setOnItemClickListener(new OnItemClickListener(){
+ public void onItemClick(AdapterView<?> a, View v, int position, long id) {
+ //onclick put select pod to editTextCurrentpod
+ editTextCurrentpod.setText(lvPods.getItemAtPosition(position).toString());
+ }
+ });
+ }
+ //Screen orientation crashes app fix
+ //http://jamesgiang.wordpress.com/2010/06/05/screen-orientation-crashes-my-app/
+ @Override
+ public void onConfigurationChanged(Configuration newConfig)
+ {
+ super.onConfigurationChanged(newConfig);
+ }
+ // Handle the Back button
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent msg){
+ if((keyCode == KeyEvent.KEYCODE_BACK))
+ {
+ this.finish();
+ startActivity(new Intent(this, MainActivity.class));
+ return false;
+ }
+ else
+ return true;
+ }
+ public void Onclick_SaveSettings(View v) throws IOException
+ {
+ //get userinput
+ String new_currentpod = editTextCurrentpod.getText().toString();
+ //if user has added a pod
+ if(!new_currentpod.equals(""))
+ {
+ // Save the new currentpod
+ SharedPreferences preferences = getSharedPreferences(SETTINGS_FILENAME, MODE_PRIVATE);
+ SharedPreferences.Editor editor = preferences.edit();
+ editor.putString("currentpod", new_currentpod);
+ editor.commit();
+ //goto MainActivity
+ this.finish();
+ startActivity(new Intent(this, MainActivity.class));
+ }
+ else
+ Toast.makeText(getApplicationContext(), "You need to choose a pod", Toast.LENGTH_SHORT).show();
+ }
+ //simple json parsing, to retrieve list of pods from podupti.me
+ //https://github.com/voidcode/Diaspora-Webclient/pull/4
+ //by: https://github.com/vipulnsward
+
+ private boolean isNetworkAvailable()
+ {
+ ConnectivityManager connec = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo mobileInfo = connec.getNetworkInfo(0);
+ NetworkInfo wifiInfo = connec.getNetworkInfo(1);
+ NetworkInfo wimaxInfo = connec.getNetworkInfo(6);
+ if (wimaxInfo!=null) {
+ return mobileInfo.isConnected() || wifiInfo.isConnected()|| wimaxInfo.isConnected();
+ }
+ else {
+ return mobileInfo.isConnected() || wifiInfo.isConnected();
+ }
+ }
+}
View
10 src/com/voidcode/diasporawebclient/ShareActivity.java
@@ -23,11 +23,11 @@ public void onCreate(Bundle savedInstanceState) {
//set cache size to 8mb by default.
settings.setCacheMode(1);
- //settings.setAppCacheMaxSize(1024*1024*8);
- // settings.setDomStorageEnabled(true);
- //settings.setAppCachePath("/data/data/com.voidcode.diasporawebclient/cache");
- //settings.setAllowFileAccess(true);
- //settings.setAppCacheEnabled(true);
+ settings.setAppCacheMaxSize(1024*1024*8);
+ settings.setDomStorageEnabled(true);
+ settings.setAppCachePath("/data/data/com.voidcode.diasporawebclient/cache");
+ settings.setAllowFileAccess(true);
+ settings.setAppCacheEnabled(true);
//settings.setBuiltInZoomControls(true);
// load: open new messages
View
95 src/com/voidcode/diasporawebclient/getPodlistTask.java
@@ -0,0 +1,95 @@
+package com.voidcode.diasporawebclient;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.StatusLine;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+import android.content.Context;
+import android.app.ProgressDialog;
+import android.os.AsyncTask;
+
+public class getPodlistTask extends AsyncTask<Void, Void, String[]> {
+ protected Context context;
+ private ProgressDialog dialog;
+
+ public getPodlistTask(Context c)
+ {
+ context = c;
+ }
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+ dialog = new ProgressDialog(context);
+ dialog.setMessage("Downloading podlist from poduptime.me");
+ dialog.setIndeterminate(true);
+ dialog.setCancelable(false);
+ dialog.show();
+ }
+ protected void onPostExecute(String[] pods) {
+ dialog.dismiss();
+ }
+ @Override
+ protected String[] doInBackground(Void... params) {
+ StringBuilder builder = new StringBuilder();
+ HttpClient client = new DefaultHttpClient();
+ List<String> list = null;
+ try {
+ HttpGet httpGet = new HttpGet("http://podupti.me/api.php?key=4r45tg&format=json");
+ HttpResponse response = client.execute(httpGet);
+ StatusLine statusLine = response.getStatusLine();
+ int statusCode = statusLine.getStatusCode();
+ if (statusCode == 200) {
+ HttpEntity entity = response.getEntity();
+ InputStream content = entity.getContent();
+ BufferedReader reader = new BufferedReader(
+ new InputStreamReader(content));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ builder.append(line);
+ }
+ } else {
+ //TODO Notify User about failure
+ //Log.e("Diaspora-WebClient", "Failed to download file");
+ }
+ } catch (ClientProtocolException e) {
+ //TODO handle network unreachable exception here
+ e.printStackTrace();
+ } catch (IOException e) {
+ //TODO handle json buggy feed
+ e.printStackTrace();
+ }
+ //Parse the JSON Data
+ try {
+ JSONObject j=new JSONObject(builder.toString());
+ JSONArray jr=j.getJSONArray("pods");
+ //Log.i("Diaspora-WebClient","Number of entries " + jr.length());
+ list=new ArrayList<String>();
+ for (int i = 0; i < jr.length(); i++) {
+ JSONObject jo = jr.getJSONObject(i);
+ //Log.i("Diaspora-WebClient", jo.getString("domain"));
+ String secure=jo.getString("secure");
+ if(secure.equals("true"))
+ list.add(jo.getString("domain"));
+ }
+
+ }catch (Exception e) {
+ //TODO Handle Parsing errors here
+ e.printStackTrace();
+ }
+ return list.toArray(new String[list.size()]);
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.