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 @@ @@ -3,8 +3,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="acr.browser.lightning"
android:versionCode="71"
android:versionName="4.0.3a" >
android:versionCode="72"
android:versionName="4.0.4a" >
<uses-permission android:name="android.permission.INTERNET" />
<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 { @@ -54,7 +54,6 @@ public class AnimatedProgressBar extends LinearLayout {
* @param attrs is the attribute set passed by the constructor
*/
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);
int backgroundColor;
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 @@ -1316,6 +1316,9 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
mPreferences.edit().putString(PreferenceConstants.SAVE_URL, reference.getUrl()).apply();
}
boolean isShown = reference.isShown();
if (isShown) {
mBrowserFrame.setBackgroundColor(mBackgroundColor);
}
if (current > position) {
mWebViews.remove(position);
mDrawerListLeft.setItemChecked(current - 1, true);
@ -1678,6 +1681,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl @@ -1678,6 +1681,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
@Override
public void onGenerated(Palette palette) {
// OR with opaque black to remove transparency glitches
int color = 0xff000000 | palette.getVibrantColor(mContext.getResources()
.getColor(R.color.primary_color));

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

@ -211,7 +211,8 @@ public class DownloadHandler { @@ -211,7 +211,8 @@ public class DownloadHandler {
manager.enqueue(request);
}
}.start();
}
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; @@ -5,15 +5,14 @@ package acr.browser.lightning;
import android.app.DownloadManager;
import android.content.Context;
import android.net.http.AndroidHttpClient;
import android.os.Environment;
import android.webkit.MimeTypeMap;
import android.webkit.URLUtil;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpHead;
import android.widget.Toast;
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
@ -42,48 +41,50 @@ public class FetchUrlMimeType extends Thread { @@ -42,48 +41,50 @@ public class FetchUrlMimeType extends Thread {
mUri = uri;
mCookies = cookies;
mUserAgent = userAgent;
Toast.makeText(mContext, R.string.download_pending, Toast.LENGTH_SHORT).show();
}
@Override
public void run() {
// User agent is likely to be null, though the AndroidHttpClient
// 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 contentDisposition = null;
HttpURLConnection connection = null;
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
// the download manager take care of it, and thus trust that
// the server sends the right mimetype
if (response.getStatusLine().getStatusCode() == 200) {
Header header = response.getFirstHeader("Content-Type");
if (connection.getResponseCode() == 200) {
String header = connection.getHeaderField("Content-Type");
if (header != null) {
mimeType = header.getValue();
mimeType = header;
final int semicolonIndex = mimeType.indexOf(';');
if (semicolonIndex != -1) {
mimeType = mimeType.substring(0, semicolonIndex);
}
}
Header contentDispositionHeader = response.getFirstHeader("Content-Disposition");
String contentDispositionHeader = connection.getHeaderField("Content-Disposition");
if (contentDispositionHeader != null) {
contentDisposition = contentDispositionHeader.getValue();
contentDisposition = contentDispositionHeader;
}
}
} catch (IllegalArgumentException ex) {
request.abort();
if (connection != null)
connection.disconnect();
} catch (IOException ex) {
request.abort();
if (connection != null)
connection.disconnect();
} finally {
client.close();
if (connection != null)
connection.disconnect();
}
if (mimeType != null) {

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

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

Loading…
Cancel
Save