add a Fab to the main calendar view too

This commit is contained in:
tibbi 2016-07-05 15:12:35 +02:00
parent 862c926690
commit c9a86bb347
5 changed files with 25 additions and 0 deletions

View File

@ -72,6 +72,7 @@ public class EventActivity extends AppCompatActivity implements DBHelper.DBOpera
}
private void setupEditEvent() {
setTitle(getResources().getString(R.string.edit_event));
mEventStartDateTime = new DateTime(mEvent.getStartTS() * 1000L, DateTimeZone.getDefault());
mEventEndDateTime = new DateTime(mEvent.getEndTS() * 1000L, DateTimeZone.getDefault());
mTitleET.setText(mEvent.getTitle());
@ -80,6 +81,7 @@ public class EventActivity extends AppCompatActivity implements DBHelper.DBOpera
}
private void setupNewEvent(String dayCode) {
setTitle(getResources().getString(R.string.new_event));
mEventStartDateTime = Formatter.getDateTimeFromCode(dayCode).withZone(DateTimeZone.getDefault()).withHourOfDay(13);
mEventEndDateTime = Formatter.getDateTimeFromCode(dayCode).withZone(DateTimeZone.getDefault()).withHourOfDay(14);
}

View File

@ -21,11 +21,13 @@ import com.simplemobiletools.calendar.Calendar;
import com.simplemobiletools.calendar.CalendarImpl;
import com.simplemobiletools.calendar.Config;
import com.simplemobiletools.calendar.Constants;
import com.simplemobiletools.calendar.Formatter;
import com.simplemobiletools.calendar.R;
import com.simplemobiletools.calendar.Utils;
import com.simplemobiletools.calendar.models.Day;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import java.util.List;
import java.util.Locale;
@ -110,6 +112,14 @@ public class MainActivity extends AppCompatActivity implements Calendar {
}
}
@OnClick(R.id.calendar_fab)
public void fabClicked(View view) {
final Intent intent = new Intent(getApplicationContext(), EventActivity.class);
final String tomorrowCode = Formatter.getDayCodeFromDateTime(new DateTime(DateTimeZone.getDefault()).plusDays(1));
intent.putExtra(Constants.DAY_CODE, tomorrowCode);
startActivity(intent);
}
private void updateDays(List<Day> days) {
final int len = days.size();

View File

@ -42,6 +42,7 @@ public class WidgetConfigureActivity extends AppCompatActivity implements Calend
@BindView(R.id.config_text_color) View mTextColorPicker;
@BindView(R.id.config_calendar) View mWidgetBackground;
@BindView(R.id.config_save) Button mSaveBtn;
@BindView(R.id.calendar_fab) View mFab;
@BindDimen(R.dimen.day_text_size) float mDayTextSize;
@BindDimen(R.dimen.today_text_size) float mTodayTextSize;
@ -101,6 +102,8 @@ public class WidgetConfigureActivity extends AppCompatActivity implements Calend
mCalendar = new CalendarImpl(this, getApplicationContext());
mCalendar.updateCalendar(new DateTime());
mFab.setVisibility(View.GONE);
}
private SharedPreferences initPrefs(Context context) {

View File

@ -7,4 +7,12 @@
<include layout="@layout/calendar_layout"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/calendar_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/activity_margin"
android:src="@mipmap/plus"/>
</android.support.design.widget.CoordinatorLayout>

View File

@ -4,6 +4,8 @@
<!-- Event -->
<string name="event">Event</string>
<string name="edit_event">Edit Event</string>
<string name="new_event">New Event</string>
<string name="save">Save</string>
<string name="delete">Delete</string>
<string name="title_empty">Title cannot be empty</string>