Commit 0676deec authored by Nate Fischer's avatar Nate Fischer Committed by Commit Bot

AW: remove NavigationMenuHelper

No change to logic. This inlines NavigationMenuHelper because the logic
should only ever be called from the MainActivity now.

This also removes one piece of commented-out code that was accidentally
uploaded in a previous CL.

Bug: 1017532
Test: Manually confirm navigation is the same
Change-Id: I3d574316f8de55d80f5a2a6f5010b6d3f053a424
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2123646Reviewed-by: default avatarHazem Ashmawy <hazems@chromium.org>
Commit-Queue: Nate Fischer <ntfschr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754545}
parent b2a39960
...@@ -41,7 +41,6 @@ android_library("devui_java") { ...@@ -41,7 +41,6 @@ android_library("devui_java") {
"java/src/org/chromium/android_webview/devui/PersistentErrorView.java", "java/src/org/chromium/android_webview/devui/PersistentErrorView.java",
"java/src/org/chromium/android_webview/devui/WebViewPackageError.java", "java/src/org/chromium/android_webview/devui/WebViewPackageError.java",
"java/src/org/chromium/android_webview/devui/util/CrashInfoLoader.java", "java/src/org/chromium/android_webview/devui/util/CrashInfoLoader.java",
"java/src/org/chromium/android_webview/devui/util/NavigationMenuHelper.java",
"java/src/org/chromium/android_webview/devui/util/UnuploadedFilesStateLoader.java", "java/src/org/chromium/android_webview/devui/util/UnuploadedFilesStateLoader.java",
"java/src/org/chromium/android_webview/devui/util/UploadedCrashesInfoLoader.java", "java/src/org/chromium/android_webview/devui/util/UploadedCrashesInfoLoader.java",
"java/src/org/chromium/android_webview/devui/util/WebViewCrashInfoCollector.java", "java/src/org/chromium/android_webview/devui/util/WebViewCrashInfoCollector.java",
......
...@@ -215,7 +215,6 @@ public class FlagsFragment extends Fragment { ...@@ -215,7 +215,6 @@ public class FlagsFragment extends Fragment {
* @param state the state of the flag. * @param state the state of the flag.
*/ */
private void formatListEntry(View toggleableFlag, int state) { private void formatListEntry(View toggleableFlag, int state) {
// View stateIndicator = toggleableFlag.findViewById(R.id.flag_state_indicator);
TextView flagName = toggleableFlag.findViewById(R.id.flag_name); TextView flagName = toggleableFlag.findViewById(R.id.flag_name);
if (state == /* STATE_DEFAULT */ 0) { if (state == /* STATE_DEFAULT */ 0) {
// Unset the compound drawable. // Unset the compound drawable.
......
...@@ -7,7 +7,9 @@ import android.content.Intent; ...@@ -7,7 +7,9 @@ import android.content.Intent;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter; import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Settings;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
...@@ -19,7 +21,6 @@ import androidx.fragment.app.FragmentActivity; ...@@ -19,7 +21,6 @@ import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction; import androidx.fragment.app.FragmentTransaction;
import org.chromium.android_webview.devui.util.NavigationMenuHelper;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
import java.util.HashMap; import java.util.HashMap;
...@@ -156,13 +157,17 @@ public class MainActivity extends FragmentActivity { ...@@ -156,13 +157,17 @@ public class MainActivity extends FragmentActivity {
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
NavigationMenuHelper.inflate(this, menu); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
getMenuInflater().inflate(R.menu.navigation_menu, menu);
}
return true; return true;
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
if (NavigationMenuHelper.onOptionsItemSelected(this, item)) { if (item.getItemId() == R.id.nav_menu_switch_provider
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
startActivity(new Intent(Settings.ACTION_WEBVIEW_SETTINGS));
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.android_webview.devui.util;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.provider.Settings;
import android.view.Menu;
import android.view.MenuItem;
import androidx.fragment.app.FragmentActivity;
import org.chromium.android_webview.devui.R;
/**
* Helper class for menu to access external tools. Built-in tools should be handled by Fragments in
* the MainActivity.
*/
public final class NavigationMenuHelper {
/**
* Inflate the navigation menu in the given {@code activity} options menu.
*
* This should be called inside {@link Activity#onCreateOptionsMenu} or
* {@link android.support.v4.app.Fragment#onCreateOptionsMenu}.
*/
public static void inflate(Activity activity, Menu menu) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
return;
}
activity.getMenuInflater().inflate(R.menu.navigation_menu, menu);
}
/**
* Handle {@code onOptionsItemSelected} event for navigation menu.
*
* This should be called inside {@code Activity#onOptionsItemSelected} method.
* @return {@code true} if the item selection event is consumed.
*/
public static boolean onOptionsItemSelected(FragmentActivity activity, MenuItem item) {
if (item.getItemId() == R.id.nav_menu_switch_provider
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
activity.startActivity(new Intent(Settings.ACTION_WEBVIEW_SETTINGS));
return true;
}
return false;
}
// Do not instantiate this class.
private NavigationMenuHelper() {}
}
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