Skip to content

Commit

Permalink
Hide widgets menu when the user is not in testing
Browse files Browse the repository at this point in the history
The feature is still experimental and I haven't had the chance to fix
the kinks — for now, let's sweep it under the rug.
  • Loading branch information
F4uzan committed Oct 11, 2018
1 parent 59d8f8f commit ce2643c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/src/main/java/mono/hg/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,11 @@ public class MainActivity extends AppCompatActivity
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_main, menu);

if (PreferenceHelper.hasWidget()) {
// Only show widget options when the user is in testing mode.
if (!PreferenceHelper.isTesting()) {
menu.removeItem(R.id.action_remove_widget);
menu.removeItem(R.id.action_add_widget);
} else if (PreferenceHelper.hasWidget()) {
// When there is a widget, we don't want 'add widget' menu to be visible.
menu.removeItem(R.id.action_add_widget);
} else {
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/java/mono/hg/helpers/PreferenceHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ public class PreferenceHelper {
private static boolean icon_hide, list_order, shade_view,
keyboard_focus, web_search_enabled, comfy_padding,
tap_to_drawer, favourites_panel, dismiss_panel,
static_favourites_panel, adaptive_shade, has_widget;
static_favourites_panel, adaptive_shade, has_widget,
is_testing;
private static String launch_anim;
private static String app_theme;
private static String search_provider_set;
Expand All @@ -17,6 +18,10 @@ public class PreferenceHelper {
private static SharedPreferences preferences;
private static SharedPreferences.Editor editor;

public static boolean isTesting() {
return is_testing;
}

public static boolean hasWidget() {
return has_widget;
}
Expand Down Expand Up @@ -109,6 +114,7 @@ public static void initPreference(Context context) {
}

public static void fetchPreference() {
is_testing = preferences.getBoolean("is_grandma", false);
has_widget = preferences.getBoolean("has_widget", false);
launch_anim = preferences.getString("launch_anim", "default");
icon_hide = preferences.getBoolean("icon_hide_switch", false);
Expand Down

0 comments on commit ce2643c

Please sign in to comment.