From 6cec9b1c86be0481128dc1f5e623e673914a0ff5 Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Sat, 25 Sep 2021 19:01:51 +0200 Subject: [PATCH] Remove Splash activity --- app/src/main/AndroidManifest.xml | 17 +++-- .../java/com/readrops/app/SplashActivity.java | 63 ------------------- .../readrops/app/itemslist/MainActivity.java | 33 +++++++--- app/src/main/res/layout/activity_splash.xml | 9 --- 4 files changed, 32 insertions(+), 90 deletions(-) delete mode 100644 app/src/main/java/com/readrops/app/SplashActivity.java delete mode 100644 app/src/main/res/layout/activity_splash.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index fb1ff613..ecd8d41a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -45,16 +45,9 @@ - - - - - - + @@ -67,7 +60,13 @@ android:name=".itemslist.MainActivity" android:label="@string/articles" android:launchMode="singleTask" - android:theme="@style/AppTheme.NoActionBar" /> + android:theme="@style/SplashTheme"> + + + + + + () { - @Override - public void onSuccess(Integer count) { - if (count > 0) { - Intent intent = new Intent(getApplicationContext(), MainActivity.class); - startActivity(intent); - finish(); - - } else { - Intent intent = new Intent(getApplicationContext(), AccountTypeListActivity.class); - startActivity(intent); - finish(); - } - } - - @Override - public void onError(Throwable e) { - Log.d(TAG, e.getMessage()); - } - }); - - - /*PeriodicWorkRequest request = new PeriodicWorkRequest.Builder(SyncWorker.class, 15, TimeUnit.MINUTES) - .addTag(SyncWorker.Companion.getTAG()) - .build(); - - WorkManager.getInstance(this).enqueueUniquePeriodicWork(SyncWorker.Companion.getTAG(), ExistingPeriodicWorkPolicy.REPLACE, request);*/ - } -} diff --git a/app/src/main/java/com/readrops/app/itemslist/MainActivity.java b/app/src/main/java/com/readrops/app/itemslist/MainActivity.java index aa60123b..e9a06601 100644 --- a/app/src/main/java/com/readrops/app/itemslist/MainActivity.java +++ b/app/src/main/java/com/readrops/app/itemslist/MainActivity.java @@ -1,5 +1,14 @@ package com.readrops.app.itemslist; +import static com.readrops.app.utils.ReadropsKeys.ACCOUNT; +import static com.readrops.app.utils.ReadropsKeys.ACCOUNT_ID; +import static com.readrops.app.utils.ReadropsKeys.FEEDS; +import static com.readrops.app.utils.ReadropsKeys.FROM_MAIN_ACTIVITY; +import static com.readrops.app.utils.ReadropsKeys.IMAGE_URL; +import static com.readrops.app.utils.ReadropsKeys.ITEM_ID; +import static com.readrops.app.utils.ReadropsKeys.SETTINGS; +import static com.readrops.app.utils.ReadropsKeys.SYNCING; + import android.content.Intent; import android.graphics.drawable.Drawable; import android.os.Build; @@ -35,6 +44,7 @@ import com.mikepenz.materialdrawer.model.SecondaryDrawerItem; import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; import com.readrops.app.R; import com.readrops.app.account.AccountTypeListActivity; +import com.readrops.app.account.AccountViewModel; import com.readrops.app.addfeed.AddFeedActivity; import com.readrops.app.databinding.ActivityMainBinding; import com.readrops.app.item.ItemActivity; @@ -67,15 +77,6 @@ import io.reactivex.disposables.Disposable; import io.reactivex.observers.DisposableSingleObserver; import io.reactivex.schedulers.Schedulers; -import static com.readrops.app.utils.ReadropsKeys.ACCOUNT; -import static com.readrops.app.utils.ReadropsKeys.ACCOUNT_ID; -import static com.readrops.app.utils.ReadropsKeys.FEEDS; -import static com.readrops.app.utils.ReadropsKeys.FROM_MAIN_ACTIVITY; -import static com.readrops.app.utils.ReadropsKeys.IMAGE_URL; -import static com.readrops.app.utils.ReadropsKeys.ITEM_ID; -import static com.readrops.app.utils.ReadropsKeys.SETTINGS; -import static com.readrops.app.utils.ReadropsKeys.SYNCING; - public class MainActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener, ReadropsItemTouchCallback.SwipeCallback, ActionMode.Callback { @@ -109,7 +110,21 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou @Override protected void onCreate(Bundle savedInstanceState) { + setTheme(R.style.AppTheme_NoActionBar); super.onCreate(savedInstanceState); + + // surely a better way to do this, but hopefully this code will be replaced with jetpack compose + AccountViewModel accountViewModel = ViewModelCompat.getViewModel(this, AccountViewModel.class); + int accountCount = accountViewModel.getAccountCount() + .subscribeOn(Schedulers.io()) + .blockingGet(); + + if (accountCount == 0) { + Intent intent = new Intent(getApplicationContext(), AccountTypeListActivity.class); + startActivity(intent); + finish(); + } + binding = ActivityMainBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); diff --git a/app/src/main/res/layout/activity_splash.xml b/app/src/main/res/layout/activity_splash.xml deleted file mode 100644 index 5825a84a..00000000 --- a/app/src/main/res/layout/activity_splash.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - \ No newline at end of file