Browse Source

Embolden text when a tab is selected for more contrast, smoothed animation of drawer hide when tab is switched

master
Anthony Restaino 11 years ago
parent
commit
253e6f06fd
  1. 8
      res/values/styles.xml
  2. 25
      src/acr/browser/lightning/BrowserActivity.java
  3. 10
      src/acr/browser/lightning/LightningView.java

8
res/values/styles.xml

@ -37,4 +37,12 @@ @@ -37,4 +37,12 @@
<item name="android:background">@color/gray_light</item>
</style>
<style name="boldText" >
<item name="android:textStyle">bold</item>
</style>
<style name="normalText" >
<item name="android:textStyle">normal</item>
</style>
</resources>

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

@ -55,6 +55,7 @@ import android.media.MediaPlayer; @@ -55,6 +55,7 @@ import android.media.MediaPlayer;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.Browser;
import android.support.v4.app.ActionBarDrawerToggle;
@ -991,10 +992,11 @@ public class BrowserActivity extends Activity implements BrowserController { @@ -991,10 +992,11 @@ public class BrowserActivity extends Activity implements BrowserController {
return;
}
if (mCurrentView != null) {
mCurrentView.setIsForgroundTab(false);
mCurrentView.onPause();
}
mCurrentView = view;
mCurrentView.setIsForgroundTab(true);
if (view.getWebView() != null) {
updateUrl(view.getUrl());
updateProgress(view.getProgress());
@ -1006,6 +1008,7 @@ public class BrowserActivity extends Activity implements BrowserController { @@ -1006,6 +1008,7 @@ public class BrowserActivity extends Activity implements BrowserController {
mBrowserFrame.removeAllViews();
mCurrentView.onResume();
mBrowserFrame.addView(view.getWebView());
}
/**
@ -1042,13 +1045,23 @@ public class BrowserActivity extends Activity implements BrowserController { @@ -1042,13 +1045,23 @@ public class BrowserActivity extends Activity implements BrowserController {
}
}
private void selectItem(int position) {
private void selectItem(final int position) {
// update selected item and title, then close the drawer
mDrawerList.setItemChecked(position, true);
showTab(mWebViews.get(position));
mDrawerLayout.closeDrawer(mDrawer);
//Use a delayed handler to make the transition smooth
//otherwise it will get caught up with the showTab code
//and cause a janky motion
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
mDrawerLayout.closeDrawer(mDrawer);
}
}, 150);
}
/**
@ -1533,6 +1546,12 @@ public class BrowserActivity extends Activity implements BrowserController { @@ -1533,6 +1546,12 @@ public class BrowserActivity extends Activity implements BrowserController {
LightningView web = data.get(position);
holder.txtTitle.setText(web.getTitle());
if (web.getIsForgroundTab()) {
holder.txtTitle.setTextAppearance(context, R.style.boldText);
} else {
holder.txtTitle.setTextAppearance(context, R.style.normalText);
}
Bitmap favicon = web.getFavicon();
holder.favicon.setImageBitmap(favicon);
return row;

10
src/acr/browser/lightning/LightningView.java

@ -75,6 +75,7 @@ public class LightningView { @@ -75,6 +75,7 @@ public class LightningView {
private static boolean mWideViewPort;
private static AdBlock mAdBlock;
private CookieManager mCookieManager;
private boolean isForgroundTab = false;
@SuppressLint("NewApi")
public LightningView(Activity activity, String url,
@ -416,6 +417,15 @@ public class LightningView { @@ -416,6 +417,15 @@ public class LightningView {
mWebView.onResume();
}
public void setIsForgroundTab(boolean isForground) {
isForgroundTab = isForground;
mBrowserController.update();
}
public boolean getIsForgroundTab() {
return isForgroundTab;
}
public int getProgress() {
if (mWebView != null) {
return mWebView.getProgress();

Loading…
Cancel
Save