Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6ee69994 authored by Jason Monk's avatar Jason Monk Committed by Android (Google) Code Review
Browse files

Merge "Start Neko job service after reboot (if needed)" into nyc-mr1-dev

parents b04d40e0 946c2b89
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -102,6 +102,14 @@ public class NekoService extends JobService {
        return false;
    }

    public static void registerJobIfNeeded(Context context, long intervalMinutes) {
        JobScheduler jss = context.getSystemService(JobScheduler.class);
        JobInfo info = jss.getPendingJob(JOB_ID);
        if (info == null) {
            registerJob(context, intervalMinutes);
        }
    }

    public static void registerJob(Context context, long intervalMinutes) {
        JobScheduler jss = context.getSystemService(JobScheduler.class);
        jss.cancel(JOB_ID);
+3 −0
Original line number Diff line number Diff line
@@ -68,6 +68,9 @@ public class NekoTile extends TileService implements PrefsListener {
        Tile tile = getQsTile();
        int foodState = mPrefs.getFoodState();
        Food food = new Food(foodState);
        if (foodState != 0) {
            NekoService.registerJobIfNeeded(this, food.getInterval(this));
        }
        tile.setIcon(food.getIcon(this));
        tile.setLabel(food.getName(this));
        tile.setState(foodState != 0 ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
+3 −5
Original line number Diff line number Diff line
@@ -43,13 +43,11 @@ public class PrefState implements OnSharedPreferenceChangeListener {
    public void addCat(Cat cat) {
        mPrefs.edit()
              .putString(CAT_KEY_PREFIX + String.valueOf(cat.getSeed()), cat.getName())
              .commit();
              .apply();
    }

    public void removeCat(Cat cat) {
        mPrefs.edit()
                .remove(CAT_KEY_PREFIX + String.valueOf(cat.getSeed()))
                .commit();
        mPrefs.edit().remove(CAT_KEY_PREFIX + String.valueOf(cat.getSeed())).apply();
    }

    public List<Cat> getCats() {
@@ -71,7 +69,7 @@ public class PrefState implements OnSharedPreferenceChangeListener {
    }

    public void setFoodState(int foodState) {
        mPrefs.edit().putInt(FOOD_STATE, foodState).commit();
        mPrefs.edit().putInt(FOOD_STATE, foodState).apply();
    }

    public void setListener(PrefsListener listener) {