Browse Source

Change Navigation Drawer layout slightly, fix dark theme for drawer

master
Anthony Restaino 10 years ago
parent
commit
d9e888e8a9
  1. 4
      AndroidManifest.xml
  2. BIN
      res/drawable-hdpi/ic_action_tabs_dark.png
  3. BIN
      res/drawable-hdpi/ic_action_tabs_light.png
  4. BIN
      res/drawable-xhdpi/ic_action_tabs_dark.png
  5. BIN
      res/drawable-xhdpi/ic_action_tabs_light.png
  6. BIN
      res/drawable-xxhdpi/ic_action_tabs_dark.png
  7. BIN
      res/drawable-xxhdpi/ic_action_tabs_light.png
  8. 7
      res/drawable/list_bg_dark.xml
  9. 7
      res/drawable/list_bg_light.xml
  10. 18
      res/layout/bookmark_drawer.xml
  11. 5
      res/layout/bookmark_list_item.xml
  12. 47
      res/layout/tab_drawer.xml
  13. 13
      res/layout/tab_list_item.xml
  14. 4
      res/values-v21/styles.xml
  15. 2
      res/values/attr.xml
  16. 4
      res/values/colors.xml
  17. 1
      res/values/strings.xml
  18. 4
      res/values/styles.xml
  19. 102
      src/acr/browser/lightning/BrowserActivity.java

4
AndroidManifest.xml

@ -3,8 +3,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="acr.browser.lightning" package="acr.browser.lightning"
android:versionCode="72" android:versionCode="74"
android:versionName="4.0.4a" > android:versionName="4.0.6a" >
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" /> <uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" />

BIN
res/drawable-hdpi/ic_action_tabs_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B

BIN
res/drawable-hdpi/ic_action_tabs_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

BIN
res/drawable-xhdpi/ic_action_tabs_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 B

BIN
res/drawable-xhdpi/ic_action_tabs_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

BIN
res/drawable-xxhdpi/ic_action_tabs_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

BIN
res/drawable-xxhdpi/ic_action_tabs_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

7
res/drawable/list_bg_dark.xml

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/selected_dark" android:state_pressed="true"/>
<item android:drawable="@color/selected_dark" android:state_activated="true"/>
</selector>

7
res/drawable/list_bg_light.xml

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/selected_light" android:state_pressed="true"/>
<item android:drawable="@color/selected_light" android:state_activated="true"/>
</selector>

18
res/layout/bookmark_drawer.xml

@ -13,35 +13,35 @@
android:id="@+id/bookmark_title" android:id="@+id/bookmark_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
android:background="?attr/listBackground" android:background="?attr/dividerColor"
android:clickable="true"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" > android:orientation="horizontal" >
<ImageView <ImageView
android:id="@+id/starIcon" android:id="@+id/starIcon"
android:layout_width="24dp" android:layout_width="26dp"
android:layout_height="24dp" android:layout_height="26dp"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginLeft="16dp" android:layout_marginLeft="15dp"
android:layout_marginRight="16dp" android:layout_marginRight="15dp"
android:contentDescription="Favicon" android:contentDescription="Favicon"
android:gravity="center_vertical" android:gravity="center_vertical"
android:src="?attr/starDrawable" > android:src="?attr/starDrawable" >
</ImageView> </ImageView>
<TextView <TextView
android:id="@+id/text2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_toRightOf="@+id/starIcon" android:layout_toRightOf="@+id/starIcon"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical" android:gravity="center_vertical"
android:maxLines="1" android:maxLines="1"
android:minHeight="?android:attr/listPreferredItemHeightSmall" android:minHeight="?android:attr/listPreferredItemHeight"
android:text="@string/action_bookmarks" android:text="@string/action_bookmarks"
android:textAppearance="?android:attr/textAppearanceListItemSmall" /> android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout> </RelativeLayout>
<View <View

5
res/layout/bookmark_list_item.xml

@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp" android:layout_height="56dp"
android:background="@drawable/list_bg" android:background="?attr/selectedBackground"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" > android:orientation="horizontal" >
@ -20,12 +20,13 @@
android:id="@+id/textBookmark" android:id="@+id/textBookmark"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:ellipsize="end" android:ellipsize="end"
android:fontFamily="sans-serif-light" android:fontFamily="sans-serif-light"
android:gravity="center_vertical" android:gravity="center_vertical"
android:maxLines="1" android:maxLines="1"
android:minHeight="?android:attr/listPreferredItemHeightSmall" android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:paddingRight="16dp"
android:singleLine="true" android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceListItemSmall" /> android:textAppearance="?android:attr/textAppearanceListItemSmall" />

47
res/layout/tab_drawer.xml

@ -10,37 +10,37 @@
android:orientation="vertical" > android:orientation="vertical" >
<RelativeLayout <RelativeLayout
android:id="@+id/new_tab_button"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
android:background="?attr/listBackground" android:background="?attr/dividerColor"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" > android:orientation="horizontal" >
<ImageView <ImageView
android:id="@+id/plusIcon" android:id="@+id/plusIcon"
android:layout_width="24dp" android:layout_width="26dp"
android:layout_height="24dp" android:layout_height="26dp"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginLeft="16dp" android:layout_marginLeft="15dp"
android:layout_marginRight="16dp" android:layout_marginRight="15dp"
android:contentDescription="@string/action_new_tab" android:contentDescription="@string/action_new_tab"
android:gravity="center_vertical" android:gravity="center_vertical"
android:src="?attr/plusDrawable" > android:src="?attr/tabDrawable" >
</ImageView> </ImageView>
<TextView <TextView
android:id="@+id/text1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_toRightOf="@+id/plusIcon" android:layout_toRightOf="@+id/plusIcon"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical" android:gravity="center_vertical"
android:maxLines="1" android:maxLines="1"
android:minHeight="?android:attr/listPreferredItemHeightSmall" android:minHeight="?android:attr/listPreferredItemHeight"
android:text="@string/action_new_tab" android:text="@string/tabs"
android:textAppearance="?android:attr/textAppearanceListItemSmall" /> android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout> </RelativeLayout>
<View <View
@ -65,12 +65,12 @@
android:background="?attr/dividerColor" /> android:background="?attr/dividerColor" />
<LinearLayout <LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
android:background="?attr/dividerColor"
android:baselineAligned="false" android:baselineAligned="false"
android:orientation="horizontal" android:orientation="horizontal"
android:weightSum="2" > android:weightSum="3" >
<RelativeLayout <RelativeLayout
android:id="@+id/action_back" android:id="@+id/action_back"
@ -92,6 +92,27 @@
android:src="?attr/arrowBackDrawable" /> android:src="?attr/arrowBackDrawable" />
</RelativeLayout> </RelativeLayout>
<RelativeLayout
android:id="@+id/new_tab_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/listBackground"
android:clickable="true" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:contentDescription="@string/action_new_tab"
android:paddingBottom="4dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingTop="4dp"
android:src="?attr/plusDrawable" >
</ImageView>
</RelativeLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/action_forward" android:id="@+id/action_forward"
android:layout_width="match_parent" android:layout_width="match_parent"

13
res/layout/tab_list_item.xml

@ -2,7 +2,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp" android:layout_height="56dp"
android:background="@drawable/list_bg" android:background="?attr/selectedBackground"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" > android:orientation="horizontal" >
@ -23,6 +23,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_toLeftOf="@+id/deleteButton" android:layout_toLeftOf="@+id/deleteButton"
android:layout_toRightOf="@+id/faviconTab" android:layout_toRightOf="@+id/faviconTab"
android:ellipsize="end" android:ellipsize="end"
@ -35,16 +37,15 @@
<ImageView <ImageView
android:id="@+id/deleteButton" android:id="@+id/deleteButton"
android:layout_width="30dp" android:layout_width="48dp"
android:layout_height="30dp" android:layout_height="48dp"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginRight="13dp" android:layout_marginRight="4dp"
android:alpha="0.5"
android:background="?attr/actionBarItemBackground" android:background="?attr/actionBarItemBackground"
android:contentDescription="Delete Tab" android:contentDescription="Delete Tab"
android:gravity="center_vertical" android:gravity="center_vertical"
android:padding="3dp" android:padding="12dp"
android:src="?attr/deleteDrawable" > android:src="?attr/deleteDrawable" >
</ImageView> </ImageView>

4
res/values-v21/styles.xml

@ -57,6 +57,8 @@
<item name="deleteDrawable">@drawable/ic_action_delete</item> <item name="deleteDrawable">@drawable/ic_action_delete</item>
<item name="starDrawable">@drawable/ic_action_star</item> <item name="starDrawable">@drawable/ic_action_star</item>
<item name="dividerColor">@color/divider_light</item> <item name="dividerColor">@color/divider_light</item>
<item name="tabDrawable">@drawable/ic_action_tabs_light</item>
<item name="selectedBackground">@drawable/list_bg_light</item>
</style> </style>
<style name="Theme.DarkTheme" parent="Theme.AppCompat"> <style name="Theme.DarkTheme" parent="Theme.AppCompat">
@ -83,6 +85,8 @@
<item name="deleteDrawable">@drawable/ic_action_delete_dark</item> <item name="deleteDrawable">@drawable/ic_action_delete_dark</item>
<item name="starDrawable">@drawable/ic_action_star_dark</item> <item name="starDrawable">@drawable/ic_action_star_dark</item>
<item name="dividerColor">@color/divider_dark</item> <item name="dividerColor">@color/divider_dark</item>
<item name="tabDrawable">@drawable/ic_action_tabs_dark</item>
<item name="selectedBackground">@drawable/list_bg_dark</item>
</style> </style>
</resources> </resources>

2
res/values/attr.xml

@ -16,7 +16,9 @@
<attr name="plusDrawable" format="reference|color" /> <attr name="plusDrawable" format="reference|color" />
<attr name="deleteDrawable" format="reference|color" /> <attr name="deleteDrawable" format="reference|color" />
<attr name="starDrawable" format="reference|color" /> <attr name="starDrawable" format="reference|color" />
<attr name="tabDrawable" format="reference|color" />
<attr name="dividerColor" format="reference|color" /> <attr name="dividerColor" format="reference|color" />
<attr name="selectedBackground" format="reference|color" />
<declare-styleable name="AnimatedProgressBar"> <declare-styleable name="AnimatedProgressBar">
<attr name="progressColor" format="color" /> <attr name="progressColor" format="color" />

4
res/values/colors.xml

@ -28,4 +28,8 @@
<color name="divider_dark">#1EFFFFFF</color> <color name="divider_dark">#1EFFFFFF</color>
<color name="divider_light">#1E000000</color> <color name="divider_light">#1E000000</color>
<color name="selected_dark">#0FFFFFFF</color>
<color name="selected_light">#0F000000</color>
</resources> </resources>

1
res/values/strings.xml

@ -213,4 +213,5 @@
<string name="invert_color">Invert color</string> <string name="invert_color">Invert color</string>
<string name="dark_theme">Use Dark Theme</string> <string name="dark_theme">Use Dark Theme</string>
<string name="change_after_restart">The theme change will take effect after you restart the browser.</string> <string name="change_after_restart">The theme change will take effect after you restart the browser.</string>
<string name="tabs">Tabs</string>
</resources> </resources>

4
res/values/styles.xml

@ -56,7 +56,9 @@
<item name="plusDrawable">@drawable/ic_action_plus</item> <item name="plusDrawable">@drawable/ic_action_plus</item>
<item name="deleteDrawable">@drawable/ic_action_delete</item> <item name="deleteDrawable">@drawable/ic_action_delete</item>
<item name="starDrawable">@drawable/ic_action_star</item> <item name="starDrawable">@drawable/ic_action_star</item>
<item name="tabDrawable">@drawable/ic_action_tabs_light</item>
<item name="dividerColor">@color/divider_light</item> <item name="dividerColor">@color/divider_light</item>
<item name="selectedBackground">@drawable/list_bg_light</item>
</style> </style>
<style name="Theme.DarkTheme" parent="Theme.AppCompat"> <style name="Theme.DarkTheme" parent="Theme.AppCompat">
@ -82,7 +84,9 @@
<item name="plusDrawable">@drawable/ic_action_plus_dark</item> <item name="plusDrawable">@drawable/ic_action_plus_dark</item>
<item name="deleteDrawable">@drawable/ic_action_delete_dark</item> <item name="deleteDrawable">@drawable/ic_action_delete_dark</item>
<item name="starDrawable">@drawable/ic_action_star_dark</item> <item name="starDrawable">@drawable/ic_action_star_dark</item>
<item name="tabDrawable">@drawable/ic_action_tabs_dark</item>
<item name="dividerColor">@color/divider_dark</item> <item name="dividerColor">@color/divider_dark</item>
<item name="selectedBackground">@drawable/list_bg_dark</item>
</style> </style>
<style name="overFlowButtonStyle" parent="@style/Widget.AppCompat.ActionButton.Overflow"> <style name="overFlowButtonStyle" parent="@style/Widget.AppCompat.ActionButton.Overflow">

102
src/acr/browser/lightning/BrowserActivity.java

@ -125,7 +125,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private synchronized void initialize() { private synchronized void initialize() {
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
getWindow().setBackgroundDrawable(null);
mToolbar = (Toolbar) findViewById(R.id.toolbar); mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar); setSupportActionBar(mToolbar);
@ -147,7 +147,6 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
} }
mActivity = this; mActivity = this;
mClickHandler = new ClickHandler(this); mClickHandler = new ClickHandler(this);
getWindow().setBackgroundDrawable(null);
mBrowserFrame = (FrameLayout) findViewById(R.id.content_frame); mBrowserFrame = (FrameLayout) findViewById(R.id.content_frame);
mToolbarLayout = (LinearLayout) findViewById(R.id.toolbar_layout); mToolbarLayout = (LinearLayout) findViewById(R.id.toolbar_layout);
mPageLayout = (LinearLayout) findViewById(R.id.main_layout); mPageLayout = (LinearLayout) findViewById(R.id.main_layout);
@ -896,7 +895,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mIsNewIntent = false; mIsNewIntent = false;
selectItem(position); showTab(mWebViews.get(position));
} }
} }
@ -1107,18 +1106,10 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
// don't delete the tab because the browser will close and mess stuff up // don't delete the tab because the browser will close and mess stuff up
} }
private void selectItem(final int position) {
// update selected item and title, then close the drawer
showTab(mWebViews.get(position));
}
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public void onTrimMemory(int level) { public void onTrimMemory(int level) {
if (level > TRIM_MEMORY_RUNNING_MODERATE if (level > TRIM_MEMORY_MODERATE && Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
&& Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
Log.d(Constants.TAG, "Low Memory, Free Memory"); Log.d(Constants.TAG, "Low Memory, Free Memory");
for (LightningView view : mWebViews) { for (LightningView view : mWebViews) {
view.getWebView().freeMemory(); view.getWebView().freeMemory();
@ -1553,8 +1544,6 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
}); });
mToolbarLayout.setBackgroundColor(finalColor);
mPageLayout.setBackgroundColor(finalColor);
anim.setDuration(300); anim.setDuration(300);
anim.start(); anim.start();
} }
@ -1778,23 +1767,6 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@Override @Override
public void updateProgress(int n) { public void updateProgress(int n) {
/*
* if (n > mProgressBar.getProgress()) { ObjectAnimator animator =
* ObjectAnimator.ofInt(mProgressBar, "progress", n);
* animator.setDuration(200); animator.setInterpolator(new
* DecelerateInterpolator()); animator.start(); } else if (n <
* mProgressBar.getProgress()) { ObjectAnimator animator =
* ObjectAnimator.ofInt(mProgressBar, "progress", 0, n);
* animator.setDuration(200); animator.setInterpolator(new
* DecelerateInterpolator()); animator.start(); } if (n >= 100) {
* Handler handler = new Handler(); handler.postDelayed(new Runnable() {
*
* @Override public void run() {
* mProgressBar.setVisibility(View.INVISIBLE); setIsFinishedLoading(); }
* }, 200);
*
* } else { mProgressBar.setVisibility(View.VISIBLE); setIsLoading(); }
*/
if (n >= 100) { if (n >= 100) {
setIsFinishedLoading(); setIsFinishedLoading();
} else { } else {
@ -2534,42 +2506,42 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@Override @Override
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()) { switch (v.getId()) {
case R.id.action_back: case R.id.action_back:
if (mCurrentView != null) { if (mCurrentView != null) {
if (mCurrentView.canGoBack()) { if (mCurrentView.canGoBack()) {
mCurrentView.goBack(); mCurrentView.goBack();
} else { } else {
deleteTab(mDrawerListLeft.getCheckedItemPosition()); deleteTab(mDrawerListLeft.getCheckedItemPosition());
}
} }
} break;
break; case R.id.action_forward:
case R.id.action_forward: if (mCurrentView != null) {
if (mCurrentView != null) { if (mCurrentView.canGoForward()) {
if (mCurrentView.canGoForward()) { mCurrentView.goForward();
mCurrentView.goForward(); }
} }
} break;
break; case R.id.arrow_button:
case R.id.arrow_button: if (mSearch != null && mSearch.hasFocus()) {
if (mSearch != null && mSearch.hasFocus()) { mCurrentView.requestFocus();
mCurrentView.requestFocus(); } else {
} else { mDrawerLayout.openDrawer(mDrawerLeft);
mDrawerLayout.openDrawer(mDrawerLeft); }
} break;
break; case R.id.new_tab_button:
case R.id.new_tab_button: newTab(null, true);
newTab(null, true); break;
break; case R.id.button_next:
case R.id.button_next: mCurrentView.getWebView().findNext(false);
mCurrentView.getWebView().findNext(false); break;
break; case R.id.button_back:
case R.id.button_back: mCurrentView.getWebView().findNext(true);
mCurrentView.getWebView().findNext(true); break;
break; case R.id.button_quit:
case R.id.button_quit: mCurrentView.getWebView().clearMatches();
mCurrentView.getWebView().clearMatches(); mSearchBar.setVisibility(View.GONE);
mSearchBar.setVisibility(View.GONE); break;
break;
} }
} }
} }

Loading…
Cancel
Save