GithubHelp home page GithubHelp logo

crc-32 / fossil Goto Github PK

View Code? Open in Web Editor NEW
6.0 5.0 1.0 478 KB

Codenamed 'Fossil', a multiplatform Pebble-compatible companion app

License: Apache License 2.0

Kotlin 28.00% Swift 0.41% Objective-C 0.04% Dart 71.55%

fossil's Introduction

fossil's People

Contributors

piggehperson avatar tannermeade avatar crc-32 avatar

Stargazers

Uriel avatar Keshav Pratap K avatar Matej Drobnič avatar  avatar Will0 avatar  avatar

Watchers

Matej Drobnič avatar James Cloos avatar Uriel avatar  avatar  avatar

Forkers

matejdro

fossil's Issues

Flutter complains about missing .packages file

When I attempt to build this, I get this error:

Starting a Gradle Daemon (subsequent builds will be faster)

> Configure project :app
WARNING: The option 'android.enableR8' is deprecated and should not be used anymore.
It will be removed in a future version of the Android Gradle plugin, and will no longer allow you to disable R8.

> Task :app:compileFlutterBuildDebug
Downloading Material fonts...                                       0.2s
Downloading Gradle Wrapper...                                       0.1s
Downloading package sky_engine...                                   0.1s
Downloading flutter_patched_sdk tools...                            0.5s
Downloading flutter_patched_sdk_product tools...                    0.4s
Downloading linux-x64 tools...                                      1.3s
Downloading linux-x64/font-subset tools...                          0.3s
Target kernel_snapshot failed: FileSystemException: Cannot open file, path = '/home/matej/projects/pebble/fossil/.packages' (OS Error: No such file or directory, errno = 2)
build failed.

> Task :app:compileFlutterBuildDebug FAILED

FAILURE: Build failed with an exception.

* Where:
Script '/opt/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 882

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/opt/flutter/bin/flutter'' finished with non-zero exit value 1

Admittedly, I have never used flutter before, so I assume it is something wrong on my end. Any tips?

Dependency Injection (Dagger)

Continuation of the #11 (you said you wanted it to have in separate ticket).

Dependency Injection is a pattern where all dependencies of any class are provided through its constructor. For example NotificationService currently has dependency on BlobDBService, which is currently an object:

object NotificationService {

    fun send() {
        BlobDBService.send(...)
    }
}

If we switch to dependency injection, we provide BlobDbService via constructor:

class NotificationService(private val blobDbService: BlobDBService) {

    fun send() {
        blobDbService.send(...)
    }
}

This has mainly two advantages:

  • If BlobDBService is no longer object and we move all its initialization to its constructor, we can guarantee that BlobDBService is completely initialized when provided (currently there is no compile time guarantee that BlobDBService.init() would be called before it is used. If someone forgets to initialize it, whole app can crash without previous warning)
  • If/when we decide to add unit tests, it is trivial to replace this Blob db service with fake test version

Now, manual dependency injection is quite a lot of work and boilerplate (you have to write a lot of code that just passes around objects to constructors). That is why this is usually done with a framework that does most of the heavy lifting for you. Most known frameworks for Kotlin are:

  • Dagger - It is de facto standard one. Very fast (most of the work is done at compile time) and pretty powerful, but it is the the most complicated one (however, once it clicks, it is very nice to use). This is the only one from the bunch I have any real experience with.
  • Hilt - Variant of Dagger made by Google's Android team that simplifies a bunch of things and adds better support for Android stuff like Activities and Service. One downside of this is that it is still in Alpha.
  • Kodein
  • Koin

What do you think?

Architecture of the app

Hello,

I've finally found some time to take a look at the app and I think architecture could be significantly improved.

Some questions / remarks:

  1. LocalBroadcastManager is deprecated. We could switch to EventBus, but I still think that global event routing is an antipattern.
  2. It would probably be a good idea to add some kind of dependency injection framework (I vote for Dagger, but you can pick anything else if you don't like it). For example, with DI framework, we don't need to transfer any events to the WatchService with LocalBroadcastManager. Instead we can have separate class (for example NotificationHandler) that gets injected into NotificationListener and then we can call NotificationHandler.send() directly.
  3. Move away from threads on Bluetooth to Kotlin coroutines. This should make our job much easier since a lot of things in the app is/will be asynchronous.
  4. To me it seems a bad idea that every packet service creates its own coroutine. Instead all send functions suspend and coroutines should be started in the service.
  5. Nitpick: instead of BlobDbService.send having callback, it could be suspend function that just returns BlobResponse.
  6. Singleton with init method is a bad idea, since init can happen at any time. How can we be sure that BlobDBService is always initialized when we call it? Instead, a better idea would be that all services are normal classes that receive already initialized BlobDBService as parameter. Aforementioned dependency injection would help here.

I can help you with some pull request for above things if you agree. Also, this is all for Android side. I have zero knowledge about dart/flutter, so feel free to correct me if anything here is needed for the flutter.

Disclaimer: I'm not attempting to attack or criticise anything. My goal is to have the best possible Pebble app, so these are just my suggestions.

Android - Notifications

  • Simple notification relaying
  • Grouped notifications (e.g. Gmail) handling
  • Notification actions and dismiss handling

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.