Browse Source

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

master
Anthony Restaino 10 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

@ -36,5 +36,13 @@
<style name="LightActionBar" parent="android:Widget.Holo.Light.ActionBar.Solid"> <style name="LightActionBar" parent="android:Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">@color/gray_light</item> <item name="android:background">@color/gray_light</item>
</style> </style>
<style name="boldText" >
<item name="android:textStyle">bold</item>
</style>
<style name="normalText" >
<item name="android:textStyle">normal</item>
</style>
</resources> </resources>

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

@ -55,6 +55,7 @@ import android.media.MediaPlayer;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.provider.Browser; import android.provider.Browser;
import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.app.ActionBarDrawerToggle;
@ -991,10 +992,11 @@ public class BrowserActivity extends Activity implements BrowserController {
return; return;
} }
if (mCurrentView != null) { if (mCurrentView != null) {
mCurrentView.setIsForgroundTab(false);
mCurrentView.onPause(); mCurrentView.onPause();
} }
mCurrentView = view; mCurrentView = view;
mCurrentView.setIsForgroundTab(true);
if (view.getWebView() != null) { if (view.getWebView() != null) {
updateUrl(view.getUrl()); updateUrl(view.getUrl());
updateProgress(view.getProgress()); updateProgress(view.getProgress());
@ -1006,6 +1008,7 @@ public class BrowserActivity extends Activity implements BrowserController {
mBrowserFrame.removeAllViews(); mBrowserFrame.removeAllViews();
mCurrentView.onResume(); mCurrentView.onResume();
mBrowserFrame.addView(view.getWebView()); mBrowserFrame.addView(view.getWebView());
} }
/** /**
@ -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 // update selected item and title, then close the drawer
mDrawerList.setItemChecked(position, true); mDrawerList.setItemChecked(position, true);
showTab(mWebViews.get(position)); showTab(mWebViews.get(position));
//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);
mDrawerLayout.closeDrawer(mDrawer);
} }
/** /**
@ -1533,6 +1546,12 @@ public class BrowserActivity extends Activity implements BrowserController {
LightningView web = data.get(position); LightningView web = data.get(position);
holder.txtTitle.setText(web.getTitle()); 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(); Bitmap favicon = web.getFavicon();
holder.favicon.setImageBitmap(favicon); holder.favicon.setImageBitmap(favicon);
return row; return row;

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

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

Loading…
Cancel
Save