mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 17:59:33 +02:00
highlighting color selection ui (in progress)
This commit is contained in:
parent
3f7b68c96d
commit
b0e91e82b7
7 changed files with 88 additions and 42 deletions
|
@ -107,6 +107,7 @@
|
||||||
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable"/>
|
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable"/>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="org.geometerplus.android.fbreader.CancelActivity" android:theme="@style/FBReader.Dialog" android:configChanges="orientation|keyboardHidden|screenSize"/>
|
<activity android:name="org.geometerplus.android.fbreader.CancelActivity" android:theme="@style/FBReader.Dialog" android:configChanges="orientation|keyboardHidden|screenSize"/>
|
||||||
|
<activity android:name="org.geometerplus.android.fbreader.StyleListActivity" android:theme="@style/FBReader.Dialog" android:configChanges="orientation|keyboardHidden|screenSize"/>
|
||||||
<activity android:name="org.geometerplus.android.fbreader.image.ImageViewActivity" android:process=":imageView" android:theme="@style/FBReader.Activity" android:configChanges="orientation|keyboardHidden|screenSize"/>
|
<activity android:name="org.geometerplus.android.fbreader.image.ImageViewActivity" android:process=":imageView" android:theme="@style/FBReader.Activity" android:configChanges="orientation|keyboardHidden|screenSize"/>
|
||||||
<service android:name="org.geometerplus.android.fbreader.libraryService.LibraryService" android:launchMode="singleTask" android:process=":libraryService">
|
<service android:name="org.geometerplus.android.fbreader.libraryService.LibraryService" android:launchMode="singleTask" android:process=":libraryService">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
|
|
@ -107,6 +107,7 @@
|
||||||
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable"/>
|
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable"/>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="org.geometerplus.android.fbreader.CancelActivity" android:theme="@style/FBReader.Dialog" android:configChanges="orientation|keyboardHidden|screenSize"/>
|
<activity android:name="org.geometerplus.android.fbreader.CancelActivity" android:theme="@style/FBReader.Dialog" android:configChanges="orientation|keyboardHidden|screenSize"/>
|
||||||
|
<activity android:name="org.geometerplus.android.fbreader.StyleListActivity" android:theme="@style/FBReader.Dialog" android:configChanges="orientation|keyboardHidden|screenSize"/>
|
||||||
<activity android:name="org.geometerplus.android.fbreader.image.ImageViewActivity" android:process=":imageView" android:theme="@style/FBReader.Activity" android:configChanges="orientation|keyboardHidden|screenSize"/>
|
<activity android:name="org.geometerplus.android.fbreader.image.ImageViewActivity" android:process=":imageView" android:theme="@style/FBReader.Activity" android:configChanges="orientation|keyboardHidden|screenSize"/>
|
||||||
<service android:name="org.geometerplus.android.fbreader.libraryService.LibraryService" android:launchMode="singleTask" android:process=":libraryService">
|
<service android:name="org.geometerplus.android.fbreader.libraryService.LibraryService" android:launchMode="singleTask" android:process=":libraryService">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
|
|
@ -3,16 +3,27 @@
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
|
android:paddingLeft="5dip"
|
||||||
|
android:paddingRight="8dp"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
>
|
>
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/style_item_color"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
|
android:minWidth="?android:attr/listPreferredItemHeight"
|
||||||
|
/>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/style_item_title"
|
android:id="@+id/style_item_title"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="fill_parent"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical|left"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:ellipsize="marquee"
|
/>
|
||||||
android:marqueeRepeatLimit="marquee_forever"
|
<View
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
/>
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
package org.geometerplus.android.fbreader;
|
package org.geometerplus.android.fbreader;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.book.Bookmark;
|
import org.geometerplus.fbreader.book.Bookmark;
|
||||||
|
@ -40,6 +42,9 @@ public class SelectionBookmarkAction extends FBAndroidAction {
|
||||||
ZLResource.resource("selection").getResource("bookmarkCreated").getValue()
|
ZLResource.resource("selection").getResource("bookmarkCreated").getValue()
|
||||||
.replace("%s", bookmark.getText())
|
.replace("%s", bookmark.getText())
|
||||||
);
|
);
|
||||||
//final Intent styleIntent = new Intent();
|
final Intent intent =
|
||||||
|
new Intent(BaseActivity.getApplicationContext(), StyleListActivity.class);
|
||||||
|
intent.putExtra(FBReader.BOOKMARK_KEY, SerializerUtil.serialize(bookmark));
|
||||||
|
OrientationUtil.startActivity(BaseActivity, intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
|
|
||||||
package org.geometerplus.android.fbreader;
|
package org.geometerplus.android.fbreader;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import android.app.ListActivity;
|
import android.app.ListActivity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -27,34 +30,63 @@ import android.view.*;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.ui.android.R;
|
import org.geometerplus.zlibrary.ui.android.R;
|
||||||
|
|
||||||
|
import org.geometerplus.fbreader.book.*;
|
||||||
|
|
||||||
|
import org.geometerplus.android.fbreader.libraryService.BookCollectionShadow;
|
||||||
|
|
||||||
public class StyleListActivity extends ListActivity {
|
public class StyleListActivity extends ListActivity {
|
||||||
static final String LIST_SIZE = "listSize";
|
private final BookCollectionShadow myCollection = new BookCollectionShadow();
|
||||||
static final String ITEM_TITLE = "title";
|
private Bookmark myBookmark;
|
||||||
static final String ITEM_SUMMARY = "summary";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle icicle) {
|
protected void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
final ActionListAdapter adapter = new ActionListAdapter(getIntent());
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
myCollection.bindToService(this, new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
myBookmark = SerializerUtil.deserializeBookmark(
|
||||||
|
getIntent().getStringExtra(FBReader.BOOKMARK_KEY)
|
||||||
|
);
|
||||||
|
if (myBookmark == null) {
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final List<HighlightingStyle> styles = myCollection.highlightingStyles();
|
||||||
|
if (styles.isEmpty()) {
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final ActionListAdapter adapter = new ActionListAdapter(styles);
|
||||||
setListAdapter(adapter);
|
setListAdapter(adapter);
|
||||||
getListView().setOnItemClickListener(adapter);
|
getListView().setOnItemClickListener(adapter);
|
||||||
setResult(-1);
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
myCollection.unbind();
|
||||||
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ActionListAdapter extends BaseAdapter implements AdapterView.OnItemClickListener {
|
private class ActionListAdapter extends BaseAdapter implements AdapterView.OnItemClickListener {
|
||||||
private final Intent myIntent;
|
private final List<HighlightingStyle> myStyles;
|
||||||
|
|
||||||
ActionListAdapter(Intent intent) {
|
ActionListAdapter(List<HighlightingStyle> styles) {
|
||||||
myIntent = intent;
|
myStyles = new ArrayList<HighlightingStyle>(styles);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getCount() {
|
public final int getCount() {
|
||||||
return myIntent.getIntExtra(LIST_SIZE, 0);
|
return myStyles.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Integer getItem(int position) {
|
public final HighlightingStyle getItem(int position) {
|
||||||
return position;
|
return myStyles.get(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final long getItemId(int position) {
|
public final long getItemId(int position) {
|
||||||
|
@ -64,30 +96,21 @@ public class StyleListActivity extends ListActivity {
|
||||||
public View getView(int position, View convertView, final ViewGroup parent) {
|
public View getView(int position, View convertView, final ViewGroup parent) {
|
||||||
final View view = convertView != null
|
final View view = convertView != null
|
||||||
? convertView
|
? convertView
|
||||||
: LayoutInflater.from(parent.getContext()).inflate(R.layout.cancel_item, parent, false);
|
: LayoutInflater.from(parent.getContext()).inflate(R.layout.style_item, parent, false);
|
||||||
final TextView titleView = (TextView)view.findViewById(R.id.cancel_item_title);
|
final TextView titleView = (TextView)view.findViewById(R.id.style_item_title);
|
||||||
final TextView summaryView = (TextView)view.findViewById(R.id.cancel_item_summary);
|
final String title = "Style " + getItem(position).Id;
|
||||||
final String title = myIntent.getStringExtra(ITEM_TITLE + position);
|
|
||||||
final String summary = myIntent.getStringExtra(ITEM_SUMMARY + position);
|
|
||||||
titleView.setText(title);
|
titleView.setText(title);
|
||||||
if (summary != null) {
|
|
||||||
summaryView.setVisibility(View.VISIBLE);
|
|
||||||
summaryView.setText(summary);
|
|
||||||
titleView.setLayoutParams(new LinearLayout.LayoutParams(
|
|
||||||
LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
summaryView.setVisibility(View.GONE);
|
|
||||||
titleView.setLayoutParams(new LinearLayout.LayoutParams(
|
|
||||||
LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT
|
|
||||||
));
|
|
||||||
}
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public final void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
|
||||||
setResult((int)id + 1);
|
myCollection.bindToService(StyleListActivity.this, new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
myBookmark.setStyleId(getItem(position).Id);
|
||||||
|
myCollection.saveBookmark(myBookmark);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -898,14 +898,14 @@ final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
if (bookmark.getId() == -1) {
|
if (bookmark.getId() == -1) {
|
||||||
if (myInsertBookmarkStatement == null) {
|
if (myInsertBookmarkStatement == null) {
|
||||||
myInsertBookmarkStatement = myDatabase.compileStatement(
|
myInsertBookmarkStatement = myDatabase.compileStatement(
|
||||||
"INSERT OR IGNORE INTO Bookmarks (book_id,bookmark_text,creation_time,modification_time,access_time,access_counter,model_id,paragraph,word,char,end_paragraph,end_word,end_character,visible) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
|
"INSERT OR IGNORE INTO Bookmarks (book_id,bookmark_text,creation_time,modification_time,access_time,access_counter,model_id,paragraph,word,char,end_paragraph,end_word,end_character,visible,style_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
statement = myInsertBookmarkStatement;
|
statement = myInsertBookmarkStatement;
|
||||||
} else {
|
} else {
|
||||||
if (myUpdateBookmarkStatement == null) {
|
if (myUpdateBookmarkStatement == null) {
|
||||||
myUpdateBookmarkStatement = myDatabase.compileStatement(
|
myUpdateBookmarkStatement = myDatabase.compileStatement(
|
||||||
"UPDATE Bookmarks SET book_id = ?, bookmark_text = ?, creation_time =?, modification_time = ?,access_time = ?, access_counter = ?, model_id = ?, paragraph = ?, word = ?, char = ?, end_paragraph = ?, end_word = ?, end_character = ?, visible = ? WHERE bookmark_id = ?"
|
"UPDATE Bookmarks SET book_id = ?, bookmark_text = ?, creation_time =?, modification_time = ?,access_time = ?, access_counter = ?, model_id = ?, paragraph = ?, word = ?, char = ?, end_paragraph = ?, end_word = ?, end_character = ?, visible = ?, style_id = ? WHERE bookmark_id = ?"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
statement = myUpdateBookmarkStatement;
|
statement = myUpdateBookmarkStatement;
|
||||||
|
@ -932,12 +932,13 @@ final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
statement.bindNull(13);
|
statement.bindNull(13);
|
||||||
}
|
}
|
||||||
statement.bindLong(14, bookmark.IsVisible ? 1 : 0);
|
statement.bindLong(14, bookmark.IsVisible ? 1 : 0);
|
||||||
|
statement.bindLong(15, bookmark.getStyleId());
|
||||||
|
|
||||||
if (statement == myInsertBookmarkStatement) {
|
if (statement == myInsertBookmarkStatement) {
|
||||||
return statement.executeInsert();
|
return statement.executeInsert();
|
||||||
} else {
|
} else {
|
||||||
final long id = bookmark.getId();
|
final long id = bookmark.getId();
|
||||||
statement.bindLong(12, id);
|
statement.bindLong(16, id);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,6 +257,10 @@ mainLoop:
|
||||||
return myStyleId;
|
return myStyleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setStyleId(int styleId) {
|
||||||
|
myStyleId = styleId;
|
||||||
|
}
|
||||||
|
|
||||||
public String getText() {
|
public String getText() {
|
||||||
return myText;
|
return myText;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue