Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to add events to calendar #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions app/src/main/java/net/gaast/giggity/EventDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.FrameLayout;
Expand All @@ -49,6 +50,7 @@
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;

/* Mind you, one day this was an actual Dialog, but not anymore technically. It's just a pretty
densely populated view used in two different ways (depending on whether we're on a tablet. */
Expand Down Expand Up @@ -226,6 +228,45 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
ImageButton shareButton= new ShareButton(ctx_);
bottomBox.addView(shareButton, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0));

Button addToCalendar = new Button(ctx_);
addToCalendar.setText(R.string.add_to_calendar);
bottomBox.addView(addToCalendar, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1));
addToCalendar.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("beginTime", item_.getStartTime().getTime());
intent.putExtra("endTime", item_.getEndTime().getTime());
intent.putExtra("allDay", false);
intent.putExtra("title", item_.getTitle());
String location = item_.getLine().getTitle();
if (item_.getLine().getLocation() != null) {
location += item_.getLine().getLocation();
}
intent.putExtra("eventLocation", location);

StringBuilder description = new StringBuilder();
if (item_.getTrack() != null) {
description.append(ctx_.getResources().getString(R.string.track))
.append(' ')
.append(item_.getTrack())
.append('\n');
}
if (item_.getSpeakers() != null) {
for (String speaker : item_.getSpeakers()) {
description.append(ctx_.getResources().getString(R.string.speaker))
.append(' ')
.append(speaker)
.append('\n');
}
}
description.append(item_.getDescription());
intent.putExtra("description", description.toString());

ctx_.startActivity(intent);
}
});

ImageButton delButton;
if (!item_.isHidden()) {
delButton = new HideButton(ctx_);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<string name="speakers">Speakers:</string>
<string name="track">Track:</string>
<string name="remind_me">Remind me</string>
<string name="add_to_calendar">Add to calendar</string>
<string name="overlap">Overlaps with</string>
<string name="hide_what">Hide...</string>
<string name="unhide_what">Unhide...</string>
Expand Down