parent
8b438113ce
commit
042099a6ef
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.hmkcode.browser.bookmark"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="11"
|
||||
android:targetSdkVersion="19" />
|
||||
|
||||
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@ -0,0 +1,14 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context="com.hmkcode.browser.bookmark.MainActivity" >
|
||||
|
||||
<ListView android:id="@+id/listView1" android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" />
|
||||
|
||||
</RelativeLayout>
|
||||
@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="6dip" >
|
||||
|
||||
<ImageView android:id="@+id/favicon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="20dp"
|
||||
android:minWidth="20dp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvDate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:text="Date: "
|
||||
android:layout_below="@+id/favicon"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@+id/tvDate"
|
||||
android:layout_below="@+id/tvDate"
|
||||
android:text="Title: "
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvBoV"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@+id/tvTitle"
|
||||
android:layout_below="@+id/tvTitle"
|
||||
android:text="Type: "
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
<TextView
|
||||
android:id="@+id/tvUrl"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@+id/tvTitle"
|
||||
android:layout_below="@+id/tvBoV"
|
||||
android:text="URL: "
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/favicon"
|
||||
|
||||
android:layout_toRightOf="@+id/tvDate"
|
||||
android:text="Date" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/tvDate"
|
||||
android:layout_toRightOf="@+id/tvTitle"
|
||||
android:text="Title"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bov"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/tvTitle"
|
||||
|
||||
android:layout_toRightOf="@+id/tvBoV"
|
||||
android:text="Title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/url"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@+id/tvUrl"
|
||||
android:layout_below="@+id/tvBoV"
|
||||
android:text="URL" />
|
||||
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
@ -0,0 +1,30 @@
|
||||
package com.hmkcode.browser.bookmark;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Browser;
|
||||
|
||||
import android.widget.ListView;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
|
||||
ListView listView;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
listView = (ListView) findViewById(R.id.listView1);
|
||||
getBrowserHist();
|
||||
}
|
||||
|
||||
public void getBrowserHist() {
|
||||
|
||||
Cursor cursor = getContentResolver().query(Browser.BOOKMARKS_URI, null, null, null, null);
|
||||
|
||||
// Cursor cursor = getContentResolver().query(Browser.SEARCHES_URI, null, null, null, null);
|
||||
|
||||
MyCursorAdapter myCursorAdapter = new MyCursorAdapter(this,cursor,0);
|
||||
listView.setAdapter(myCursorAdapter);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package com.hmkcode.browser.bookmark;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.provider.Browser;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CursorAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class MyCursorAdapter extends CursorAdapter {
|
||||
|
||||
private LayoutInflater cursorInflater;
|
||||
|
||||
// Default constructor
|
||||
public MyCursorAdapter(Context context, Cursor cursor, int flags) {
|
||||
super(context, cursor, flags);
|
||||
cursorInflater = (LayoutInflater) context.getSystemService(
|
||||
Context.LAYOUT_INFLATER_SERVICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindView(View view, Context context, Cursor cursor) {
|
||||
|
||||
TextView tvDate = (TextView) view.findViewById(R.id.date);
|
||||
TextView tvTitle = (TextView) view.findViewById(R.id.title);
|
||||
TextView tvBoV = (TextView) view.findViewById(R.id.bov);
|
||||
TextView tvURL = (TextView) view.findViewById(R.id.url);
|
||||
ImageView ivFavicon = (ImageView) view.findViewById(R.id.favicon);
|
||||
|
||||
// long date = cursor.getLong(Browser.SEARCHES_PROJECTION_DATE_INDEX);
|
||||
// String title = cursor.getString(Browser.SEARCHES_PROJECTION_SEARCH_INDEX);
|
||||
|
||||
long date = cursor.getLong(Browser.HISTORY_PROJECTION_DATE_INDEX);
|
||||
String title = cursor.getString(Browser.HISTORY_PROJECTION_TITLE_INDEX);
|
||||
String url = cursor.getString(Browser.HISTORY_PROJECTION_URL_INDEX);
|
||||
byte[] icon = cursor.getBlob(Browser.HISTORY_PROJECTION_FAVICON_INDEX);
|
||||
String bokmrk = cursor.getString(Browser.HISTORY_PROJECTION_BOOKMARK_INDEX);
|
||||
String visits = cursor.getString(Browser.HISTORY_PROJECTION_VISITS_INDEX);
|
||||
String id = cursor.getString(Browser.HISTORY_PROJECTION_ID_INDEX);
|
||||
|
||||
// String names[] = cursor.getColumnNames();
|
||||
|
||||
|
||||
tvDate.setText(new Date(date).toString());
|
||||
tvBoV.setText(bokmrk.equals("1")?"Bookmarked":"Visited");
|
||||
tvTitle.setText(title);
|
||||
tvURL.setText(url);
|
||||
if(icon != null){
|
||||
Bitmap bm = BitmapFactory.decodeByteArray(icon, 0, icon.length);
|
||||
ivFavicon.setImageBitmap(bm);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
||||
return cursorInflater.inflate(R.layout.link, parent, false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue