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

Unverified Commit 1c1c5b28 authored by Kavita Patil's avatar Kavita Patil Committed by Michael Bestas
Browse files

Widget Enhancement- Option To Add A New Event From The Widget Screen (#1105)

Added enhancement to the Widget to add an event from Widget

Change-Id: Ie3e6fa3686947aeaa1ab243b3ae91545d6ffadac
parent 7dda9e82
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@
    android:orientation="vertical">

    <!-- Header -->
    <LinearLayout
    <RelativeLayout
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
@@ -41,10 +41,21 @@
            android:shadowRadius="3"
            android:textColor="@color/appwidget_week" />
        <TextView
            android:layout_below="@+id/day_of_week"
            android:id="@+id/date"
            style="@style/WidgetDateStyle"
            android:textColor="@color/appwidget_month" />
    </LinearLayout>

        <ImageView
            android:paddingStart="8dip"
            android:paddingEnd="8dip"
            android:layout_centerVertical="true"
            android:layout_alignParentEnd="true"
            android:id="@+id/iv_add"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_add_event"/>
    </RelativeLayout>

    <!-- Event list -->
    <ListView
+15 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.provider.CalendarContract;
import android.text.format.DateUtils;
import android.text.format.Time;
@@ -39,6 +40,9 @@ import com.android.calendar.AllInOneActivity;
import com.android.calendar.DynamicTheme;
import com.android.calendar.EventInfoActivity;
import com.android.calendar.Utils;
import com.android.calendar.event.EditEventActivity;

import java.util.Calendar;

import ws.xsoh.etar.R;

@@ -54,6 +58,7 @@ public class CalendarAppWidgetProvider extends AppWidgetProvider {

    // TODO Move these to Calendar.java
    static final String EXTRA_EVENT_IDS = "com.android.calendar.EXTRA_EVENT_IDS";
    private static final int PI_FLAG_IMMUTABLE = Build.VERSION.SDK_INT >= 23 ? PendingIntent.FLAG_IMMUTABLE : 0;

    /**
     * Build {@link ComponentName} describing this specific
@@ -234,6 +239,16 @@ public class CalendarAppWidgetProvider extends AppWidgetProvider {
                    context, 0 /* no requestCode */, launchCalendarIntent, Utils.PI_FLAG_IMMUTABLE);
            views.setOnClickPendingIntent(R.id.header, launchCalendarPendingIntent);

            // Open Add event option when user clicks on the add button on widget
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setClass(context, EditEventActivity.class);
            intent.putExtra(EXTRA_EVENT_ALL_DAY, false);
            intent.putExtra(CalendarContract.Events.CALENDAR_ID, -1);

            final PendingIntent addEventPendingIntent = PendingIntent.getActivity(
                    context, 0 /* no requestCode */, intent, PI_FLAG_IMMUTABLE);
            views.setOnClickPendingIntent(R.id.iv_add, addEventPendingIntent);

            // Each list item will call setOnClickExtra() to let the list know
            // which item
            // is selected by a user.