0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-16 16:25:11 +00:00

Merge pull request #562 from cl-ement05/dev

Minor UI/UX improvements (show changelog after update + show pathy of saved log file)
This commit is contained in:
Tornike Khintibidze 2021-05-29 17:39:47 +04:00 committed by GitHub
commit a7ee51a90b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 3 deletions

View file

@ -11,20 +11,25 @@ import android.view.MenuInflater
import android.view.ViewGroup import android.view.ViewGroup
import androidx.fragment.app.viewModels import androidx.fragment.app.viewModels
import androidx.localbroadcastmanager.content.LocalBroadcastManager import androidx.localbroadcastmanager.content.LocalBroadcastManager
import androidx.preference.PreferenceManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.crowdin.platform.util.inflateWithCrowdin import com.crowdin.platform.util.inflateWithCrowdin
import com.google.android.flexbox.FlexboxLayoutManager import com.google.android.flexbox.FlexboxLayoutManager
import com.google.android.flexbox.JustifyContent import com.google.android.flexbox.JustifyContent
import com.vanced.manager.BuildConfig.VERSION_CODE
import com.vanced.manager.R import com.vanced.manager.R
import com.vanced.manager.adapter.ExpandableAppListAdapter import com.vanced.manager.adapter.ExpandableAppListAdapter
import com.vanced.manager.adapter.LinkAdapter import com.vanced.manager.adapter.LinkAdapter
import com.vanced.manager.adapter.SponsorAdapter import com.vanced.manager.adapter.SponsorAdapter
import com.vanced.manager.core.ui.base.BindingFragment import com.vanced.manager.core.ui.base.BindingFragment
import com.vanced.manager.core.ui.ext.showDialog
import com.vanced.manager.databinding.FragmentHomeBinding import com.vanced.manager.databinding.FragmentHomeBinding
import com.vanced.manager.ui.dialogs.AppInfoDialog
import com.vanced.manager.ui.dialogs.DialogContainer.installAlertBuilder import com.vanced.manager.ui.dialogs.DialogContainer.installAlertBuilder
import com.vanced.manager.ui.viewmodels.HomeViewModel import com.vanced.manager.ui.viewmodels.HomeViewModel
import com.vanced.manager.ui.viewmodels.HomeViewModelFactory import com.vanced.manager.ui.viewmodels.HomeViewModelFactory
import com.vanced.manager.utils.isFetching import com.vanced.manager.utils.isFetching
import com.vanced.manager.utils.manager
class HomeFragment : BindingFragment<FragmentHomeBinding>() { class HomeFragment : BindingFragment<FragmentHomeBinding>() {
@ -56,6 +61,20 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>() {
homeRefresh.setOnRefreshListener { viewModel.fetchData() } homeRefresh.setOnRefreshListener { viewModel.fetchData() }
isFetching.observe(viewLifecycleOwner) { homeRefresh.isRefreshing = it } isFetching.observe(viewLifecycleOwner) { homeRefresh.isRefreshing = it }
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
if (prefs.contains("LastVersionCode")) {
if (prefs.getInt("LastVersionCode", -1) < VERSION_CODE) {
showDialog(
AppInfoDialog.newInstance(
appName = getString(R.string.app_name),
appIcon = R.mipmap.ic_launcher,
changelog = manager.value?.string("changelog")
)
)
prefs.edit().putInt("LastVersionCode", VERSION_CODE).apply()
}
} else prefs.edit().putInt("LastVersionCode", VERSION_CODE).apply()
recyclerAppList.apply { recyclerAppList.apply {
layoutManager = LinearLayoutManager(requireActivity()) layoutManager = LinearLayoutManager(requireActivity())
adapter = ExpandableAppListAdapter(requireActivity(), viewModel /*, tooltip*/) adapter = ExpandableAppListAdapter(requireActivity(), viewModel /*, tooltip*/)

View file

@ -38,14 +38,15 @@ class LogFragment : BindingFragment<FragmentLogBinding>() {
val hour = calendar.get(Calendar.HOUR_OF_DAY) val hour = calendar.get(Calendar.HOUR_OF_DAY)
val minute = calendar.get(Calendar.MINUTE) val minute = calendar.get(Calendar.MINUTE)
val second = calendar.get(Calendar.SECOND) val second = calendar.get(Calendar.SECOND)
val savePath = requireActivity().getExternalFilesDir("logs")?.path + "/$year$month${day}_$hour$minute$second.log"
val log = val log =
File(requireActivity().getExternalFilesDir("logs")?.path + "/$year$month${day}_$hour$minute$second.log") File(savePath)
FileWriter(log).apply { FileWriter(log).apply {
append(logs) append(logs)
flush() flush()
close() close()
} }
Toast.makeText(requireActivity(), R.string.logs_saved, Toast.LENGTH_SHORT).show() Toast.makeText(requireActivity(), getString(R.string.logs_saved, savePath), Toast.LENGTH_SHORT).show()
} catch (e: IOException) { } catch (e: IOException) {
Toast.makeText(requireActivity(), R.string.logs_not_saved, Toast.LENGTH_SHORT) Toast.makeText(requireActivity(), R.string.logs_not_saved, Toast.LENGTH_SHORT)
.show() .show()

View file

@ -73,7 +73,7 @@
<!-- Logs --> <!-- Logs -->
<string name="logs_not_saved">Could not save logs</string> <string name="logs_not_saved">Could not save logs</string>
<string name="logs_saved">Successfully saved logs</string> <string name="logs_saved">Successfully saved logs to %1$s</string>
<!-- Dialogs --> <!-- Dialogs -->
<string name="advanced">Details</string> <string name="advanced">Details</string>