Commit c98f476c authored by Alan McNatty's avatar Alan McNatty

A small batch of changes:

- Some tweaks to the Artefact Settings UI (renaming the layout)
- A first cut of a gallery to show images being worked on the Artefacts Settings UI
parent d1d262b2
......@@ -139,7 +139,7 @@ catch (ParameterException $e) { }
// Set tags
try {
$tags = explode(" ", param_variable('tags'));
$tags = explode(",", param_variable('tags'));
}
catch (ParameterException $e) { }
......@@ -148,12 +148,13 @@ $artefact_id = ''; // our resulting artefact id on creation
if ( $_FILES ) {
$file_title = $title;
if ( $blog || ! $title ) { // set the filename to be the title of the artefact
$title = basename($_FILES['userfile']['name']);
$file_title = basename($_FILES['userfile']['name']);
}
try {
$data->title = ArtefactTypeFileBase::get_new_file_title($title, $data->parent, $data->owner);
$data->title = ArtefactTypeFileBase::get_new_file_title($file_title, $data->parent, $data->owner);
if ( ! $blog ) { // only set a description if it's an artefact upload
$data->description = $description;
}
......
......@@ -41,7 +41,8 @@
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView android:text="@string/upload_description_label"
<TextView android:id="@+id/txtArtefactDescriptionLabel"
android:text="@string/upload_description_label"
android:layout_width="60dp"
android:singleLine="false"
android:layout_height="wrap_content"
......
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/top"
android:padding="10dp"
android:orientation="vertical"
>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtefactJournalLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView android:text="@string/upload_journal_label"
android:layout_width="60dip"
android:layout_height="wrap_content"
android:padding="2dip"
android:layout_margin="5dip"
style="@android:style/TextAppearance.Small">
</TextView>
<Spinner
android:id="@+id/upload_journal_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtefactConfirmLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
style="@android:style/TextAppearance.Small"
android:id="@+id/chkUpload"
android:layout_width="60dip"
android:layout_height="wrap_content"
android:layout_margin="5dip"
/>
<TextView android:text="@string/upload_confirm_text"
android:id="@+id/txtArtefactConfirm"
android:layout_width="wrap_content"
android:singleLine="false"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:paddingBottom="5dip"
style="@android:style/TextAppearance.Small">
</TextView>
</LinearLayout>
<!--
<ImageView android:id="@+id/UploadArtefact"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtefactTitleLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<TextView android:text="@string/upload_title_label"
android:layout_width="60dip"
android:singleLine="false"
android:layout_height="wrap_content"
android:padding="2dip"
android:layout_margin="5dip"
style="@android:style/TextAppearance.Small">
</TextView>
<EditText android:text=""
android:id="@+id/txtArtefactTitle"
android:singleLine="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</EditText>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtefactDescriptionLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<TextView android:text="@string/upload_description_label"
android:layout_width="60dip"
android:singleLine="false"
android:layout_height="wrap_content"
android:padding="2dip"
android:layout_margin="5dip"
style="@android:style/TextAppearance.Small">
</TextView>
<EditText android:text=""
android:id="@+id/txtArtefactDescription"
android:singleLine="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
</EditText>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<TextView android:text="@string/upload_tags_label"
android:layout_width="60dip"
android:singleLine="false"
android:layout_height="wrap_content"
android:padding="2dip"
android:layout_margin="5dip"
style="@android:style/TextAppearance.Small">
</TextView>
<EditText android:text=""
android:id="@+id/txtArtefactTags"
android:singleLine="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</EditText>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<TextView android:text=""
android:layout_width="60dip"
android:singleLine="false"
android:layout_height="wrap_content"
android:padding="2dip"
android:layout_margin="5dip"
style="@android:style/TextAppearance.Small">
</TextView>
<Spinner
android:id="@+id/upload_tags_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtefactJournalExtrasLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtefactIsDraftLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- android:text="@string/upload_is_draft_label"-->
<CheckBox
style="@android:style/TextAppearance.Small"
android:id="@+id/txtArtefactIsDraft"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:checked="false"
android:layout_width="60dip"
/>
<TextView android:text="@string/upload_is_draft_text"
android:layout_width="wrap_content"
android:singleLine="false"
android:layout_height="wrap_content"
android:padding="5dip"
android:layout_margin="5dip"
style="@android:style/TextAppearance.Small">
</TextView>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtefactAllowCommentsLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- android:text="@string/upload_allow_comments_label" -->
<CheckBox
style="@android:style/TextAppearance.Small"
android:id="@+id/txtArtefactAllowComments"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:checked="true"
android:layout_width="60dip"
/>
<TextView android:text="@string/upload_allow_comments_text"
android:layout_width="wrap_content"
android:singleLine="false"
android:layout_height="wrap_content"
android:padding="5dip"
android:layout_margin="5dip"
style="@android:style/TextAppearance.Small">
</TextView>
</LinearLayout>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtefactSettingsButtonLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="center_horizontal"
android:orientation="horizontal">
<Button android:text="@string/btnupload"
android:id="@+id/btnUpload"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:enabled="false"
style="@style/MaharaButton"
>
</Button>
<Button android:text="@string/btnsave"
android:id="@+id/btnSave"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:enabled="true"
style="@style/MaharaButton"
>
</Button>
<Button android:text="@string/btncancellabel"
android:id="@+id/btnCancel"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@style/MaharaButton"
>
</Button>
</LinearLayout>
<EditText android:text=""
android:id="@+id/txtArtefactId"
android:singleLine="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="invisible">
</EditText>
</LinearLayout>
</ScrollView>
\ No newline at end of file
......@@ -104,6 +104,7 @@
<string name="savefailed">Save failed</string>
<string name="uploadsaved">Upload saved</string>
<string name="uploadnotavailable">Sorry you can only uploaded files.</string>
<string name="capturefailed">Sorry there was a problem capturing that image.</string>
<string name="uploadingartifact">Uploading ...</string>
<string name="uploading">Uploading</string>
<string name="uploadnoconnection">Sorry you don\'t have a working data connection to upload at this time.</string>
......@@ -111,19 +112,21 @@
<string name="filetransfers">File Transfers</string>
<string name="upload_journal_label">Journal:</string>
<string name="upload_journal_prompt">Select Journal to post to</string>
<string name="upload_journal_prompt">Upload as file or choose Journal</string>
<string name="upload_journal_default">Upload as file</string>
<string name="upload_is_draft_label"></string>
<string name="upload_is_draft_text">Check this to if your entry is a draft. As a draft no one except you can see it.</string>
<string name="upload_is_draft_text">Check this if your entry is a draft. As a draft no one except you can see it.</string>
<string name="upload_allow_comments_label"></string>
<string name="upload_allow_comments_text">Check this to allow comments on your entry.</string>
<string name="upload_tags_prompt">Add tag</string>
<string name="upload_tags_prompt">Add existing tag</string>
<string name="upload_confirm_label"></string>
<string name="upload_confirm_text">Yes, the file I am attempting to upload is my own or I have express
permission to reproduce and/or distribute this item. My use of this file
does not breach any local Copyright legislation. This file also adheres to
the Terms and Conditions outlined on this site.</string>
<string name="upload_title_label">Title:</string>
<string name="upload_description_label">Entry:</string>
<string name="upload_file_description_label">Desc:</string>
<string name="upload_journal_description_label">Entry:</string>
<string name="upload_tags_label">Tag(s):</string>
<string name="upload_time_label">Last:</string>
<string name="upload_files_label">Files:</string>
......
......@@ -252,9 +252,13 @@ public class Utils {
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.TITLE, fileName);
values.put(MediaStore.Images.Media.DESCRIPTION,"Image capture by camera for MaharaDroid");
//imageUri is the current activity attribute, define and save it for later usage (also in onSaveInstanceState)
Uri imageUri = mContext.getContentResolver().insert(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
if ( VERBOSE ) Log.v(TAG, "imageUri is '" + imageUri.toString() + "'");
//create new Intent
Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
i.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
......
......@@ -66,8 +66,12 @@ public class Artefact extends Object implements Parcelable {
public String getFilename() {
return filename;
}
public String getBaseFilename() {
return ( filename == null ) ? null : filename.substring(filename.lastIndexOf("/") + 1);
public String getBaseFilename(Context context) {
// Returns the base of the actual file name - not the content store file
// (which would just be it's content:// ... /ID)
String filepath = this.getFilePath(context);
return ( filepath == null ) ? null : filepath.substring(filepath.lastIndexOf("/") + 1);
}
public String getTitle() {
return title;
......@@ -224,6 +228,10 @@ public class Artefact extends Object implements Parcelable {
allow_comments = a;
time = System.currentTimeMillis();
}
public Artefact(String f) {
filename = f;
time = System.currentTimeMillis();
}
public void upload(Boolean auto, Context mContext) {
Intent i = new Intent(mContext, TransferService.class);
......
......@@ -57,6 +57,7 @@ import android.widget.ExpandableListView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
public class ArtefactExpandableListAdapterActivity extends Activity implements OnCreateContextMenuListener {
......@@ -207,6 +208,11 @@ public class ArtefactExpandableListAdapterActivity extends Activity implements O
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if ( intent == null ) {
Log.e(TAG, "Empty intent received from request code '" + requestCode + "'");
Toast.makeText(mContext, getString(R.string.capturefailed), Toast.LENGTH_LONG);
return;
}
if (resultCode == Activity.RESULT_OK) {
Intent i = new Intent(this, ArtifactSettingsActivity.class);
......@@ -314,12 +320,17 @@ public class ArtefactExpandableListAdapterActivity extends Activity implements O
if ( l != null ) l.setVisibility(LinearLayout.VISIBLE);
l = (LinearLayout)convertView.findViewById(R.id.ArtefactJournalExtrasLayout);
if ( l != null ) l.setVisibility(LinearLayout.VISIBLE);
((TextView) convertView.findViewById(R.id.txtArtefactDescriptionLabel)).setText(getResources().getString(R.string.upload_journal_description_label));
} else {
// TDODO hide layout
l = (LinearLayout)convertView.findViewById(R.id.ArtefactJournalLayout);
if ( l != null ) l.setVisibility(LinearLayout.GONE);
l = (LinearLayout)convertView.findViewById(R.id.ArtefactJournalExtrasLayout);
if ( l != null ) l.setVisibility(LinearLayout.GONE);
((TextView) convertView.findViewById(R.id.txtArtefactDescriptionLabel)).setText(getResources().getString(R.string.upload_file_description_label));
}
((TextView) convertView.findViewById(R.id.txtArtefactTime)).setText(date.toString());
((TextView) convertView.findViewById(R.id.txtArtefactDescription)).setText(art.getDescription());
......
......@@ -37,6 +37,7 @@ import android.preference.PreferenceManager;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
......@@ -49,6 +50,7 @@ import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
......@@ -80,6 +82,15 @@ public class ArtifactSettingsActivity extends Activity implements OnClickListene
private Button btnUpload;
private Context mContext;
// a) The artefact can be passed from saved
// b) The artefact will be created if a single url shared to this UI
// c) May be initially be null if more than one url is shared
//
// Note: 1) multiple individual artefacts will be created based on details
// for them all if saved or uploaded
// 2) by attaching a single photo to the UI if the artefact object
// doesn't yet exist (multi scenario only) - one will be created
private Artefact a;
public void onCreate(Bundle savedInstanceState) {
......@@ -90,14 +101,14 @@ public class ArtifactSettingsActivity extends Activity implements OnClickListene
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.artifact_settings);
setContentView(R.layout.artefact_settings);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.windowtitle);
((TextView) findViewById(R.id.windowtitle_text)).setText(getString(R.string.artifactsettings));
Spinner spinner = (Spinner) findViewById(R.id.upload_journal_spinner);
String[][] journalItems = Utils.getJournals("", mContext);
String[][] journalItems = Utils.getJournals(getString(R.string.upload_journal_default), mContext);
journalKeys = journalItems[0];
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, journalItems[1]);
......@@ -107,7 +118,7 @@ public class ArtifactSettingsActivity extends Activity implements OnClickListene
spinner = (Spinner) findViewById(R.id.upload_tags_spinner);
final String[][] tagItems = Utils.getTags("", mContext);
final String[][] tagItems = Utils.getTags(getString(R.string.upload_tags_prompt), mContext);
adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, tagItems[1]);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
......@@ -152,6 +163,9 @@ public class ArtifactSettingsActivity extends Activity implements OnClickListene
((CheckBox)findViewById(R.id.txtArtefactAllowComments)).setChecked(a.getAllowComments());
setDefaultJournal();
// TODO - get working .. for multiple files by URL also .. no operational yet :(
// showFileThumbnail(a);
} else if ( m_extras.containsKey("uri") ) {
if ( DEBUG ) Log.d(TAG, "Have a new upload");
......@@ -164,7 +178,8 @@ public class ArtifactSettingsActivity extends Activity implements OnClickListene
// If single - show the title (with default) and description
if ( uris.length == 1 ) {
if ( DEBUG ) Log.d(TAG, "Have a single upload");
setDefaultTitle(uris[0]);
a = new Artefact(uris[0]);
setDefaultTitle(a.getBaseFilename(mContext));
} else if ( uris.length > 1 ) {
if ( DEBUG ) Log.d(TAG, "Have a multi upload");
} else {
......@@ -183,7 +198,36 @@ public class ArtifactSettingsActivity extends Activity implements OnClickListene
btnUpload.setEnabled(false);
}
}
private void setDefaultTitle(String f) {
private void showFileThumbnail(Artefact art) {
// TODO Auto-generated method stub
LinearLayout l = (LinearLayout) findViewById(R.id.ArtefactFileLayout);
if ( VERBOSE ) Log.v(TAG, "showFileThumbnail called");
if ( art.getFilename() != null ) {
LayoutInflater inflator = getLayoutInflater();
// we set attachToRoot to false so that the returned view is the
// link frame, not parent's root
View linkFrame = inflator.inflate(R.layout.artefact_settings_file_frame, l, false);
ImageView iv = (ImageView) linkFrame.findViewById(R.id.txtArtefactFileThumb);
// ((TextView) findViewById(R.id.txtArtefactFilename)).setText(art.getFilename());
iv.setImageBitmap(art.getFileThumbData(mContext));
iv.setClickable(true);
iv.setOnClickListener(this);
iv.setTag(art);
iv.invalidate();
if ( l != null ) l.setVisibility(LinearLayout.VISIBLE);
l.invalidate();
((View) l.getParent()).invalidate();
if ( DEBUG ) Log.d(TAG, "Adding file '" + art.getFilename() + "' thumbnail to view");
} else {
if ( l != null ) l.setVisibility(LinearLayout.GONE);
if ( VERBOSE ) Log.v(TAG, "no file(name) so no thumbnail(s) to show");
}
}
private void setDefaultTitle(String f) {
EditText et = (EditText)findViewById(R.id.txtArtefactTitle);
if ( et.getText().toString().length() > 0 ) {
......@@ -235,6 +279,10 @@ public class ArtifactSettingsActivity extends Activity implements OnClickListene
LinearLayout l;
l = (LinearLayout)this.findViewById(R.id.ArtefactJournalExtrasLayout);
l.setVisibility(LinearLayout.VISIBLE);
TextView tv;
tv = (TextView)this.findViewById(R.id.txtArtefactDescriptionLabel);
tv.setText(getResources().getString(R.string.upload_journal_description_label));
}
break;
}
......@@ -432,6 +480,11 @@ public class ArtifactSettingsActivity extends Activity implements OnClickListene
return true;
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if ( intent == null ) {
Log.e(TAG, "Empty intent received from request code '" + requestCode + "'");
Toast.makeText(mContext, getString(R.string.capturefailed), Toast.LENGTH_LONG);
return;
}
if (resultCode == Activity.RESULT_OK) {
Uri uri;
......@@ -440,17 +493,23 @@ public class ArtifactSettingsActivity extends Activity implements OnClickListene
if ( ! intent.hasExtra(MediaStore.EXTRA_OUTPUT) )
break;
uri = (Uri) intent.getParcelableExtra(MediaStore.EXTRA_OUTPUT);
// a.setFilename(uri.toString());
// a.save(mContext);
if ( a == null ) {
a = new Artefact(uri.toString());
}
a.setFilename(uri.toString());
setDefaultTitle(a.getBaseFilename(mContext));
a.save(mContext);
uris = new String[] { uri.toString() };
setDefaultTitle(uris[0]);
break;
case GlobalResources.REQ_GALLERY_RETURN:
uri = intent.getData();
// a.setFilename(uri.toString());
// a.save(mContext);
if ( a == null ) {
a = new Artefact(uri.toString());
}
a.setFilename(uri.toString());
a.save(mContext);
setDefaultTitle(a.getBaseFilename(mContext));
uris = new String[] { uri.toString() };
setDefaultTitle(uris[0]);
break;
}
}
......@@ -461,7 +520,7 @@ public class ArtifactSettingsActivity extends Activity implements OnClickListene
View view, int pos, long id) {
String new_tag = parent.getItemAtPosition(pos).toString();
if ( new_tag.length() == 0 ) {
if ( pos <= 0 || new_tag.trim().length() <= 0 ) {
return; // support an empty first element, also don't support empty tags
}
......@@ -499,12 +558,24 @@ public class ArtifactSettingsActivity extends Activity implements OnClickListene
LinearLayout l;
l = (LinearLayout) findViewById(R.id.ArtefactJournalExtrasLayout);
l.setVisibility( pos > 0 ? LinearLayout.VISIBLE : LinearLayout.GONE );
}
TextView tv;
tv = (TextView) findViewById(R.id.txtArtefactDescriptionLabel);
if ( pos > 0 ) {
tv.setText(getResources().getString(R.string.upload_journal_description_label));
} else {
tv.setText(getResources().getString(R.string.upload_file_description_label));
}
}
public void onNothingSelected(AdapterView<?> parent) {
LinearLayout l;
l = (LinearLayout) findViewById(R.id.ArtefactJournalExtrasLayout);
l.setVisibility( LinearLayout.GONE );
TextView tv;
tv = (TextView) findViewById(R.id.txtArtefactDescriptionLabel);
tv.setText(getResources().getString(R.string.upload_file_description_label));
}
}
}
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