Browse Source

Fix deprecation issues, fix a couple rendering issues

master
Anthony Restaino 10 years ago
parent
commit
1d6a445d33
  1. 4
      AndroidManifest.xml
  2. 1
      src/acr/browser/lightning/AnimatedProgressBar.java
  3. 4
      src/acr/browser/lightning/BrowserActivity.java
  4. 3
      src/acr/browser/lightning/DownloadHandler.java
  5. 45
      src/acr/browser/lightning/FetchUrlMimeType.java
  6. 5
      src/acr/browser/lightning/Reading/ArticleTextExtractor.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="71" android:versionCode="72"
android:versionName="4.0.3a" > android:versionName="4.0.4a" >
<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" />

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

@ -54,7 +54,6 @@ public class AnimatedProgressBar extends LinearLayout {
* @param attrs is the attribute set passed by the constructor * @param attrs is the attribute set passed by the constructor
*/ */
private void init(final Context context, AttributeSet attrs) { private void init(final Context context, AttributeSet attrs) {
this.setLayerType(LAYER_TYPE_HARDWARE, null);
TypedArray array = context.getTheme().obtainStyledAttributes(attrs, R.styleable.AnimatedProgressBar, 0, 0); TypedArray array = context.getTheme().obtainStyledAttributes(attrs, R.styleable.AnimatedProgressBar, 0, 0);
int backgroundColor; int backgroundColor;
try { // Retrieve the style of the progress bar that the user hopefully set try { // Retrieve the style of the progress bar that the user hopefully set

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

@ -1316,6 +1316,9 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
mPreferences.edit().putString(PreferenceConstants.SAVE_URL, reference.getUrl()).apply(); mPreferences.edit().putString(PreferenceConstants.SAVE_URL, reference.getUrl()).apply();
} }
boolean isShown = reference.isShown(); boolean isShown = reference.isShown();
if (isShown) {
mBrowserFrame.setBackgroundColor(mBackgroundColor);
}
if (current > position) { if (current > position) {
mWebViews.remove(position); mWebViews.remove(position);
mDrawerListLeft.setItemChecked(current - 1, true); mDrawerListLeft.setItemChecked(current - 1, true);
@ -1678,6 +1681,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
@Override @Override
public void onGenerated(Palette palette) { public void onGenerated(Palette palette) {
// OR with opaque black to remove transparency glitches
int color = 0xff000000 | palette.getVibrantColor(mContext.getResources() int color = 0xff000000 | palette.getVibrantColor(mContext.getResources()
.getColor(R.color.primary_color)); .getColor(R.color.primary_color));

3
src/acr/browser/lightning/DownloadHandler.java

@ -211,7 +211,8 @@ public class DownloadHandler {
manager.enqueue(request); manager.enqueue(request);
} }
}.start(); }.start();
Toast.makeText(activity, R.string.download_pending, Toast.LENGTH_SHORT).show();
} }
Toast.makeText(activity, R.string.download_pending, Toast.LENGTH_SHORT).show();
} }
} }

45
src/acr/browser/lightning/FetchUrlMimeType.java

@ -5,15 +5,14 @@ package acr.browser.lightning;
import android.app.DownloadManager; import android.app.DownloadManager;
import android.content.Context; import android.content.Context;
import android.net.http.AndroidHttpClient;
import android.os.Environment; import android.os.Environment;
import android.webkit.MimeTypeMap; import android.webkit.MimeTypeMap;
import android.webkit.URLUtil; import android.webkit.URLUtil;
import org.apache.http.Header; import android.widget.Toast;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpHead;
import java.io.IOException; import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
/** /**
* This class is used to pull down the http headers of a given URL so that we * This class is used to pull down the http headers of a given URL so that we
@ -42,48 +41,50 @@ public class FetchUrlMimeType extends Thread {
mUri = uri; mUri = uri;
mCookies = cookies; mCookies = cookies;
mUserAgent = userAgent; mUserAgent = userAgent;
Toast.makeText(mContext, R.string.download_pending, Toast.LENGTH_SHORT).show();
} }
@Override @Override
public void run() { public void run() {
// User agent is likely to be null, though the AndroidHttpClient // User agent is likely to be null, though the AndroidHttpClient
// seems ok with that. // seems ok with that.
AndroidHttpClient client = AndroidHttpClient.newInstance(mUserAgent);
HttpHead request = new HttpHead(mUri);
if (mCookies != null && mCookies.length() > 0) {
request.addHeader("Cookie", mCookies);
}
HttpResponse response;
String mimeType = null; String mimeType = null;
String contentDisposition = null; String contentDisposition = null;
HttpURLConnection connection = null;
try { try {
response = client.execute(request); URL url = new URL(mUri);
connection = (HttpURLConnection) url.openConnection();
if (mCookies != null && mCookies.length() > 0) {
connection.addRequestProperty("Cookie", mCookies);
connection.setRequestProperty("User-Agent", mUserAgent);
}
connection.connect();
// We could get a redirect here, but if we do lets let // We could get a redirect here, but if we do lets let
// the download manager take care of it, and thus trust that // the download manager take care of it, and thus trust that
// the server sends the right mimetype // the server sends the right mimetype
if (response.getStatusLine().getStatusCode() == 200) { if (connection.getResponseCode() == 200) {
Header header = response.getFirstHeader("Content-Type"); String header = connection.getHeaderField("Content-Type");
if (header != null) { if (header != null) {
mimeType = header.getValue(); mimeType = header;
final int semicolonIndex = mimeType.indexOf(';'); final int semicolonIndex = mimeType.indexOf(';');
if (semicolonIndex != -1) { if (semicolonIndex != -1) {
mimeType = mimeType.substring(0, semicolonIndex); mimeType = mimeType.substring(0, semicolonIndex);
} }
} }
Header contentDispositionHeader = response.getFirstHeader("Content-Disposition"); String contentDispositionHeader = connection.getHeaderField("Content-Disposition");
if (contentDispositionHeader != null) { if (contentDispositionHeader != null) {
contentDisposition = contentDispositionHeader.getValue(); contentDisposition = contentDispositionHeader;
} }
} }
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
request.abort(); if (connection != null)
connection.disconnect();
} catch (IOException ex) { } catch (IOException ex) {
request.abort(); if (connection != null)
connection.disconnect();
} finally { } finally {
client.close(); if (connection != null)
connection.disconnect();
} }
if (mimeType != null) { if (mimeType != null) {

5
src/acr/browser/lightning/Reading/ArticleTextExtractor.java

@ -6,20 +6,17 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;
import org.jsoup.select.Elements; import org.jsoup.select.Elements;
import android.util.Log;
/** /**
* This class is thread safe. * This class is thread safe.
* *

Loading…
Cancel
Save