From 6d4af947a570517d0275175dfac8f126692cd6e2 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Fri, 17 Jul 2020 10:54:51 +0200 Subject: [PATCH] Default number of columns in subscription fragment --- .../danoeh/antennapod/fragment/SubscriptionFragment.java | 8 ++++++-- app/src/main/res/values-sw600dp/integers.xml | 4 ++++ app/src/main/res/values/integers.xml | 4 ++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/values-sw600dp/integers.xml create mode 100644 app/src/main/res/values/integers.xml diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java index ba5d44b4d..7ae28130e 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java @@ -90,7 +90,7 @@ public class SubscriptionFragment extends Fragment { View root = inflater.inflate(R.layout.fragment_subscriptions, container, false); ((AppCompatActivity) getActivity()).setSupportActionBar(root.findViewById(R.id.toolbar)); subscriptionGridLayout = root.findViewById(R.id.subscriptions_grid); - subscriptionGridLayout.setNumColumns(prefs.getInt(PREF_NUM_COLUMNS, 3)); + subscriptionGridLayout.setNumColumns(prefs.getInt(PREF_NUM_COLUMNS, getDefaultNumOfColumns())); registerForContextMenu(subscriptionGridLayout); subscriptionAddButton = root.findViewById(R.id.subscriptions_add); progressBar = root.findViewById(R.id.progLoading); @@ -102,7 +102,7 @@ public class SubscriptionFragment extends Fragment { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.subscriptions, menu); - int columns = prefs.getInt(PREF_NUM_COLUMNS, 3); + int columns = prefs.getInt(PREF_NUM_COLUMNS, getDefaultNumOfColumns()); menu.findItem(R.id.subscription_num_columns_2).setChecked(columns == 2); menu.findItem(R.id.subscription_num_columns_3).setChecked(columns == 3); menu.findItem(R.id.subscription_num_columns_4).setChecked(columns == 4); @@ -200,6 +200,10 @@ public class SubscriptionFragment extends Fragment { }, error -> Log.e(TAG, Log.getStackTraceString(error))); } + private int getDefaultNumOfColumns() { + return getResources().getInteger(R.integer.subscriptions_default_num_of_columns); + } + @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); diff --git a/app/src/main/res/values-sw600dp/integers.xml b/app/src/main/res/values-sw600dp/integers.xml new file mode 100644 index 000000000..fb43e5de6 --- /dev/null +++ b/app/src/main/res/values-sw600dp/integers.xml @@ -0,0 +1,4 @@ + + + 5 + \ No newline at end of file diff --git a/app/src/main/res/values/integers.xml b/app/src/main/res/values/integers.xml new file mode 100644 index 000000000..5b45a8b1e --- /dev/null +++ b/app/src/main/res/values/integers.xml @@ -0,0 +1,4 @@ + + + 3 + \ No newline at end of file