Jedi Burrell 7dc4b2b4b7 Add Google Smart Lock.
You now no longer have to type in your email and password, with Google
Smart Lock.

Simply tap "Basic Authentication", and if you've previously logged in,
let Google do it's magic and you don't even touch that log-in form.
2017-05-20 00:53:33 -04:00

75 lines
2.4 KiB
Java

package com.fastaccess;
import android.app.Application;
import android.support.annotation.NonNull;
import android.support.v7.preference.PreferenceManager;
import com.fastaccess.data.dao.model.Models;
import com.fastaccess.helper.TypeFaceHelper;
import com.fastaccess.provider.tasks.notification.NotificationSchedulerJobTask;
import com.fastaccess.provider.uil.UILProvider;
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.common.Scopes;
import com.google.android.gms.common.api.GoogleApiClient;
import io.requery.Persistable;
import io.requery.android.sqlite.DatabaseSource;
import io.requery.meta.EntityModel;
import io.requery.rx.RxSupport;
import io.requery.rx.SingleEntityStore;
import io.requery.sql.Configuration;
import io.requery.sql.EntityDataStore;
import io.requery.sql.TableCreationMode;
import shortbread.Shortbread;
/**
* Created by Kosh on 03 Feb 2017, 12:07 AM
*/
public class App extends Application {
private static App instance;
private SingleEntityStore<Persistable> dataStore;
private static GoogleApiClient googleApiClient;
@Override public void onCreate() {
super.onCreate();
instance = this;
init();
}
@NonNull public static App getInstance() {
return instance;
}
private void init() {
deleteDatabase("database.db");
getDataStore();//init requery before anything.
PreferenceManager.setDefaultValues(this, R.xml.fasthub_settings, false);
UILProvider.initUIL(this);
TypeFaceHelper.generateTypeface(this);
NotificationSchedulerJobTask.scheduleJob(this);
Shortbread.create(this);
googleApiClient = new GoogleApiClient.Builder(this)
.addApi(Auth.CREDENTIALS_API)
.build();
googleApiClient.connect();
}
public SingleEntityStore<Persistable> getDataStore() {
if (dataStore == null) {
EntityModel model = Models.DEFAULT;
DatabaseSource source = new DatabaseSource(this, model, "FastHub-DB", 9);
Configuration configuration = source.getConfiguration();
if (BuildConfig.DEBUG) {
source.setTableCreationMode(TableCreationMode.CREATE_NOT_EXISTS);
}
dataStore = RxSupport.toReactiveStore(new EntityDataStore<Persistable>(configuration));
}
return dataStore;
}
public GoogleApiClient getGoogleApiClient() {
return googleApiClient;
}
}