Keywords: Angular, Ionic, Cordova, Android, Typescript, Bootstrap, Time, Management
Try it online (stackblitz.com)
Try it on your phone (Android 9 apk)
An application which can let you:
-
Mark when you do what.
-
Show record data with a vertical timeline chart.
-
Edit the record easily.
-
Give full statistic data and chart.
-
Save and export the record data to external storage.
Install, serve and package
npm, Ionic, Cordova, Angular, Android Studio, Android SDK
npm install -g ionic cordova
cd time-controller
ionic serve
ionic cordova build android --prod --release
First time: keytool -genkey -v -keystore my-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias my-alias
Move app-release-unsigned.apk to root path:
C:\'Program Files'\Java\jdk1.8.0_211\bin\jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.jks app-release-unsigned.apk my-alias
C:\Users\JINGJIAWEI\AppData\Local\Android\Sdk\build-tools\29.0.1\zipalign -v 4 app-release-unsigned.apk TimeController.apk
C:\Users\JINGJIAWEI\AppData\Local\Android\Sdk\build-tools\29.0.1\apksigner verify TimeController.apkPath before SDK tools and apk:
C:\WorkPlace\Github\WorkRep\time-controller\platforms\android\app\build\outputs\apk\release
C:\Users\JINGJIAWEI\AppData\Local\Android\Sdk\build-tools\29.0.1Reference info Ionic document deploying
-
Color Picker => don't have a very well performance, handle it later
-
Feature:
Obj.some(obj => obj.label === label))
Obj.reduce((prev, curr) => prev.id < curr.id ? prev : curr).id;- Bugfix:
let xxx = list.filter(...)[index].someLabel,
let xxx = someValue // list would be changed -> pass value via reference, be cautious-
Adjust the input color selection position.
-
Drag and drop => maybe not working in Ionic, handle it later
-
Problems during version update of Angular 0.7.3->8.1.2 / Ionic 4->5
1.Module not found => restart VScode
2.Could not find the implementation for builder @angular-devkit/build-angular
3.Could not find the implementation for builder @ionic/angular-toolkit:cordova-build
npm i @angular-devkit/build-angular @angular-devkit/architect@latest @angular-devkit/core@latest @angular-devkit/schematics@latest- get UTC and local time.
dateObj.getMonth() // Local
dateObj.getUTCMonth() // UTC- Set loop timer in Ionic.
setTimeout(() => {...}, 500); // NG
setInterval(() => {...}, 500); // OK- PS drawing scales and arrange the template steps & hot keys
ctrl + J
ctrl + T
move
ctrl + shift + alt + T-
Some slider (input range) tools
-
EventListener
document.getElementById('rangeTime').addEventListener('change', () => { //console.log('valueChanged');
document.getElementById('rangeTime').addEventListener('input', () => { //console.log('valueChanging');-
Some color picker tools
@NgModule({
entryComponents: [ColorPickerPage],
imports: [ColorPickerPageModule],
providers: [ColorPickerPage],
})// entryComponent
this.XXXXX = this.navParams.get('setting');
this.popCtrl.getTop().then(p => p.dismiss(YYYYY));// parentComponent
async onColorPicking(event: Event) {
const comp = await this.pop.create({
component: ColorPickerPage,
event,
componentProps: {setting: XXXXX,}
});
comp.onDidDismiss().then((data) => {YYYYY = data.data});
return await comp.present();
}.phBlack::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
color: black;
opacity: 1; /* Firefox */
}const alert = await this.alertController.create({
header: 'Ooouch, nothing performed',
subHeader: 'On click label button',
message: 'Current event is the same as button clicked when adding record. Try to choose another one.',
buttons: [{
text: 'Confirm',
role: 'cancel',
cssClass: 'secondary',
handler: () => {console.log('Alert'); }
}]});
await alert.present();-
Ionic: Date picker <= seems not working in cordova
-
<= Solved: ion-datetime attribute (like min and max) must contain '0' in month and day. Trans under Cordova
<= Issue: Ignored attempt to cancel a touchstart event with cancelable=false.
<= Issue: Pick only YYYY/MM/DD while return minutes etc not equals zero.
<= Issue: Sync problem when chaning flag / press confirm button in calendar.
=> Decide to achieve the event natively.
-
Multi days data charts & record edit process.
-
Local storage in the phone.
1.Ionic storage <= Reference example
- Delete object in object[] via object.attr
list.splice(list.indexOf(list.filter((obj: { timestamp: number; }) => obj.timestamp === x)[0]), 1);- Sort object[] via object.attr
r.sort((prev: { timestamp: number; }, curr: { timestamp: number; }) => {
return prev.timestamp - curr.timestamp;
});- Notice .pop(), .splice(), .filter() have returns, do not make such mistake
// filter out
result = XXX.filter();
// filter left
XXX.filter();
result = XXX;ionic serve --devapp
ionic cordova run android --device -l --debug --verbosechrome://inspect/#devicesIonicStorageModule.forRoot({name: '__mydb', driverOrder: ['websql', 'indexeddb', 'sqlite']})
await this.storageDB.ready().then(async () => {
await this.dbInit();
}).catch(e => {console.error(e); });-
DONE: Local: Ionic serve
Problem: Some bug only appear on device.
Solution: On device debug.
-
DONE: On device via devapp: ionic serve --devapp
Step: Download app , run in the same wifi, if facing a time_out problem, !TURN OFF the firewall!
Problem: Issus: Got no console log on device once error.
Problem: Storage still not working on device using apk install, while under --devapp on device works well.
Solution: Try to debug using USB drivers.
-
DONE: On device via USB: ionic cordova run android --device -l --debug --verbose
Step:
1.Install Android SDK tools: Google USB Driver, check the install position
2.Install OEM USB driver to device
3.On the device, open the Settings app, select Developer options, and then enable USB debugging. => Huawei Step (WTF)
4.For Huawei, turn the USB install need permission off, otherwise (WTF) => Failure [INSTALL_FAILED_ABORTED: User rejected permissions]
5.Check if your device is ready => chrome://inspect/.
6.Click inspect under ionic to start debug.
Result: Worked well.
-
Bugfix: Ionic storage
? Issus: Ionic storage not working on devices
? Solution: try JSON format manually
?Bingo Solution: storage.ready().then(), IonicStorageModule.forRoot({name: '__mydb', driverOrder: ['indexeddb', 'sqlite', 'websql']})
After having done debug on device.
1.Creat keys in storage before using it! <= Error: Undefined
2.Set the setInterval in ngOnInit rather than constructor. <= Error: Undefined
3.Change the driverOrder from sqlite to websql. <= Could not open database <= more info in this issus
-
Bug fix:
OK 1.Local DB init fix.
OK 2.Change date range and direct click label giving wrong position insert. And wrong label current.
OK 3.Days with null record shows white.
OK 4.Time range time display keep uncorrect position after date range return to today. => match time now.
OK 5.Template adjustment: scroll none, px offset, shining box border
-
Delete useless comment
-
Package
import { File } from '@ionic-native/file/ngx'; // OK
import { File } from '@ionic-native/file'; // NG chartRender() {
const chart = new CanvasJS.Chart('chartContainer', {
animationEnabled: true,
exportEnabled: false,
title: {
text: 'Statistic chart'
},
data: [{
type: 'pie',
showInLegend: true,
toolTipContent: '<b>{name}</b>: ${y} (#percent%)',
indexLabel: '{name} - #percent%',
dataPoints: this.renderDataList,
}]
});
chart.render();
}// Ready
ionViewDidLoad() {} // A & B
// Before
ionViewWillEnter() {} // B
ionViewWillLeave() {} // A
// After
ionViewDidEnter() {} // B
ionViewDidLeave() {} // A- Bug fix
this.timeoffset = new Date().getTimezoneOffset() * 60;
this.timeStart = this.dateStart ? Math.floor(Date.parse(this.dateStart) / 1000 + this.timeoffset) : 0;- Template adjustment
-
Tslint check document
Error: no-use-before-declare is deprecated. Since TypeScript 2.9. Please use the built-in compiler checks instead. => Solution: Delete related item in tslint.json
tslint -p tsconfig.json -c tslint.json -o output.txt-
Flesh button, refer to Zhihu Dalao
button.flash::after {
content: "";
z-index: -1;
position: absolute;
background: white;
top: -50%;
left: 5%;
bottom: -50%;
width: 1.5em;
transform: translate3d(-200%, 0, 0) rotate(35deg);
}
button.flash:disabled::after {
transition: transform 0.2s ease-in-out;
transform: translate3d(500%, 0, 0) rotate(35deg);
}-
Feature:
1.Restore the storage json file into external position.3.Button css refer to Zhihu Dalao- CSS Pseudo Classes4.Date picker default, chart hours, selectable options.5.Contact page: Press to copy
-
Rewrite
1.Global variables
2.Charts and range input => Component
3.Sass px->em, class etc
-
Rewrite using React
