Browse Source

Formatting

master
Anthony Restaino 10 years ago
parent
commit
1e2908ccd6
  1. 17
      src/acr/browser/lightning/BrowserActivity.java
  2. 7
      src/acr/browser/lightning/ReplacingInputStream.java
  3. 37
      src/acr/browser/lightning/Utils.java

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

@ -466,8 +466,7 @@ public class BrowserActivity extends Activity implements BrowserController {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
switch (which) { switch (which) {
case DialogInterface.BUTTON_POSITIVE: case DialogInterface.BUTTON_POSITIVE:
mPreferences.edit().putBoolean(PreferenceConstants.USE_PROXY, true) mPreferences.edit().putBoolean(PreferenceConstants.USE_PROXY, true).apply();
.apply();
initializeTor(); initializeTor();
break; break;
@ -596,8 +595,7 @@ public class BrowserActivity extends Activity implements BrowserController {
case 0: case 0:
mSearchText = mPreferences.getString(PreferenceConstants.SEARCH_URL, mSearchText = mPreferences.getString(PreferenceConstants.SEARCH_URL,
Constants.GOOGLE_SEARCH); Constants.GOOGLE_SEARCH);
if (!mSearchText.startsWith(Constants.HTTP) if (!mSearchText.startsWith(Constants.HTTP) && !mSearchText.startsWith(Constants.HTTPS)) {
&& !mSearchText.startsWith(Constants.HTTPS)) {
mSearchText = Constants.GOOGLE_SEARCH; mSearchText = Constants.GOOGLE_SEARCH;
} }
break; break;
@ -714,8 +712,7 @@ public class BrowserActivity extends Activity implements BrowserController {
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) { if (!mCurrentView.getUrl().startsWith(Constants.FILE)) {
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("text/plain"); shareIntent.setType("text/plain");
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mCurrentView.getTitle());
mCurrentView.getTitle());
String shareMessage = mCurrentView.getUrl(); String shareMessage = mCurrentView.getUrl();
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareMessage); shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareMessage);
startActivity(Intent.createChooser(shareIntent, startActivity(Intent.createChooser(shareIntent,
@ -729,8 +726,8 @@ public class BrowserActivity extends Activity implements BrowserController {
if (mCurrentView != null) { if (mCurrentView != null) {
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) { if (!mCurrentView.getUrl().startsWith(Constants.FILE)) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("label", mCurrentView.getUrl() ClipData clip = ClipData
.toString()); .newPlainText("label", mCurrentView.getUrl().toString());
clipboard.setPrimaryClip(clip); clipboard.setPrimaryClip(clip);
Utils.showToast(mContext, Utils.showToast(mContext,
mContext.getResources().getString(R.string.message_link_copied)); mContext.getResources().getString(R.string.message_link_copied));
@ -2274,8 +2271,8 @@ public class BrowserActivity extends Activity implements BrowserController {
case DialogInterface.BUTTON_NEUTRAL: case DialogInterface.BUTTON_NEUTRAL:
if (API > 8) { if (API > 8) {
Utils.downloadFile(mActivity, url, Utils.downloadFile(mActivity, url, mCurrentView.getUserAgent(),
mCurrentView.getUserAgent(), "attachment", false); "attachment", false);
} }
break; break;
} }

7
src/acr/browser/lightning/ReplacingInputStream.java

@ -15,8 +15,7 @@ public class ReplacingInputStream extends FilterInputStream {
final byte[] search, replacement; final byte[] search, replacement;
protected ReplacingInputStream(InputStream in, byte[] search, protected ReplacingInputStream(InputStream in, byte[] search, byte[] replacement) {
byte[] replacement) {
super(in); super(in);
this.search = search; this.search = search;
this.replacement = replacement; this.replacement = replacement;
@ -43,7 +42,6 @@ public class ReplacingInputStream extends FilterInputStream {
} }
} }
@Override @Override
public int read() throws IOException { public int read() throws IOException {
@ -69,7 +67,8 @@ public class ReplacingInputStream extends FilterInputStream {
} }
/** /**
* Returns false. REFilterInputStream does not support mark() and reset() methods. * Returns false. REFilterInputStream does not support mark() and reset()
* methods.
*/ */
@Override @Override
public boolean markSupported() { public boolean markSupported() {

37
src/acr/browser/lightning/Utils.java

@ -23,11 +23,11 @@ public final class Utils {
private Utils() { private Utils() {
} }
public static void downloadFile(final Activity activity, final String url, final String userAgent, public static void downloadFile(final Activity activity, final String url,
final String contentDisposition, final boolean privateBrowsing) { final String userAgent, final String contentDisposition, final boolean privateBrowsing) {
String fileName = URLUtil.guessFileName(url, null, String fileName = URLUtil.guessFileName(url, null, null);
null); DownloadHandler.onDownloadStart(activity, url, userAgent, contentDisposition, null,
DownloadHandler.onDownloadStart(activity, url, userAgent, contentDisposition, null, privateBrowsing); privateBrowsing);
Log.i(Constants.TAG, "Downloading" + fileName); Log.i(Constants.TAG, "Downloading" + fileName);
} }
@ -38,8 +38,7 @@ public final class Utils {
return; return;
} }
try { try {
BufferedReader readUrlRead = new BufferedReader(new FileReader( BufferedReader readUrlRead = new BufferedReader(new FileReader(bookUrl));
bookUrl));
String u; String u;
while ((u = readUrlRead.readLine()) != null) { while ((u = readUrlRead.readLine()) != null) {
if (u.contentEquals(url)) { if (u.contentEquals(url)) {
@ -54,10 +53,8 @@ public final class Utils {
} catch (NullPointerException ignored) { } catch (NullPointerException ignored) {
} }
try { try {
BufferedWriter bookWriter = new BufferedWriter(new FileWriter(book, BufferedWriter bookWriter = new BufferedWriter(new FileWriter(book, true));
true)); BufferedWriter urlWriter = new BufferedWriter(new FileWriter(bookUrl, true));
BufferedWriter urlWriter = new BufferedWriter(new FileWriter(
bookUrl, true));
bookWriter.write(title); bookWriter.write(title);
urlWriter.write(url); urlWriter.write(url);
bookWriter.newLine(); bookWriter.newLine();
@ -70,10 +67,10 @@ public final class Utils {
} }
} }
public static Intent newEmailIntent(Context context, String address, public static Intent newEmailIntent(Context context, String address, String subject,
String subject, String body, String cc) { String body, String cc) {
Intent intent = new Intent(Intent.ACTION_SEND); Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{address}); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { address });
intent.putExtra(Intent.EXTRA_TEXT, body); intent.putExtra(Intent.EXTRA_TEXT, body);
intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_CC, cc); intent.putExtra(Intent.EXTRA_CC, cc);
@ -81,11 +78,11 @@ public final class Utils {
return intent; return intent;
} }
public static void createInformativeDialog(Context context, String title, public static void createInformativeDialog(Context context, String title, String message) {
String message) {
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(title); builder.setTitle(title);
builder.setMessage(message).setCancelable(true) builder.setMessage(message)
.setCancelable(true)
.setPositiveButton(context.getResources().getString(R.string.action_ok), .setPositiveButton(context.getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
@ -124,15 +121,13 @@ public final class Utils {
public static List<HistoryItem> getBookmarks(Context context) { public static List<HistoryItem> getBookmarks(Context context) {
List<HistoryItem> bookmarks = new ArrayList<HistoryItem>(); List<HistoryItem> bookmarks = new ArrayList<HistoryItem>();
File bookUrl = new File(context.getFilesDir(), File bookUrl = new File(context.getFilesDir(), "bookurl");
"bookurl");
File book = new File(context.getFilesDir(), "bookmarks"); File book = new File(context.getFilesDir(), "bookmarks");
try { try {
BufferedReader readUrl = new BufferedReader(new FileReader(bookUrl)); BufferedReader readUrl = new BufferedReader(new FileReader(bookUrl));
BufferedReader readBook = new BufferedReader(new FileReader(book)); BufferedReader readBook = new BufferedReader(new FileReader(book));
String u, t; String u, t;
while ((u = readUrl.readLine()) != null while ((u = readUrl.readLine()) != null && (t = readBook.readLine()) != null) {
&& (t = readBook.readLine()) != null) {
HistoryItem map = new HistoryItem(u, t, R.drawable.ic_bookmark); HistoryItem map = new HistoryItem(u, t, R.drawable.ic_bookmark);
bookmarks.add(map); bookmarks.add(map);
} }

Loading…
Cancel
Save