Commit 0be84e83 authored by Alan McNatty's avatar Alan McNatty
Browse files

Changes for 1.3 (though some included and missed from 1.2)

parent 8338d4d9
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="nz.net.catalyst.MaharaDroid"
android:versionCode="1"
android:versionName="1.1">
android:versionCode="2"
android:versionName="1.3">
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="false">
<activity android:name=".MaharaDroid"
......@@ -46,8 +46,8 @@
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
<!-- <data android:mimeType="image/*" />-->
<!-- <data android:mimeType="*/*" /> -->
<data android:mimeType="image/*" />
</intent-filter>
</activity>
<activity android:name=".EditPreferences"
......
......@@ -13,19 +13,18 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:orientation="horizontal">
<CheckBox android:text="@string/chkupload"
<CheckBox android:text="@string/upload_confirm_label"
style="@android:style/TextAppearance.Small"
android:id="@+id/chkUpload"
android:layout_width="wrap_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dip"
>
</CheckBox>
<TextView android:text="@string/confirmtext"
<TextView android:text="@string/upload_confirm_text"
android:id="@+id/txtArtifactConfirm"
android:layout_width="wrap_content"
android:singleLine="false"
......@@ -35,27 +34,83 @@
style="@android:style/TextAppearance.Small">
</TextView>
</LinearLayout>
<!--
<ImageView android:id="@+id/UploadArtifact"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArtifactUploadLayout"
android:id="@+id/ArtifactConfirmLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:orientation="horizontal">
<TextView android:text="@string/upload_title_label"
android:layout_width="50dip"
android:singleLine="false"
android:layout_height="wrap_content"
android:padding="2dip"
android:layout_margin="10dip"
style="@android:style/TextAppearance.Small">
</TextView>
<ImageView android:id="@+id/UploadArtifact"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
<EditText android:text=""
android:id="@+id/txtArtifactTitle"
android:singleLine="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</EditText>
</LinearLayout>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView android:text="@string/upload_description_label"
android:layout_width="50dip"
android:singleLine="false"
android:layout_height="wrap_content"
android:padding="2dip"
android:layout_margin="10dip"
style="@android:style/TextAppearance.Small">
</TextView>
<EditText android:text=""
android:id="@+id/txtArtifactDescription"
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="10dp"
android:orientation="horizontal">
<TextView android:text="@string/upload_tags_label"
android:layout_width="50dip"
android:singleLine="false"
android:layout_height="wrap_content"
android:padding="2dip"
android:layout_margin="10dip"
style="@android:style/TextAppearance.Small">
</TextView>
<EditText android:text=""
android:id="@+id/txtArtifactTags"
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"
......
......@@ -24,6 +24,11 @@
<string name="pref_upload_folder_summary">Enter the (base) folder to upload your artefacts into</string>
<string name="pref_upload_folder_default">MobileUploads</string>
<string name="pref_upload_tags_key">upload.tags</string>
<string name="pref_upload_tags_title">Artefact Tags</string>
<string name="pref_upload_tags_summary">Enter the tags (space separated) to add to all uploaded artefacts</string>
<string name="pref_upload_tags_default">Android</string>
<string name="pref_upload_view_key">upload.view</string>
<string name="pref_upload_view_title">Create Public View</string>
<string name="pref_upload_view_summary">Automatically create a public view for this folder?</string>
......@@ -43,15 +48,20 @@
<string name="transferprogress">File Transfer Progress</string>
<string name="uploadstarting">Your Upload is Starting</string>
<string name="uploadfinished">Your Upload is Finished</string>
<string name="uploadfailed">Upload failed</string>
<string name="uploadingartifact">Uploading Artefact</string>
<string name="uploading">Uploading</string>
<string name="filetransfers">File Transfers</string>
<string name="chkupload">Yes:</string>
<string name="confirmtext">The file I am attempting to upload is my own or I have express
<string name="upload_confirm_label">Yes:</string>
<string name="upload_confirm_text">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">Desc:</string>
<string name="upload_tags_label">Tag(s):</string>
<!-- About page -->
<string name="about_title">About MaharaDroid</string>
<string name="about_top_section_title">MaharaDroid</string>
......
......@@ -25,6 +25,11 @@
android:title="@string/pref_upload_folder_title"
android:summary="@string/pref_upload_folder_summary"
android:defaultValue="@string/pref_upload_folder_default" />
<EditTextPreference
android:key="@string/pref_upload_tags_key"
android:title="@string/pref_upload_tags_title"
android:summary="@string/pref_upload_tags_summary"
android:defaultValue="@string/pref_upload_tags_default" />
<CheckBoxPreference
android:key="@string/pref_upload_view_key"
android:title="@string/pref_upload_view_title"
......
......@@ -23,14 +23,18 @@ package nz.net.catalyst.MaharaDroid;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
/*
......@@ -50,13 +54,17 @@ public class ArtifactSettings extends Activity implements OnClickListener {
// whether VERBOSE level logging is enabled
static final boolean VERBOSE = LogConfig.VERBOSE;
// application preferences
private SharedPreferences mPrefs;
private Bundle m_extras;
private String m_filepath = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
//TODO: Add thumbnail of image to upload options screen.
setContentView(R.layout.artifact_settings);
......@@ -64,6 +72,8 @@ public class ArtifactSettings extends Activity implements OnClickListener {
((Button)findViewById(R.id.btnUpload)).setOnClickListener(this);
((Button)findViewById(R.id.btnCancel)).setOnClickListener(this);
checkAcceptanceOfConditions();
m_extras = getIntent().getExtras();
if (m_extras == null) {
finish();
......@@ -73,6 +83,7 @@ public class ArtifactSettings extends Activity implements OnClickListener {
Uri uri = Uri.parse(m_extras.getString("uri"));
// Get the filename of the image and use that as the default title.
//TODO: assumes image so we should either restrict to image/* or check file type
Cursor cursor = cr.query(uri, new String[]{android.provider.MediaStore.Images.ImageColumns.DATA},
null, null, null);
if (cursor == null) {
......@@ -85,19 +96,35 @@ public class ArtifactSettings extends Activity implements OnClickListener {
cursor.close();
if (m_filepath != null) {
String title = m_filepath.substring(m_filepath.lastIndexOf("/") + 1,
m_filepath.lastIndexOf("."));
String title = m_filepath.substring(m_filepath.lastIndexOf("/") + 1);
((EditText)findViewById(R.id.txtArtifactTitle)).setText(title);
((EditText)findViewById(R.id.txtArtifactTitle)).selectAll();
}
}
}
}
public void onResume(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
checkAcceptanceOfConditions();
}
public void onClick(View v) {
if (v.getId() == R.id.chkUpload ) {
final CheckBox checkBox = (CheckBox)findViewById(R.id.chkUpload);
acceptConditions(checkBox.isChecked());
}
else if (v.getId() == R.id.btnUpload) {
InitiateUpload();
finish();
}
else if (v.getId() == R.id.btnCancel) {
finish();
}
}
private void InitiateUpload() {
//String[] safety_levels = getResources().getStringArray(R.array.safety_levels_list);
final CheckBox checkBox = (CheckBox)findViewById(R.id.chkUpload);
if (! checkBox.isChecked()) {
if (! checkAcceptanceOfConditions() ) {
return;
}
......@@ -106,6 +133,8 @@ public class ArtifactSettings extends Activity implements OnClickListener {
Intent uploader_intent = new Intent(this, TransferService.class);
uploader_intent.putExtra("filename", m_filepath);
uploader_intent.putExtra("title", ((EditText)findViewById(R.id.txtArtifactTitle)).getText().toString());
uploader_intent.putExtra("tags", ((EditText)findViewById(R.id.txtArtifactTags)).getText().toString());
uploader_intent.putExtra("description", ((EditText)findViewById(R.id.txtArtifactDescription)).getText().toString());
// Start the uploader service and pass in the intent containing
// the upload information.
......@@ -113,21 +142,29 @@ public class ArtifactSettings extends Activity implements OnClickListener {
Toast.makeText(this, R.string.uploadstarting, Toast.LENGTH_SHORT).show();
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.chkUpload ) {
final Button button = (Button)findViewById(R.id.btnUpload);
final CheckBox checkBox = (CheckBox)findViewById(R.id.chkUpload);
button.setEnabled(checkBox.isChecked());
}
else if (v.getId() == R.id.btnUpload) {
InitiateUpload();
finish();
}
else if (v.getId() == R.id.btnCancel) {
finish();
}
private void acceptConditions(Boolean accepted) {
final Button button = (Button)findViewById(R.id.btnUpload);
button.setEnabled(accepted);
mPrefs.edit()
.putBoolean("Upload Conditions Confirmed", accepted)
.commit()
;
}
private Boolean checkAcceptanceOfConditions() {
final Button button = (Button)findViewById(R.id.btnUpload);
// Hide the confirmation section if user has accepted T&C's
Log.d(TAG, "Upload Conditions Confirmed: " + mPrefs.getBoolean("Upload Conditions Confirmed", false));
if ( mPrefs.getBoolean("Upload Conditions Confirmed", false) ) {
((CheckBox)findViewById(R.id.chkUpload)).setVisibility(CheckBox.GONE);
((CheckBox)findViewById(R.id.chkUpload)).invalidate();
((TextView)findViewById(R.id.txtArtifactConfirm)).setVisibility(TextView.GONE);
((TextView)findViewById(R.id.txtArtifactConfirm)).invalidate();
button.setEnabled(true);
return true;
}
return false;
}
}
......@@ -29,6 +29,7 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
......@@ -84,16 +85,17 @@ public class EditPreferences extends PreferenceActivity implements OnSharedPrefe
}
}
//public void onContentChanged() {
//}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
// refresh displayed values by restarting activity (a hack, but apparently there
// isn't a nicer way)
if ( key == getString(R.string.pref_upload_token_key)) {
finish();
//startActivity(getIntent());
if ( this.getCallingActivity() != null ) {
if ( DEBUG ) Log.d(TAG, "Calling activity is '" + this.getCallingActivity().getClassName().toString());
if ( this.getCallingActivity().getClassName().toString() == "ArtifactSendReceiver" ) {
finish();
}
}
}
}
......
......@@ -101,8 +101,8 @@ public class RestClient {
// TODO: change this to be a hash of post variables
public static JSONObject UploadArtifact(String url, String token, String username, Boolean view,
String foldername, String filename, String title,
Context context){
String foldername, String tags, String filename, String title,
String description, Context context){
Vector<String> pNames = new Vector<String>();
Vector<String> pVals = new Vector<String>();
......@@ -110,6 +110,10 @@ public class RestClient {
pNames.add("title");
pVals.add(title);
}
if (!description.equals("")) {
pNames.add("description");
pVals.add(description);
}
if (!token.equals("")) {
pNames.add("token");
pVals.add(token);
......@@ -122,6 +126,10 @@ public class RestClient {
pNames.add("foldername");
pVals.add(foldername);
}
if (!tags.equals("")) {
pNames.add("tags");
pVals.add(tags);
}
if (!filename.equals("")) {
pNames.add("filename");
pVals.add(filename);
......
......@@ -75,7 +75,7 @@ public class TransferService extends Service {
}
// This is the receiver that we use to update the percentage progress display
// for the current download.
// for the current upload.
public class NotificationProgressUpdateReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
......@@ -114,8 +114,10 @@ public class TransferService extends Service {
getUploadUsernamePref(),
getUploadCreateViewPref(),
getUploadFolderPref(),
getUploadTagsPref(upload_info.getString("tags")),
upload_info.getString("filename"),
upload_info.getString("title"),
upload_info.getString("description"),
getApplicationContext());
publishProgress(new String[]{"start", upload_info.getString("title")});
......@@ -176,7 +178,7 @@ public class TransferService extends Service {
getApplicationContext().sendBroadcast(broadcast_intent);
((NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE)).cancel(GlobalResources.UPLOADER_ID);
Toast.makeText(getApplicationContext(), "Upload Failed:\n" + progress[1], Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), getResources().getString(R.string.uploadfailed) + ": " + progress[1], Toast.LENGTH_SHORT).show();
stopSelf();
}
}
......@@ -298,6 +300,11 @@ public class TransferService extends Service {
public String getUploadUsernamePref() {
return mPrefs.getString(getString(R.string.pref_upload_username_key), null);
}
public String getUploadTagsPref(String pref_tags) {
String tags = ( pref_tags != null ) ? pref_tags.trim() : "" ;
return (mPrefs.getString(getString(R.string.pref_upload_tags_key), null) + " " + tags).trim();
}
public void setUploadAuthTokenPref(String newToken) {
if ( DEBUG ) Log.d(TAG, "New Token is '" + newToken + "'");
......
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