Bug 1337238 - Reuse some id resources in layout xml file
No need to create id resources for common widgets in each activities, e.g.
toolbar. Reuse id resources to make less ambiguous when invoking `findViewById`
In BrowserApp and CustomTabsActivity, both of them have ActionBar and
Progress-Bar. Let them use the same id resource.
MozReview-Commit-ID: 2jq18dwlBlm
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -639,17 +639,17 @@ public class BrowserApp extends GeckoApp
}
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
}
});
- mProgressView = (ToolbarProgressView) findViewById(R.id.progress);
+ mProgressView = (ToolbarProgressView) findViewById(R.id.page_progress);
mProgressView.setDynamicToolbar(mDynamicToolbar);
mBrowserToolbar.setProgressBar(mProgressView);
// Initialize Tab History Controller.
tabHistoryController = new TabHistoryController(new OnShowTabHistory() {
@Override
public void onShowHistory(final List<TabHistoryPage> historyPageList, final int toIndex) {
runOnUiThread(new Runnable() {
--- a/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
@@ -70,17 +70,17 @@ public class CustomTabsActivity extends
toolbarColor = getIntent().getIntExtra(EXTRA_TOOLBAR_COLOR, DEFAULT_ACTION_BAR_COLOR);
}
// Translucent color does not make sense for toolbar color. Ensure it is 0xFF.
toolbarColor = 0xFF000000 | toolbarColor;
setThemeFromToolbarColor();
- final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ final Toolbar toolbar = (Toolbar) findViewById(R.id.actionbar);
setSupportActionBar(toolbar);
final ActionBar actionBar = getSupportActionBar();
bindNavigationCallback(toolbar);
actionBarPresenter = new ActionBarPresenter(actionBar);
actionBarPresenter.displayUrlOnly(getIntent().getDataString());
actionBarPresenter.setBackgroundColor(toolbarColor, getWindow());
actionBar.setDisplayHomeAsUpEnabled(true);
--- a/mobile/android/base/resources/layout/customtabs_activity.xml
+++ b/mobile/android/base/resources/layout/customtabs_activity.xml
@@ -12,27 +12,27 @@
android:layout_height="match_parent">
<!--
This layout is quite complex because GeckoApp accesses all view groups
in this tree. In a perfect world this should just include a GeckoView.
-->
<android.support.v7.widget.Toolbar
- android:id="@+id/toolbar"
+ android:id="@id/actionbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="4dp"
android:background="@color/text_and_tabs_tray_grey"
app:layout_scrollFlags="scroll|enterAlways"/>
<view class="org.mozilla.gecko.GeckoApp$MainLayout"
android:id="@+id/main_layout"
android:layout_width="match_parent"
- android:layout_below="@+id/toolbar"
+ android:layout_below="@id/actionbar"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<RelativeLayout android:id="@+id/gecko_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/tablet_tab_strip"
android:layout_above="@+id/find_in_page">
--- a/mobile/android/base/resources/layout/gecko_app.xml
+++ b/mobile/android/base/resources/layout/gecko_app.xml
@@ -139,26 +139,26 @@
android:id="@+id/browser_toolbar"
style="@style/BrowserToolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true"
android:background="@drawable/url_bar_bg"/>
- <org.mozilla.gecko.ActionModeCompatView android:id="@+id/actionbar"
+ <org.mozilla.gecko.ActionModeCompatView android:id="@id/actionbar"
android:layout_height="match_parent"
android:layout_width="match_parent"
style="@style/GeckoActionBar.ActionMode"/>
</ViewFlipper>
</LinearLayout>
- <org.mozilla.gecko.toolbar.ToolbarProgressView android:id="@+id/progress"
+ <org.mozilla.gecko.toolbar.ToolbarProgressView android:id="@id/page_progress"
android:layout_width="match_parent"
android:layout_height="14dp"
android:layout_marginTop="-8dp"
android:layout_below="@id/browser_chrome"
android:src="@drawable/progress"
android:background="@null"
android:visibility="gone" />
--- a/mobile/android/base/resources/values/ids.xml
+++ b/mobile/android/base/resources/values/ids.xml
@@ -14,11 +14,13 @@
<item type="id" name="recycler_view_click_support" />
<item type="id" name="range_list"/>
<item type="id" name="pref_header_general"/>
<item type="id" name="pref_header_privacy"/>
<item type="id" name="pref_header_search"/>
<item type="id" name="updateServicePermissionNotification" />
<item type="id" name="websiteContentNotification" />
<item type="id" name="foregroundNotification" />
+ <item type="id" name="actionbar"/>
<item type="id" name="action_button"/>
+ <item type="id" name="page_progress"/>
</resources>