New fh-sync-android initialization

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

New fh-sync-android initialization

Vojtech Sazel
Hi,

I followed up the work started by Wojciech and made decoupled Android fh-sync-android working.

Changes done:
1) Network calls are not static, but done through NetworkClient is now interface, with NetworkClientImpl having implementation with OkHttp Android.
2) Dataset storage is written against FileStorage with implementation FileStorageImpl that uses internal Android storage in files (as was in old sync)
3) Client unique Id generator was added in ClientIdGenerator an ClientIdGeneratorImpl, this is needed by cloud app to properly sync (done the same way as in old sync)
4) FHSyncListener and  FHSyncConfig improved, with new initialization for Android apps

For Android initialization it's now needed to use 
Sync.init(Application application, FHSyncConfig config, String cloudUrl) method
in your Application object like this:
public class SyncApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        Sync.init(SyncApplication.this, (new FHSyncConfig.Builder())
.useCustomSync(false).syncFrequencySeconds(10).notifyEnableAll().build(), "http://192.168.13.14:3000/sync");
    }

}

When fh-android-sdk wrapper is written it should be still backwards compatibile with current old sync.


--

VOJTĚCH SÁZEL

SENIOR QUALITY ENGINEER, MOBILE QE

Red Hat 

Remote Czech Republic

[hidden email]    IM: vsazel


_______________________________________________
feedhenry-dev mailing list
[hidden email]
https://www.redhat.com/mailman/listinfo/feedhenry-dev
Reply | Threaded
Open this post in threaded view
|

Re: New fh-sync-android initialization

Vojtech Sazel
Sorry, I accidentally sent the mail unfinished. 
Follow up.

On Fri, Sep 8, 2017 at 8:48 PM, Vojtech Sazel <[hidden email]> wrote:
Hi,

I followed up the work started by Wojciech and made decoupled Android fh-sync-android working.

Changes done:
1) Network calls are not static, but done through NetworkClient is now interface, with NetworkClientImpl having implementation with OkHttp Android.
2) Dataset storage is written against FileStorage with implementation FileStorageImpl that uses internal Android storage in files (as was in old sync)
3) Client unique Id generator was added in ClientIdGenerator an ClientIdGeneratorImpl, this is needed by cloud app to properly sync (done the same way as in old sync)
4) FHSyncListener and  FHSyncConfig improved, with new initialization for Android apps

For Android initialization it's now needed to use 
Sync.init(Application application, FHSyncConfig config, String cloudUrl) method
in your Application object like this:
public class SyncApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        Sync.init(SyncApplication.this, (new FHSyncConfig.Builder())
.useCustomSync(false).syncFrequencySeconds(10).notifyEnableAll().build(), "http://192.168.13.14:3000/sync");
    }

}

When fh-android-sdk wrapper is written it should be still backwards compatibile with current old sync.


--

VOJTĚCH SÁZEL

SENIOR QUALITY ENGINEER, MOBILE QE

Red Hat 

Remote Czech Republic

[hidden email]    IM: vsazel




--

VOJTĚCH SÁZEL

SENIOR QUALITY ENGINEER, MOBILE QE

Red Hat 

Remote Czech Republic

[hidden email]    IM: vsazel


_______________________________________________
feedhenry-dev mailing list
[hidden email]
https://www.redhat.com/mailman/listinfo/feedhenry-dev
Reply | Threaded
Open this post in threaded view
|

Re: New fh-sync-android initialization

Vojtech Sazel
ad 4)
Then you can implement your sync activity by implementing SyncableActivity interface where you implement onBindSyncListener() where sync listner is created and bound. Such activity doesn't need to call pauseSync() and resumeSync().It's done automatically by watching activities lifecycle.

public class ListOfItemsActivity extends AppCompatActivity implements SyncableActivity {
:
:
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list_of_items_activity);
       // Start the sync process
        try {
FHSyncClient.getInstance().manage(DATA_ID, null, new JSONObject());
} catch (Exception e) { Log.e(TAG, e.getMessage(), e); } } : :
    @Override
    public FHSyncListener onBindSyncListener() {
        FHSyncListener.Builder builder=new FHSyncListener.Builder();
        builder.onSyncCompleted(pMessage -> {
           :
           :
        }).onLocalUpdateApplied(pMessage -> {
           :
           :
        });
        return builder.build();
}
}

Pull request: 
https://github.com/feedhenry/fh-sync-android/pull/3

You can see new initialization in modified sync-cloud-app:
https://github.com/wojta/sync-android-app/pull/1/files

There are still changes to be made and wrapper to old sync needs to be written.
It also needs review of unit tests and other tasks we have in SDK team:
https://issues.jboss.org/browse/FH-3855

Please feel free to comment here and to the PRs. You may want to contact me on Slack/RocketChat but I'm not available on Monday and all afternoons next week (12:00 GMT and after). 

Vojtech 

On Fri, Sep 8, 2017 at 8:49 PM, Vojtech Sazel <[hidden email]> wrote:
Sorry, I accidentally sent the mail unfinished. 
Follow up.

On Fri, Sep 8, 2017 at 8:48 PM, Vojtech Sazel <[hidden email]> wrote:
Hi,

I followed up the work started by Wojciech and made decoupled Android fh-sync-android working.

Changes done:
1) Network calls are not static, but done through NetworkClient is now interface, with NetworkClientImpl having implementation with OkHttp Android.
2) Dataset storage is written against FileStorage with implementation FileStorageImpl that uses internal Android storage in files (as was in old sync)
3) Client unique Id generator was added in ClientIdGenerator an ClientIdGeneratorImpl, this is needed by cloud app to properly sync (done the same way as in old sync)
4) FHSyncListener and  FHSyncConfig improved, with new initialization for Android apps

For Android initialization it's now needed to use 
Sync.init(Application application, FHSyncConfig config, String cloudUrl) method
in your Application object like this:
public class SyncApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        Sync.init(SyncApplication.this, (new FHSyncConfig.Builder())
.useCustomSync(false).syncFrequencySeconds(10).notifyEnableAll().build(), "http://192.168.13.14:3000/sync");
    }

}

When fh-android-sdk wrapper is written it should be still backwards compatibile with current old sync.


--

VOJTĚCH SÁZEL

SENIOR QUALITY ENGINEER, MOBILE QE

Red Hat 

Remote Czech Republic

[hidden email]    IM: vsazel




--

VOJTĚCH SÁZEL

SENIOR QUALITY ENGINEER, MOBILE QE

Red Hat 

Remote Czech Republic

[hidden email]    IM: vsazel




--

VOJTĚCH SÁZEL

SENIOR QUALITY ENGINEER, MOBILE QE

Red Hat 

Remote Czech Republic

[hidden email]    IM: vsazel


_______________________________________________
feedhenry-dev mailing list
[hidden email]
https://www.redhat.com/mailman/listinfo/feedhenry-dev