Added support for "showOnlyCustom"

Added support for "showOnlyCustom": Only shows apps specified in appnames.txt.
This commit is contained in:
tverona1
2019-07-28 00:23:09 -07:00
parent 4b3bd0b2ee
commit a5c987acef
6 changed files with 178 additions and 81 deletions
+12 -1
View File
@@ -27,10 +27,21 @@ namespace QuestAppLauncher
public int cols = 3;
}
// Grid size, specified as cols x rows
public GridSize gridSize = new GridSize();
// Whether to show 2D apps
public bool show2D = false;
// Category types: "none", "automatic", "custom"
// Whether to only show apps that are explicitly specified in appnames.txt file.
// If true, this will not show installed apps that are not in appnames.txt. This
// is useful for organizing the launcher with a highly curated list of apps.
public bool showOnlyCustom = false;
// Category types: "none", "auto", "custom":
// - none: No categories - all apps are listed in a single pane
// - auto: Apps are automatically categorized into 3 tabs - Quest, Go/GearVr, 2D
// - custom: Apps are categorized according to appnames.txt file
public string categoryType = Category_Auto;
}
+27 -5
View File
@@ -21,8 +21,10 @@ namespace QuestAppLauncher
public int Index;
public string PackageName;
public string AppName;
public string AutoTabName;
public string Tab1Name;
public string Tab2Name;
public bool IsOverride;
}
// File name of app name overrides
@@ -138,16 +140,19 @@ namespace QuestAppLauncher
/// <summary>
/// Static method to delete the excludedFile
/// </summary>
/// <param name="packageName"></param>
static public void DeleteExcludedApksFile()
/// <returns>true if file exists</returns>
static public bool DeleteExcludedAppsFile()
{
var persistentDataPath = UnityEngine.Application.persistentDataPath;
var excludedPackageNamesFilePath = Path.Combine(persistentDataPath, ExcludedPackagesFile);
if (File.Exists(excludedPackageNamesFilePath))
{
File.Delete(excludedPackageNamesFilePath);
return true;
}
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
return false;
}
public void SetGridSize(GameObject gridContent, int rows, int cols)
@@ -276,7 +281,7 @@ namespace QuestAppLauncher
tabName = Tab_Go;
}
apps.Add(packageName, new ProcessedApp { PackageName = packageName, Index = i, Tab1Name = tabName, AppName = appName });
apps.Add(packageName, new ProcessedApp { PackageName = packageName, Index = i, AutoTabName = tabName, Tab1Name = tabName, AppName = appName });
Debug.LogFormat("[{0}] package: {1}, name: {2}, tab: {3}", i, packageName, appName, tabName);
yield return null;
}
@@ -334,8 +339,10 @@ namespace QuestAppLauncher
PackageName = apps[entry[0]].PackageName,
Index = apps[entry[0]].Index,
AppName = appName,
AutoTabName = apps[entry[0]].AutoTabName,
Tab1Name = tab1 ?? apps[entry[0]].Tab1Name,
Tab2Name = tab2
Tab2Name = tab2,
IsOverride = true
};
}
}
@@ -387,6 +394,7 @@ namespace QuestAppLauncher
List<string> tabs;
bool isNoneTab = false;
bool isAutoTab = false;
if (config.categoryType.Equals(Config.Category_None, StringComparison.OrdinalIgnoreCase))
{
@@ -402,6 +410,7 @@ namespace QuestAppLauncher
tabs.Add(Tab_Quest);
tabs.Add(Tab_Go);
tabs.Add(Tab_2D);
isAutoTab = true;
}
else
{
@@ -468,11 +477,24 @@ namespace QuestAppLauncher
// Sort by app name
foreach (var app in apps.OrderBy(key => key.Value.AppName))
{
if (config.showOnlyCustom && !app.Value.IsOverride)
{
// Since showOnlyCustom is set, skip apps that are not in the appnames.txt file
Debug.LogFormat("Skipping non-Show Only Custom [{0}] Package: {1}, name: {2}",
app.Value.Index, app.Value.PackageName, app.Value.AppName);
continue;
}
if (isNoneTab)
{
// No tabs, so use the special "None" tab
yield return AddCellToGrid(app.Value, gridContents[Tab_None].transform, iconOverrides, currentActivity);
}
else if (isAutoTab)
{
// Add to auto (built-in) tabs
yield return AddCellToGrid(app.Value, gridContents[app.Value.AutoTabName].transform, iconOverrides, currentActivity);
}
else
{
// Add to tab1
-1
View File
@@ -64,7 +64,6 @@ namespace QuestAppLauncher
else if (isInBounds)
{
// We are outside the scroll view and were previously inside, so disable box colliders on children.
Debug.Log("ScrollRectOverride: Disabling box colliders on children");
foreach (var boxCollider in this.content.gameObject.GetComponentsInChildren<BoxCollider>())
{
boxCollider.enabled = false;
+24 -3
View File
@@ -20,11 +20,14 @@ namespace QuestAppLauncher
public GameObject gridRowsText;
public GameObject gridPopulation;
public GameObject show2DToggle;
public GameObject showOnlyCustomToggle;
public Toggle tabsNone;
public Toggle tabsAuto;
public Toggle tabsCustom;
private bool deletedHiddenAppsFile = false;
private Config config = new Config();
public void OpenSettings()
@@ -53,6 +56,9 @@ namespace QuestAppLauncher
// Set 2D toggle
this.show2DToggle.GetComponent<Toggle>().SetIsOnWithoutNotify(this.config.show2D);
// Set ShowOnlyCustom toggle
this.showOnlyCustomToggle.GetComponent<Toggle>().SetIsOnWithoutNotify(this.config.showOnlyCustom);
// Set tab mode
if (this.config.categoryType.Equals(Config.Category_None, StringComparison.OrdinalIgnoreCase))
{
@@ -82,8 +88,12 @@ namespace QuestAppLauncher
public void DeleteExcludedApksFile()
{
Debug.Log("Delete Excluded Apk List");
QuestAppLauncher.GridPopulation.DeleteExcludedApksFile();
Debug.Log("Delete Excluded App List");
if (!this.deletedHiddenAppsFile)
{
this.deletedHiddenAppsFile = QuestAppLauncher.GridPopulation.DeleteExcludedAppsFile();
}
}
public void UpdateGridColText()
@@ -124,6 +134,14 @@ namespace QuestAppLauncher
saveConfig = true;
}
// Update ShowOnlyCustom toggle
var showOnlyCustom = this.showOnlyCustomToggle.GetComponent<Toggle>().isOn;
if (showOnlyCustom != this.config.showOnlyCustom)
{
this.config.showOnlyCustom = showOnlyCustom;
saveConfig = true;
}
// Update tabbing
string tabMode;
if (this.tabsNone.isOn)
@@ -150,8 +168,11 @@ namespace QuestAppLauncher
if (saveConfig)
{
ConfigPersistence.SaveConfig(this.config);
}
// Re-populate grid
// If we touched the config file or we deleted the hidden apps file, re-populate the grid
if (saveConfig || deletedHiddenAppsFile)
{
Debug.Log("Re-populating panel");
this.gridPopulation.GetComponent<GridPopulation>().StartPopulate();
}