Commit 7ae9ef3e authored by Alan McNatty's avatar Alan McNatty

1. Reworked the main UI (artefacts) to switch out if no artefacts remain.

   - Help text to be included.
2. Fixed a NPE bug in the httpclient if a space or similar exists in the post URI
3. Adjusted the onActivityResult method to support attaching multiple files
parent 4b4602dc
......@@ -3,63 +3,113 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="right" >
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/body_heading"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/introduction"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="2dip"
style="@style/headerBackground"
>
<ImageView
android:id="@+id/saved"
android:visibility="visible"
>
<ImageView
android:id="@+id/banner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/saved"
android:layout_gravity="left"
android:layout_marginLeft="10dp"
/>
<TextView android:id="@+id/saved_artefacts_header"
android:text="@string/options_menu_viewsaved"
android:layout_width="fill_parent"
android:singleLine="true"
android:layout_height="wrap_content"
style="@style/headerText"
android:layout_marginLeft="10dp"
android:gravity="left|bottom"
android:layout_toRightOf="@id/saved"
android:layout_centerInParent="true"
android:layout_margin="5dp"
android:src="@drawable/banner"
/>
<TextView android:id="@+id/artefacts_banner_text"
android:text="@string/artefacts_banner_text"
android:layout_width="wrap_content"
android:singleLine="false"
android:layout_height="wrap_content"
android:textStyle="bold"
android:layout_margin="5dp"
style="@android:style/TextAppearance.Large"
android:layout_below="@+id/banner"
/>
<TextView android:id="@+id/artefacts_banner_text2"
android:text="@string/artefacts_banner_text2"
android:layout_margin="5dp"
android:layout_width="fill_parent"
android:singleLine="false"
android:layout_height="wrap_content"
style="@android:style/TextAppearance.Small"
android:layout_below="@+id/artefacts_banner_text"
/>
<TextView android:text="@string/artefacts_help"
android:layout_margin="5dp"
android:layout_width="fill_parent"
android:singleLine="false"
android:layout_height="wrap_content"
style="@android:style/TextAppearance.Small"
android:layout_below="@+id/artefacts_banner_text2"
/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/body"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/artefacts"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/body_heading"
android:layout_margin="5dp"
>
<ExpandableListView android:id="@+id/listView"
android:scrollbars="none"
android:choiceMode="multipleChoice"
android:fastScrollEnabled="true"
android:layout_below="@+id/saved_artefacts_header"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone"
android:headerDividersEnabled="true"
android:footerDividersEnabled="true"
android:padding="2dip"
style="@style/headerBackground"
android:visibility="visible"
android:layout_below="@+id/introduction"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/body_heading"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@style/headerBackground"
>
<ImageView
android:id="@+id/saved"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/saved"
android:layout_gravity="left"
android:layout_marginLeft="10dp"
/>
<!-- android:groupIndicator="@drawable/expander_group" -->
<TextView android:id="@+id/no_saved_artefacts"
android:text="@string/artefacts_no_saved_artefacts"
android:layout_margin="0dp"
android:layout_width="fill_parent"
android:singleLine="true"
android:layout_height="wrap_content"
style="@android:style/TextAppearance.Small"
android:layout_below="@+id/listView"
android:visibility="gone"
/>
<TextView android:id="@+id/saved_artefacts_header"
android:text="@string/options_menu_viewsaved"
android:layout_width="fill_parent"
android:singleLine="true"
android:layout_height="wrap_content"
style="@style/headerText"
android:layout_marginLeft="10dp"
android:gravity="left|bottom"
android:layout_toRightOf="@id/saved"
android:layout_centerInParent="true"
/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/body"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/body_heading"
android:layout_margin="5dp"
>
<ExpandableListView android:id="@+id/listView"
android:scrollbars="none"
android:choiceMode="multipleChoice"
android:fastScrollEnabled="true"
android:layout_below="@+id/saved_artefacts_header"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:headerDividersEnabled="true"
android:footerDividersEnabled="true"
/>
<!-- android:groupIndicator="@drawable/expander_group" -->
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="2dip"
>
<ImageView
android:id="@+id/banner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:src="@drawable/banner"
/>
<TextView android:text="Open source eportfolios"
android:layout_width="wrap_content"
android:singleLine="false"
android:layout_height="wrap_content"
android:textStyle="bold"
android:layout_margin="5dp"
style="@android:style/TextAppearance.Large"
/>
<TextView android:text="[mah-har-rah;verb]: to think, thinking, thought"
android:layout_margin="5dp"
android:layout_width="fill_parent"
android:singleLine="false"
android:layout_height="wrap_content"
style="@android:style/TextAppearance.Small"
/>
</LinearLayout>
</ScrollView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/context_upload"
android:icon="@android:drawable/ic_menu_upload"
android:title="@string/context_menu_upload" />
<item android:id="@+id/context_view"
android:icon="@android:drawable/ic_menu_view"
android:title="@string/context_menu_view" />
<item android:id="@+id/context_delete"
android:icon="@android:drawable/ic_delete"
android:title="@string/context_menu_delete" />
</menu>
......@@ -4,6 +4,9 @@
<string name="artefacts_banner_text">Open source ePortfolios</string>
<string name="artefacts_banner_text2">[mah-har-rah;verb]: to think, thinking, thought</string>
<string name="artefacts_help">
</string>
<string name="artefacts_no_saved_artefacts">Nothing saved.</string>
<string name="options_menu_prefs">Preferences</string>
......
......@@ -29,6 +29,7 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;
import android.util.Log;
import android.widget.Toast;
/** Helper to the database, manages versions and creation */
public class ArtefactDataSQLHelper extends SQLiteOpenHelper {
......@@ -137,6 +138,21 @@ public class ArtefactDataSQLHelper extends SQLiteOpenHelper {
cursor.close();
}
}
public int countSavedArtefacts() {
SQLiteDatabase db = this.getReadableDatabase();
int count = 0;
Cursor cursor = db.query(ArtefactDataSQLHelper.TABLE, null, null, null, null, null, null);
try {
if (cursor == null)
return count;
return cursor.getCount();
} finally {
cursor.close();
}
}
public Artefact[] loadSavedArtefacts() {
SQLiteDatabase db = this.getReadableDatabase();
......@@ -161,8 +177,8 @@ public class ArtefactDataSQLHelper extends SQLiteOpenHelper {
|| (a.getFilename() != null && a.getFilePath(mContext) != null)) {
a_array[items++] = a;
} else {
Log.i(TAG, "Artefact '" + a.getTitle() + "' file [" + a.getFilename()
+ "] no longer exists, deleting from saved artefacts");
Log.w(TAG, "File '" + a.getTitle() + "' does not exist on the device, deleting from saved artefacts");
Toast.makeText(mContext, "File '" + a.getTitle() + "' does not exist on the device, deleting from saved artefacts", Toast.LENGTH_LONG);
this.deleteSavedArtefact(a.getId());
}
}
......
......@@ -494,13 +494,23 @@ public class ArtifactSettingsActivity extends Activity implements OnClickListene
break;
}
if ( a == null ) {
a = new Artefact(imageFile);
}
a.setFilename(imageFile);
//a.save(mContext); // don't auto save - they might want to cancel
setDefaultTitle(a.getBaseFilename(mContext));
uris = new String[] { imageFile };
if ( uris == null ) {
if ( a == null ) {
a = new Artefact(imageFile);
}
a.setFilename(imageFile);
//a.save(mContext); // don't auto save - they might want to cancel
setDefaultTitle(a.getBaseFilename(mContext));
uris = new String[] { imageFile };
} else {
String [] new_uris = new String[uris.length + 1];
for ( int i = 0; i < uris.length; i++ ) {
new_uris[i] = uris[i];
}
new_uris[uris.length] = imageFile;
uris = new_uris;
}
}
}
public class TagChooser implements OnItemSelectedListener {
......
......@@ -269,7 +269,19 @@ public class RestClient {
SortedMap<String,String> sig_params = new TreeMap<String,String>();
HttpResponse response = null;
HttpPost httppost = new HttpPost(url);
HttpPost httppost = null;
try {
httppost = new HttpPost(url);
} catch (IllegalArgumentException e) {
try {
json.put("fail", e.getMessage());
} catch (JSONException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
return json;
}
try {
File file = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment