Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

Commit

Permalink
Update to version v0.2
Browse files Browse the repository at this point in the history
Now notifies you even the app is running in the foreground.
- UI changes
- Minor bug fixes
- Disable Advertising ID collection by Google Firebase
  • Loading branch information
superfashi committed Apr 15, 2019
1 parent 8bca6b6 commit 8a70471
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 30 deletions.
5 changes: 2 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ android {
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "edu.hanbangw.pennmate_notify"
minSdkVersion 16
targetSdkVersion 28
versionCode 2
versionName '0.1'
versionCode 3
versionName '0.2'
// testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Expand Down
15 changes: 10 additions & 5 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="Pennmate Notify"
android:icon="@mipmap/pennmate_notify"
android:label="Pennmate Notify"
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
Expand All @@ -26,9 +27,13 @@
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<meta-data
android:name="google_analytics_adid_collection_enabled"
android:value="false" />

<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Expand Down
72 changes: 51 additions & 21 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,18 @@ class MainPage extends StatefulWidget {
class _MainPageState extends State<MainPage> {
final _messaging = FirebaseMessaging();
final _regExp = new RegExp(
r'^([A-Z]{2,4})\s*-?(?!000?)(\d{2,3})-?(?!000)(\d{3})$',
r'^([A-Z]{2,4})\s*-?((?!000)\d{3}|(?!00)\d{2})-?(?!000)(\d{3})$',
caseSensitive: false);
final _pref = SharedPreferences.getInstance();
List<String> _children = <String>[];

@override
void initState() {
super.initState();
_messaging.configure(onMessage: (m) {
print(m);
_showNormalAlert(m['notification']['title'], m['notification']['body']);
});
_pref.then((pref) {
final clist = _getList(pref);
_updateList(clist);
Expand Down Expand Up @@ -112,19 +116,18 @@ class _MainPageState extends State<MainPage> {
context: context,
builder: (context) => AlertDialog(
title: const Text("Add Course"),
contentPadding: const EdgeInsets.all(16.0),
content: Form(
key: key,
child: TextFormField(
autofocus: true,
textCapitalization: TextCapitalization.characters,
decoration: const InputDecoration(
labelText: 'Course ID',
labelText: 'Course & Section ID',
hintText: 'e.g. NETS-212-001',
),
validator: (s) {
match = _regExp.firstMatch(s);
return match == null ? 'invalid course ID' : null;
return match == null ? 'Invalid ID' : null;
},
onEditingComplete: () {
if (key.currentState.validate()) {
Expand All @@ -136,9 +139,7 @@ class _MainPageState extends State<MainPage> {
actions: <Widget>[
FlatButton(
child: const Text('Cancel'),
onPressed: () {
Navigator.pop(context);
}),
onPressed: () => Navigator.pop(context)),
RaisedButton(
child: const Text('Confirm'),
onPressed: () {
Expand All @@ -158,19 +159,16 @@ class _MainPageState extends State<MainPage> {
context: context,
builder: (context) => AlertDialog(
title: const Text("Confirm Deletion"),
contentPadding: const EdgeInsets.all(16.0),
content: Row(
children: <Widget>[
Expanded(
child: Text('Do you really want to delete course\n $s ?'))
child: Text('Do you really want to delete course\n$s?'))
],
),
actions: <Widget>[
FlatButton(
child: const Text('No'),
onPressed: () {
Navigator.pop(context);
}),
onPressed: () => Navigator.pop(context)),
RaisedButton(
child: const Text('Yes'),
onPressed: () {
Expand All @@ -183,6 +181,22 @@ class _MainPageState extends State<MainPage> {
));
}

_showNormalAlert(title, body) async {
await showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
title: Text(title),
content: Row(
children: <Widget>[Expanded(child: Text(body))],
),
actions: <Widget>[
FlatButton(
child: const Text('OK'),
onPressed: () => Navigator.pop(context)),
],
));
}

@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
Expand All @@ -206,24 +220,40 @@ class _MainPageState extends State<MainPage> {
if (_children.isEmpty) {
return const <Widget>[
Text(
'No courses added for now...',
'No course added for now...',
style: TextStyle(fontSize: 20.0),
)
];
}
return _children
.map((s) => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
s,
style: const TextStyle(fontSize: 30.0),
),
IconButton(
icon: const Icon(Icons.delete),
onPressed: () => _showDeleteAlert(s))
Text(s.replaceAll(" ", ""),
style: const TextStyle(fontSize: 30.0)),
Ink(
width: 40,
height: 40,
decoration: ShapeDecoration(
color: Colors.lightBlue,
shape: CircleBorder(),
),
child: IconButton(
iconSize: 25,
icon: const Icon(Icons.delete_outline),
onPressed: () => _showDeleteAlert(s),
color: Colors.white,
),
)
],
))
.toList();
.fold(<Widget>[
const Text('Course List', style: TextStyle(fontSize: 40.0))
], (List<Widget> l, row) {
l.add(const Divider());
l.add(row);
return l;
});
}(),
)),
floatingActionButton: FloatingActionButton(
Expand Down
1 change: 0 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ dependencies:
flutter:
sdk: flutter
firebase_messaging:

shared_preferences:

# The following adds the Cupertino Icons font to your application.
Expand Down

0 comments on commit 8a70471

Please sign in to comment.