Remove room migration code
authorDa Risk <da_risk@geekorum.com>
Wed, 28 Nov 2018 17:49:46 -0800
changeset 11 fcbfbf6d3ac6
parent 10 6899d51602b6
child 12 6e64970c6126
Remove room migration code
app/src/main/AndroidManifest.xml
app/src/main/java/com/geekorum/ttrss/articles_list/ArticleListActivity.java
app/src/main/java/com/geekorum/ttrss/data/ArticlesDatabase.java
app/src/main/java/com/geekorum/ttrss/di/ApplicationComponent.java
app/src/main/java/com/geekorum/ttrss/room_migration/MigrationViewModel.java
app/src/main/java/com/geekorum/ttrss/room_migration/RoomMigration.java
app/src/main/java/com/geekorum/ttrss/room_migration/RoomMigrationActivity.java
app/src/main/java/com/geekorum/ttrss/room_migration/RoomMigrationComponent.java
app/src/main/java/com/geekorum/ttrss/room_migration/RoomMigrationDao.java
app/src/main/java/com/geekorum/ttrss/room_migration/RoomMigrationModule.java
app/src/main/java/com/geekorum/ttrss/room_migration/RoomMigrationService.java
app/src/main/java/com/geekorum/ttrss/room_migration/RunningMigrationLiveData.java
app/src/main/res/layout/activity_room_migration.xml
app/src/main/res/values/strings.xml
--- a/app/src/main/AndroidManifest.xml	Wed Nov 28 16:39:55 2018 -0800
+++ b/app/src/main/AndroidManifest.xml	Wed Nov 28 17:49:46 2018 -0800
@@ -89,10 +89,6 @@
                 android:parentActivityName="com.geekorum.ttrss.articles_list.ArticleListActivity">
         </activity>
 
-        <activity android:name="com.geekorum.ttrss.room_migration.RoomMigrationActivity"
-                android:label="@string/activity_title_room_migration"
-                android:launchMode="singleTop"/>
-
         <activity android:name=".add_feed.AddFeedActivity"
                   android:label="@string/activity_add_feed_title"
                   android:theme="@style/AppTheme.AddFeedActivity"
--- a/app/src/main/java/com/geekorum/ttrss/articles_list/ArticleListActivity.java	Wed Nov 28 16:39:55 2018 -0800
+++ b/app/src/main/java/com/geekorum/ttrss/articles_list/ArticleListActivity.java	Wed Nov 28 17:49:46 2018 -0800
@@ -46,8 +46,6 @@
 import com.geekorum.ttrss.databinding.ActivityArticleListBinding;
 import com.geekorum.ttrss.di.ViewModelsFactory;
 import com.geekorum.ttrss.providers.ArticlesContract;
-import com.geekorum.ttrss.room_migration.RoomMigrationActivity;
-import com.geekorum.ttrss.room_migration.RoomMigrationService;
 import com.geekorum.ttrss.session.SessionActivity;
 
 import javax.inject.Inject;
@@ -87,7 +85,6 @@
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        runRoomMigrationIfNeeded();
         setupPeriodicJobs();
         PreferenceManager.setDefaultValues(this, R.xml.pref_general, false);
 
@@ -153,14 +150,6 @@
         setupActionBar();
     }
 
-    private void runRoomMigrationIfNeeded() {
-        if (RoomMigrationService.needMigration(this)) {
-            Intent intent = new Intent(this, RoomMigrationActivity.class);
-            startActivity(intent);
-            finish();
-        }
-    }
-
     private void setupActionBar() {
         Toolbar toolbar = binding.toolbar.toolbar;
         setSupportActionBar(toolbar);
--- a/app/src/main/java/com/geekorum/ttrss/data/ArticlesDatabase.java	Wed Nov 28 16:39:55 2018 -0800
+++ b/app/src/main/java/com/geekorum/ttrss/data/ArticlesDatabase.java	Wed Nov 28 17:49:46 2018 -0800
@@ -23,7 +23,6 @@
 import androidx.room.Database;
 import androidx.room.RoomDatabase;
 import com.geekorum.ttrss.providers.ArticlesProvidersDao;
-import com.geekorum.ttrss.room_migration.RoomMigrationDao;
 
 @Database(entities = {Article.class, Category.class, Feed.class, Transaction.class},
         version = 4)
@@ -33,8 +32,6 @@
 
     public abstract ArticleDao articleDao();
 
-    public abstract RoomMigrationDao roomMigrationDao();
-
     public abstract TransactionsDao transactionsDao();
 
     public abstract SynchronizationDao synchronizationDao();
--- a/app/src/main/java/com/geekorum/ttrss/di/ApplicationComponent.java	Wed Nov 28 16:39:55 2018 -0800
+++ b/app/src/main/java/com/geekorum/ttrss/di/ApplicationComponent.java	Wed Nov 28 17:49:46 2018 -0800
@@ -25,7 +25,6 @@
 import com.geekorum.ttrss.data.ArticlesDatabaseModule;
 import com.geekorum.ttrss.logging.LoggingModule;
 import com.geekorum.ttrss.providers.ArticleProviderComponent;
-import com.geekorum.ttrss.room_migration.RoomMigrationComponent;
 import dagger.BindsInstance;
 import dagger.Component;
 import dagger.android.AndroidInjectionModule;
@@ -63,8 +62,6 @@
 
     void inject(Application application);
 
-    RoomMigrationComponent.Builder createRoomMigrationComponent();
-
     ArticleProviderComponent.Builder createArticleProviderComponent();
 
 }
--- a/app/src/main/java/com/geekorum/ttrss/room_migration/MigrationViewModel.java	Wed Nov 28 16:39:55 2018 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/**
- * Geekttrss is a RSS feed reader application on the Android Platform.
- *
- * Copyright (C) 2017-2018 by Frederic-Charles Barthelery.
- *
- * This file is part of Geekttrss.
- *
- * Geekttrss is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Geekttrss is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Geekttrss.  If not, see <http://www.gnu.org/licenses/>.
- */
-package com.geekorum.ttrss.room_migration;
-
-import android.app.Application;
-import androidx.lifecycle.AndroidViewModel;
-import androidx.databinding.BaseObservable;
-import androidx.databinding.Bindable;
-import com.geekorum.ttrss.BR;
-
-/**
- * {@link androidx.lifecycle.ViewModel } for the {@link RoomMigrationActivity}.
- */
-public class MigrationViewModel extends AndroidViewModel {
-    RunningMigrationLiveData migrationProgress = new RunningMigrationLiveData(getApplication());
-    MigrationModel model = new MigrationModel();
-
-    public MigrationViewModel(Application application) {
-        super(application);
-    }
-
-    MigrationModel getModel() {
-        return model;
-    }
-
-    public static class MigrationModel extends BaseObservable {
-        private int max = 1;
-        private int progress;
-        private boolean isSuccessful;
-
-        @Bindable
-        public int getMax() {
-            return max;
-        }
-
-        public void setMax(int max) {
-            this.max = max;
-            notifyPropertyChanged(BR.max);
-        }
-
-        @Bindable
-        public int getProgress() {
-            return progress;
-        }
-
-        public void setProgress(int progress) {
-            this.progress = progress;
-            notifyPropertyChanged(BR.progress);
-        }
-
-        @Bindable({"progress", "max"})
-        public boolean isRunning() {
-            return progress < max;
-        }
-
-        @Bindable({"progress", "max"})
-        public boolean isComplete() {
-            return progress != 0 && progress == max;
-        }
-
-        @Bindable({"complete"})
-        public boolean isSuccessful() {
-            return  isComplete() && isSuccessful;
-        }
-
-        public void setSuccessful(boolean successful) {
-            this.isSuccessful = successful;
-            notifyPropertyChanged(BR.successful);
-        }
-    }
-}
--- a/app/src/main/java/com/geekorum/ttrss/room_migration/RoomMigration.java	Wed Nov 28 16:39:55 2018 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,266 +0,0 @@
-/**
- * Geekttrss is a RSS feed reader application on the Android Platform.
- *
- * Copyright (C) 2017-2018 by Frederic-Charles Barthelery.
- *
- * This file is part of Geekttrss.
- *
- * Geekttrss is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Geekttrss is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Geekttrss.  If not, see <http://www.gnu.org/licenses/>.
- */
-package com.geekorum.ttrss.room_migration;
-
-import android.database.Cursor;
-import android.database.sqlite.SQLiteQueryBuilder;
-import android.util.Log;
-import com.geekorum.ttrss.data.ArticlesDatabase;
-import com.geekorum.ttrss.data.Article;
-import com.geekorum.ttrss.data.Category;
-import com.geekorum.ttrss.data.Feed;
-import com.geekorum.ttrss.data.Transaction;
-import com.geekorum.ttrss.providers.ArticlesContract;
-import com.geekorum.ttrss.providers.DbHelper;
-
-import java.util.Arrays;
-
-import javax.inject.Inject;
-
-/**
- * Quick and dirty process to migrate all database data into a Room database.
- */
-public class RoomMigration {
-
-    private static final String TAG = RoomMigration.class.getSimpleName();
-    private final ProgressListener progressListener;
-    private final CompletionListener completionListener;
-    private final DbHelper dbHelper;
-    private final ArticlesDatabase articlesDatabase;
-    private final RoomMigrationDao roomMigrationDao;
-    private final TableMigration[] tableMigrations = new TableMigration[]{
-            new CategoryTableMigration(),
-            new FeedTableMigration(),
-            new ArticleTableMigration(),
-            new TransactionTableMigration()
-    };
-    private int totalRows;
-    private int inserted;
-
-    private RoomMigration(DbHelper dbHelper, ArticlesDatabase articlesDatabase, ProgressListener progressListener, CompletionListener completionListener) {
-        this.dbHelper = dbHelper;
-        this.articlesDatabase = articlesDatabase;
-        this.progressListener = progressListener;
-        this.completionListener = completionListener;
-        roomMigrationDao = articlesDatabase.roomMigrationDao();
-    }
-
-    public void execute() {
-        Log.i(TAG, "Start migration");
-        totalRows = getTotalRows();
-        articlesDatabase.beginTransaction();
-        boolean success = false;
-        try {
-            Arrays.stream(tableMigrations).forEach(TableMigration::execute);
-            dbHelper.selfDelete();
-            articlesDatabase.setTransactionSuccessful();
-            success = true;
-            Log.i(TAG, "End of migration");
-        } catch (Exception e) {
-            Log.e(TAG, "unable to complete migration", e);
-            success = false;
-        } finally {
-            articlesDatabase.endTransaction();
-            completionListener.onComplete(success);
-        }
-    }
-
-    private int getTotalRows() {
-        return Arrays.stream(tableMigrations)
-                .map(TableMigration::getCount)
-                .reduce(Integer::sum).orElse(0);
-    }
-
-    public static class Factory {
-        private ProgressListener progressListener;
-        private CompletionListener completionListener;
-        private final DbHelper dbHelper;
-        private final ArticlesDatabase articlesDatabase;
-
-        @Inject
-        public Factory(DbHelper dbHelper, ArticlesDatabase articlesDatabase) {
-            this.dbHelper = dbHelper;
-            this.articlesDatabase = articlesDatabase;
-        }
-
-        Factory setProgressListener(ProgressListener progressListener) {
-            this.progressListener = progressListener;
-            return this;
-        }
-
-        Factory setCompletionListener(CompletionListener completionListener) {
-            this.completionListener = completionListener;
-            return this;
-        }
-
-        public RoomMigration build() {
-            return new RoomMigration(dbHelper, articlesDatabase, progressListener, completionListener);
-        }
-    }
-
-    /** Migrate a table into a Room table of Entity */
-    private abstract class TableMigration<Entity> {
-
-        private final String tableName;
-
-        TableMigration(String tableName) {
-            this.tableName = tableName;
-        }
-
-        void execute() {
-            try (Cursor cursor = getOldData(tableName)) {
-                while (cursor.moveToNext()) {
-                    Entity item = mapData(cursor);
-                    insertItem(item);
-                    inserted++;
-                    progressListener.onProgress(inserted, totalRows);
-                }
-            }
-        }
-
-        int getCount() {
-            try (Cursor cursor = getOldData(tableName)) {
-                return cursor.getCount();
-            }
-        }
-
-        private Cursor getOldData(String tableName) {
-            SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
-            queryBuilder.setTables(tableName);
-            return queryBuilder.query(dbHelper.getReadableDatabase(), null,
-                    null, null, null, null, null);
-        }
-
-        abstract Entity mapData(Cursor cursor);
-
-        abstract void insertItem(Entity item);
-    }
-
-    private class CategoryTableMigration extends TableMigration<Category> {
-        CategoryTableMigration() {
-            super(DbHelper.TABLE_CATEGORIES);
-        }
-
-        @Override
-        Category mapData(Cursor cursor) {
-            Category category = new Category();
-            category.setId(cursor.getLong(cursor.getColumnIndexOrThrow(ArticlesContract.Category._ID)));
-            category.setTitle(cursor.getString(cursor.getColumnIndexOrThrow(ArticlesContract.Category.TITLE)));
-            category.setUnreadCount(cursor.getInt(cursor.getColumnIndexOrThrow(ArticlesContract.Category.UNREAD_COUNT)));
-            return category;
-        }
-
-        @Override
-        void insertItem(Category item) {
-            roomMigrationDao.insertCategories(item);
-        }
-
-    }
-
-    private class FeedTableMigration extends TableMigration<Feed> {
-        FeedTableMigration() {
-            super(DbHelper.TABLE_FEEDS);
-        }
-
-        @Override
-        Feed mapData(Cursor cursor) {
-            Feed feed = new Feed();
-            feed.setId(cursor.getLong(cursor.getColumnIndexOrThrow(ArticlesContract.Feed._ID)));
-            feed.setTitle(cursor.getString(cursor.getColumnIndexOrThrow(ArticlesContract.Feed.TITLE)));
-            feed.setUnreadCount(cursor.getInt(cursor.getColumnIndexOrThrow(ArticlesContract.Category.UNREAD_COUNT)));
-            feed.setDisplayTitle(cursor.getString(cursor.getColumnIndexOrThrow(ArticlesContract.Category.TITLE)));
-            feed.setCatId(cursor.getLong(cursor.getColumnIndexOrThrow(ArticlesContract.Feed.CAT_ID)));
-            feed.setLastTimeUpdate(cursor.getLong(cursor.getColumnIndexOrThrow(ArticlesContract.Feed.LAST_TIME_UPDATE)));
-            feed.setUnreadCount(cursor.getInt(cursor.getColumnIndexOrThrow(ArticlesContract.Feed.UNREAD_COUNT)));
-            feed.setUrl(cursor.getString(cursor.getColumnIndexOrThrow(ArticlesContract.Feed.URL)));
-            return feed;
-        }
-
-        @Override
-        void insertItem(Feed item) {
-            roomMigrationDao.insertFeeds(item);
-        }
-    }
-
-    private class ArticleTableMigration extends TableMigration<Article> {
-
-        private ArticleTableMigration() {
-            super(DbHelper.TABLE_ARTICLES);
-        }
-
-        @Override
-        Article mapData(Cursor cursor) {
-            Article article = new Article();
-            article.setId(cursor.getLong(cursor.getColumnIndexOrThrow(ArticlesContract.Article._ID)));
-            article.setAuthor(cursor.getString(cursor.getColumnIndexOrThrow(ArticlesContract.Article.AUTHOR)));
-            article.setContent(cursor.getString(cursor.getColumnIndexOrThrow(ArticlesContract.Article.CONTENT)));
-            article.setContentExcerpt(cursor.getString(cursor.getColumnIndexOrThrow(ArticlesContract.Article.CONTENT_EXCERPT)));
-            article.setFeedId(cursor.getLong(cursor.getColumnIndexOrThrow(ArticlesContract.Article.FEED_ID)));
-            article.setFlavorImageUri(cursor.getString(cursor.getColumnIndexOrThrow(ArticlesContract.Article.FLAVOR_IMAGE_URI)));
-            article.setLastTimeUpdate(cursor.getLong(cursor.getColumnIndexOrThrow(ArticlesContract.Article.LAST_TIME_UPDATE)));
-            article.setLink(cursor.getString(cursor.getColumnIndexOrThrow(ArticlesContract.Article.LINK)));
-            article.setScore(cursor.getInt(cursor.getColumnIndexOrThrow(ArticlesContract.Article.SCORE)));
-            article.setTags(cursor.getString(cursor.getColumnIndexOrThrow(ArticlesContract.Article.TAGS)));
-            article.setTitle(cursor.getString(cursor.getColumnIndexOrThrow(ArticlesContract.Article.TITLE)));
-            article.setPublished(cursor.getInt(cursor.getColumnIndexOrThrow(ArticlesContract.Article.PUBLISHED)) != 0);
-            article.setStarred(cursor.getInt(cursor.getColumnIndexOrThrow(ArticlesContract.Article.STARRED)) != 0);
-            article.setTransientUnread(
-                    cursor.getInt(cursor.getColumnIndexOrThrow(ArticlesContract.Article.TRANSIENT_UNREAD)) != 0);
-            article.setUnread(cursor.getInt(cursor.getColumnIndexOrThrow(ArticlesContract.Article.UNREAD)) != 0);
-            article.setUpdated(cursor.getInt(cursor.getColumnIndexOrThrow(ArticlesContract.Article.IS_UPDATED)) != 0);
-            return article;
-        }
-
-        @Override
-        void insertItem(Article item) {
-            roomMigrationDao.insertArticles(item);
-        }
-    }
-
-    private class TransactionTableMigration extends TableMigration<Transaction> {
-        TransactionTableMigration() {
-            super(DbHelper.TABLE_TRANSACTIONS);
-        }
-
-        @Override
-        Transaction mapData(Cursor cursor) {
-            Transaction transaction = new Transaction();
-            transaction.setId(cursor.getLong(cursor.getColumnIndexOrThrow(ArticlesContract.Transaction._ID)));
-            transaction.setField(cursor.getString(cursor.getColumnIndexOrThrow(ArticlesContract.Transaction.FIELD)));
-            transaction.setValue(cursor.getInt(cursor.getColumnIndexOrThrow(ArticlesContract.Transaction.VALUE)) != 0);
-            transaction.setArticleId(cursor.getLong(cursor.getColumnIndexOrThrow(ArticlesContract.Transaction.ARTICLE_ID)));
-            return transaction;
-        }
-
-        @Override
-        void insertItem(Transaction item) {
-            roomMigrationDao.insertTranscations(item);
-        }
-    }
-
-    interface ProgressListener {
-        void onProgress(int progress, int max);
-    }
-
-    interface CompletionListener {
-        void onComplete(boolean success);
-    }
-}
--- a/app/src/main/java/com/geekorum/ttrss/room_migration/RoomMigrationActivity.java	Wed Nov 28 16:39:55 2018 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/**
- * Geekttrss is a RSS feed reader application on the Android Platform.
- *
- * Copyright (C) 2017-2018 by Frederic-Charles Barthelery.
- *
- * This file is part of Geekttrss.
- *
- * Geekttrss is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Geekttrss is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Geekttrss.  If not, see <http://www.gnu.org/licenses/>.
- */
-package com.geekorum.ttrss.room_migration;
-
-import androidx.lifecycle.ViewModelProviders;
-import android.content.Intent;
-import androidx.databinding.DataBindingUtil;
-import android.os.Bundle;
-import androidx.appcompat.app.AppCompatActivity;
-import com.geekorum.ttrss.R;
-import com.geekorum.ttrss.articles_list.ArticleListActivity;
-import com.geekorum.ttrss.databinding.ActivityRoomMigrationBinding;
-
-public class RoomMigrationActivity extends AppCompatActivity {
-
-    private ActivityRoomMigrationBinding binding;
-    private boolean migrationSucceed;
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        binding = DataBindingUtil.setContentView(this, R.layout.activity_room_migration);
-
-        MigrationViewModel migrationViewModel = ViewModelProviders.of(this).get(MigrationViewModel.class);
-        MigrationViewModel.MigrationModel migrationModel = migrationViewModel.getModel();
-        binding.setMigration(migrationModel);
-
-        migrationViewModel.migrationProgress.observe(this, migrationProgress -> {
-            migrationModel.setMax(migrationProgress.max);
-            migrationModel.setProgress(migrationProgress.progress);
-            migrationModel.setSuccessful(migrationProgress.isSuccessFull);
-            migrationSucceed = migrationProgress.isSuccessFull;
-        });
-    }
-
-    @Override
-    public void onBackPressed() {
-        super.onBackPressed();
-        if (migrationSucceed) {
-            Intent intent = new Intent(this, ArticleListActivity.class);
-            startActivity(intent);
-        }
-    }
-}
--- a/app/src/main/java/com/geekorum/ttrss/room_migration/RoomMigrationComponent.java	Wed Nov 28 16:39:55 2018 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/**
- * Geekttrss is a RSS feed reader application on the Android Platform.
- *
- * Copyright (C) 2017-2018 by Frederic-Charles Barthelery.
- *
- * This file is part of Geekttrss.
- *
- * Geekttrss is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Geekttrss is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Geekttrss.  If not, see <http://www.gnu.org/licenses/>.
- */
-package com.geekorum.ttrss.room_migration;
-
-import android.content.Context;
-import com.geekorum.ttrss.di.AndroidComponentsModule;
-import com.geekorum.ttrss.di.PerAndroidComponent;
-import dagger.BindsInstance;
-import dagger.Subcomponent;
-
-/**
- * Component to run the Room migration.
- */
-@Subcomponent(modules = { AndroidComponentsModule.class, RoomMigrationModule.class} )
-@PerAndroidComponent
-public interface RoomMigrationComponent {
-    void inject(RoomMigrationService roomMigrationService);
-
-    @Subcomponent.Builder
-    interface Builder {
-
-        @BindsInstance
-        Builder bindAndroidComponent(Context context);
-
-        RoomMigrationComponent build();
-    }
-}
--- a/app/src/main/java/com/geekorum/ttrss/room_migration/RoomMigrationDao.java	Wed Nov 28 16:39:55 2018 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/**
- * Geekttrss is a RSS feed reader application on the Android Platform.
- *
- * Copyright (C) 2017-2018 by Frederic-Charles Barthelery.
- *
- * This file is part of Geekttrss.
- *
- * Geekttrss is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Geekttrss is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Geekttrss.  If not, see <http://www.gnu.org/licenses/>.
- */
-package com.geekorum.ttrss.room_migration;
-
-import androidx.room.Dao;
-import androidx.room.Insert;
-import androidx.room.OnConflictStrategy;
-import com.geekorum.ttrss.data.Article;
-import com.geekorum.ttrss.data.Category;
-import com.geekorum.ttrss.data.Feed;
-import com.geekorum.ttrss.data.Transaction;
-
-/**
- * Dao to perform Room migration.
- */
-@Dao
-public interface RoomMigrationDao {
-
-    @Insert(onConflict = OnConflictStrategy.REPLACE)
-    void insertArticles(Article... articles);
-
-
-    @Insert(onConflict = OnConflictStrategy.REPLACE)
-    void insertCategories(Category... categories);
-
-
-    @Insert(onConflict = OnConflictStrategy.REPLACE)
-    void insertFeeds(Feed... feeds);
-
-    @Insert(onConflict = OnConflictStrategy.REPLACE)
-    void insertTranscations(Transaction... transactions);
-
-
-}
--- a/app/src/main/java/com/geekorum/ttrss/room_migration/RoomMigrationModule.java	Wed Nov 28 16:39:55 2018 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/**
- * Geekttrss is a RSS feed reader application on the Android Platform.
- *
- * Copyright (C) 2017-2018 by Frederic-Charles Barthelery.
- *
- * This file is part of Geekttrss.
- *
- * Geekttrss is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Geekttrss is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Geekttrss.  If not, see <http://www.gnu.org/licenses/>.
- */
-package com.geekorum.ttrss.room_migration;
-
-import android.content.Context;
-import com.geekorum.ttrss.providers.DbHelper;
-import dagger.Module;
-import dagger.Provides;
-
-/**
- * Provides some dependencies needed to run the Room migration.
- */
-@Module
-public class RoomMigrationModule {
-
-    @Provides
-    public static DbHelper providesDbHelper(Context context) {
-        return new DbHelper(context);
-    }
-
-}
--- a/app/src/main/java/com/geekorum/ttrss/room_migration/RoomMigrationService.java	Wed Nov 28 16:39:55 2018 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,145 +0,0 @@
-/**
- * Geekttrss is a RSS feed reader application on the Android Platform.
- *
- * Copyright (C) 2017-2018 by Frederic-Charles Barthelery.
- *
- * This file is part of Geekttrss.
- *
- * Geekttrss is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Geekttrss is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Geekttrss.  If not, see <http://www.gnu.org/licenses/>.
- */
-package com.geekorum.ttrss.room_migration;
-
-import android.app.IntentService;
-import android.app.Notification;
-import android.app.PendingIntent;
-import android.content.Context;
-import android.content.Intent;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.core.app.NotificationCompat;
-import androidx.localbroadcastmanager.content.LocalBroadcastManager;
-import com.geekorum.ttrss.Application;
-import com.geekorum.ttrss.NotificationCenter;
-import com.geekorum.ttrss.R;
-import com.geekorum.ttrss.di.ApplicationComponent;
-import com.geekorum.ttrss.providers.DbHelper;
-
-import java.util.Arrays;
-
-import javax.inject.Inject;
-
-import static android.app.NotificationChannel.DEFAULT_CHANNEL_ID;
-import static com.geekorum.ttrss.NotificationCenter.NOTIF_ID_ROOM_MIGRATION_SERVICE;
-
-/**
- * Service to migrate data to Room database.
- */
-public class RoomMigrationService extends IntentService {
-    public static final String ACTION_MIGRATION_PROGRESS = "com.geekorum.ttrss.room_migration_progress";
-    public static final String EXTRA_PROGRESS = "progress";
-    public static final String EXTRA_MAX = "max";
-    public static final String EXTRA_SUCCESS = "success";
-
-    @Inject
-    NotificationCenter notificationCenter;
-
-    @Inject
-    RoomMigration.Factory roomMigrationFactory;
-
-    @Inject
-    LocalBroadcastManager localBroadcastManager;
-
-    public RoomMigrationService() {
-        super("Room migration service");
-    }
-
-    @Override
-    public void onCreate() {
-        super.onCreate();
-        getRoomMigrationComponent().inject(this);
-    }
-
-    @Override
-    protected void onHandleIntent(@Nullable Intent intent) {
-        if (needMigration(this)) {
-            Notification notification = buildNotification(0, 100);
-            startForeground(NOTIF_ID_ROOM_MIGRATION_SERVICE, notification);
-            RoomMigration migration = roomMigrationFactory
-                    .setProgressListener(this::notifyProgress)
-                    .setCompletionListener(this::onCompletion)
-                    .build();
-            migration.execute();
-        } else {
-            onCompletion(true);
-        }
-    }
-
-    private void notifyProgress(int progress, int max) {
-        updateNotification(progress, max);
-        Intent intent = new Intent(ACTION_MIGRATION_PROGRESS);
-        intent.putExtra(EXTRA_PROGRESS, progress);
-        intent.putExtra(EXTRA_MAX, max);
-        localBroadcastManager.sendBroadcast(intent);
-    }
-
-    public static boolean needMigration(Context context) {
-        return Arrays.asList(context.databaseList()).contains(DbHelper.DATABASE_NAME);
-    }
-
-    private void onCompletion(boolean success) {
-        stopForeground(true);
-        Intent intent = new Intent(ACTION_MIGRATION_PROGRESS);
-        intent.putExtra(EXTRA_PROGRESS, 100);
-        intent.putExtra(EXTRA_MAX, 100);
-        intent.putExtra(EXTRA_SUCCESS, success);
-        localBroadcastManager.sendBroadcast(intent);
-    }
-
-    private Notification buildNotification(int progress, int max) {
-        NotificationCompat.Builder builder = getNotificationBuilder();
-        Intent intent = new Intent(this, RoomMigrationActivity.class);
-        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
-        return builder.setContentTitle(getString(R.string.notif_room_migration_title))
-                .setCategory(NotificationCompat.CATEGORY_PROGRESS)
-                .setProgress(max, progress, false)
-                .setSmallIcon(R.mipmap.ic_launcher)
-                .setOngoing(true)
-                .setContentIntent(contentIntent)
-                .setVisibility(NotificationCompat.VISIBILITY_PUBLIC).build();
-    }
-
-    @SuppressWarnings("deprecation")
-    @NonNull
-    private NotificationCompat.Builder getNotificationBuilder() {
-        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
-            return new NotificationCompat.Builder(this, DEFAULT_CHANNEL_ID);
-        }
-        return new NotificationCompat.Builder(this);
-    }
-
-    private void updateNotification(int progress, int max) {
-        Notification notification = buildNotification(progress, max);
-        notificationCenter.notify(NotificationCenter.NOTIF_ID_ROOM_MIGRATION_SERVICE, notification);
-    }
-
-    private RoomMigrationComponent getRoomMigrationComponent() {
-        ApplicationComponent applicationComponent = ((Application) getApplication()).getApplicationComponent();
-        return applicationComponent
-                .createRoomMigrationComponent()
-                .bindAndroidComponent(this)
-                .build();
-    }
-
-}
--- a/app/src/main/java/com/geekorum/ttrss/room_migration/RunningMigrationLiveData.java	Wed Nov 28 16:39:55 2018 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/**
- * Geekttrss is a RSS feed reader application on the Android Platform.
- *
- * Copyright (C) 2017-2018 by Frederic-Charles Barthelery.
- *
- * This file is part of Geekttrss.
- *
- * Geekttrss is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Geekttrss is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Geekttrss.  If not, see <http://www.gnu.org/licenses/>.
- */
-package com.geekorum.ttrss.room_migration;
-
-import androidx.lifecycle.LiveData;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.Build;
-import androidx.localbroadcastmanager.content.LocalBroadcastManager;
-
-/**
- * A {@link LiveData} to follow a running migration.
- */
-public class RunningMigrationLiveData extends LiveData<RunningMigrationLiveData.MigrationProgress> {
-
-    private LocalBroadcastManager localBroadcastManager;
-    private Context context;
-    private BroadcastReceiver receiver = new BroadcastReceiver() {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            if (RoomMigrationService.ACTION_MIGRATION_PROGRESS.equals(intent.getAction())) {
-                int progress = intent.getIntExtra(RoomMigrationService.EXTRA_PROGRESS, 0);
-                int max = intent.getIntExtra(RoomMigrationService.EXTRA_MAX, 100);
-                boolean success = intent.getBooleanExtra(RoomMigrationService.EXTRA_SUCCESS, false);
-                MigrationProgress migrationProgress = new MigrationProgress(success, progress, max);
-                setValue(migrationProgress);
-            }
-        }
-    };
-
-    public RunningMigrationLiveData(Context context) {
-        this.context = context.getApplicationContext();
-        this.localBroadcastManager = LocalBroadcastManager.getInstance(this.context);
-    }
-
-    @Override
-    protected void onActive() {
-        IntentFilter filter = new IntentFilter(RoomMigrationService.ACTION_MIGRATION_PROGRESS);
-        localBroadcastManager.registerReceiver(receiver, filter);
-        Intent intent = new Intent(context, RoomMigrationService.class);
-        startService(intent);
-    }
-
-    private void startService(Intent intent) {
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
-            context.startForegroundService(intent);
-        } else {
-            context.startService(intent);
-        }
-    }
-
-    @Override
-    protected void onInactive() {
-        localBroadcastManager.unregisterReceiver(receiver);
-    }
-
-    static class MigrationProgress {
-        boolean isSuccessFull;
-        int progress;
-        int max;
-
-        MigrationProgress(boolean isSuccessFull, int progress, int max) {
-            this.isSuccessFull = isSuccessFull;
-            this.progress = progress;
-            this.max = max;
-        }
-    }
-
-}
--- a/app/src/main/res/layout/activity_room_migration.xml	Wed Nov 28 16:39:55 2018 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-
-    Geekttrss is a RSS feed reader application on the Android Platform.
-
-    Copyright (C) 2017-2018 by Frederic-Charles Barthelery.
-
-    This file is part of Geekttrss.
-
-    Geekttrss is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    Geekttrss is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with Geekttrss.  If not, see <http://www.gnu.org/licenses/>.
-
--->
-<layout xmlns:android="http://schemas.android.com/apk/res/android"
-        xmlns:tools="http://schemas.android.com/tools"
-        xmlns:app="http://schemas.android.com/apk/res-auto"
-        tools:context="com.geekorum.ttrss.room_migration.RoomMigrationActivity">
-
-    <data>
-        <import type="android.view.View" />
-
-        <variable name="migration" type="com.geekorum.ttrss.room_migration.MigrationViewModel.MigrationModel" />
-    </data>
-
-    <androidx.constraintlayout.widget.ConstraintLayout
-            android:layout_width="match_parent"
-            android:layout_height="match_parent">
-
-        <ImageView
-                android:id="@+id/imageView"
-                android:layout_width="128dp"
-                android:layout_height="128dp"
-                app:layout_constraintStart_toStartOf="parent"
-                app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintBottom_toTopOf="@+id/textView"
-                app:layout_constraintTop_toTopOf="parent"
-                android:layout_marginTop="16dp"
-                app:srcCompat="@mipmap/ic_launcher"
-                app:layout_constraintVertical_chainStyle="packed"
-                app:layout_constraintVertical_bias="0.1"
-                tools:ignore="ContentDescription" />
-
-        <TextView
-                android:id="@+id/textView"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="16dp"
-                android:maxWidth="256dp"
-                android:gravity="center"
-                app:layout_constraintStart_toStartOf="parent"
-                app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintTop_toBottomOf="@+id/imageView"
-                app:layout_constraintBottom_toTopOf="@+id/progressBar"
-                android:text="@string/activity_room_migration_label"
-                android:visibility="@{migration.isRunning ? View.VISIBLE : View.INVISIBLE}"/>
-
-
-        <TextView
-                android:id="@+id/textViewComplete"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:maxWidth="256dp"
-                android:gravity="center"
-                android:layout_marginTop="16dp"
-                app:layout_constraintStart_toStartOf="parent"
-                app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintTop_toBottomOf="@+id/imageView"
-                android:text="@{migration.isSuccessful ? @string/activity_room_migration_label_success :  @string/activity_room_migration_label_failed }"
-                android:visibility="@{migration.isComplete ? View.VISIBLE : View.GONE}"/>
-
-        <ProgressBar
-                android:id="@+id/progressBar"
-                style="?android:attr/progressBarStyleHorizontal"
-                android:layout_width="128dp"
-                android:layout_height="wrap_content"
-                app:layout_constraintTop_toBottomOf="@+id/textView"
-                app:layout_constraintBottom_toBottomOf="parent"
-                app:layout_constraintStart_toStartOf="parent"
-                app:layout_constraintEnd_toEndOf="parent"
-                android:max="@{migration.max}"
-                android:progress="@{migration.progress}"
-                android:visibility="@{migration.isRunning ? View.VISIBLE : View.INVISIBLE}"/>
-
-
-    </androidx.constraintlayout.widget.ConstraintLayout>
-</layout>
--- a/app/src/main/res/values/strings.xml	Wed Nov 28 16:39:55 2018 -0800
+++ b/app/src/main/res/values/strings.xml	Wed Nov 28 17:49:46 2018 -0800
@@ -80,13 +80,6 @@
     <string name="activity_add_feed_account_subtitle">Account</string>
     <string name="activity_add_feed_btn_subscribe">Subscribe</string>
 
-    <!-- activity room migration -->
-    <string name="activity_title_room_migration">Database migration</string>
-    <string name="activity_room_migration_label">We are migrating the database. Please be patient</string>
-    <string name="activity_room_migration_label_success">Migration is complete. Everything went fine</string>
-    <string name="activity_room_migration_label_failed">Something wrong happened :/</string>
-    <string name="notif_room_migration_title">Migrating database</string>
-
     <!-- Menus -->
     <string name="share_article">Share article</string>
     <string name="context_selection_toggle_unread">(Un)Read</string>