Browse Source

Navigation Drawer UI update

master
Anthony Restaino 11 years ago
parent
commit
2d9f942bde
  1. 7
      res/drawable/list_bg.xml
  2. 12
      res/layout/bookmark_list_item.xml
  3. 13
      res/layout/tab_list_item.xml
  4. 4
      res/values/colors.xml
  5. 1
      res/values/dimens.xml
  6. 65
      src/acr/browser/lightning/BrowserActivity.java
  7. 1
      src/acr/browser/lightning/IncognitoActivity.java
  8. 1
      src/acr/browser/lightning/MainActivity.java
  9. 6
      src/acr/browser/lightning/Utils.java

7
res/drawable/list_bg.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/gray_list_bg" android:state_pressed="true"/>
<item android:drawable="@color/gray_list_bg" android:state_activated="true"/>
</selector>

12
res/layout/bookmark_list_item.xml

@ -1,18 +1,18 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<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="match_parent" android:layout_height="56dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:background="?android:attr/activatedBackgroundIndicator" android:background="@drawable/list_bg"
android:orientation="horizontal" > android:orientation="horizontal" >
<ImageView <ImageView
android:id="@+id/favicon1" android:id="@+id/favicon1"
android:layout_width="22dp" android:layout_width="24dp"
android:layout_height="22dp" android:layout_height="24dp"
android:contentDescription="Favicon" android:contentDescription="Favicon"
android:gravity="center_vertical" android:gravity="center_vertical"
android:layout_marginLeft="3dp" android:layout_marginLeft="4dp"
android:layout_marginRight="2dp" android:layout_marginRight="2dp"
android:paddingLeft="2dp" android:paddingLeft="2dp"
android:paddingRight="2dp" > android:paddingRight="2dp" >
@ -27,6 +27,6 @@
android:minHeight="?android:attr/listPreferredItemHeightSmall" android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:paddingRight="4dp" android:paddingRight="4dp"
android:textAppearance="?android:attr/textAppearanceListItemSmall" android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="#656565" /> android:textColor="@color/dark_text" />
</LinearLayout> </LinearLayout>

13
res/layout/tab_list_item.xml

@ -1,20 +1,21 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<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="match_parent" android:layout_height="56dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:background="?android:attr/activatedBackgroundIndicator" android:background="@drawable/list_bg"
android:orientation="horizontal" > android:orientation="horizontal" >
<ImageView <ImageView
android:id="@+id/favicon1" android:id="@+id/favicon1"
android:layout_width="22dp" android:layout_width="24dp"
android:layout_height="22dp" android:layout_height="24dp"
android:contentDescription="Favicon" android:contentDescription="Favicon"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:gravity="center_vertical" android:gravity="center_vertical"
android:layout_marginLeft="2dp" android:layout_marginLeft="4dp"
android:layout_marginRight="2dp"
android:paddingLeft="2dp" android:paddingLeft="2dp"
android:paddingRight="2dp" > android:paddingRight="2dp" >
</ImageView> </ImageView>
@ -30,7 +31,7 @@
android:layout_toLeftOf="@+id/delete1" android:layout_toLeftOf="@+id/delete1"
android:minHeight="?android:attr/listPreferredItemHeightSmall" android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:textAppearance="?android:attr/textAppearanceListItemSmall" android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="#6a6a6a" /> android:textColor="@color/dark_text" />
<ImageView <ImageView
android:id="@+id/delete1" android:id="@+id/delete1"

4
res/values/colors.xml

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="drawer_background">#e4e4e4</color> <color name="drawer_background">#ffffff</color>
<color name="black">#ff000000</color> <color name="black">#ff000000</color>
<color name="light">#ffa0a0a0</color> <color name="light">#ffa0a0a0</color>
<color name="gray_dark">#222222</color> <color name="gray_dark">#222222</color>
@ -9,5 +9,7 @@
<color name="gray_medium">#cdcdcd</color> <color name="gray_medium">#cdcdcd</color>
<color name="white">#ffffff</color> <color name="white">#ffffff</color>
<color name="gray_extra_dark">#1b1b1b</color> <color name="gray_extra_dark">#1b1b1b</color>
<color name="gray_list_bg">#0d000000</color>
<color name="dark_text">#3f3f3f</color>
</resources> </resources>

1
res/values/dimens.xml

@ -3,5 +3,6 @@
<!-- Default screen margins, per the Android Design guidelines. --> <!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen> <dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen> <dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="navigation_width">260dp</dimen>
</resources> </resources>

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

@ -190,8 +190,13 @@ public class BrowserActivity extends Activity implements BrowserController {
mDrawer = (RelativeLayout) findViewById(R.id.drawer); mDrawer = (RelativeLayout) findViewById(R.id.drawer);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.left_drawer); mDrawerList = (ListView) findViewById(R.id.left_drawer);
mDrawerList.setDivider(null);
mDrawerList.setDividerHeight(0);
mDrawerRight = (LinearLayout) findViewById(R.id.right_drawer); mDrawerRight = (LinearLayout) findViewById(R.id.right_drawer);
mDrawerListRight = (ListView) findViewById(R.id.right_drawer_list); mDrawerListRight = (ListView) findViewById(R.id.right_drawer_list);
mDrawerListRight.setDivider(null);
mDrawerListRight.setDividerHeight(0);
setNavigationDrawerWidth();
mWebpageBitmap = BitmapFactory.decodeResource(getResources(), mWebpageBitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.ic_webpage); R.drawable.ic_webpage);
mActionBar = getActionBar(); mActionBar = getActionBar();
@ -437,8 +442,10 @@ public class BrowserActivity extends Activity implements BrowserController {
}); });
mDrawerLayout.setDrawerListener(mDrawerToggle); mDrawerLayout.setDrawerListener(mDrawerToggle);
mDrawerLayout.setDrawerShadow(R.drawable.drawer_right_shadow, GravityCompat.END); mDrawerLayout.setDrawerShadow(R.drawable.drawer_right_shadow,
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); GravityCompat.END);
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow,
GravityCompat.START);
initializePreferences(); initializePreferences();
initializeTabs(); initializeTabs();
@ -512,7 +519,7 @@ public class BrowserActivity extends Activity implements BrowserController {
OrbotHelper oh = new OrbotHelper(this); OrbotHelper oh = new OrbotHelper(this);
if (!oh.isOrbotRunning()) if (!oh.isOrbotRunning())
oh.requestOrbotStart(this); oh.requestOrbotStart(this);
WebkitProxy wkp = new WebkitProxy(); WebkitProxy wkp = new WebkitProxy();
try { try {
String host = mPreferences.getString( String host = mPreferences.getString(
@ -527,6 +534,30 @@ public class BrowserActivity extends Activity implements BrowserController {
} }
public void setNavigationDrawerWidth() {
int width = getResources().getDisplayMetrics().widthPixels * 4 / 5;
int maxWidth = Utils.convertToDensityPixels(mContext, 300);
if (width > maxWidth) {
DrawerLayout.LayoutParams params = (android.support.v4.widget.DrawerLayout.LayoutParams) mDrawer
.getLayoutParams();
params.width = maxWidth;
mDrawer.setLayoutParams(params);
DrawerLayout.LayoutParams paramsRight = (android.support.v4.widget.DrawerLayout.LayoutParams) mDrawerRight
.getLayoutParams();
paramsRight.width = maxWidth;
mDrawerRight.setLayoutParams(paramsRight);
} else {
DrawerLayout.LayoutParams params = (android.support.v4.widget.DrawerLayout.LayoutParams) mDrawer
.getLayoutParams();
params.width = width;
mDrawer.setLayoutParams(params);
DrawerLayout.LayoutParams paramsRight = (android.support.v4.widget.DrawerLayout.LayoutParams) mDrawerRight
.getLayoutParams();
paramsRight.width = width;
mDrawerRight.setLayoutParams(paramsRight);
}
}
/* /*
* Override this class * Override this class
*/ */
@ -669,6 +700,13 @@ public class BrowserActivity extends Activity implements BrowserController {
// The action bar home/up action should open or close the drawer. // The action bar home/up action should open or close the drawer.
// ActionBarDrawerToggle will take care of this. // ActionBarDrawerToggle will take care of this.
if (mDrawerToggle.onOptionsItemSelected(item)) { if (mDrawerToggle.onOptionsItemSelected(item)) {
if (mDrawerLayout.isDrawerOpen(mDrawerRight)) {
mDrawerLayout.closeDrawer(mDrawerRight);
mDrawerLayout.openDrawer(mDrawer);
} else if (mDrawerLayout.isDrawerOpen(mDrawer)) {
mDrawerLayout.closeDrawer(mDrawer);
}
mDrawerToggle.syncState();
return true; return true;
} }
// Handle action buttons // Handle action buttons
@ -1094,14 +1132,16 @@ public class BrowserActivity extends Activity implements BrowserController {
Log.i(Constants.LOGTAG, "Cache Cleared"); Log.i(Constants.LOGTAG, "Cache Cleared");
} }
if (mPreferences.getBoolean(PreferenceConstants.CLEAR_HISTORY_EXIT, if (mPreferences.getBoolean(
false) && !isIncognito()) { PreferenceConstants.CLEAR_HISTORY_EXIT, false)
&& !isIncognito()) {
clearHistory(); clearHistory();
Log.i(Constants.LOGTAG, "History Cleared"); Log.i(Constants.LOGTAG, "History Cleared");
} }
if (mPreferences.getBoolean(PreferenceConstants.CLEAR_COOKIES_EXIT, if (mPreferences.getBoolean(
false) && !isIncognito()) { PreferenceConstants.CLEAR_COOKIES_EXIT, false)
&& !isIncognito()) {
clearCookies(); clearCookies();
Log.i(Constants.LOGTAG, "Cookies Cleared"); Log.i(Constants.LOGTAG, "Cookies Cleared");
@ -1160,11 +1200,10 @@ public class BrowserActivity extends Activity implements BrowserController {
} }
return true; return true;
} }
public void clearHistory() { public void clearHistory() {
this.deleteDatabase(DatabaseHandler.DATABASE_NAME); this.deleteDatabase(DatabaseHandler.DATABASE_NAME);
WebViewDatabase m = WebViewDatabase WebViewDatabase m = WebViewDatabase.getInstance(this);
.getInstance(this);
m.clearFormData(); m.clearFormData();
m.clearHttpAuthUsernamePassword(); m.clearHttpAuthUsernamePassword();
if (API < 18) { if (API < 18) {
@ -1180,7 +1219,7 @@ public class BrowserActivity extends Activity implements BrowserController {
SettingsController.setClearHistory(true); SettingsController.setClearHistory(true);
Utils.trimCache(this); Utils.trimCache(this);
} }
public void clearCookies() { public void clearCookies() {
CookieManager c = CookieManager.getInstance(); CookieManager c = CookieManager.getInstance();
CookieSyncManager.createInstance(this); CookieSyncManager.createInstance(this);
@ -1915,6 +1954,10 @@ public class BrowserActivity extends Activity implements BrowserController {
mDrawerLayout.openDrawer(mDrawerRight); mDrawerLayout.openDrawer(mDrawerRight);
} }
public void closeDrawers() {
mDrawerLayout.closeDrawers();
}
@Override @Override
/** /**
* open the HTML bookmarks page, parameter view is the WebView that should show the page * open the HTML bookmarks page, parameter view is the WebView that should show the page

1
src/acr/browser/lightning/IncognitoActivity.java

@ -70,6 +70,7 @@ public class IncognitoActivity extends BrowserActivity {
@Override @Override
public void closeActivity() { public void closeActivity() {
closeDrawers();
finish(); finish();
} }

1
src/acr/browser/lightning/MainActivity.java

@ -69,6 +69,7 @@ public class MainActivity extends BrowserActivity {
@Override @Override
public void closeActivity() { public void closeActivity() {
closeDrawers();
moveTaskToBack(true); moveTaskToBack(true);
} }

6
src/acr/browser/lightning/Utils.java

@ -101,6 +101,12 @@ public class Utils {
Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
} }
/**
* Returns the number of pixels corresponding to the passed density pixels
* @param context
* @param densityPixels
* @return
*/
public static int convertToDensityPixels(Context context, int densityPixels) { public static int convertToDensityPixels(Context context, int densityPixels) {
float scale = context.getResources().getDisplayMetrics().density; float scale = context.getResources().getDisplayMetrics().density;
int pixels = (int) (densityPixels * scale + 0.5f); int pixels = (int) (densityPixels * scale + 0.5f);

Loading…
Cancel
Save