Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Temp to merge back iteration4

  • Loading branch information...
commit 245e9008147a5214a374c56303e1ff432830a45a 1 parent bcec0ea
Sam Karp authored
View
11 android/AndroidManifest.xml
@@ -17,19 +17,20 @@
android:theme="@style/default_style">
<activity android:name="gov.nasa.arc.geocam.talk.activity.GeoCamTalkActivity"
android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
</activity>
<activity android:name="gov.nasa.arc.geocam.talk.activity.GeoCamTalkCreateActivity"
android:windowSoftInputMode="adjustResize">
</activity>
-
<activity android:name="gov.nasa.arc.geocam.talk.activity.GeoCamTalkSettings">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
</activity>
+
+
<receiver android:name=".service.C2DMReciever" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
View
12 android/res/layout/main.xml
@@ -16,13 +16,21 @@
android:onClick="onGoHomeClick" />
<Button android:id="@+id/title_create_button"
android:text="Create"
- android:layout_width="@dimen/title_height"
android:layout_height="fill_parent"
android:layout_alignWithParentIfMissing="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
- android:onClick="onCreateTalkClick" />
+ android:onClick="onCreateTalkClick" android:layout_width="wrap_content"/>
+ <EditText android:id="@+id/username_label"
+ android:text="!"
+ style="@style/TitleBar"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_alignWithParentIfMissing="true"
+ android:layout_alignParentRight="true"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentBottom="true" android:focusable="false" android:focusableInTouchMode="false"/>
</LinearLayout>
<ListView android:id="@+id/TalkListView" android:layout_width="wrap_content"
View
18 android/src/gov/nasa/arc/geocam/talk/activity/GeoCamTalkActivity.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
@@ -26,6 +27,7 @@
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
+import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
@@ -47,11 +49,13 @@
ISiteAuth siteAuth;
@Inject
IAudioPlayer player;
-
+ @Inject
+ SharedPreferences prefs;
@Inject
IIntentHelper intentHelper;
List<GeoCamTalkMessage> talkMessages;
+ private EditText username;
private BroadcastReceiver receiver = new BroadcastReceiver() {
@@ -70,7 +74,16 @@ public void onReceive(Context context, Intent intent) {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
+ setUsername();
+ }
+
+ private void setUsername()
+ {
+ username = (EditText)findViewById(R.id.username_label);
+ if (prefs.getString("webapp_username", null) != null)
+ {
+ username.setText(prefs.getString("webapp_username", null));
+ }
}
@Override
@@ -155,6 +168,7 @@ protected void onResume() {
registerReceiver(receiver, filter);
setContentView(R.layout.main);
+ setUsername();
talkListView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
@Override
View
27 android/src/gov/nasa/arc/geocam/talk/activity/GeoCamTalkSettings.java
@@ -11,6 +11,8 @@
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
import android.view.View;
import android.widget.Toast;
@@ -22,10 +24,8 @@
@Inject
SharedPreferences prefs;
-
@InjectResource(R.string.url_message_list)
String urlMessageList;
-
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -34,20 +34,29 @@ public void onCreate(Bundle savedInstanceState) {
addPreferencesFromResource(R.xml.prefs);
}
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ return true;
+ }
+
public void onLoginClick(View v) {
-
- try {
- Editor editor = prefs.edit();
- editor.commit();
- siteAuth.login(prefs.getString("webapp_username", null),prefs.getString("webapp_password", null));
- Intent intent = new Intent(this, GeoCamTalkActivity.class);
- this.startActivity(intent);
+ String url = String.format(urlMessageList,0);
+
+ try
+ {
+ ServerResponse r = siteAuth.get(url, null);
+ if (403 != r.getResponseCode())
+ {
+ Intent intent = new Intent(this, GeoCamTalkActivity.class);
+ this.startActivity(intent);
+ }
} catch (AuthenticationFailedException f) {
Toast.makeText(this.getApplicationContext(), "Bad Username/Password combination",
Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Log.i("Talk", "Error:" + e.getMessage());
}
+
}
View
2  android/src/gov/nasa/arc/geocam/talk/service/SiteAuthCookie.java
@@ -211,8 +211,6 @@ public void login(String username, String password) throws ClientProtocolExcepti
}
throw new AuthenticationFailedException(
"Session cookie was missing from server login response.");
- } else if (200 == r.getStatusLine().getStatusCode()){
- return;
} else {
throw new AuthenticationFailedException("Got unexpected response code from server: "
+ r.getStatusLine().getStatusCode());
Please sign in to comment.
Something went wrong with that request. Please try again.