diff --git a/app/src/main/java/com/topjohnwu/magisk/InstallFragment.java b/app/src/main/java/com/topjohnwu/magisk/InstallFragment.java index 8f6d9562d..aedc39ec8 100644 --- a/app/src/main/java/com/topjohnwu/magisk/InstallFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/InstallFragment.java @@ -1,10 +1,10 @@ package com.topjohnwu.magisk; -import android.app.Fragment; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; import android.support.v7.widget.CardView; import android.view.LayoutInflater; import android.view.View; diff --git a/app/src/main/java/com/topjohnwu/magisk/LogFragment.java b/app/src/main/java/com/topjohnwu/magisk/LogFragment.java index 456555298..020cb9a92 100644 --- a/app/src/main/java/com/topjohnwu/magisk/LogFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/LogFragment.java @@ -1,9 +1,9 @@ package com.topjohnwu.magisk; -import android.app.Fragment; import android.os.Bundle; import android.support.design.widget.TabLayout; +import android.support.v4.app.Fragment; import android.support.v4.view.ViewPager; import android.view.LayoutInflater; import android.view.View; diff --git a/app/src/main/java/com/topjohnwu/magisk/MagiskHideFragment.java b/app/src/main/java/com/topjohnwu/magisk/MagiskHideFragment.java index 1568bcbff..1c264a9a6 100644 --- a/app/src/main/java/com/topjohnwu/magisk/MagiskHideFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/MagiskHideFragment.java @@ -1,9 +1,9 @@ package com.topjohnwu.magisk; -import android.app.Fragment; import android.content.pm.PackageManager; import android.os.Bundle; import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; import android.support.v4.view.MenuItemCompat; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.RecyclerView; diff --git a/app/src/main/java/com/topjohnwu/magisk/MagiskLogFragment.java b/app/src/main/java/com/topjohnwu/magisk/MagiskLogFragment.java index ad69ab15e..0dcb818fd 100644 --- a/app/src/main/java/com/topjohnwu/magisk/MagiskLogFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/MagiskLogFragment.java @@ -2,7 +2,6 @@ package com.topjohnwu.magisk; import android.Manifest; import android.annotation.SuppressLint; -import android.app.Fragment; import android.content.Intent; import android.content.pm.PackageManager; import android.net.Uri; @@ -14,6 +13,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.design.widget.Snackbar; import android.support.v4.app.ActivityCompat; +import android.support.v4.app.Fragment; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.Menu; diff --git a/app/src/main/java/com/topjohnwu/magisk/MainActivity.java b/app/src/main/java/com/topjohnwu/magisk/MainActivity.java index a4e82a44b..859f43bfa 100644 --- a/app/src/main/java/com/topjohnwu/magisk/MainActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/MainActivity.java @@ -1,8 +1,6 @@ package com.topjohnwu.magisk; import android.Manifest; -import android.app.Fragment; -import android.app.FragmentTransaction; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; @@ -13,6 +11,8 @@ import android.preference.PreferenceManager; import android.support.annotation.NonNull; import android.support.design.widget.NavigationView; import android.support.v4.app.ActivityCompat; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentTransaction; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; @@ -30,8 +30,6 @@ import butterknife.ButterKnife; public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, CallbackHandler.EventListener { - private static final String SELECTED_ITEM_ID = "SELECTED_ITEM_ID"; - private final Handler mDrawerHandler = new Handler(); private SharedPreferences prefs; @@ -39,7 +37,6 @@ public class MainActivity extends AppCompatActivity @BindView(R.id.drawer_layout) DrawerLayout drawer; @BindView(R.id.nav_view) public NavigationView navigationView; - private int mSelectedId = R.id.status; private float toolbarElevation; @Override @@ -79,15 +76,11 @@ public class MainActivity extends AppCompatActivity drawer.addDrawerListener(toggle); toggle.syncState(); - if (savedInstanceState == null) { - navigate(mSelectedId, true); - navigationView.setCheckedItem(mSelectedId); - } else { - mSelectedId = savedInstanceState.getInt(SELECTED_ITEM_ID); - } + navigate(R.id.status); navigationView.setNavigationItemSelectedListener(this); CallbackHandler.register(Global.Events.reloadMainActivity, this); + } @Override @@ -112,12 +105,6 @@ public class MainActivity extends AppCompatActivity super.onDestroy(); } - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - outState.putInt(SELECTED_ITEM_ID, mSelectedId); - } - @Override public void onBackPressed() { if (drawer.isDrawerOpen(navigationView)) { @@ -129,9 +116,8 @@ public class MainActivity extends AppCompatActivity @Override public boolean onNavigationItemSelected(@NonNull final MenuItem menuItem) { - mSelectedId = menuItem.getItemId(); mDrawerHandler.removeCallbacksAndMessages(null); - mDrawerHandler.postDelayed(() -> navigate(menuItem.getItemId(), false), 250); + mDrawerHandler.postDelayed(() -> navigate(menuItem.getItemId()), 250); drawer.closeDrawer(navigationView); return true; } @@ -159,29 +145,28 @@ public class MainActivity extends AppCompatActivity } } - public void navigate(int itemId, boolean now) { - toolbar.setElevation(toolbarElevation); + public void navigate(int itemId) { switch (itemId) { case R.id.status: - displayFragment(new StatusFragment(), "status", now); + displayFragment(new StatusFragment(), "status", true); break; case R.id.install: - displayFragment(new InstallFragment(), "install", now); + displayFragment(new InstallFragment(), "install", true); break; case R.id.superuser: - displayFragment(new SuperuserFragment(), "superuser", now); + displayFragment(new SuperuserFragment(), "superuser", true); break; case R.id.modules: - displayFragment(new ModulesFragment(), "modules", now); + displayFragment(new ModulesFragment(), "modules", true); break; case R.id.downloads: - displayFragment(new ReposFragment(), "downloads", now); + displayFragment(new ReposFragment(), "downloads", true); break; case R.id.magiskhide: - displayFragment(new MagiskHideFragment(), "magiskhide", now); + displayFragment(new MagiskHideFragment(), "magiskhide", true); break; case R.id.log: - displayFragment(new LogFragment(), "log", now); + displayFragment(new LogFragment(), "log", false); toolbar.setElevation(0); break; case R.id.settings: @@ -193,11 +178,10 @@ public class MainActivity extends AppCompatActivity } } - private void displayFragment(@NonNull Fragment navFragment, String tag, boolean now) { - FragmentTransaction transaction = getFragmentManager().beginTransaction(); - if (!now) { - transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); - } - transaction.replace(R.id.content_frame, navFragment, tag).commit(); + private void displayFragment(@NonNull Fragment navFragment, String tag, boolean setElevation) { + FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); + transaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); + transaction.replace(R.id.content_frame, navFragment, tag).commitNow(); + if (setElevation) toolbar.setElevation(toolbarElevation); } } diff --git a/app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java b/app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java index 0c5a79c50..bd9bf9c31 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java @@ -1,11 +1,11 @@ package com.topjohnwu.magisk; import android.app.Activity; -import android.app.Fragment; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; diff --git a/app/src/main/java/com/topjohnwu/magisk/ReposFragment.java b/app/src/main/java/com/topjohnwu/magisk/ReposFragment.java index 35f12bbaf..d5739d01b 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ReposFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/ReposFragment.java @@ -1,8 +1,8 @@ package com.topjohnwu.magisk; -import android.app.Fragment; import android.os.Bundle; import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; import android.support.v4.view.MenuItemCompat; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.RecyclerView; diff --git a/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java b/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java index f875db801..2f85e2695 100644 --- a/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java @@ -1,12 +1,12 @@ package com.topjohnwu.magisk; import android.app.AlertDialog; -import android.app.Fragment; -import android.app.FragmentTransaction; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentTransaction; import android.support.v4.widget.SwipeRefreshLayout; import android.view.LayoutInflater; import android.view.View; diff --git a/app/src/main/java/com/topjohnwu/magisk/SuLogFragment.java b/app/src/main/java/com/topjohnwu/magisk/SuLogFragment.java index 7d0366ae4..c47545d2c 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SuLogFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/SuLogFragment.java @@ -1,8 +1,7 @@ package com.topjohnwu.magisk; - -import android.app.Fragment; import android.os.Bundle; +import android.support.v4.app.Fragment; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; diff --git a/app/src/main/java/com/topjohnwu/magisk/SuperuserFragment.java b/app/src/main/java/com/topjohnwu/magisk/SuperuserFragment.java index 16ab3d380..7f4d24dd3 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SuperuserFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/SuperuserFragment.java @@ -1,10 +1,9 @@ package com.topjohnwu.magisk; - -import android.app.Fragment; import android.content.pm.PackageManager; import android.os.Bundle; import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; diff --git a/app/src/main/java/com/topjohnwu/magisk/adapters/TabFragmentAdapter.java b/app/src/main/java/com/topjohnwu/magisk/adapters/TabFragmentAdapter.java index fdc639034..c7daba71f 100644 --- a/app/src/main/java/com/topjohnwu/magisk/adapters/TabFragmentAdapter.java +++ b/app/src/main/java/com/topjohnwu/magisk/adapters/TabFragmentAdapter.java @@ -1,8 +1,9 @@ package com.topjohnwu.magisk.adapters; -import android.app.Fragment; -import android.app.FragmentManager; -import android.support.v13.app.FragmentPagerAdapter; + +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; import java.util.ArrayList; import java.util.List;