From c81e3f3d02bc78096cd86058c19515caf364f4ef Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 29 May 2018 16:51:03 +0200 Subject: [PATCH] define default main tab as 0th element to support flavors --- .../fdroid/views/main/MainActivity.java | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/views/main/MainActivity.java b/app/src/main/java/org/fdroid/fdroid/views/main/MainActivity.java index bcf7813f0..185a1e364 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/main/MainActivity.java +++ b/app/src/main/java/org/fdroid/fdroid/views/main/MainActivity.java @@ -1,3 +1,25 @@ +/* + * Copyright (C) 2016-2017 Peter Serwylo + * Copyright (C) 2017 Christine Emrich + * Copyright (C) 2017 Hans-Christoph Steiner + * Copyright (C) 2018 Senecto Limited + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + package org.fdroid.fdroid.views.main; import android.app.SearchManager; @@ -65,7 +87,7 @@ public class MainActivity extends AppCompatActivity implements BottomNavigationB private RecyclerView pager; private MainViewAdapter adapter; private BottomNavigationBar bottomNavigation; - private int selectedMenuId = R.id.whats_new; + private int selectedMenuId; private TextBadgeItem updatesBadge; @Override @@ -110,7 +132,9 @@ public class MainActivity extends AppCompatActivity implements BottomNavigationB LocalBroadcastManager.getInstance(this).registerReceiver(onUpdateableAppsChanged, updateableAppsFilter); if (savedInstanceState != null) { - selectedMenuId = savedInstanceState.getInt(STATE_SELECTED_MENU_ID, R.id.whats_new); + selectedMenuId = savedInstanceState.getInt(STATE_SELECTED_MENU_ID, (int) adapter.getItemId(0)); + } else { + selectedMenuId = (int) adapter.getItemId(0); } setSelectedMenuInNav();