Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47f6cc69 authored by Isaac Katzenelson's avatar Isaac Katzenelson
Browse files

Support non-standard VIEW intent format

Change-Id: I329d1e48b5f5c1ba6f7cf318489c2ab9564abbaa
parent 957ba343
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -289,6 +289,8 @@
    <string name="email_picker_label">Email with</string>
    <!-- The is shown in the email subject as the prefix appended to the event title -->
    <string translatable="false" name="email_subject_prefix">Re:\u0020</string>
    <!-- Toast message displayed when the event id was not found LIMIT=30] -->
    <string name="event_not_found">"Event not found."</string>

    <!-- Title of the quick response item in Settings [CHAR LIMIT=18]-->
    <string name="quick_response_settings">Quick responses</string>
+31 −3
Original line number Diff line number Diff line
@@ -29,6 +29,9 @@ import android.net.Uri;
import android.os.Bundle;
import android.provider.CalendarContract.Attendees;
import android.util.Log;
import android.widget.Toast;

import java.util.List;

public class EventInfoActivity extends Activity {
//        implements CalendarController.EventHandler, SearchView.OnQueryTextListener,
@@ -46,7 +49,7 @@ public class EventInfoActivity extends Activity {
        // Get the info needed for the fragment
        Intent intent = getIntent();
        int attendeeResponse = 0;
        mEventId = 0;
        mEventId = -1;
        boolean isDialog = false;

        if (icicle != null) {
@@ -63,13 +66,38 @@ public class EventInfoActivity extends Activity {
            Uri data = intent.getData();
            if (data != null) {
                try {
                    List<String> pathSegments = data.getPathSegments();
                    int size = pathSegments.size();
                    if (size > 2 && "EventTime".equals(pathSegments.get(2))) {
                        // Support non-standard VIEW intent format:
                        //dat = content://com.android.calendar/events/[id]/EventTime/[start]/[end]
                        mEventId = Long.parseLong(pathSegments.get(1));
                        if (size > 4) {
                            mStartMillis = Long.parseLong(pathSegments.get(3));
                            mEndMillis = Long.parseLong(pathSegments.get(4));
                        }
                    } else {
                        mEventId = Long.parseLong(data.getLastPathSegment());
                    }
                } catch (NumberFormatException e) {
                    Log.wtf(TAG,"No event id");
                    if (mEventId == -1) {
                        // do nothing here , deal with it later
                    } else if (mStartMillis == 0 || mEndMillis ==0) {
                        // Parsing failed on the start or end time , make sure the times were not
                        // pulled from the intent's extras and reset them.
                        mStartMillis = 0;
                        mEndMillis = 0;
                    }
                }
            }
        }

        if (mEventId == -1) {
            Log.w(TAG, "No event id");
            Toast.makeText(this, R.string.event_not_found, Toast.LENGTH_SHORT).show();
            finish();
        }

        // If we do not support showing full screen event info in this configuration,
        // close the activity and show the event in AllInOne.
        Resources res = getResources();
+3 −1
Original line number Diff line number Diff line
@@ -398,7 +398,9 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange
            // if the activity is finishing, then close the cursor and return
            final Activity activity = getActivity();
            if (activity == null || activity.isFinishing()) {
                if (cursor != null) {
                    cursor.close();
                }
                return;
            }