Add BookmarkActivity that allows centralized management of bookmarks
This commit is contained in:
parent
e92ad4303b
commit
25a1b86307
@ -150,6 +150,18 @@
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="acr.browser.lightning.BookmarkActivity"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||
android:label="@string/bookmark_settings"
|
||||
android:theme="@style/DefaultTheme" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOKMARK" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -776,47 +776,6 @@
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:background="#cdcdcd" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/r9"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
android:minHeight="60dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/importbookmarks"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/isImportAvailable"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="text"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="@color/light" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
|
91
res/layout/bookmark_activity.xml
Normal file
91
res/layout/bookmark_activity.xml
Normal file
@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/exportBackup"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/export_bookmarks"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:background="#cdcdcd" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/importBackup"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/import_backup"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:background="#cdcdcd" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/importFromBrowser"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/importbookmarks"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/isImportBrowserAvailable"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/recommended"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="@color/light" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:background="#cdcdcd" />
|
||||
|
||||
</LinearLayout>
|
@ -5,7 +5,7 @@
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/browserLicense"
|
||||
android:id="@+id/exportBackup"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
@ -39,7 +39,7 @@
|
||||
android:background="#cdcdcd" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/licenseAOSP"
|
||||
android:id="@+id/importBackup"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
|
@ -385,6 +385,32 @@
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="@color/light" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:background="#cdcdcd" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/layoutBookmarks"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
android:minHeight="60dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/bookmark_settings"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -182,4 +182,10 @@
|
||||
<string name="title_file_chooser">File Chooser</string>
|
||||
<string name="library_netcipher">NetCipher</string>
|
||||
<string name="license_gnu">GNU Lesser General Public License</string>
|
||||
<string name="export_bookmarks">Export bookmarks to backup</string>
|
||||
<string name="import_backup">Import bookmarks from backup</string>
|
||||
<string name="bookmark_export_path">Bookmarks exported to</string>
|
||||
<string name="bookmark_settings">Bookmark Settings</string>
|
||||
<string name="import_bookmark_error">Could not import bookmarks from file</string>
|
||||
<string name="title_chooser">Choose a file</string>
|
||||
</resources>
|
||||
|
@ -70,7 +70,7 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
|
||||
private void initialize() {
|
||||
|
||||
RelativeLayout r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, rIncognitoCookies, rClearCache, rSearchSuggestions, rClearHistoryExit, rClearCookiesExit;
|
||||
RelativeLayout r1, r2, r3, r4, r5, r6, r7, r8, r10, r11, r12, r13, r14, r15, rIncognitoCookies, rClearCache, rSearchSuggestions, rClearHistoryExit, rClearCookiesExit;
|
||||
|
||||
r1 = (RelativeLayout) findViewById(R.id.r1);
|
||||
r2 = (RelativeLayout) findViewById(R.id.r2);
|
||||
@ -82,7 +82,6 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
r6 = (RelativeLayout) findViewById(R.id.r6);
|
||||
r7 = (RelativeLayout) findViewById(R.id.r7);
|
||||
r8 = (RelativeLayout) findViewById(R.id.rClearHistory);
|
||||
r9 = (RelativeLayout) findViewById(R.id.r9);
|
||||
r10 = (RelativeLayout) findViewById(R.id.r10);
|
||||
r11 = (RelativeLayout) findViewById(R.id.r11);
|
||||
r12 = (RelativeLayout) findViewById(R.id.r12);
|
||||
@ -144,7 +143,6 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
r6(r6);
|
||||
r7(r7);
|
||||
r8(r8);
|
||||
r9(r9);
|
||||
r10(r10);
|
||||
r11(r11);
|
||||
r12(r12);
|
||||
@ -170,7 +168,6 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
cbIncognitoCookies(cbIncognitoCookies);
|
||||
cbSearchSuggestions(cbSearchSuggestions);
|
||||
|
||||
TextView importBookmarks = (TextView) findViewById(R.id.isImportAvailable);
|
||||
TextView syncHistory = (TextView) findViewById(R.id.isBrowserAvailable);
|
||||
|
||||
RelativeLayout layoutSyncHistory = (RelativeLayout) findViewById(R.id.rBrowserHistory);
|
||||
@ -195,13 +192,11 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
if (!mSystemBrowser) {
|
||||
cbSyncHistory.setChecked(false);
|
||||
cbSyncHistory.setEnabled(false);
|
||||
importBookmarks.setText(getResources().getString(R.string.stock_browser_unavailable));
|
||||
syncHistory.setText(getResources().getString(R.string.stock_browser_unavailable));
|
||||
} else {
|
||||
cbSyncHistory.setEnabled(true);
|
||||
cbSyncHistory.setChecked(mPreferences
|
||||
.getBoolean(PreferenceConstants.SYNC_HISTORY, true));
|
||||
importBookmarks.setText(getResources().getString(R.string.stock_browser_available));
|
||||
syncHistory.setText(getResources().getString(R.string.stock_browser_available));
|
||||
}
|
||||
|
||||
@ -726,22 +721,6 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
messageHandler.sendEmptyMessage(2);
|
||||
}
|
||||
|
||||
private void r9(RelativeLayout view) {
|
||||
|
||||
view.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
importFromStockBrowser();
|
||||
} catch (Exception e) {
|
||||
// ignored exception
|
||||
// TODO add logging
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void r10(RelativeLayout view) {
|
||||
view.setOnClickListener(new OnClickListener() {
|
||||
|
||||
|
175
src/acr/browser/lightning/BookmarkActivity.java
Normal file
175
src/acr/browser/lightning/BookmarkActivity.java
Normal file
@ -0,0 +1,175 @@
|
||||
package acr.browser.lightning;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class BookmarkActivity extends Activity implements OnClickListener {
|
||||
|
||||
private BookmarkManager mBookmarkManager;
|
||||
private boolean mSystemBrowser;
|
||||
private SharedPreferences mPreferences;
|
||||
private File[] mFileList;
|
||||
private String[] mFileNameList;
|
||||
private File mPath = new File(Environment.getExternalStorageDirectory().toString());
|
||||
private static final int DIALOG_LOAD_FILE = 1000;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.bookmark_activity);
|
||||
|
||||
ActionBar actionBar = getActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setHomeButtonEnabled(true);
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
LinearLayout exportBackup = (LinearLayout) findViewById(R.id.exportBackup);
|
||||
LinearLayout importBackup = (LinearLayout) findViewById(R.id.importBackup);
|
||||
LinearLayout importFromBrowser = (LinearLayout) findViewById(R.id.importFromBrowser);
|
||||
|
||||
TextView importBookmarks = (TextView) findViewById(R.id.isImportBrowserAvailable);
|
||||
|
||||
mBookmarkManager = new BookmarkManager(this);
|
||||
|
||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||
|
||||
mSystemBrowser = mPreferences.getBoolean(PreferenceConstants.SYSTEM_BROWSER_PRESENT, false);
|
||||
|
||||
exportBackup.setOnClickListener(this);
|
||||
importBackup.setOnClickListener(this);
|
||||
importFromBrowser.setOnClickListener(this);
|
||||
|
||||
if (mSystemBrowser) {
|
||||
importBookmarks.setText(getResources().getString(R.string.stock_browser_available));
|
||||
} else {
|
||||
importBookmarks.setText(getResources().getString(R.string.stock_browser_unavailable));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.importBackup:
|
||||
loadFileList(null);
|
||||
onCreateDialog(DIALOG_LOAD_FILE);
|
||||
break;
|
||||
case R.id.importFromBrowser:
|
||||
mBookmarkManager.importBookmarksFromBrowser();
|
||||
break;
|
||||
case R.id.exportBackup:
|
||||
mBookmarkManager.exportBookmarks();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void loadFileList(File path) {
|
||||
File file;
|
||||
if (path != null) {
|
||||
file = path;
|
||||
} else {
|
||||
file = mPath;
|
||||
}
|
||||
try {
|
||||
file.mkdirs();
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (file.exists()) {
|
||||
mFileList = file.listFiles();
|
||||
} else {
|
||||
mFileList = new File[0];
|
||||
}
|
||||
|
||||
Arrays.sort(mFileList, new SortFileName());
|
||||
Arrays.sort(mFileList, new SortFolders());
|
||||
|
||||
if (mFileList == null) {
|
||||
mFileNameList = new String[0];
|
||||
mFileList = new File[0];
|
||||
} else {
|
||||
mFileNameList = new String[mFileList.length];
|
||||
}
|
||||
for (int n = 0; n < mFileList.length; n++) {
|
||||
mFileNameList[n] = mFileList[n].getName();
|
||||
}
|
||||
}
|
||||
|
||||
protected Dialog onCreateDialog(int id) {
|
||||
Dialog dialog = null;
|
||||
final AlertDialog.Builder builder = new Builder(this);
|
||||
|
||||
switch (id) {
|
||||
case DIALOG_LOAD_FILE:
|
||||
builder.setTitle(R.string.title_chooser);
|
||||
if (mFileList == null) {
|
||||
dialog = builder.create();
|
||||
return dialog;
|
||||
}
|
||||
builder.setItems(mFileNameList, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (mFileList[which].isDirectory()) {
|
||||
loadFileList(mFileList[which]);
|
||||
builder.setItems(mFileNameList, this);
|
||||
builder.show();
|
||||
} else {
|
||||
mBookmarkManager.importBookmarksFromFile(mFileList[which]);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
break;
|
||||
}
|
||||
dialog = builder.show();
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public class SortFileName implements Comparator<File> {
|
||||
|
||||
@Override
|
||||
public int compare(File f1, File f2) {
|
||||
return f1.getName().compareTo(f2.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class SortFolders implements Comparator<File> {
|
||||
|
||||
@Override
|
||||
public int compare(File f1, File f2) {
|
||||
if (f1.isDirectory() == f2.isDirectory())
|
||||
return 0;
|
||||
else if (f1.isDirectory() && !f2.isDirectory())
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -8,7 +8,10 @@ import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@ -19,6 +22,7 @@ import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.os.Environment;
|
||||
import android.provider.Browser;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class BookmarkManager {
|
||||
|
||||
@ -103,7 +107,7 @@ public class BookmarkManager {
|
||||
public synchronized boolean deleteBookmark(String url) {
|
||||
List<HistoryItem> list = new ArrayList<HistoryItem>();
|
||||
mBookmarkMap.remove(url);
|
||||
list = getBookmarks();
|
||||
list = getBookmarks(false);
|
||||
File bookmarksFile = new File(mContext.getFilesDir(), FILE_BOOKMARKS);
|
||||
boolean bookmarkDeleted = false;
|
||||
try {
|
||||
@ -135,10 +139,17 @@ public class BookmarkManager {
|
||||
* external download directory
|
||||
*/
|
||||
public synchronized void exportBookmarks() {
|
||||
List<HistoryItem> bookmarkList = getBookmarks();
|
||||
List<HistoryItem> bookmarkList = getBookmarks(true);
|
||||
File bookmarksExport = new File(
|
||||
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
|
||||
"BookmarksExport.txt");
|
||||
int counter = 0;
|
||||
while (bookmarksExport.exists()) {
|
||||
counter++;
|
||||
bookmarksExport = new File(
|
||||
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
|
||||
"BookmarksExport-" + counter + ".txt");
|
||||
}
|
||||
try {
|
||||
BufferedWriter bookmarkWriter = new BufferedWriter(new FileWriter(bookmarksExport,
|
||||
false));
|
||||
@ -152,11 +163,16 @@ public class BookmarkManager {
|
||||
bookmarkWriter.newLine();
|
||||
}
|
||||
bookmarkWriter.close();
|
||||
Toast.makeText(
|
||||
mContext,
|
||||
mContext.getString(R.string.bookmark_export_path) + " "
|
||||
+ bookmarksExport.getPath(), Toast.LENGTH_SHORT).show();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -164,7 +180,7 @@ public class BookmarkManager {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public synchronized List<HistoryItem> getBookmarks() {
|
||||
public synchronized List<HistoryItem> getBookmarks(boolean sort) {
|
||||
List<HistoryItem> bookmarks = new ArrayList<HistoryItem>();
|
||||
File bookmarksFile = new File(mContext.getFilesDir(), FILE_BOOKMARKS);
|
||||
try {
|
||||
@ -188,6 +204,9 @@ public class BookmarkManager {
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (sort) {
|
||||
Collections.sort(bookmarks, new SortIgnoreCase());
|
||||
}
|
||||
return bookmarks;
|
||||
}
|
||||
|
||||
@ -335,12 +354,16 @@ public class BookmarkManager {
|
||||
* @param dir
|
||||
* @param file
|
||||
*/
|
||||
public synchronized void importBookmarksFromFile(File dir, String file) {
|
||||
File bookmarksImport = new File(dir, file);
|
||||
public synchronized void importBookmarksFromFile(File file) {
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
File bookmarksImport = file;
|
||||
List<HistoryItem> list = new ArrayList<HistoryItem>();
|
||||
try {
|
||||
BufferedReader bookmarksReader = new BufferedReader(new FileReader(bookmarksImport));
|
||||
String line;
|
||||
int number = 0;
|
||||
while ((line = bookmarksReader.readLine()) != null) {
|
||||
JSONObject object = new JSONObject(line);
|
||||
HistoryItem item = new HistoryItem();
|
||||
@ -349,15 +372,27 @@ public class BookmarkManager {
|
||||
item.setFolder(object.getString(FOLDER));
|
||||
item.setOrder(object.getInt(ORDER));
|
||||
list.add(item);
|
||||
number++;
|
||||
}
|
||||
bookmarksReader.close();
|
||||
addBookmarkList(list);
|
||||
Utils.showToast(mContext,
|
||||
number + " " + mContext.getResources().getString(R.string.message_import));
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
Utils.createInformativeDialog(mContext,
|
||||
mContext.getResources().getString(R.string.title_error), mContext
|
||||
.getResources().getString(R.string.import_bookmark_error));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Utils.createInformativeDialog(mContext,
|
||||
mContext.getResources().getString(R.string.title_error), mContext
|
||||
.getResources().getString(R.string.import_bookmark_error));
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
Utils.createInformativeDialog(mContext,
|
||||
mContext.getResources().getString(R.string.title_error), mContext
|
||||
.getResources().getString(R.string.import_bookmark_error));
|
||||
}
|
||||
}
|
||||
|
||||
@ -388,4 +423,13 @@ public class BookmarkManager {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private class SortIgnoreCase implements Comparator<HistoryItem> {
|
||||
|
||||
public int compare(HistoryItem o1, HistoryItem o2) {
|
||||
return o1.getTitle().toLowerCase(Locale.getDefault())
|
||||
.compareTo(o2.getTitle().toLowerCase(Locale.getDefault()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
||||
mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
|
||||
mDrawerList.setOnItemLongClickListener(new DrawerItemLongClickListener());
|
||||
|
||||
mBookmarkList = mBookmarkManager.getBookmarks();
|
||||
mBookmarkList = mBookmarkManager.getBookmarks(true);
|
||||
mBookmarkAdapter = new BookmarkViewAdapter(this, R.layout.bookmark_list_item, mBookmarkList);
|
||||
mDrawerListRight.setAdapter(mBookmarkAdapter);
|
||||
mDrawerListRight.setOnItemClickListener(new BookmarkItemClickListener());
|
||||
@ -1275,7 +1275,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
||||
} else if (!mHistoryHandler.isOpen()) {
|
||||
mHistoryHandler = new HistoryDatabaseHandler(this);
|
||||
}
|
||||
mBookmarkList = mBookmarkManager.getBookmarks();
|
||||
mBookmarkList = mBookmarkManager.getBookmarks(true);
|
||||
notifyBookmarkDataSetChanged();
|
||||
} else {
|
||||
initialize();
|
||||
|
@ -23,8 +23,8 @@ public class LicenseActivity extends Activity implements View.OnClickListener {
|
||||
setContentView(R.layout.license_activity);
|
||||
getActionBar().setHomeButtonEnabled(true);
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
findViewById(R.id.browserLicense).setOnClickListener(this);
|
||||
findViewById(R.id.licenseAOSP).setOnClickListener(this);
|
||||
findViewById(R.id.exportBackup).setOnClickListener(this);
|
||||
findViewById(R.id.importBackup).setOnClickListener(this);
|
||||
findViewById(R.id.licenseHosts).setOnClickListener(this);
|
||||
findViewById(R.id.licenseOrbot).setOnClickListener(this);
|
||||
}
|
||||
@ -32,10 +32,10 @@ public class LicenseActivity extends Activity implements View.OnClickListener {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.browserLicense:
|
||||
case R.id.exportBackup:
|
||||
actionView("http://www.mozilla.org/MPL/2.0/");
|
||||
break;
|
||||
case R.id.licenseAOSP:
|
||||
case R.id.importBackup:
|
||||
actionView("http://www.apache.org/licenses/LICENSE-2.0");
|
||||
break;
|
||||
case R.id.licenseHosts:
|
||||
|
@ -46,7 +46,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
||||
mBookmarks = new ArrayList<HistoryItem>();
|
||||
mSuggestions = new ArrayList<HistoryItem>();
|
||||
mBookmarkManager = new BookmarkManager(context);
|
||||
mAllBookmarks = mBookmarkManager.getBookmarks();
|
||||
mAllBookmarks = mBookmarkManager.getBookmarks(true);
|
||||
mPreferences = context.getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||
mUseGoogle = mPreferences.getBoolean(PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, true);
|
||||
mContext = context;
|
||||
@ -61,7 +61,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
||||
}
|
||||
|
||||
public void refreshBookmarks() {
|
||||
mAllBookmarks = mBookmarkManager.getBookmarks();
|
||||
mAllBookmarks = mBookmarkManager.getBookmarks(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -85,6 +85,16 @@ public class SettingsActivity extends Activity {
|
||||
RelativeLayout layoutFlash = (RelativeLayout) findViewById(R.id.layoutFlash);
|
||||
RelativeLayout layoutBlockAds = (RelativeLayout) findViewById(R.id.layoutAdBlock);
|
||||
RelativeLayout layoutOrbot = (RelativeLayout) findViewById(R.id.layoutUseOrbot);
|
||||
RelativeLayout layoutBookmarks = (RelativeLayout) findViewById(R.id.layoutBookmarks);
|
||||
|
||||
layoutBookmarks.setOnClickListener(new OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(mContext, BookmarkActivity.class));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mSearchText = (TextView) findViewById(R.id.searchText);
|
||||
mRenderText = (TextView) findViewById(R.id.renderText);
|
||||
|
Loading…
x
Reference in New Issue
Block a user