mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-27 00:47:56 +01:00
open a Details activity on date click
+ misc preparations for further work
This commit is contained in:
parent
4204c6a8c5
commit
f67b4ec2f5
@ -30,6 +30,7 @@ dependencies {
|
|||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
compile 'com.android.support:appcompat-v7:23.4.0'
|
compile 'com.android.support:appcompat-v7:23.4.0'
|
||||||
|
compile 'com.android.support:design:23.4.0'
|
||||||
compile 'joda-time:joda-time:2.9.1'
|
compile 'joda-time:joda-time:2.9.1'
|
||||||
compile 'com.jakewharton:butterknife:8.0.1'
|
compile 'com.jakewharton:butterknife:8.0.1'
|
||||||
compile 'com.github.yukuku:ambilwarna:2.0.1'
|
compile 'com.github.yukuku:ambilwarna:2.0.1'
|
||||||
|
@ -33,6 +33,11 @@
|
|||||||
android:label="@string/about"
|
android:label="@string/about"
|
||||||
android:screenOrientation="portrait"/>
|
android:screenOrientation="portrait"/>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".activities.DetailsActivity"
|
||||||
|
android:label="@string/details"
|
||||||
|
android:screenOrientation="portrait"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.LicenseActivity"
|
android:name=".activities.LicenseActivity"
|
||||||
android:label="@string/third_party_licences"
|
android:label="@string/third_party_licences"
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.simplemobiletools.calendar;
|
package com.simplemobiletools.calendar;
|
||||||
|
|
||||||
|
import com.simplemobiletools.calendar.models.Day;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface Calendar {
|
public interface Calendar {
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
package com.simplemobiletools.calendar;
|
package com.simplemobiletools.calendar;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.SparseBooleanArray;
|
||||||
|
|
||||||
|
import com.simplemobiletools.calendar.models.Day;
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
import org.joda.time.DateTimeZone;
|
||||||
|
|
||||||
import java.text.DateFormatSymbols;
|
import java.text.DateFormatSymbols;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -8,16 +14,19 @@ import java.util.List;
|
|||||||
|
|
||||||
public class CalendarImpl {
|
public class CalendarImpl {
|
||||||
public static final int DAYS_CNT = 42;
|
public static final int DAYS_CNT = 42;
|
||||||
private static final String DATE_PATTERN = "ddMMYYYY";
|
|
||||||
private static final String YEAR_PATTERN = "YYYY";
|
private static final String YEAR_PATTERN = "YYYY";
|
||||||
|
|
||||||
private final Calendar mCallback;
|
private final Calendar mCallback;
|
||||||
private final String mToday;
|
private final String mToday;
|
||||||
|
private final Context mContext;
|
||||||
private DateTime mTargetDate;
|
private DateTime mTargetDate;
|
||||||
|
private SparseBooleanArray mEvents;
|
||||||
|
|
||||||
public CalendarImpl(Calendar callback) {
|
public CalendarImpl(Calendar callback, Context context) {
|
||||||
this.mCallback = callback;
|
this.mCallback = callback;
|
||||||
mToday = new DateTime().toString(DATE_PATTERN);
|
mToday = new DateTime().toString(Constants.DATE_PATTERN);
|
||||||
|
mContext = context;
|
||||||
|
mEvents = Config.newInstance(context).getEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateCalendar(DateTime targetDate) {
|
public void updateCalendar(DateTime targetDate) {
|
||||||
@ -44,21 +53,26 @@ public class CalendarImpl {
|
|||||||
boolean isThisMonth = false;
|
boolean isThisMonth = false;
|
||||||
boolean isToday;
|
boolean isToday;
|
||||||
int value = prevMonthDays - firstDayIndex + 1;
|
int value = prevMonthDays - firstDayIndex + 1;
|
||||||
|
DateTime curDay = targetDate;
|
||||||
|
|
||||||
for (int i = 0; i < DAYS_CNT; i++) {
|
for (int i = 0; i < DAYS_CNT; i++) {
|
||||||
if (i < firstDayIndex) {
|
if (i < firstDayIndex) {
|
||||||
isThisMonth = false;
|
isThisMonth = false;
|
||||||
|
curDay = targetDate.minusMonths(1);
|
||||||
} else if (i == firstDayIndex) {
|
} else if (i == firstDayIndex) {
|
||||||
value = 1;
|
value = 1;
|
||||||
isThisMonth = true;
|
isThisMonth = true;
|
||||||
|
curDay = targetDate;
|
||||||
} else if (value == currMonthDays + 1) {
|
} else if (value == currMonthDays + 1) {
|
||||||
value = 1;
|
value = 1;
|
||||||
isThisMonth = false;
|
isThisMonth = false;
|
||||||
|
curDay = targetDate.plusMonths(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
isToday = isThisMonth && isToday(targetDate, value);
|
isToday = isThisMonth && isToday(targetDate, value);
|
||||||
|
|
||||||
final Day day = new Day(value, isThisMonth, isToday);
|
final String dayCode = curDay.withDayOfMonth(value).toDateTime(DateTimeZone.UTC).toString(Constants.DATE_PATTERN);
|
||||||
|
final Day day = new Day(value, isThisMonth, isToday, dayCode, hasEvent(dayCode));
|
||||||
days.add(day);
|
days.add(day);
|
||||||
value++;
|
value++;
|
||||||
}
|
}
|
||||||
@ -66,8 +80,12 @@ public class CalendarImpl {
|
|||||||
mCallback.updateCalendar(getMonthName(), days);
|
mCallback.updateCalendar(getMonthName(), days);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean hasEvent(String dayCode) {
|
||||||
|
return mEvents.get(Integer.parseInt(dayCode));
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isToday(DateTime targetDate, int curDayInMonth) {
|
private boolean isToday(DateTime targetDate, int curDayInMonth) {
|
||||||
return targetDate.withDayOfMonth(curDayInMonth).toString(DATE_PATTERN).equals(mToday);
|
return targetDate.withDayOfMonth(curDayInMonth).toString(Constants.DATE_PATTERN).equals(mToday);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMonthName() {
|
private String getMonthName() {
|
||||||
|
@ -2,6 +2,7 @@ package com.simplemobiletools.calendar;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.util.SparseBooleanArray;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
private SharedPreferences mPrefs;
|
private SharedPreferences mPrefs;
|
||||||
@ -21,4 +22,13 @@ public class Config {
|
|||||||
public void setIsFirstRun(boolean firstRun) {
|
public void setIsFirstRun(boolean firstRun) {
|
||||||
mPrefs.edit().putBoolean(Constants.IS_FIRST_RUN, firstRun).apply();
|
mPrefs.edit().putBoolean(Constants.IS_FIRST_RUN, firstRun).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SparseBooleanArray getEvents() {
|
||||||
|
final String json = mPrefs.getString(Constants.EVENTS, "{}");
|
||||||
|
return Utils.deserializeJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEvents(SparseBooleanArray events) {
|
||||||
|
mPrefs.edit().putString(Constants.EVENTS, Utils.serializeArray(events)).apply();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,4 +8,8 @@ public class Constants {
|
|||||||
public static final String IS_FIRST_RUN = "is_first_run";
|
public static final String IS_FIRST_RUN = "is_first_run";
|
||||||
public static final String WIDGET_BG_COLOR = "widget_bg_color";
|
public static final String WIDGET_BG_COLOR = "widget_bg_color";
|
||||||
public static final String WIDGET_TEXT_COLOR = "widget_text_color";
|
public static final String WIDGET_TEXT_COLOR = "widget_text_color";
|
||||||
|
public static final String EVENTS = "events";
|
||||||
|
|
||||||
|
public static final String DAY_CODE = "day_code";
|
||||||
|
public static final String DATE_PATTERN = "YYMMdd";
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.simplemobiletools.calendar;
|
||||||
|
|
||||||
|
import org.joda.time.format.DateTimeFormat;
|
||||||
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
public class Formatter {
|
||||||
|
private static final String EVENT_PATTERN = "d MMMM YYYY";
|
||||||
|
|
||||||
|
public static String getEventDate(String dayCode) {
|
||||||
|
final DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(Constants.DATE_PATTERN);
|
||||||
|
return dateTimeFormatter.parseDateTime(dayCode).toString(EVENT_PATTERN);
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +0,0 @@
|
|||||||
package com.simplemobiletools.calendar;
|
|
||||||
|
|
||||||
import android.graphics.Color;
|
|
||||||
|
|
||||||
public class Helpers {
|
|
||||||
public static int adjustAlpha(int color, float factor) {
|
|
||||||
final int alpha = Math.round(Color.alpha(color) * factor);
|
|
||||||
final int red = Color.red(color);
|
|
||||||
final int green = Color.green(color);
|
|
||||||
final int blue = Color.blue(color);
|
|
||||||
return Color.argb(alpha, red, green, blue);
|
|
||||||
}
|
|
||||||
}
|
|
@ -18,6 +18,7 @@ import android.graphics.Paint;
|
|||||||
import android.widget.RemoteViews;
|
import android.widget.RemoteViews;
|
||||||
|
|
||||||
import com.simplemobiletools.calendar.activities.MainActivity;
|
import com.simplemobiletools.calendar.activities.MainActivity;
|
||||||
|
import com.simplemobiletools.calendar.models.Day;
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
@ -52,8 +53,8 @@ public class MyWidgetProvider extends AppWidgetProvider implements Calendar {
|
|||||||
|
|
||||||
final SharedPreferences prefs = initPrefs(mContext);
|
final SharedPreferences prefs = initPrefs(mContext);
|
||||||
final int storedTextColor = prefs.getInt(Constants.WIDGET_TEXT_COLOR, Color.WHITE);
|
final int storedTextColor = prefs.getInt(Constants.WIDGET_TEXT_COLOR, Color.WHITE);
|
||||||
mTextColor = Helpers.adjustAlpha(storedTextColor, Constants.HIGH_ALPHA);
|
mTextColor = Utils.adjustAlpha(storedTextColor, Constants.HIGH_ALPHA);
|
||||||
mWeakTextColor = Helpers.adjustAlpha(storedTextColor, Constants.LOW_ALPHA);
|
mWeakTextColor = Utils.adjustAlpha(storedTextColor, Constants.LOW_ALPHA);
|
||||||
|
|
||||||
mDayTextSize = mRes.getDimension(R.dimen.day_text_size) / mRes.getDisplayMetrics().density;
|
mDayTextSize = mRes.getDimension(R.dimen.day_text_size) / mRes.getDisplayMetrics().density;
|
||||||
mTodayTextSize = mRes.getDimension(R.dimen.today_text_size) / mRes.getDisplayMetrics().density;
|
mTodayTextSize = mRes.getDimension(R.dimen.today_text_size) / mRes.getDisplayMetrics().density;
|
||||||
@ -68,7 +69,7 @@ public class MyWidgetProvider extends AppWidgetProvider implements Calendar {
|
|||||||
final int bgColor = prefs.getInt(Constants.WIDGET_BG_COLOR, Color.BLACK);
|
final int bgColor = prefs.getInt(Constants.WIDGET_BG_COLOR, Color.BLACK);
|
||||||
mRemoteViews.setInt(R.id.calendar_holder, "setBackgroundColor", bgColor);
|
mRemoteViews.setInt(R.id.calendar_holder, "setBackgroundColor", bgColor);
|
||||||
|
|
||||||
mCalendar = new CalendarImpl(this);
|
mCalendar = new CalendarImpl(this, mContext);
|
||||||
mCalendar.updateCalendar(new DateTime());
|
mCalendar.updateCalendar(new DateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
51
app/src/main/java/com/simplemobiletools/calendar/Utils.java
Normal file
51
app/src/main/java/com/simplemobiletools/calendar/Utils.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package com.simplemobiletools.calendar;
|
||||||
|
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.util.SparseBooleanArray;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
public class Utils {
|
||||||
|
private static final String TAG = Utils.class.getSimpleName();
|
||||||
|
|
||||||
|
public static int adjustAlpha(int color, float factor) {
|
||||||
|
final int alpha = Math.round(Color.alpha(color) * factor);
|
||||||
|
final int red = Color.red(color);
|
||||||
|
final int green = Color.green(color);
|
||||||
|
final int blue = Color.blue(color);
|
||||||
|
return Color.argb(alpha, red, green, blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String serializeArray(SparseBooleanArray arr) {
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
try {
|
||||||
|
for (int i = 0; i < arr.size(); i++) {
|
||||||
|
int key = arr.keyAt(i);
|
||||||
|
json.put(String.valueOf(key), arr.get(key));
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
Log.e(TAG, "serializeArray " + e.getMessage());
|
||||||
|
}
|
||||||
|
return json.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SparseBooleanArray deserializeJson(String string) {
|
||||||
|
final SparseBooleanArray sparseBooleanArray = new SparseBooleanArray();
|
||||||
|
try {
|
||||||
|
final JSONObject json = new JSONObject(string);
|
||||||
|
final Iterator<String> iter = json.keys();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
String key = iter.next();
|
||||||
|
Boolean value = (Boolean) json.get(key);
|
||||||
|
sparseBooleanArray.put(Integer.parseInt(key), value);
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
Log.e(TAG, "deserializeJson " + e.getMessage());
|
||||||
|
}
|
||||||
|
return sparseBooleanArray;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package com.simplemobiletools.calendar.activities;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.simplemobiletools.calendar.Constants;
|
||||||
|
import com.simplemobiletools.calendar.Formatter;
|
||||||
|
import com.simplemobiletools.calendar.R;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.OnClick;
|
||||||
|
|
||||||
|
public class DetailsActivity extends AppCompatActivity {
|
||||||
|
@BindView(R.id.details_date) TextView mDateTV;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_details);
|
||||||
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
|
final Intent intent = getIntent();
|
||||||
|
if (intent == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
final String dayCode = intent.getStringExtra(Constants.DAY_CODE);
|
||||||
|
if (dayCode == null || dayCode.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
final String date = Formatter.getEventDate(dayCode);
|
||||||
|
mDateTV.setText(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.details_fab)
|
||||||
|
public void fabClicked(View view) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -21,9 +21,9 @@ import com.simplemobiletools.calendar.Calendar;
|
|||||||
import com.simplemobiletools.calendar.CalendarImpl;
|
import com.simplemobiletools.calendar.CalendarImpl;
|
||||||
import com.simplemobiletools.calendar.Config;
|
import com.simplemobiletools.calendar.Config;
|
||||||
import com.simplemobiletools.calendar.Constants;
|
import com.simplemobiletools.calendar.Constants;
|
||||||
import com.simplemobiletools.calendar.Day;
|
|
||||||
import com.simplemobiletools.calendar.Helpers;
|
|
||||||
import com.simplemobiletools.calendar.R;
|
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.DateTime;
|
||||||
|
|
||||||
@ -51,6 +51,8 @@ public class MainActivity extends AppCompatActivity implements Calendar {
|
|||||||
|
|
||||||
private int mTextColor;
|
private int mTextColor;
|
||||||
private int mWeakTextColor;
|
private int mWeakTextColor;
|
||||||
|
private int mTextColorWithNote;
|
||||||
|
private int mWeakTextColorWithNote;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -58,13 +60,15 @@ public class MainActivity extends AppCompatActivity implements Calendar {
|
|||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
|
mRes = getResources();
|
||||||
Locale.setDefault(Locale.ENGLISH);
|
Locale.setDefault(Locale.ENGLISH);
|
||||||
mTextColor = Helpers.adjustAlpha(Color.BLACK, Constants.HIGH_ALPHA);
|
mTextColor = Utils.adjustAlpha(Color.BLACK, Constants.HIGH_ALPHA);
|
||||||
mWeakTextColor = Helpers.adjustAlpha(Color.BLACK, Constants.LOW_ALPHA);
|
mTextColorWithNote = Utils.adjustAlpha(mRes.getColor(R.color.colorPrimary), Constants.HIGH_ALPHA);
|
||||||
|
mWeakTextColor = Utils.adjustAlpha(Color.BLACK, Constants.LOW_ALPHA);
|
||||||
|
mWeakTextColorWithNote = Utils.adjustAlpha(mRes.getColor(R.color.colorPrimary), Constants.LOW_ALPHA);
|
||||||
mLeftArrow.getDrawable().mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP);
|
mLeftArrow.getDrawable().mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP);
|
||||||
mRightArrow.getDrawable().mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP);
|
mRightArrow.getDrawable().mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP);
|
||||||
|
|
||||||
mRes = getResources();
|
|
||||||
mPackageName = getPackageName();
|
mPackageName = getPackageName();
|
||||||
mDayTextSize /= mRes.getDisplayMetrics().density;
|
mDayTextSize /= mRes.getDisplayMetrics().density;
|
||||||
mTodayTextSize /= mRes.getDisplayMetrics().density;
|
mTodayTextSize /= mRes.getDisplayMetrics().density;
|
||||||
@ -73,7 +77,7 @@ public class MainActivity extends AppCompatActivity implements Calendar {
|
|||||||
final FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mCalendarHolder.getLayoutParams();
|
final FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mCalendarHolder.getLayoutParams();
|
||||||
params.setMargins(mActivityMargin, mActivityMargin, mActivityMargin, mActivityMargin);
|
params.setMargins(mActivityMargin, mActivityMargin, mActivityMargin, mActivityMargin);
|
||||||
|
|
||||||
mCalendar = new CalendarImpl(this);
|
mCalendar = new CalendarImpl(this, getApplicationContext());
|
||||||
mCalendar.updateCalendar(new DateTime());
|
mCalendar.updateCalendar(new DateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,6 +111,9 @@ public class MainActivity extends AppCompatActivity implements Calendar {
|
|||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
final Day day = days.get(i);
|
final Day day = days.get(i);
|
||||||
final TextView dayTV = (TextView) findViewById(mRes.getIdentifier("day_" + i, "id", mPackageName));
|
final TextView dayTV = (TextView) findViewById(mRes.getIdentifier("day_" + i, "id", mPackageName));
|
||||||
|
if (dayTV == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
int curTextColor = mWeakTextColor;
|
int curTextColor = mWeakTextColor;
|
||||||
float curTextSize = mDayTextSize;
|
float curTextSize = mDayTextSize;
|
||||||
|
|
||||||
@ -121,9 +128,25 @@ public class MainActivity extends AppCompatActivity implements Calendar {
|
|||||||
dayTV.setText(String.valueOf(day.getValue()));
|
dayTV.setText(String.valueOf(day.getValue()));
|
||||||
dayTV.setTextColor(curTextColor);
|
dayTV.setTextColor(curTextColor);
|
||||||
dayTV.setTextSize(curTextSize);
|
dayTV.setTextSize(curTextSize);
|
||||||
|
|
||||||
|
dayTV.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
openDetails(day.getCode());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void openDetails(String code) {
|
||||||
|
if (code.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
final Intent intent = new Intent(getApplicationContext(), DetailsActivity.class);
|
||||||
|
intent.putExtra(Constants.DAY_CODE, code);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
@OnClick(R.id.left_arrow)
|
@OnClick(R.id.left_arrow)
|
||||||
public void leftArrowClicked() {
|
public void leftArrowClicked() {
|
||||||
mCalendar.getPrevMonth();
|
mCalendar.getPrevMonth();
|
||||||
|
@ -18,8 +18,8 @@ import android.widget.TextView;
|
|||||||
import com.simplemobiletools.calendar.Calendar;
|
import com.simplemobiletools.calendar.Calendar;
|
||||||
import com.simplemobiletools.calendar.CalendarImpl;
|
import com.simplemobiletools.calendar.CalendarImpl;
|
||||||
import com.simplemobiletools.calendar.Constants;
|
import com.simplemobiletools.calendar.Constants;
|
||||||
import com.simplemobiletools.calendar.Day;
|
import com.simplemobiletools.calendar.models.Day;
|
||||||
import com.simplemobiletools.calendar.Helpers;
|
import com.simplemobiletools.calendar.Utils;
|
||||||
import com.simplemobiletools.calendar.MyWidgetProvider;
|
import com.simplemobiletools.calendar.MyWidgetProvider;
|
||||||
import com.simplemobiletools.calendar.R;
|
import com.simplemobiletools.calendar.R;
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ public class WidgetConfigureActivity extends AppCompatActivity implements Calend
|
|||||||
mBgSeekBar.setProgress((int) (mBgAlpha * 100));
|
mBgSeekBar.setProgress((int) (mBgAlpha * 100));
|
||||||
updateBgColor();
|
updateBgColor();
|
||||||
|
|
||||||
mCalendar = new CalendarImpl(this);
|
mCalendar = new CalendarImpl(this, getApplicationContext());
|
||||||
mCalendar.updateCalendar(new DateTime());
|
mCalendar.updateCalendar(new DateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,8 +166,8 @@ public class WidgetConfigureActivity extends AppCompatActivity implements Calend
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateTextColors() {
|
private void updateTextColors() {
|
||||||
mTextColor = Helpers.adjustAlpha(mTextColorWithoutTransparency, Constants.HIGH_ALPHA);
|
mTextColor = Utils.adjustAlpha(mTextColorWithoutTransparency, Constants.HIGH_ALPHA);
|
||||||
mWeakTextColor = Helpers.adjustAlpha(mTextColorWithoutTransparency, Constants.LOW_ALPHA);
|
mWeakTextColor = Utils.adjustAlpha(mTextColorWithoutTransparency, Constants.LOW_ALPHA);
|
||||||
|
|
||||||
mLeftArrow.getDrawable().mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP);
|
mLeftArrow.getDrawable().mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP);
|
||||||
mRightArrow.getDrawable().mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP);
|
mRightArrow.getDrawable().mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP);
|
||||||
@ -178,7 +178,7 @@ public class WidgetConfigureActivity extends AppCompatActivity implements Calend
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateBgColor() {
|
private void updateBgColor() {
|
||||||
mBgColor = Helpers.adjustAlpha(mBgColorWithoutTransparency, mBgAlpha);
|
mBgColor = Utils.adjustAlpha(mBgColorWithoutTransparency, mBgAlpha);
|
||||||
mWidgetBackground.setBackgroundColor(mBgColor);
|
mWidgetBackground.setBackgroundColor(mBgColor);
|
||||||
mBgColorPicker.setBackgroundColor(mBgColor);
|
mBgColorPicker.setBackgroundColor(mBgColor);
|
||||||
mSaveBtn.setBackgroundColor(mBgColor);
|
mSaveBtn.setBackgroundColor(mBgColor);
|
||||||
|
@ -5,9 +5,9 @@ public class Day {
|
|||||||
private final boolean mIsThisMonth;
|
private final boolean mIsThisMonth;
|
||||||
private final boolean mIsToday;
|
private final boolean mIsToday;
|
||||||
private final boolean mHasNote;
|
private final boolean mHasNote;
|
||||||
private final int mCode;
|
private final String mCode;
|
||||||
|
|
||||||
public Day(int value, boolean isThisMonth, boolean isToday, int code, boolean hasNote) {
|
public Day(int value, boolean isThisMonth, boolean isToday, String code, boolean hasNote) {
|
||||||
mValue = value;
|
mValue = value;
|
||||||
mIsThisMonth = isThisMonth;
|
mIsThisMonth = isThisMonth;
|
||||||
mIsToday = isToday;
|
mIsToday = isToday;
|
||||||
@ -27,7 +27,7 @@ public class Day {
|
|||||||
return mIsToday;
|
return mIsToday;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCode() {
|
public String getCode() {
|
||||||
return mCode;
|
return mCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
24
app/src/main/res/layout/activity_details.xml
Normal file
24
app/src/main/res/layout/activity_details.xml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.design.widget.CoordinatorLayout
|
||||||
|
android:id="@+id/details_holder"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="@dimen/activity_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/details_date"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:textSize="@dimen/month_text_size"/>
|
||||||
|
|
||||||
|
<android.support.design.widget.FloatingActionButton
|
||||||
|
android:id="@+id/details_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>
|
BIN
app/src/main/res/mipmap-hdpi/plus.png
Normal file
BIN
app/src/main/res/mipmap-hdpi/plus.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 232 B |
BIN
app/src/main/res/mipmap-mdpi/plus.png
Normal file
BIN
app/src/main/res/mipmap-mdpi/plus.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 148 B |
BIN
app/src/main/res/mipmap-xhdpi/plus.png
Normal file
BIN
app/src/main/res/mipmap-xhdpi/plus.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 185 B |
BIN
app/src/main/res/mipmap-xxhdpi/plus.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/plus.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 292 B |
BIN
app/src/main/res/mipmap-xxxhdpi/plus.png
Normal file
BIN
app/src/main/res/mipmap-xxxhdpi/plus.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 269 B |
@ -1,6 +1,9 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Simple Calendar</string>
|
<string name="app_name">Simple Calendar</string>
|
||||||
|
|
||||||
|
<!-- Details -->
|
||||||
|
<string name="details">Details</string>
|
||||||
|
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="about">About</string>
|
<string name="about">About</string>
|
||||||
<string name="website">More simple apps and source code at:\nhttp://simplemobiletools.com</string>
|
<string name="website">More simple apps and source code at:\nhttp://simplemobiletools.com</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user