Commit 9058e266 authored by Geoffrey Métais's avatar Geoffrey Métais

Remove visual selection background in nav menu

parent bef126e8
......@@ -3,7 +3,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:id="@+id/scrollable_group"
android:checkableBehavior="all"
android:checkableBehavior="none"
android:orderInCategory="1">
<item
android:id="@+id/nav_video"
......
......@@ -29,19 +29,12 @@ import android.database.Cursor;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.navigation.NavigationView;
import androidx.fragment.app.Fragment;
import androidx.core.view.GravityCompat;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.view.ActionMode;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.widget.FilterQueryProvider;
import com.google.android.material.navigation.NavigationView;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.medialibrary.Medialibrary;
import org.videolan.vlc.BuildConfig;
......@@ -70,6 +63,14 @@ import org.videolan.vlc.util.Util;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.view.ActionMode;
import androidx.core.view.GravityCompat;
import androidx.fragment.app.Fragment;
public class MainActivity extends ContentActivity implements FilterQueryProvider, ExtensionManagerService.ExtensionManagerActivity {
public final static String TAG = "VLC/MainActivity";
......@@ -111,7 +112,6 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
}
}, 500);
}
mNavigator.reloadPreferences();
}
/* Set up the action bar */
......@@ -420,10 +420,11 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
return;
default:
final int currentId = mNavigator.getCurrentFragmentId();
if (id != currentId && mNavigationView.getMenu().findItem(id) != null) {
if (mNavigationView.getMenu().findItem(currentId) != null)
mNavigationView.getMenu().findItem(currentId).setChecked(false);
mNavigationView.getMenu().findItem(id).setChecked(true);
final MenuItem target = mNavigationView.getMenu().findItem(id);
if (id != currentId && target != null) {
final MenuItem current = mNavigationView.getMenu().findItem(currentId);
if (current != null) current.setChecked(false);
target.setChecked(true);
/* Save the tab status in pref */
mSettings.edit().putInt("fragment_id", id).apply();
}
......
......@@ -23,18 +23,13 @@
package org.videolan.vlc.gui.helpers
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
import android.content.Intent
import android.content.SharedPreferences
import android.os.Bundle
import com.google.android.material.navigation.NavigationView
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.collection.SimpleArrayMap
import android.util.Log
import android.view.MenuItem
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
import org.videolan.vlc.R
import org.videolan.vlc.extensions.ExtensionManagerService
import org.videolan.vlc.extensions.api.VLCExtensionItem
......@@ -67,13 +62,16 @@ class Navigator(private val activity: MainActivity,
state?.let {
val fm = activity.supportFragmentManager
currentFragment = fm.getFragment(it, "current_fragment")
currentFragmentId = it.getInt("current", settings.getInt("fragment_id", defaultFragmentId))
Log.d(TAG, "init currentFragmentId $currentFragmentId, default $defaultFragmentId")
//Restore fragments stack
restoreFragmentsStack(fm)
}
}
@OnLifecycleEvent(Lifecycle.Event.ON_START)
fun onStart() {
if (currentFragment === null && !currentIdIsExtension()) showFragment(settings.getInt("fragment_id", defaultFragmentId))
}
private fun getNewFragment(id: Int): androidx.fragment.app.Fragment {
return when (id) {
R.id.nav_audio -> AudioBrowserFragment()
......@@ -121,11 +119,6 @@ class Navigator(private val activity: MainActivity,
}
}
@OnLifecycleEvent(Lifecycle.Event.ON_START)
fun onStart() {
if (currentFragment === null && !currentIdIsExtension()) showFragment(currentFragmentId)
}
/**
* Show a secondary fragment.
*/
......@@ -141,7 +134,7 @@ class Navigator(private val activity: MainActivity,
fun currentIdIsExtension() = idIsExtension(currentFragmentId)
private fun idIsExtension(id: Int) = id <= 100
private fun idIsExtension(id: Int) = id in 1..100
private fun clearBackstackFromClass(clazz: Class<*>) {
val fm = activity.supportFragmentManager
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment