Simplified History Logging
This commit is contained in:
parent
c270d39639
commit
448c168513
@ -701,7 +701,7 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void clearHistory() {
|
public void clearHistory() {
|
||||||
deleteDatabase(DatabaseHandler.DATABASE_NAME);
|
deleteDatabase(HistoryDatabaseHandler.DATABASE_NAME);
|
||||||
WebViewDatabase m = WebViewDatabase.getInstance(this);
|
WebViewDatabase m = WebViewDatabase.getInstance(this);
|
||||||
m.clearFormData();
|
m.clearFormData();
|
||||||
m.clearHttpAuthUsernamePassword();
|
m.clearHttpAuthUsernamePassword();
|
||||||
|
@ -14,8 +14,6 @@ import android.content.res.Configuration;
|
|||||||
import android.content.res.Resources.Theme;
|
import android.content.res.Resources.Theme;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.DatabaseUtils;
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
|
||||||
import android.database.sqlite.SQLiteException;
|
import android.database.sqlite.SQLiteException;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Bitmap.Config;
|
import android.graphics.Bitmap.Config;
|
||||||
@ -99,8 +97,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||||
private Bitmap mDefaultVideoPoster;
|
private Bitmap mDefaultVideoPoster;
|
||||||
private View mVideoProgressView;
|
private View mVideoProgressView;
|
||||||
private DatabaseHandler mHistoryHandler;
|
private HistoryDatabaseHandler mHistoryHandler;
|
||||||
private SQLiteDatabase mHistoryDatabase;
|
|
||||||
private SharedPreferences mPreferences;
|
private SharedPreferences mPreferences;
|
||||||
private SharedPreferences.Editor mEditPrefs;
|
private SharedPreferences.Editor mEditPrefs;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@ -189,11 +186,10 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
mDrawerListRight.setOnItemLongClickListener(new BookmarkItemLongClickListener());
|
mDrawerListRight.setOnItemLongClickListener(new BookmarkItemLongClickListener());
|
||||||
|
|
||||||
if (mHistoryHandler == null) {
|
if (mHistoryHandler == null) {
|
||||||
mHistoryHandler = new DatabaseHandler(this);
|
mHistoryHandler = new HistoryDatabaseHandler(this);
|
||||||
} else if (!mHistoryHandler.isOpen()) {
|
} else if (!mHistoryHandler.isOpen()) {
|
||||||
mHistoryHandler = new DatabaseHandler(this);
|
mHistoryHandler = new HistoryDatabaseHandler(this);
|
||||||
}
|
}
|
||||||
mHistoryDatabase = mHistoryHandler.getReadableDatabase();
|
|
||||||
|
|
||||||
// set display options of the ActionBar
|
// set display options of the ActionBar
|
||||||
mActionBar.setDisplayShowTitleEnabled(false);
|
mActionBar.setDisplayShowTitleEnabled(false);
|
||||||
@ -412,7 +408,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
|
|
||||||
mDrawerLayout.setDrawerListener(mDrawerToggle);
|
mDrawerLayout.setDrawerListener(mDrawerToggle);
|
||||||
mDrawerLayout.setDrawerShadow(R.drawable.drawer_right_shadow, GravityCompat.END);
|
mDrawerLayout.setDrawerShadow(R.drawable.drawer_right_shadow, GravityCompat.END);
|
||||||
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
|
mDrawerLayout.setDrawerShadow(R.drawable.drawer_left_shadow, GravityCompat.START);
|
||||||
initializePreferences();
|
initializePreferences();
|
||||||
initializeTabs();
|
initializeTabs();
|
||||||
|
|
||||||
@ -1166,7 +1162,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void clearHistory() {
|
public void clearHistory() {
|
||||||
this.deleteDatabase(DatabaseHandler.DATABASE_NAME);
|
this.deleteDatabase(HistoryDatabaseHandler.DATABASE_NAME);
|
||||||
WebViewDatabase m = WebViewDatabase.getInstance(this);
|
WebViewDatabase m = WebViewDatabase.getInstance(this);
|
||||||
m.clearFormData();
|
m.clearFormData();
|
||||||
m.clearHttpAuthUsernamePassword();
|
m.clearHttpAuthUsernamePassword();
|
||||||
@ -1226,11 +1222,6 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
mCurrentView.pauseTimers();
|
mCurrentView.pauseTimers();
|
||||||
mCurrentView.onPause();
|
mCurrentView.onPause();
|
||||||
}
|
}
|
||||||
if (mHistoryDatabase != null) {
|
|
||||||
if (mHistoryDatabase.isOpen()) {
|
|
||||||
mHistoryDatabase.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mHistoryHandler != null) {
|
if (mHistoryHandler != null) {
|
||||||
if (mHistoryHandler.isOpen()) {
|
if (mHistoryHandler.isOpen()) {
|
||||||
mHistoryHandler.close();
|
mHistoryHandler.close();
|
||||||
@ -1255,11 +1246,6 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
Log.i(Constants.TAG, "onDestroy");
|
Log.i(Constants.TAG, "onDestroy");
|
||||||
if (mHistoryDatabase != null) {
|
|
||||||
if (mHistoryDatabase.isOpen()) {
|
|
||||||
mHistoryDatabase.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mHistoryHandler != null) {
|
if (mHistoryHandler != null) {
|
||||||
if (mHistoryHandler.isOpen()) {
|
if (mHistoryHandler.isOpen()) {
|
||||||
mHistoryHandler.close();
|
mHistoryHandler.close();
|
||||||
@ -1288,11 +1274,10 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
mCurrentView.onResume();
|
mCurrentView.onResume();
|
||||||
|
|
||||||
if (mHistoryHandler == null) {
|
if (mHistoryHandler == null) {
|
||||||
mHistoryHandler = new DatabaseHandler(this);
|
mHistoryHandler = new HistoryDatabaseHandler(this);
|
||||||
} else if (!mHistoryHandler.isOpen()) {
|
} else if (!mHistoryHandler.isOpen()) {
|
||||||
mHistoryHandler = new DatabaseHandler(this);
|
mHistoryHandler = new HistoryDatabaseHandler(this);
|
||||||
}
|
}
|
||||||
mHistoryDatabase = mHistoryHandler.getReadableDatabase();
|
|
||||||
mBookmarkList = getBookmarks();
|
mBookmarkList = getBookmarks();
|
||||||
notifyBookmarkDataSetChanged();
|
notifyBookmarkDataSetChanged();
|
||||||
} else {
|
} else {
|
||||||
@ -1742,31 +1727,10 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
StringBuilder sb = new StringBuilder("url" + " = ");
|
if (mHistoryHandler == null && !mHistoryHandler.isOpen()) {
|
||||||
DatabaseUtils.appendEscapedSQLString(sb, url);
|
mHistoryHandler = new HistoryDatabaseHandler(mContext);
|
||||||
|
|
||||||
if (mHistoryHandler == null) {
|
|
||||||
mHistoryHandler = new DatabaseHandler(mContext);
|
|
||||||
mHistoryDatabase = mHistoryHandler.getReadableDatabase();
|
|
||||||
} else if (!mHistoryHandler.isOpen()) {
|
|
||||||
mHistoryHandler = new DatabaseHandler(mContext);
|
|
||||||
mHistoryDatabase = mHistoryHandler.getReadableDatabase();
|
|
||||||
} else if (mHistoryDatabase == null) {
|
|
||||||
mHistoryDatabase = mHistoryHandler.getReadableDatabase();
|
|
||||||
} else if (!mHistoryDatabase.isOpen()) {
|
|
||||||
mHistoryDatabase = mHistoryHandler.getReadableDatabase();
|
|
||||||
}
|
}
|
||||||
Cursor cursor = mHistoryDatabase.query(DatabaseHandler.TABLE_HISTORY,
|
mHistoryHandler.visitHistoryItem(url, title);
|
||||||
new String[] { "id", "url", "title" }, sb.toString(), null, null, null,
|
|
||||||
null);
|
|
||||||
if (!cursor.moveToFirst()) {
|
|
||||||
mHistoryHandler.addHistoryItem(new HistoryItem(url, title));
|
|
||||||
} else {
|
|
||||||
mHistoryHandler.delete(url);
|
|
||||||
mHistoryHandler.addHistoryItem(new HistoryItem(url, title));
|
|
||||||
}
|
|
||||||
cursor.close();
|
|
||||||
cursor = null;
|
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
Log.e(Constants.TAG, "IllegalStateException in updateHistory");
|
Log.e(Constants.TAG, "IllegalStateException in updateHistory");
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
@ -1884,7 +1848,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
* returns a list of HistoryItems
|
* returns a list of HistoryItems
|
||||||
*/
|
*/
|
||||||
private List<HistoryItem> getLatestHistory() {
|
private List<HistoryItem> getLatestHistory() {
|
||||||
DatabaseHandler historyHandler = new DatabaseHandler(mContext);
|
HistoryDatabaseHandler historyHandler = new HistoryDatabaseHandler(mContext);
|
||||||
return historyHandler.getLastHundredItems();
|
return historyHandler.getLastHundredItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import android.database.sqlite.SQLiteOpenHelper;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DatabaseHandler extends SQLiteOpenHelper {
|
public class HistoryDatabaseHandler extends SQLiteOpenHelper {
|
||||||
|
|
||||||
// All Static variables
|
// All Static variables
|
||||||
// Database Version
|
// Database Version
|
||||||
@ -33,7 +33,7 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
|||||||
|
|
||||||
public static SQLiteDatabase mDatabase;
|
public static SQLiteDatabase mDatabase;
|
||||||
|
|
||||||
public DatabaseHandler(Context context) {
|
public HistoryDatabaseHandler(Context context) {
|
||||||
super(context.getApplicationContext(), DATABASE_NAME, null, DATABASE_VERSION);
|
super(context.getApplicationContext(), DATABASE_NAME, null, DATABASE_VERSION);
|
||||||
mDatabase = this.getWritableDatabase();
|
mDatabase = this.getWritableDatabase();
|
||||||
}
|
}
|
||||||
@ -82,13 +82,20 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
|||||||
deleteHistoryItem(n);
|
deleteHistoryItem(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized void visitHistoryItem(String url, String title){
|
||||||
|
mDatabase.delete(TABLE_HISTORY, KEY_URL + " = ?", new String[] { url });
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(KEY_URL, url);
|
||||||
|
values.put(KEY_TITLE, title);
|
||||||
|
mDatabase.insert(TABLE_HISTORY, null, values);
|
||||||
|
}
|
||||||
|
|
||||||
// Adding new item
|
// Adding new item
|
||||||
public synchronized void addHistoryItem(HistoryItem item) {
|
public synchronized void addHistoryItem(HistoryItem item) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(KEY_URL, item.getUrl()); // HistoryItem Name
|
values.put(KEY_URL, item.getUrl());
|
||||||
values.put(KEY_TITLE, item.getTitle()); // HistoryItem Phone
|
values.put(KEY_TITLE, item.getTitle());
|
||||||
// Inserting Row
|
|
||||||
mDatabase.insert(TABLE_HISTORY, null, values);
|
mDatabase.insert(TABLE_HISTORY, null, values);
|
||||||
}
|
}
|
||||||
|
|
@ -9,14 +9,12 @@ public class HistoryItem implements Comparable<HistoryItem> {
|
|||||||
|
|
||||||
// private variables
|
// private variables
|
||||||
private int mId;
|
private int mId;
|
||||||
|
|
||||||
private String mUrl;
|
private String mUrl;
|
||||||
|
|
||||||
private String mTitle;
|
private String mTitle;
|
||||||
|
|
||||||
private Bitmap mBitmap;
|
private Bitmap mBitmap;
|
||||||
|
private String mFolder;
|
||||||
private int mImageId;
|
private int mImageId;
|
||||||
|
private int mOrder;
|
||||||
|
|
||||||
// Empty constructor
|
// Empty constructor
|
||||||
public HistoryItem() {
|
public HistoryItem() {
|
||||||
@ -68,6 +66,22 @@ public class HistoryItem implements Comparable<HistoryItem> {
|
|||||||
mBitmap = image;
|
mBitmap = image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFolder(String folder) {
|
||||||
|
mFolder = folder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrder(int order) {
|
||||||
|
mOrder = order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOrder() {
|
||||||
|
return mOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFolder() {
|
||||||
|
return mFolder;
|
||||||
|
}
|
||||||
|
|
||||||
public Bitmap getBitmap() {
|
public Bitmap getBitmap() {
|
||||||
return mBitmap;
|
return mBitmap;
|
||||||
}
|
}
|
||||||
|
@ -32,14 +32,14 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
private List<HistoryItem> mSuggestions;
|
private List<HistoryItem> mSuggestions;
|
||||||
private List<HistoryItem> mFilteredList;
|
private List<HistoryItem> mFilteredList;
|
||||||
private List<HistoryItem> mAllBookmarks;
|
private List<HistoryItem> mAllBookmarks;
|
||||||
private DatabaseHandler mDatabaseHandler;
|
private HistoryDatabaseHandler mDatabaseHandler;
|
||||||
private SharedPreferences mPreferences;
|
private SharedPreferences mPreferences;
|
||||||
private boolean mUseGoogle = true;
|
private boolean mUseGoogle = true;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private boolean mIncognito;
|
private boolean mIncognito;
|
||||||
|
|
||||||
public SearchAdapter(Context context, boolean incognito) {
|
public SearchAdapter(Context context, boolean incognito) {
|
||||||
mDatabaseHandler = new DatabaseHandler(context);
|
mDatabaseHandler = new HistoryDatabaseHandler(context);
|
||||||
mFilteredList = new ArrayList<HistoryItem>();
|
mFilteredList = new ArrayList<HistoryItem>();
|
||||||
mHistory = new ArrayList<HistoryItem>();
|
mHistory = new ArrayList<HistoryItem>();
|
||||||
mBookmarks = new ArrayList<HistoryItem>();
|
mBookmarks = new ArrayList<HistoryItem>();
|
||||||
@ -188,7 +188,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
if (mDatabaseHandler == null || !mDatabaseHandler.isOpen()) {
|
if (mDatabaseHandler == null || !mDatabaseHandler.isOpen()) {
|
||||||
mDatabaseHandler = new DatabaseHandler(mContext);
|
mDatabaseHandler = new HistoryDatabaseHandler(mContext);
|
||||||
}
|
}
|
||||||
mHistory = mDatabaseHandler.findItemsContaining(constraint.toString());
|
mHistory = mDatabaseHandler.findItemsContaining(constraint.toString());
|
||||||
for (int n = 0; n < mHistory.size(); n++) {
|
for (int n = 0; n < mHistory.size(); n++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user