Skip to content

Commit

Permalink
14 june2021 solve issue #12 again
Browse files Browse the repository at this point in the history
  • Loading branch information
jignesh13 committed Jun 14, 2021
1 parent daf749b commit ed6ced7
Show file tree
Hide file tree
Showing 8 changed files with 286 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public class EventInfo {
public String[] eventtitles;
public boolean isallday;
public int id;
public String accountname;
public long starttime;
public long endtime;
public EventInfo nextnode;
Expand Down
209 changes: 200 additions & 9 deletions app/src/main/java/com/example/GoogleCalendar/MainActivity.java

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions app/src/main/java/com/example/GoogleCalendar/Utility.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static HashMap<LocalDate, EventInfo> readCalendarEvent(Context context, L
Cursor cursor = context.getContentResolver().query(
CalendarContract.Events.CONTENT_URI,
new String[]{"_id", "title", "description",
"dtstart", "dtend", "eventLocation", "account_name", CalendarContract.Events.ALL_DAY, CalendarContract.Events.EVENT_COLOR, CalendarContract.Events.CALENDAR_COLOR, CalendarContract.Events.EVENT_TIMEZONE}, null,
"dtstart", "dtend", "eventLocation", "calendar_displayName", CalendarContract.Events.ALL_DAY, CalendarContract.Events.EVENT_COLOR, CalendarContract.Events.CALENDAR_COLOR, CalendarContract.Events.EVENT_TIMEZONE}, null,
null, null);


Expand All @@ -78,12 +78,13 @@ public static HashMap<LocalDate, EventInfo> readCalendarEvent(Context context, L

if (true) {
LocalDate localDate = getDate(Long.parseLong(cursor.getString(3)));
Log.e("Acc", cursor.getString(1) + "," + syncacc + "," + cursor.getInt(8) + "," + localDate);
// Log.e("Acc", cursor.getString(6) + "," + syncacc + "," + cursor.getInt(8) + "," + localDate);
if (!localDateHashMap.containsKey(localDate)) {
EventInfo eventInfo = new EventInfo();
eventInfo.id = cursor.getInt(0);
eventInfo.starttime = cursor.getLong(3);
eventInfo.endtime = cursor.getLong(4);
eventInfo.accountname=cursor.getString(6);
eventInfo.isallday = cursor.getInt(7) == 1 ? true : false;
if (eventInfo.endtime-eventInfo.starttime>86400000)eventInfo.isallday=true;
eventInfo.eventtitles = new String[]{cursor.getString(1)};
Expand Down Expand Up @@ -125,6 +126,7 @@ public static HashMap<LocalDate, EventInfo> readCalendarEvent(Context context, L
if (eventInfo.endtime-eventInfo.starttime>86400000)eventInfo.isallday=true;

nextnode.title = cursor.getString(1);
nextnode.accountname=cursor.getString(6);
nextnode.timezone = cursor.getString(10);
nextnode.eventcolor = cursor.getInt(8)==0? Color.parseColor("#009688"):cursor.getInt(8);
prev.nextnode = nextnode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,10 @@ public boolean onSingleTapConfirmed(MotionEvent e) {
// If the tap was on an event then trigger the callback.
if (mEventRects != null && mEventClickListener != null) {
List<EventRect> reversedEventRects = mEventRects;
Collections.reverse(reversedEventRects);
// Collections.reverse(reversedEventRects);
for (EventRect event : reversedEventRects) {
if (event.rectF != null && e.getX() > event.rectF.left && e.getX() < event.rectF.right && e.getY() > event.rectF.top && e.getY() < event.rectF.bottom) {
mEventClickListener.onEventClick(event.originalEvent, event.rectF);
mEventClickListener.onEventClick(event.event, event.rectF);
playSoundEffect(SoundEffectConstants.CLICK);
return super.onSingleTapConfirmed(e);
}
Expand All @@ -343,7 +343,7 @@ public void onLongPress(MotionEvent e) {

if (mEventLongPressListener != null && mEventRects != null) {
List<EventRect> reversedEventRects = mEventRects;
Collections.reverse(reversedEventRects);
// Collections.reverse(reversedEventRects);
for (EventRect event : reversedEventRects) {
if (event.rectF != null && e.getX() > event.rectF.left && e.getX() < event.rectF.right && e.getY() > event.rectF.top && e.getY() < event.rectF.bottom) {
mEventLongPressListener.onEventLongPress(event.originalEvent, event.rectF);
Expand Down Expand Up @@ -1168,7 +1168,7 @@ top < getHeight() &&
while (k>0&&mEventRects.get(k-1).event.isAllDay()&&mEventRects.get(k-1).event.getDaytype()==0){
k--;
}
while (k>0&&mEventRects.get(k-1).event.isIsmoreday()&&ff>196){
while (k>0&&mEventRects.get(k-1).event.isIsmoreday()&&ff>mHeaderColumnWidth){
Log.e("ds",mEventRects.get(k-1).event.getName());

ff=ff-mWidthPerDay;
Expand All @@ -1180,7 +1180,7 @@ top < getHeight() &&

}

if (ff<196)ff=196;
if (ff<mHeaderColumnWidth)ff=mHeaderColumnWidth;
canvas.drawText(mEventRects.get(i).event.getName(), ff+10, mEventRects.get(i).rectF.centerY() - jheaderEventheight, jheaderEventTextpaint);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,41 @@
*/
public class WeekViewEvent {
private long mId;
private Calendar mStartTime;
private Calendar mEndTime;
private Calendar mStartTime,actualstart;
private Calendar mEndTime,actualend;
private String mName;
private String mLocation;
private String accountname;
private int mColor;
private boolean mAllDay;
private int daytype;
private boolean ismoreday;
private long noofday;

public void setAccountname(String accountname) {
this.accountname = accountname;
}

public void setActualend(Calendar actualend) {
this.actualend = actualend;
}

public void setActualstart(Calendar actualstart) {
this.actualstart = actualstart;
}

public Calendar getActualend() {
return actualend;
}

public Calendar getActualstart() {
return actualstart;
}

public String getAccountname() {
return accountname;
}

public void setNoofday(long noofday) {
this.noofday = noofday;
}
Expand Down Expand Up @@ -99,13 +124,14 @@ public WeekViewEvent(long id, String name, int startYear, int startMonth, int st
* @param endTime The time when the event ends.
* @param allDay Is the event an all day event.
*/
public WeekViewEvent(long id, String name, String location, Calendar startTime, Calendar endTime, boolean allDay) {
public WeekViewEvent(long id, String name, String location, Calendar startTime, Calendar endTime, boolean allDay,String accountname) {
this.mId = id;
this.mName = name;
this.mLocation = location;
this.mStartTime = startTime;
this.mEndTime = endTime;
this.mAllDay = allDay;
this.accountname=accountname;
}

/**
Expand All @@ -116,8 +142,8 @@ public WeekViewEvent(long id, String name, String location, Calendar startTime,
* @param startTime The time when the event starts.
* @param endTime The time when the event ends.
*/
public WeekViewEvent(long id, String name, String location, Calendar startTime, Calendar endTime) {
this(id, name, location, startTime, endTime, false);
public WeekViewEvent(long id, String name, String location, Calendar startTime, Calendar endTime,String accountname) {
this(id, name, location, startTime, endTime, false,accountname);
}

/**
Expand All @@ -127,8 +153,8 @@ public WeekViewEvent(long id, String name, String location, Calendar startTime,
* @param startTime The time when the event starts.
* @param endTime The time when the event ends.
*/
public WeekViewEvent(long id, String name, Calendar startTime, Calendar endTime) {
this(id, name, null, startTime, endTime);
public WeekViewEvent(long id, String name, Calendar startTime, Calendar endTime,String accountname) {
this(id, name, null, startTime, endTime,accountname);
}


Expand Down Expand Up @@ -216,9 +242,11 @@ public List<WeekViewEvent> splitWeekViewEvents(){
endTime.set(Calendar.HOUR_OF_DAY, 23);
endTime.set(Calendar.MINUTE, 59);
int k=1;
WeekViewEvent event1 = new WeekViewEvent(this.getId(), this.getName(), this.getLocation(), this.getStartTime(), endTime, this.isAllDay());
WeekViewEvent event1 = new WeekViewEvent(this.getId(), this.getName(), this.getLocation(), this.getStartTime(), endTime, this.isAllDay(),this.accountname);
event1.setIsmoreday(true);
event1.setDaytype(k);
event1.setActualstart(this.getStartTime());
event1.setActualend(this.getEndTime());
event1.setNoofday(remainingDays);
event1.setColor(this.getColor());
events.add(event1);
Expand All @@ -234,9 +262,11 @@ public List<WeekViewEvent> splitWeekViewEvents(){
endOfOverDay.set(Calendar.HOUR_OF_DAY, 23);
endOfOverDay.set(Calendar.MINUTE, 59);

WeekViewEvent eventMore = new WeekViewEvent(this.getId(), this.getName(), null, overDay, endOfOverDay, this.isAllDay());
WeekViewEvent eventMore = new WeekViewEvent(this.getId(), this.getName(), null, overDay, endOfOverDay, this.isAllDay(),this.accountname);
eventMore.setColor(this.getColor());
eventMore.setIsmoreday(true);
eventMore.setActualstart(this.getStartTime());
eventMore.setActualend(this.getEndTime());
k++;
eventMore.setDaytype(k);
eventMore.setNoofday(remainingDays);
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/mytestback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="4dp" />

</shape>
12 changes: 4 additions & 8 deletions app/src/main/res/drawable/rround.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item>
<shape android:shape="rectangle">
<corners android:radius="4dp"></corners>
<solid android:color="#009688" />
</shape>
</item>
</selector>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="4dp"></corners>
<solid android:color="#009688" />
</shape>
41 changes: 28 additions & 13 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,12 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:paddingLeft="80dp"
android:paddingLeft="64dp"
android:fontFamily="@font/googlesans_regular"
android:text="Bhai Duj"
android:textColor="#505050"
android:textColor="#000"
android:paddingRight="24dp"
android:textSize="24sp"
android:textSize="23sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/closebtn" />

Expand All @@ -241,12 +241,12 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/latoregular"
android:paddingRight="36dp"
android:fontFamily="@font/googlesans_regular"
android:paddingRight="8dp"
android:text=""
android:textColor="#3C3C3C"
android:textColor="#000"
android:textSize="16sp"
android:paddingLeft="80dp"
android:paddingLeft="64dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView12" />
Expand All @@ -262,18 +262,33 @@
app:layout_constraintStart_toStartOf="@+id/closebtn"
app:layout_constraintTop_toBottomOf="@+id/textView13" />

<TextView
android:id="@+id/textView014"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/googlesans_regular"
android:paddingLeft="64dp"
android:text="Events"
android:textColor="#000"
android:textSize="15.5sp"
android:layout_marginTop="24dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView13"
/>

<TextView
android:id="@+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/latoregular"
android:fontFamily="@font/googlesans_regular"
android:paddingLeft="64dp"
android:text="Holidays in India"
android:textColor="#3C3C3C"
android:textSize="16sp"
android:paddingLeft="80dp"
app:layout_constraintBottom_toBottomOf="@+id/imageView2"
android:textColor="#787878"
android:textSize="13.6sp"
android:layout_marginTop="4dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/imageView2" />
app:layout_constraintTop_toBottomOf="@+id/textView014"
/>
</androidx.constraintlayout.widget.ConstraintLayout>


Expand Down

0 comments on commit ed6ced7

Please sign in to comment.