Commit 16a38ade authored by PKnittel's avatar PKnittel
Browse files

Fixed some Issues with Uri-parsing

Added more update-options
Revised try/catch blocks
parent 992478a2
Loading
Loading
Loading
Loading
+1 −1
Changes for src/android/notification/Asset.java: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ public class Asset {
		} else if (path.startsWith("http")){
			return getUriForHTTP(path);
		}
		return Uri.parse(path);
		return Uri.EMPTY;
	}
    

+2 −2
Changes for src/android/notification/Manager.java: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -281,9 +281,9 @@ public class Manager {
    
    
    /**
     * Retrieves a list with all currently pending notification JSONObject.
     * Retrieves a list with all currently pending notification JSONObjects that matches with the given String-Array
     *
     * @return JSONArray with all notification-JSONObjects
     * @return JSONArray with notification-JSONObjects 
     */
    public JSONArray getAll(JSONArray ids){
        SharedPreferences settings = getSharedPreferences();
+18 −1
Changes for src/android/notification/NotificationWrapper.java: 18 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Build;
import android.support.v4.app.NotificationCompat.Builder;
import android.util.Log;
import android.widget.Toast;

/**
@@ -143,7 +144,7 @@ public class NotificationWrapper {
		try {
			arguments = new JSONObject(alarms.get(id).toString());
		} catch (JSONException e) {
			e.printStackTrace();
			Log.e("NotificationWrapper", "Update failed. No Notification available for the given id: " + id );
			return;
		}
		arguments = updateArguments(arguments, updates);
@@ -188,6 +189,7 @@ public class NotificationWrapper {
				unpersist(notificationId);
			}
		} catch (JSONException e) {
			unpersist(notificationId);
			e.printStackTrace();
			return;
		}
@@ -340,6 +342,21 @@ public class NotificationWrapper {
    		if(!updates.isNull("icon")){
    			arguments.put("icon", updates.get("icon"));
    		}
    		if(!updates.isNull("date")){
    			arguments.put("date", updates.get("date"));
    		}
    		if(!updates.isNull("repeat")){
    			arguments.put("repeat", updates.get("repeat"));
    		}
    		if(!updates.isNull("json")){
    			arguments.put("json", updates.get("json"));
    		}
    		if(!updates.isNull("autoCancel")){
    			arguments.put("autoCancel", updates.get("autoCancel"));
    		}
    		if(!updates.isNull("ongoing")){
    			arguments.put("ongoing", updates.get("ongoing"));
    		}
    	} catch (JSONException jse){
    		jse.printStackTrace();
    	}
+2 −16
Changes for src/android/notification/Options.java: 2 added lines, 16 removed lines.
Original line number Diff line number Diff line
@@ -164,18 +164,10 @@ public class Options {
        Uri iconUri = null;
        try{
        	iconUri = Uri.parse(options.optString("iconUri"));
        } catch (Exception e){
        	e.printStackTrace();
        }
        
        if (iconUri != null) {
            bmp = getIconFromUri(iconUri);
        }

        if (bmp == null) {
        } catch (Exception e){
        	bmp = getIconFromRes(icon);
        }

        return bmp;
    }

@@ -317,23 +309,17 @@ public class Options {
     * @return
     *      The corresponding bitmap
     */
    private Bitmap getIconFromUri (Uri uri) {
    private Bitmap getIconFromUri (Uri uri) throws IOException {
        Bitmap bmp = null;
          
        try {           
        InputStream input = context.getContentResolver().openInputStream(uri);
        bmp = BitmapFactory.decodeStream(input);
        } catch (IOException e) {
            e.printStackTrace();
        }

        return bmp;
    }
    
    /**
     * Function to set the value of "initialDate" in the JSONArray
     * @param args The given JSONArray
     * @return A new JSONArray with the parameter "initialDate" set.
     */
    public void setInitDate(){
    	long initialDate = options.optLong("date", 0) * 1000;