Skip to content

Commit

Permalink
Merge pull request #12 from lfom/master
Browse files Browse the repository at this point in the history
Added support to local calendar.ics file and a few crashes fixed
  • Loading branch information
GreatApo authored Feb 3, 2019
2 parents f034877 + ba4f206 commit 078f50d
Show file tree
Hide file tree
Showing 3 changed files with 207 additions and 156 deletions.
146 changes: 73 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
[![latest release](https://img.shields.io/github/release/GreatApo/AmazfitPaceCalendarWidget.svg?colorB=green&label=latest%20release&style=flat-square) ![release date](https://img.shields.io/badge/release%20date-2019.02.02-orange.svg?style=flat-square) ![Downloads](https://img.shields.io/github/downloads/GreatApo/AmazfitPaceCalendarWidget/total.svg?style=flat-square) ![HitCount](http://hits.dwyl.io/GreatApo/AmazfitPaceCalendarWidget.svg)](https://github.com/GreatApo/AmazfitPaceCalendarWidget/releases/latest)

# Amazfit Pace/Stratos/Verge Calendar Widget
![Amazfit Pace Calendar Widget Banner](other%20files/amazfit-calendar-widget.png)

After [Quinny899](https://github.com/KieronQuinn)'s excellent work, we are able to make widget/apps!
So, here is the first Calendar Widget for our Amazfit Pace/Stratos!



### Features
- This is a Pace/Stratos/Verge Widget
- Press gear icon for settings
- Navigate between months (Swipe / Buttons)
- Refresh to current date
- Select calendar colors
- Show/Hide year number
- Show/Hide week numbers
- Select Sunday or Monday for 1st week day
- Vibration on button touches
- Supported languages: English, Chinese, Czech, Dutch, French, German, Greek, Hebrew, Hungarian, Italian, Japanese, Korean, Polish, Portuguese, Romanian, Russian, Slovak, Spanish, Thai, Turkish
- Right to left Calendar support
- Settings are saved
- Calendar events are shown, new style (requires Amazmod phone + watch or local ICS URL file)
- [Timeline Widget](https://forum.xda-developers.com/smartwatch/amazfit/app-widget-timeline-v1-0-1-pace-stratos-t3894632) is also integrated in the calendar
- iCal support by LFOM (write your ICS URL in a file at: /sdcard/Android/data/com.dinodevs.pacecalendar/files/pacecalendar.txt, updates through wifi, powered by [iCal4j](https://github.com/ical4j/ical4j) library)
- Long press the timer/date at the top of the Timeline to load iCal events



### Download

Get a ready to use binary
- From our [XDA topic](https://forum.xda-developers.com/smartwatch/amazfit/app-widget-calendar-pace-t3751889)
- From our [Github Releases](https://github.com/GreatApo/AmazfitPaceCalendarWidget/releases/latest)

Or if you are hardcore, compile the source code with Android Studio.



### Installation
To install this widget, you will need a PC with the ADB installed. Connect your Amazfit on your PC and fire up a terminal.

```shell
adb uninstall com.dinodevs.pacecalendarwidget
adb install -r PaceCalendarWidget.X.X.X.apk
adb shell am force-stop com.huami.watch.launcher
```



### Screenshots (Version 1.6)
![Amazfit Pace Calendar Widget v1.6](other%20files/com.dinodevs.pacecalendarwidget-1.3.png)
![Amazfit Pace Calendar Widget v1.6](other%20files/com.dinodevs.pacecalendarwidget-1.3-settings.png)



### Thanks to the Developers

This project was made possible by:

- GreatApo - *Widget Creator* - [ [Github](https://github.com/GreatApo) | [XDA](https://forum.xda-developers.com/member.php?u=3668555) ]
- LFOM - *Widget Developer*
- Quinny899 - *Widget Example Creator / Springboard Settings Creator* - [ [Github](https://github.com/KieronQuinn) | [XDA](https://forum.xda-developers.com/member.php?u=3563640) ]
- XDA developers community (testers, translators, developers)
- [iCal4j](https://github.com/ical4j/ical4j) library

Some more links:

- GreatApo's [Amazfit Pace Calendar Widget - XDA topic](https://forum.xda-developers.com/smartwatch/amazfit/app-widget-calendar-pace-t3751889)
- GreatApo's [Amazfit Timeline Widget - XDA topic](https://forum.xda-developers.com/smartwatch/amazfit/app-widget-timeline-v1-0-1-pace-stratos-t3894632)
- Quinny's [Springboard Settings - XDA topic](https://forum.xda-developers.com/smartwatch/amazfit/app-springboard-settings-pace-rearrange-t3748651)
- Quinny's [Widget Creation guide - XDA topic](https://forum.xda-developers.com/smartwatch/amazfit/dev-create-custom-home-screen-pages-pace-t3751731).
[![latest release](https://img.shields.io/github/release/GreatApo/AmazfitPaceCalendarWidget.svg?colorB=green&label=latest%20release&style=flat-square) ![release date](https://img.shields.io/badge/release%20date-2019.02.02-orange.svg?style=flat-square) ![Downloads](https://img.shields.io/github/downloads/GreatApo/AmazfitPaceCalendarWidget/total.svg?style=flat-square) ![HitCount](http://hits.dwyl.io/GreatApo/AmazfitPaceCalendarWidget.svg)](https://github.com/GreatApo/AmazfitPaceCalendarWidget/releases/latest)

# Amazfit Pace/Stratos/Verge Calendar Widget
![Amazfit Pace Calendar Widget Banner](other%20files/amazfit-calendar-widget.png)

After [Quinny899](https://github.com/KieronQuinn)'s excellent work, we are able to make widget/apps!
So, here is the first Calendar Widget for our Amazfit Pace/Stratos!



### Features
- This is a Pace/Stratos/Verge Widget
- Press gear icon for settings
- Navigate between months (Swipe / Buttons)
- Refresh to current date
- Select calendar colors
- Show/Hide year number
- Show/Hide week numbers
- Select Sunday or Monday for 1st week day
- Vibration on button touches
- Supported languages: English, Chinese, Czech, Dutch, French, German, Greek, Hebrew, Hungarian, Italian, Japanese, Korean, Polish, Portuguese, Romanian, Russian, Slovak, Spanish, Thai, Turkish
- Right to left Calendar support
- Settings are saved
- Calendar events are shown, new style (requires Amazmod phone + watch or local ICS URL file)
- [Timeline Widget](https://forum.xda-developers.com/smartwatch/amazfit/app-widget-timeline-v1-0-1-pace-stratos-t3894632) is also integrated in the calendar
- iCal support by LFOM (write your ICS URL in a file at: /sdcard/Android/data/com.dinodevs.pacecalendar/files/pacecalendar.txt, updates through wifi, powered by [iCal4j](https://github.com/ical4j/ical4j) library)
- Long press the timer/date at the top of the Timeline to load iCal events



### Download

Get a ready to use binary
- From our [XDA topic](https://forum.xda-developers.com/smartwatch/amazfit/app-widget-calendar-pace-t3751889)
- From our [Github Releases](https://github.com/GreatApo/AmazfitPaceCalendarWidget/releases/latest)

Or if you are hardcore, compile the source code with Android Studio.



### Installation
To install this widget, you will need a PC with the ADB installed. Connect your Amazfit on your PC and fire up a terminal.

```shell
adb uninstall com.dinodevs.pacecalendarwidget
adb install -r PaceCalendarWidget.X.X.X.apk
adb shell am force-stop com.huami.watch.launcher
```



### Screenshots (Version 1.6)
![Amazfit Pace Calendar Widget v1.6](other%20files/com.dinodevs.pacecalendarwidget-1.3.png)
![Amazfit Pace Calendar Widget v1.6](other%20files/com.dinodevs.pacecalendarwidget-1.3-settings.png)



### Thanks to the Developers

This project was made possible by:

- GreatApo - *Widget Creator* - [ [Github](https://github.com/GreatApo) | [XDA](https://forum.xda-developers.com/member.php?u=3668555) ]
- LFOM - *Widget Developer*
- Quinny899 - *Widget Example Creator / Springboard Settings Creator* - [ [Github](https://github.com/KieronQuinn) | [XDA](https://forum.xda-developers.com/member.php?u=3563640) ]
- XDA developers community (testers, translators, developers)
- [iCal4j](https://github.com/ical4j/ical4j) library

Some more links:

- GreatApo's [Amazfit Pace Calendar Widget - XDA topic](https://forum.xda-developers.com/smartwatch/amazfit/app-widget-calendar-pace-t3751889)
- GreatApo's [Amazfit Timeline Widget - XDA topic](https://forum.xda-developers.com/smartwatch/amazfit/app-widget-timeline-v1-0-1-pace-stratos-t3894632)
- Quinny's [Springboard Settings - XDA topic](https://forum.xda-developers.com/smartwatch/amazfit/app-springboard-settings-pace-rearrange-t3748651)
- Quinny's [Widget Creation guide - XDA topic](https://forum.xda-developers.com/smartwatch/amazfit/dev-create-custom-home-screen-pages-pace-t3751731).
23 changes: 12 additions & 11 deletions app/src/main/java/com/dinodevs/pacecalendarwidget/Timeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private void loadCalendarEvents() {
calendarEvents = Settings.System.getString(mContext.getContentResolver(), Constants.CALENDAR_DATA);

if (!(calendarEvents != null && !calendarEvents.isEmpty() && !calendarEvents.equals("{\"events\":[]}")))
Timeline.this.toast("No events found!");
Timeline.this.toast("No events found!", true);

if (calendarEvents == null)
calendarEvents = "{\"events\":[]}";
Expand Down Expand Up @@ -225,7 +225,7 @@ private void loadCalendarEvents() {
}

//All day events
if((start.startsWith("00") || start.startsWith("12")) && data.getString(3).equals("null")) {
if((start.startsWith("00") || start.startsWith("12")) && ("null".equals(data.getString(3)) || data.getString(3).isEmpty())) {
start = getString(R.string.all_day);
end = "";
}
Expand Down Expand Up @@ -282,11 +282,13 @@ private void loadiCalData() {
new Thread(new Runnable() {
@Override
public void run() {
if(icalURL!=null) {
toastMsg = "Getting iCal data,\nplease wait...";
activity.runOnUiThread(showToast);
if (iCalSupport.checkICSFile(mContext, icalURL)) {
calendarEvents = iCalSupport.getICSCalendarEvents(mContext);
} else {
toastMsg = "\niCal data not found.\n\nPlease write your ICS URL at the following file:\n/sdcard/Android/data/com.dinodevs.pacecalendar/files/pacecalendar.txt";
activity.runOnUiThread(showToast);
}
if (calendarEvents == null) {
toastMsg = "No new events!";
Expand All @@ -297,18 +299,13 @@ public void run() {
activity.runOnUiThread(showToast);
lv.post(loadEvents);
}
}else{
// No file found
toastMsg = "\niCal data not found.\n\nPlease write your ICS URL at the following file:\n/sdcard/Android/data/com.dinodevs.pacecalendar/files/pacecalendar.txt";
activity.runOnUiThread(showToast);
}
}
}).start();
}

private final Runnable showToast = new Runnable() {
public void run() {
toast(toastMsg);
toast(toastMsg, false);
}
};

Expand All @@ -319,8 +316,12 @@ public void run() {
};

// Toast wrapper
private void toast (String message) {
Toast toast = Toast.makeText(this.mContext, message, Toast.LENGTH_SHORT);
private void toast (String message, boolean shortTime) {
Toast toast;
if (shortTime)
toast = Toast.makeText(this.mContext, message, Toast.LENGTH_SHORT);
else
toast = Toast.makeText(this.mContext, message, Toast.LENGTH_LONG);
TextView v = toast.getView().findViewById(android.R.id.message);
if( v != null) v.setGravity(Gravity.CENTER);
toast.show();
Expand Down
Loading

0 comments on commit 078f50d

Please sign in to comment.