diff --git a/app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt b/app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt index 26b1a02..9570740 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/apps/AppDrawer.kt @@ -72,7 +72,8 @@ internal class AppDrawer : Fragment() { private var contactAdapter : ContactAdapter? = null private var packageInfoList: MutableList = mutableListOf() private var packageList = mutableListOf() - private var oringinPackageList = mutableListOf() + var oringinPackageList = mutableListOf() + val originContactList = arrayListOf() // private val numberPattern = Pattern.compile("[0-9]") // private val alphabetPattern = Pattern.compile("[A-Z]") @JvmStatic var settingsPrefs: SharedPreferences? = null @@ -153,7 +154,7 @@ internal class AppDrawer : Fragment() { } - val originContactList = arrayListOf() + val contactList = arrayListOf() private fun GetContact() { if (originContactList.size > 0) { @@ -229,6 +230,7 @@ internal class AppDrawer : Fragment() { } } + override fun onResume() { super.onResume() fetchApps() diff --git a/app/src/main/kotlin/rasel/lunar/launcher/apps/AppMenu.kt b/app/src/main/kotlin/rasel/lunar/launcher/apps/AppMenu.kt index 7d758e2..bebc63d 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/apps/AppMenu.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/apps/AppMenu.kt @@ -52,6 +52,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder import rasel.lunar.launcher.LauncherActivity.Companion.lActivity import rasel.lunar.launcher.R import rasel.lunar.launcher.apps.AppDrawer.Companion.appNamesPrefs +import rasel.lunar.launcher.apps.AppDrawer.Companion.oringinPackageList import rasel.lunar.launcher.databinding.ActivityBrowserDialogBinding import rasel.lunar.launcher.databinding.AppInfoDialogBinding import rasel.lunar.launcher.databinding.AppMenuBinding diff --git a/app/src/main/kotlin/rasel/lunar/launcher/apps/AppsAdapter.kt b/app/src/main/kotlin/rasel/lunar/launcher/apps/AppsAdapter.kt index 2254d6c..17f48a2 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/apps/AppsAdapter.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/apps/AppsAdapter.kt @@ -82,7 +82,8 @@ internal class AppsAdapter( /* on long click - open app menu */ setOnLongClickListener { - AppMenu().show(fragmentManager, item.packageName) + AppMenu().apply { + }.show(fragmentManager, item.packageName) true } } diff --git a/app/src/main/kotlin/rasel/lunar/launcher/feeds/Feeds.kt b/app/src/main/kotlin/rasel/lunar/launcher/feeds/Feeds.kt index d6119a2..66eccb2 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/feeds/Feeds.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/feeds/Feeds.kt @@ -45,6 +45,7 @@ import rasel.lunar.launcher.feeds.rss.Rss import rasel.lunar.launcher.feeds.rss.RssAdapter import rasel.lunar.launcher.feeds.rss.RssService import rasel.lunar.launcher.helpers.Constants.Companion.KEY_RSS_URL +import rasel.lunar.launcher.helpers.Constants.Companion.KEY_RSS_URL2 import rasel.lunar.launcher.helpers.Constants.Companion.KEY_WIDGET_HEIGHTS import rasel.lunar.launcher.helpers.Constants.Companion.KEY_WIDGET_IDS import rasel.lunar.launcher.helpers.Constants.Companion.PREFS_SETTINGS @@ -74,6 +75,7 @@ internal class Feeds : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + binding.feedsRss.rss.adapter = RssAdapter(arrayListOf(), requireContext()) expandCollapse() systemInfo() } @@ -125,6 +127,11 @@ internal class Feeds : Fragment() { /* start rss service if network is active and rss url is not empty */ private fun startService() { + binding.feedsRss.apply { + if(rss.adapter != null) { + (rss.adapter as RssAdapter).items.clear() + } + } val rssUrl = lActivity!!.getSharedPreferences(PREFS_SETTINGS, 0) .getString(KEY_RSS_URL, "") when { @@ -136,6 +143,17 @@ internal class Feeds : Fragment() { } else -> resumeService() } + val rssUrl2 = lActivity!!.getSharedPreferences(PREFS_SETTINGS, 0) + .getString(KEY_RSS_URL2, "") + when { + isNetworkAvailable && !rssUrl2.isNullOrEmpty() -> { + Intent(lActivity!!, RssService::class.java) + .putExtra(RSS_RECEIVER, resultReceiver).let { + enqueueWork(lActivity!!, RssService::class.java, rssJobId, it) + } + } + else -> resumeService() + } } /* retry to start rss service */ @@ -156,7 +174,9 @@ internal class Feeds : Fragment() { null -> resumeService() else -> { binding.feedsRss.apply { - rss.adapter = RssAdapter(items, requireContext()) + if(rss.adapter != null) { + (rss.adapter as RssAdapter).items.addAll(items) + } refresh.visibility = View.GONE loading.visibility = View.GONE rss.visibility = View.VISIBLE diff --git a/app/src/main/kotlin/rasel/lunar/launcher/feeds/rss/RssAdapter.kt b/app/src/main/kotlin/rasel/lunar/launcher/feeds/rss/RssAdapter.kt index 34dbaec..839cccf 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/feeds/rss/RssAdapter.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/feeds/rss/RssAdapter.kt @@ -34,7 +34,7 @@ import rasel.lunar.launcher.databinding.ListItemBinding import rasel.lunar.launcher.helpers.UniUtils.Companion.getColorResId -internal class RssAdapter(private val items: List, private val context: Context) : +internal class RssAdapter(var items: ArrayList = arrayListOf(), private val context: Context) : RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RssViewHolder { diff --git a/app/src/main/kotlin/rasel/lunar/launcher/helpers/Constants.kt b/app/src/main/kotlin/rasel/lunar/launcher/helpers/Constants.kt index 1b674cd..87d366b 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/helpers/Constants.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/helpers/Constants.kt @@ -63,6 +63,7 @@ internal class Constants { const val KEY_SHORTCUT_COUNT = "shortcut_count" const val KEY_ICON_SIZE = "icon_size" const val KEY_RSS_URL = "rss_url" + const val KEY_RSS_URL2 = "rss_url2" const val KEY_LOCK_METHOD = "lock_method" /* --- */ diff --git a/app/src/main/kotlin/rasel/lunar/launcher/settings/childs/Misc.kt b/app/src/main/kotlin/rasel/lunar/launcher/settings/childs/Misc.kt index 910cadc..27d693a 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/settings/childs/Misc.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/settings/childs/Misc.kt @@ -34,6 +34,7 @@ import rasel.lunar.launcher.helpers.Constants.Companion.KEY_BACK_HOME import rasel.lunar.launcher.helpers.Constants.Companion.KEY_ICON_SIZE import rasel.lunar.launcher.helpers.Constants.Companion.KEY_LOCK_METHOD import rasel.lunar.launcher.helpers.Constants.Companion.KEY_RSS_URL +import rasel.lunar.launcher.helpers.Constants.Companion.KEY_RSS_URL2 import rasel.lunar.launcher.helpers.Constants.Companion.KEY_SHORTCUT_COUNT import rasel.lunar.launcher.helpers.Constants.Companion.MAX_SHORTCUTS import rasel.lunar.launcher.helpers.UniUtils.Companion.isRooted @@ -58,6 +59,7 @@ internal class Misc : BottomSheetDialogFragment() { binding.shortcutCount.value = settingsPrefs!!.getInt(KEY_SHORTCUT_COUNT, MAX_SHORTCUTS).toFloat() binding.iconSize.value = settingsPrefs!!.getInt(KEY_ICON_SIZE, DEFAULT_ICON_SIZE).toFloat() binding.inputFeedUrl.text = SpannableStringBuilder(settingsPrefs!!.getString(KEY_RSS_URL, "")) + binding.inputFeedUrl2.text = SpannableStringBuilder(settingsPrefs!!.getString(KEY_RSS_URL2, "")) when (settingsPrefs!!.getInt(KEY_LOCK_METHOD, 0)) { 0 -> binding.selectLockNegative.isChecked = true @@ -115,6 +117,8 @@ internal class Misc : BottomSheetDialogFragment() { super.onDismiss(dialog) settingsPrefs!!.edit().putString(KEY_RSS_URL, Objects.requireNonNull(binding.inputFeedUrl.text).toString().trim { it <= ' ' }).apply() + settingsPrefs!!.edit().putString(KEY_RSS_URL2, + Objects.requireNonNull(binding.inputFeedUrl2.text).toString().trim { it <= ' ' }).apply() } } diff --git a/app/src/main/res/layout/settings_misc.xml b/app/src/main/res/layout/settings_misc.xml index 92cf84d..93010e3 100644 --- a/app/src/main/res/layout/settings_misc.xml +++ b/app/src/main/res/layout/settings_misc.xml @@ -100,8 +100,30 @@ android:gravity="center" android:imeOptions="actionDone" android:singleLine="true" /> - + + + + + + + + + app:layout_constraintTop_toBottomOf="@+id/feedInputLayout2" />