Commit 3bde57d5 authored by Alan McNatty's avatar Alan McNatty
Browse files

Changes for 1.5 - fixed bug which caused the app to crash if no preferences...

Changes for 1.5 - fixed bug which caused the app to crash if no preferences were set and you tried to share to MaharaDroid.
parent 0be84e83
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="nz.net.catalyst.MaharaDroid"
android:versionCode="2"
android:versionName="1.3">
android:versionCode="4"
android:versionName="1.5">
<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="video/*" /> creates .3gp files - mahara can't easily use them -->
</intent-filter>
</activity>
<activity android:name=".EditPreferences"
......
......@@ -76,30 +76,34 @@ public class ArtifactSettings extends Activity implements OnClickListener {
m_extras = getIntent().getExtras();
if (m_extras == null) {
if ( DEBUG ) Log.d(TAG, "No extras .. nothing to do!");
finish();
}
else {
ContentResolver cr = getContentResolver();
Uri uri = Uri.parse(m_extras.getString("uri"));
if ( DEBUG ) Log.d(TAG, "URI = '" + uri.toString() + "'");
// 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) {
Toast.makeText(this, R.string.artifact_retrieve_error, Toast.LENGTH_LONG).show();
finish();
}
else {
// Get the filename of the media file and use that as the default title.
Cursor cursor = cr.query(uri, new String[]{android.provider.MediaStore.MediaColumns.DATA}, null, null, null);
if (cursor != null) {
if ( DEBUG ) Log.d(TAG, "cursor query succeeded");
cursor.moveToFirst();
m_filepath = cursor.getString(0);
cursor.close();
} else {
if ( DEBUG ) Log.d(TAG, "cursor query failed");
// If nothing found by query then assume the file is good to go as is.
m_filepath = uri.toString();
// Remove prefix if we still have one
m_filepath = m_filepath.substring(m_filepath.indexOf(":///") + "://".length());
}
if (m_filepath != null) {
String title = m_filepath.substring(m_filepath.lastIndexOf("/") + 1);
((EditText)findViewById(R.id.txtArtifactTitle)).setText(title);
((EditText)findViewById(R.id.txtArtifactTitle)).selectAll();
}
if (m_filepath != null) {
String title = m_filepath.substring(m_filepath.lastIndexOf("/") + 1);
((EditText)findViewById(R.id.txtArtifactTitle)).setText(title);
((EditText)findViewById(R.id.txtArtifactTitle)).selectAll();
if ( DEBUG ) Log.d(TAG, "m_filepath = '" + m_filepath + "'");
}
}
}
......@@ -156,7 +160,7 @@ public class ArtifactSettings extends Activity implements OnClickListener {
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 ( DEBUG ) 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();
......
/*
* MaharaDroid - Artefact uploader
*
* This file is part of MaharaDroid.
*
* Copyright [2010] [Catalyst IT Limited]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nz.net.catalyst.MaharaDroid;
import android.util.Log;
/**
* Log configuration settings.
* Code that is guarded by a test of the LogConfig.VERBOSE constant
* will be stripped out by the compiler if the test can be determined at compile time
* to be false.<br/>
* e.g.<br/>
* <code>if (LogConfig.VERBOSE) Log.v(TAG, "a String to log");</code><br/>
* will be stripped out by the compiler if LogConfig.VERBOSE is false.
*
* @author Grant Patterson (grant.patterson@catalyst.net.nz)
*/
public class LogConfig {
/**
* Whether the application should have all tags log at DEBUG level.
* When this is true, all tags will log at DEBUG level.
* When this is false, only tags that are explicitly enabled by the Android logging
* properties mechanism (see android.util.Log.isLoggable()) will log at DEBUG level.<br/>
* This should be false in release builds so that tags will only log at DEBUG
* level when they have been explicitly told to through Android's logging properties.
* Rather than checking this directly, classes should use LogConfig.isDebug(TAG) to
* determine whether to log a DEBUG level.
*/
private static final boolean DEBUG = true;
/**
* Whether the application should allow any tags to log at VERBOSE level.
* Make sure this is set this to false in release builds so the compiler will strip out
* VERBOSE log statements.<br/>
* In general, classes should check this constant rather than checking Log.isLoggable(TAG, Log.VERBOSE).
* The Java compiler is unable to strip out calls to Log.isLoggable()
* (although, maybe the Dalvik compiler, or the JIT can ???)
*/
public static final boolean VERBOSE = true;
private static final int MAX_LOG_TAG_LENGTH = 23;
/**
* When DEBUG logging isn't globally enabled for the application, this method
* defers to Android's logging properties mechanism (see android.util.Log.isLoggable()).
* @param logTag the log tag
* @return whether the log tag should log at DEBUG level
*/
public static boolean isDebug(String logTag) {
return DEBUG || Log.isLoggable(logTag, Log.DEBUG);
}
public static String getLogTag(Class<?> clazz) {
String tag = clazz.getSimpleName();
if (tag.length() > MAX_LOG_TAG_LENGTH) {
// trim tag
StringBuilder trimmed = new StringBuilder(MAX_LOG_TAG_LENGTH);
trimmed.append(tag.substring(0, MAX_LOG_TAG_LENGTH - 2));
trimmed.append("..");
tag = trimmed.toString();
}
return tag;
}
}
......@@ -106,35 +106,35 @@ public class RestClient {
Vector<String> pNames = new Vector<String>();
Vector<String> pVals = new Vector<String>();
if (!title.equals("")) {
if ( title != null ) {
pNames.add("title");
pVals.add(title);
}
if (!description.equals("")) {
if ( description != null ) {
pNames.add("description");
pVals.add(description);
}
if (!token.equals("")) {
if ( token != null ) {
pNames.add("token");
pVals.add(token);
}
if (!username.equals("")) {
if ( username != null ) {
pNames.add("username");
pVals.add(username);
}
if (!foldername.equals("")) {
if ( foldername != null ) {
pNames.add("foldername");
pVals.add(foldername);
}
if (!tags.equals("")) {
if ( tags != null ) {
pNames.add("tags");
pVals.add(tags);
}
if (!filename.equals("")) {
if ( filename != null ) {
pNames.add("filename");
pVals.add(filename);
}
if (view) {
if (view != null && view ) {
pNames.add("view");
pVals.add("true");
}
......
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