Skip to content

Commit 1d2a460

Browse files
committed
Fixed Show/Hide of amazon apps
Fixed Name/Icon of FireTV Launcher and Settings
1 parent e641f4c commit 1d2a460

File tree

9 files changed

+92
-42
lines changed

9 files changed

+92
-42
lines changed

FiredTVLauncher/AppsAdapter.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public AppsAdapter ()
2929
public override int Count { get { return Apps.Count; } }
3030
public override AppInfo this [int index] { get { return Apps [index]; } }
3131

32+
3233
public override View GetView (int position, View convertView, ViewGroup parent)
3334
{
3435
var app = Apps [position];
@@ -43,7 +44,7 @@ public override View GetView (int position, View convertView, ViewGroup parent)
4344

4445
var imgView = view.FindViewById<ImageView> (Resource.Id.imageIcon);
4546

46-
imgView.SetImageDrawable (app.GetIcon (Context, null));
47+
imgView.SetImageDrawable (app.GetIcon (Context, Settings.ICON_OVERRIDES));
4748

4849
var iconBg = view.FindViewById<LinearLayout> (Resource.Id.iconBackground);
4950

@@ -62,7 +63,7 @@ public void Sort ()
6263
public void Reload ()
6364
{
6465

65-
AppInfo.FetchApps (Context, Settings.Instance.Blacklist, true, r => {
66+
AppInfo.FetchApps (Context, Settings.Instance.Blacklist, true, Settings.RENAME_MAPPINGS, r => {
6667

6768
Apps.Clear ();
6869
Apps.AddRange (r);

FiredTVLauncher/FiredTVLauncher.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,11 @@
508508
<AndroidResource Include="Resources\layout\ReorderLayout.axml" />
509509
<AndroidResource Include="Resources\drawable\wallpaper.png" />
510510
<AndroidResource Include="Resources\layout\seek_bar_preference.xml" />
511+
<AndroidResource Include="Resources\drawable\firetvicon.png" />
512+
<AndroidResource Include="Resources\drawable-xxhdpi\wallpaper.png" />
513+
<AndroidResource Include="Resources\drawable-xhdpi\wallpaper.png" />
514+
<AndroidResource Include="Resources\drawable-mdpi\wallpaper.png" />
515+
<AndroidResource Include="Resources\drawable-hdpi\wallpaper.png" />
511516
</ItemGroup>
512517
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
513518
<ItemGroup>

FiredTVLauncher/Properties/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="114" android:versionName="1.1.4" package="com.altusapps.firedtvlauncher">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="115" android:versionName="1.1.5" package="com.altusapps.firedtvlauncher">
33
<uses-sdk android:minSdkVersion="17" />
44
<application android:label="FiredTV" android:icon="@drawable/icon" android:theme="@style/AppTheme">
55
</application>

FiredTVLauncher/ReorderActivity.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public override View GetView (int position, View convertView, ViewGroup parent)
128128
LayoutInflater.FromContext (Context).Inflate (Resource.Layout.ReorderItemLayout, parent, false);
129129

130130
view.FindViewById<TextView> (Resource.Id.textName).Text = app.Name;
131-
view.FindViewById<ImageView> (Resource.Id.imageIcon).SetImageDrawable (app.GetIcon (Context));
131+
view.FindViewById<ImageView> (Resource.Id.imageIcon).SetImageDrawable (app.GetIcon (Context, Settings.ICON_OVERRIDES));
132132

133133
// view.FindViewById<ImageButton> (Resource.Id.buttonUp).Click += (sender, e) => {
134134
// Console.WriteLine ("UP");
@@ -173,7 +173,7 @@ public void Reorder (int position, bool up)
173173

174174
public void Reload ()
175175
{
176-
AppInfo.FetchApps (Context, Settings.Instance.Blacklist, true, r => {
176+
AppInfo.FetchApps (Context, Settings.Instance.Blacklist, true, Settings.RENAME_MAPPINGS, r => {
177177

178178
Apps.Clear ();
179179
Apps.AddRange (r);

FiredTVLauncher/Resources/Resource.designer.cs

Lines changed: 10 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FiredTVLauncher/Settings.cs

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ public class Settings
2121
public const string HOME_PACKAGE_NAME = "com.amazon.tv.launcher";
2222
public const string HOME_CLASS_NAME = "com.amazon.tv.launcher.ui.HomeActivity";
2323

24+
public static readonly Dictionary<string, int> ICON_OVERRIDES = new Dictionary<string, int> {
25+
{ Android.Provider.Settings.ActionSettings, Resource.Drawable.settings },
26+
{ Settings.HOME_PACKAGE_NAME, Resource.Drawable.firetvicon },
27+
};
28+
29+
public static readonly Dictionary<string, string> RENAME_MAPPINGS = new Dictionary<string, string> {
30+
{ Settings.HOME_PACKAGE_NAME, "FireTV Home" }
31+
};
32+
2433
static Settings()
2534
{
2635
Instance = new Settings ();
@@ -34,17 +43,6 @@ public Settings ()
3443
Blacklist = new List<string> ();
3544
Ordering = new List<AppOrder> ();
3645

37-
if (Blacklist.Count <= 0) {
38-
Blacklist.Add ("com.altusapps.firedtvlauncher");
39-
Blacklist.Add ("com.amazon.avod");
40-
Blacklist.Add ("com.amazon.bueller.photos");
41-
Blacklist.Add ("com.amazon.device.bluetoothdfu");
42-
Blacklist.Add ("com.amazon.device.gmo");
43-
Blacklist.Add ("com.amazon.venezia");
44-
Blacklist.Add ("com.amazon.storm.lightning.tutorial");
45-
Blacklist.Add ("com.broadcom.wfd.client");
46-
}
47-
4846
HideLabels = false;
4947
LabelFontSize = 18;
5048
TwentyFourHourTime = false;
@@ -85,9 +83,16 @@ public Settings ()
8583

8684
public static string GetWallpaperFilename()
8785
{
88-
var path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
89-
var filename = System.IO.Path.Combine(path, "wallpaper.png");
90-
return filename;
86+
try {
87+
var path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
88+
var filename = System.IO.Path.Combine(path, "wallpaper.png");
89+
90+
if (File.Exists (filename))
91+
return filename;
92+
} catch {
93+
}
94+
95+
return null;
9196
}
9297

9398

@@ -185,6 +190,17 @@ public static void Load ()
185190
catch (Exception ex) {
186191
Log.Error ("Failed to load settings file", ex);
187192
Settings.Instance = new Settings ();
193+
194+
if (Settings.Instance.Blacklist.Count <= 0) {
195+
Settings.Instance.Blacklist.Add ("com.altusapps.firedtvlauncher");
196+
Settings.Instance.Blacklist.Add ("com.amazon.avod");
197+
Settings.Instance.Blacklist.Add ("com.amazon.bueller.photos");
198+
Settings.Instance.Blacklist.Add ("com.amazon.device.bluetoothdfu");
199+
Settings.Instance.Blacklist.Add ("com.amazon.device.gmo");
200+
Settings.Instance.Blacklist.Add ("com.amazon.venezia");
201+
Settings.Instance.Blacklist.Add ("com.amazon.storm.lightning.tutorial");
202+
Settings.Instance.Blacklist.Add ("com.broadcom.wfd.client");
203+
}
188204
}
189205
}
190206

FiredTVLauncher/SettingsActivity.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ protected override void OnCreate (Bundle bundle)
3838
{
3939
base.OnCreate (bundle);
4040

41+
Settings.Load ();
42+
4143
// Create your application here
4244
AddPreferencesFromResource (Resource.Layout.Settings);
4345

@@ -78,7 +80,18 @@ protected override void OnCreate (Bundle bundle)
7880
prefWallpaperUse.PreferenceChange += SaveHandler;
7981
prefWallpaperUrl.PreferenceChange += SaveHandler;
8082

83+
prefAppNameFontSize.EditText.Text = Settings.Instance.LabelFontSize.ToString ();
84+
prefHideLabels.Checked = Settings.Instance.HideLabels;
85+
prefHideTopBar.Checked = Settings.Instance.HideTopBar;
86+
prefHideDate.Checked = Settings.Instance.HideDate;
87+
prefHideTime.Checked = Settings.Instance.HideTime;
88+
prefTwentyFourHourTime.Checked = Settings.Instance.TwentyFourHourTime;
8189
prefDisableHomeDetect.Checked = Settings.Instance.DisableHomeDetection;
90+
prefIconBackgroundAlpha.EditText.Text = Settings.Instance.IconBackgroundAlpha.ToString ();
91+
prefLabelBackgroundAlpha.EditText.Text = Settings.Instance.LabelBackgroundAlpha.ToString ();
92+
prefTopInfoBarBackgroundAlpha.EditText.Text = Settings.Instance.TopInfoBarBackgroundAlpha.ToString ();
93+
prefWallpaperUse.Checked = Settings.Instance.WallpaperUse;
94+
8295
}
8396

8497
void SaveHandler (object sender, Preference.PreferenceChangeEventArgs e)
@@ -116,7 +129,7 @@ void SaveHandler (object sender, Preference.PreferenceChangeEventArgs e)
116129
Settings.Instance.TopInfoBarBackgroundAlpha = ParseAlpha (prefTopInfoBarBackgroundAlpha.EditText.Text);
117130

118131
if (sender == prefWallpaperUse)
119-
Settings.Instance.WallpaperUse = prefWallpaperUse.Checked;
132+
Settings.Instance.WallpaperUse = !prefWallpaperUse.Checked;
120133

121134
if (sender == prefWallpaperUrl) {
122135

FiredTVLauncher/SettingsAppShowHideActivity.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ protected override void OnResume ()
4848
{
4949
base.OnResume ();
5050

51+
AndroidHUD.AndHUD.Shared.Show (this, "Loading Apps...");
52+
5153
adapter.Reload ();
54+
55+
AndroidHUD.AndHUD.Shared.Dismiss (this);
5256
}
5357
}
5458

@@ -69,7 +73,7 @@ public override View GetView (int position, View convertView, ViewGroup parent)
6973
LayoutInflater.FromContext (this.Context).Inflate (Resource.Layout.AppShowHideItem, parent, false);
7074

7175
view.FindViewById<TextView> (Resource.Id.textView).Text = app.Name;
72-
var icon = app.GetIcon (Context);
76+
var icon = app.GetIcon (Context, Settings.ICON_OVERRIDES);
7377
if (icon != null)
7478
view.FindViewById<ImageView> (Resource.Id.imageView).SetImageDrawable (icon);
7579

@@ -80,7 +84,7 @@ public override View GetView (int position, View convertView, ViewGroup parent)
8084

8185
public void Reload ()
8286
{
83-
AppInfo.FetchApps (Context, null, true, r => {
87+
AppInfo.FetchApps (Context, null, true, Settings.RENAME_MAPPINGS, r => {
8488

8589
apps.Clear ();
8690
apps.AddRange (r);

Launchers.Common/AppInfo.cs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,38 @@ public Drawable GetIcon (Context context, Dictionary<string, int> overrideIcons
4545

4646
if (App != null) {
4747

48-
foreach (var m in metrics) {
49-
try {
50-
var pkgContext = context.CreatePackageContext (App.PackageName, PackageContextFlags.IgnoreSecurity);
51-
icon = pkgContext.Resources.GetDrawableForDensity (App.Icon, (int)m);
52-
break;
53-
} catch {
54-
continue;
48+
var pkgContext = context.CreatePackageContext (App.PackageName, PackageContextFlags.IgnoreSecurity);
49+
50+
// Try and find the override first
51+
if (overrideIcons.ContainsKey (App.PackageName)) {
52+
icon = context.Resources.GetDrawable (overrideIcons [App.PackageName]);
53+
} else {
54+
// otherwise, go through the densities one by one
55+
foreach (var m in metrics) {
56+
try {
57+
icon = pkgContext.Resources.GetDrawableForDensity (App.Icon, (int)m);
58+
break;
59+
} catch {
60+
continue;
61+
}
5562
}
5663
}
64+
5765
} else {
58-
if (overrideIcons.ContainsKey ("Settings"))
59-
icon = context.Resources.GetDrawable (overrideIcons ["Settings"]);
66+
if (overrideIcons.ContainsKey (PackageName))
67+
icon = context.Resources.GetDrawable (overrideIcons [PackageName]);
6068
}
6169

6270
return icon;
6371
}
6472

6573

6674

67-
public static void FetchApps (Context context, List<string> ignoredPackageNames, bool addSettings, Action<List<AppInfo>> callback)
75+
public static void FetchApps (Context context, List<string> ignoredPackageNames, bool addSettings, Dictionary<string, string> renameMappings, Action<List<AppInfo>> callback)
6876
{
6977
Task.Factory.StartNew (() => {
7078

71-
var apps = FetchApps (context, addSettings, ignoredPackageNames);
79+
var apps = FetchApps (context, addSettings, ignoredPackageNames, renameMappings);
7280

7381
callback (apps);
7482
});
@@ -94,8 +102,8 @@ static List<AppInfo> FetchApps (Context context, bool addSettings = false, List<
94102
continue;
95103

96104
var label = app.LoadLabel (context.PackageManager);
97-
if (renameMappings.ContainsKey (context.PackageName))
98-
label = renameMappings [context.PackageName];
105+
if (renameMappings.ContainsKey (app.PackageName))
106+
label = renameMappings [app.PackageName];
99107

100108
results.Add (new AppInfo {
101109
LaunchIntent = launchIntent,

0 commit comments

Comments
 (0)