Navigation Drawer UI update
This commit is contained in:
parent
b255a06d8f
commit
2d9f942bde
7
res/drawable/list_bg.xml
Normal file
7
res/drawable/list_bg.xml
Normal file
@ -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>
|
@ -1,18 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:gravity="center_vertical"
|
||||
android:background="?android:attr/activatedBackgroundIndicator"
|
||||
android:background="@drawable/list_bg"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/favicon1"
|
||||
android:layout_width="22dp"
|
||||
android:layout_height="22dp"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:contentDescription="Favicon"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginLeft="3dp"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="2dp"
|
||||
android:paddingLeft="2dp"
|
||||
android:paddingRight="2dp" >
|
||||
@ -27,6 +27,6 @@
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:paddingRight="4dp"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSmall"
|
||||
android:textColor="#656565" />
|
||||
android:textColor="@color/dark_text" />
|
||||
|
||||
</LinearLayout>
|
@ -1,20 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:gravity="center_vertical"
|
||||
android:background="?android:attr/activatedBackgroundIndicator"
|
||||
android:background="@drawable/list_bg"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/favicon1"
|
||||
android:layout_width="22dp"
|
||||
android:layout_height="22dp"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:contentDescription="Favicon"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginLeft="2dp"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="2dp"
|
||||
android:paddingLeft="2dp"
|
||||
android:paddingRight="2dp" >
|
||||
</ImageView>
|
||||
@ -30,7 +31,7 @@
|
||||
android:layout_toLeftOf="@+id/delete1"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSmall"
|
||||
android:textColor="#6a6a6a" />
|
||||
android:textColor="@color/dark_text" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/delete1"
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<color name="drawer_background">#e4e4e4</color>
|
||||
<color name="drawer_background">#ffffff</color>
|
||||
<color name="black">#ff000000</color>
|
||||
<color name="light">#ffa0a0a0</color>
|
||||
<color name="gray_dark">#222222</color>
|
||||
@ -9,5 +9,7 @@
|
||||
<color name="gray_medium">#cdcdcd</color>
|
||||
<color name="white">#ffffff</color>
|
||||
<color name="gray_extra_dark">#1b1b1b</color>
|
||||
<color name="gray_list_bg">#0d000000</color>
|
||||
<color name="dark_text">#3f3f3f</color>
|
||||
|
||||
</resources>
|
@ -3,5 +3,6 @@
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
<dimen name="navigation_width">260dp</dimen>
|
||||
|
||||
</resources>
|
||||
|
@ -190,8 +190,13 @@ public class BrowserActivity extends Activity implements BrowserController {
|
||||
mDrawer = (RelativeLayout) findViewById(R.id.drawer);
|
||||
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
mDrawerList = (ListView) findViewById(R.id.left_drawer);
|
||||
mDrawerList.setDivider(null);
|
||||
mDrawerList.setDividerHeight(0);
|
||||
mDrawerRight = (LinearLayout) findViewById(R.id.right_drawer);
|
||||
mDrawerListRight = (ListView) findViewById(R.id.right_drawer_list);
|
||||
mDrawerListRight.setDivider(null);
|
||||
mDrawerListRight.setDividerHeight(0);
|
||||
setNavigationDrawerWidth();
|
||||
mWebpageBitmap = BitmapFactory.decodeResource(getResources(),
|
||||
R.drawable.ic_webpage);
|
||||
mActionBar = getActionBar();
|
||||
@ -437,8 +442,10 @@ public class BrowserActivity extends Activity implements BrowserController {
|
||||
});
|
||||
|
||||
mDrawerLayout.setDrawerListener(mDrawerToggle);
|
||||
mDrawerLayout.setDrawerShadow(R.drawable.drawer_right_shadow, GravityCompat.END);
|
||||
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
|
||||
mDrawerLayout.setDrawerShadow(R.drawable.drawer_right_shadow,
|
||||
GravityCompat.END);
|
||||
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow,
|
||||
GravityCompat.START);
|
||||
initializePreferences();
|
||||
initializeTabs();
|
||||
|
||||
@ -512,7 +519,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
||||
OrbotHelper oh = new OrbotHelper(this);
|
||||
if (!oh.isOrbotRunning())
|
||||
oh.requestOrbotStart(this);
|
||||
|
||||
|
||||
WebkitProxy wkp = new WebkitProxy();
|
||||
try {
|
||||
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
|
||||
*/
|
||||
@ -669,6 +700,13 @@ public class BrowserActivity extends Activity implements BrowserController {
|
||||
// The action bar home/up action should open or close the drawer.
|
||||
// ActionBarDrawerToggle will take care of this.
|
||||
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;
|
||||
}
|
||||
// Handle action buttons
|
||||
@ -1094,14 +1132,16 @@ public class BrowserActivity extends Activity implements BrowserController {
|
||||
Log.i(Constants.LOGTAG, "Cache Cleared");
|
||||
|
||||
}
|
||||
if (mPreferences.getBoolean(PreferenceConstants.CLEAR_HISTORY_EXIT,
|
||||
false) && !isIncognito()) {
|
||||
if (mPreferences.getBoolean(
|
||||
PreferenceConstants.CLEAR_HISTORY_EXIT, false)
|
||||
&& !isIncognito()) {
|
||||
clearHistory();
|
||||
Log.i(Constants.LOGTAG, "History Cleared");
|
||||
|
||||
}
|
||||
if (mPreferences.getBoolean(PreferenceConstants.CLEAR_COOKIES_EXIT,
|
||||
false) && !isIncognito()) {
|
||||
if (mPreferences.getBoolean(
|
||||
PreferenceConstants.CLEAR_COOKIES_EXIT, false)
|
||||
&& !isIncognito()) {
|
||||
clearCookies();
|
||||
Log.i(Constants.LOGTAG, "Cookies Cleared");
|
||||
|
||||
@ -1160,11 +1200,10 @@ public class BrowserActivity extends Activity implements BrowserController {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void clearHistory() {
|
||||
this.deleteDatabase(DatabaseHandler.DATABASE_NAME);
|
||||
WebViewDatabase m = WebViewDatabase
|
||||
.getInstance(this);
|
||||
WebViewDatabase m = WebViewDatabase.getInstance(this);
|
||||
m.clearFormData();
|
||||
m.clearHttpAuthUsernamePassword();
|
||||
if (API < 18) {
|
||||
@ -1180,7 +1219,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
||||
SettingsController.setClearHistory(true);
|
||||
Utils.trimCache(this);
|
||||
}
|
||||
|
||||
|
||||
public void clearCookies() {
|
||||
CookieManager c = CookieManager.getInstance();
|
||||
CookieSyncManager.createInstance(this);
|
||||
@ -1915,6 +1954,10 @@ public class BrowserActivity extends Activity implements BrowserController {
|
||||
mDrawerLayout.openDrawer(mDrawerRight);
|
||||
}
|
||||
|
||||
public void closeDrawers() {
|
||||
mDrawerLayout.closeDrawers();
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* open the HTML bookmarks page, parameter view is the WebView that should show the page
|
||||
|
@ -70,6 +70,7 @@ public class IncognitoActivity extends BrowserActivity {
|
||||
|
||||
@Override
|
||||
public void closeActivity() {
|
||||
closeDrawers();
|
||||
finish();
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,7 @@ public class MainActivity extends BrowserActivity {
|
||||
|
||||
@Override
|
||||
public void closeActivity() {
|
||||
closeDrawers();
|
||||
moveTaskToBack(true);
|
||||
}
|
||||
|
||||
|
@ -101,6 +101,12 @@ public class Utils {
|
||||
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) {
|
||||
float scale = context.getResources().getDisplayMetrics().density;
|
||||
int pixels = (int) (densityPixels * scale + 0.5f);
|
||||
|
Loading…
x
Reference in New Issue
Block a user