From 5d047a394bd15b0d8fca4230a7ef083fea55224f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 25 Jul 2021 15:25:22 +0200 Subject: [PATCH] Scoped storage: Make the home button simply go to the root of the current directory tree. --- Common/File/Path.cpp | 1 - UI/MainScreen.cpp | 15 ++++++++++----- UI/MainScreen.h | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Common/File/Path.cpp b/Common/File/Path.cpp index 96110fc2d3..5f0e905dda 100644 --- a/Common/File/Path.cpp +++ b/Common/File/Path.cpp @@ -279,7 +279,6 @@ Path Path::GetRootVolume() const { return Path(path); } #endif - return Path("/"); } diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 8596294209..6f7872289a 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -540,10 +540,15 @@ UI::EventReturn GameBrowser::StorageClick(UI::EventParams &e) { return UI::EVENT_DONE; } -UI::EventReturn GameBrowser::HomeClick(UI::EventParams &e) { - if (System_GetPropertyBool(SYSPROP_ANDROID_SCOPED_STORAGE)) { - if (path_.GetPath().Type() == PathType::CONTENT_URI) { - path_.SetPath(path_.GetPath().GetRootVolume()); +UI::EventReturn GameBrowser::OnHomeClick(UI::EventParams &e) { + if (path_.GetPath().Type() == PathType::CONTENT_URI) { + Path rootPath = path_.GetPath().GetRootVolume(); + if (rootPath != path_.GetPath()) { + SetPath(rootPath); + return UI::EVENT_DONE; + } + if (System_GetPropertyBool(SYSPROP_ANDROID_SCOPED_STORAGE)) { + // There'll be no sensible home, ignore. return UI::EVENT_DONE; } } @@ -669,7 +674,7 @@ void GameBrowser::Refresh() { if (browseFlags_ & BrowseFlags::NAVIGATE) { topBar->Add(new Spacer(2.0f)); topBar->Add(new TextView(path_.GetFriendlyPath().c_str(), ALIGN_VCENTER | FLAG_WRAP_TEXT, true, new LinearLayoutParams(FILL_PARENT, 64.0f, 1.0f))); - topBar->Add(new Choice(ImageID("I_HOME"), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Handle(this, &GameBrowser::HomeClick); + topBar->Add(new Choice(ImageID("I_HOME"), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Handle(this, &GameBrowser::OnHomeClick); if (System_GetPropertyBool(SYSPROP_HAS_ADDITIONAL_STORAGE)) { topBar->Add(new Choice(ImageID("I_SDCARD"), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Handle(this, &GameBrowser::StorageClick); } diff --git a/UI/MainScreen.h b/UI/MainScreen.h index 9a19321755..6b15f06427 100644 --- a/UI/MainScreen.h +++ b/UI/MainScreen.h @@ -74,7 +74,7 @@ private: UI::EventReturn LastClick(UI::EventParams &e); UI::EventReturn BrowseClick(UI::EventParams &e); UI::EventReturn StorageClick(UI::EventParams &e); - UI::EventReturn HomeClick(UI::EventParams &e); + UI::EventReturn OnHomeClick(UI::EventParams &e); UI::EventReturn PinToggleClick(UI::EventParams &e); UI::EventReturn GridSettingsClick(UI::EventParams &e); UI::EventReturn OnRecentClear(UI::EventParams &e);