Skip to content

Commit

Permalink
Made modifications for e-ink displays
Browse files Browse the repository at this point in the history
I made modifications to make Typhon suitable for e-Ink / e-Paper displays. In my case, it's for an Onyx Boox Nova 2.

I made the following modifications:
* Got rid of bookshelf image and replaced with black line on white background. Images don't look good in e-Ink, and this one serves little purpose anyways
* Made definition popup black text on white background (previously, it
  was hard-coded white/colored text on black; now, it's a hack to
  force black)
* Made definition popup not show loading indicator. This causes unnecessary flashing of the e-ink display, and loading is very fast anyways
* Changed controls to be inverted from black-on-white to
  white-on-black, when appropriate
  • Loading branch information
makuto committed Jun 15, 2020
1 parent 9004e71 commit faf352e
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 54 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,22 @@ Typhon is licensed under the GPL-V3 license.

Benjamin Marlé [email protected]

makuto's fork
-------------------
This fork uses the below [dajimenezja fork](https://github.com/dajimenezja/typhon) for its modern Android version and inclusion of JRikai.jar by default.

I then made modifications to make Typhon suitable for e-Ink / e-Paper displays. In my case, it's for an Onyx Boox Nova 2.

I made the following modifications:
- Got rid of bookshelf image and replaced with black line on white background. Images don't look good in e-Ink, and this one serves little purpose anyways
- Made definition popup black text on white background (previously, it was hard-coded white/colored text on black)
- Made definition popup not show loading indicator. This causes unnecessary flashing of the e-ink display, and loading is very fast anyways
- Changed controls to be inverted from black-on-white to white-on-black, when appropriate

Typhon改
-------------------
([dajimenezja fork](https://github.com/dajimenezja/typhon))

Revise code base to androidx api29, fixing some UI bugs (Notably fixes unused space at the bottom of tall displays)

Update anki integration so it doesn't crash on android 26+
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/java/org/zorgblub/rikai/DroidEdictEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
*/
public class DroidEdictEntry extends EdictEntry implements DroidEntry {
// default value are set to the rikaichan style
private int kanjiColor = -4724737;
private int kanjiColor = -1;

private int kanaColor = -4128832;
private int kanaColor = -1;

private int definitionColor = -1;

private int reasonColor = -8032;
private int reasonColor = -1;


public DroidEdictEntry() {
Expand Down Expand Up @@ -68,23 +68,23 @@ public void setReasonColor(int reasonColor) {

@Override
public int getBackgroundColor() {
return Color.BLACK;
return Color.WHITE;
}

@Override
public String toStringCompact() {
StringBuilder result = new StringBuilder(this.getLength());

result.append(wrapColor(kanjiColor, this.getWord()));
result.append(wrapColor(Color.BLACK, this.getWord()));

if (this.getReading().length() != 0) {
result.append(" [").append(wrapColor(kanaColor, this.getReading())).append("]");
result.append(" [").append(wrapColor(Color.BLACK, this.getReading())).append("]");
}
if (this.getReason().length() != 0) {
result.append(" (").append(wrapColor(reasonColor, this.getReason())).append(")");
result.append(" (").append(wrapColor(Color.BLACK, this.getReason())).append(")");
}

result.append("<br/>").append(wrapColor(definitionColor, this.getGloss()));
result.append("<br/>").append(wrapColor(Color.BLACK, this.getGloss()));

return result.toString();
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/zorgblub/rikai/DroidEpwingEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public Spanned render() {

@Override
public int getBackgroundColor() {
return Color.BLACK;
return Color.WHITE;
}
}
12 changes: 6 additions & 6 deletions app/src/main/java/org/zorgblub/rikai/DroidKanjiEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class DroidKanjiEntry extends KanjiEntry implements DroidEntry {

private int kanaColor = -4128832;

private int definitionColor = -1;
private int definitionColor = 0;

private int indexColor = -8032;

Expand Down Expand Up @@ -71,7 +71,7 @@ public void setHeisig6(boolean heisig6) {

@Override
public int getBackgroundColor() {
return Color.BLACK;
return Color.WHITE;
}

@Override
Expand All @@ -83,13 +83,13 @@ public String toStringCompact() {
}
String heisigNumber = prop.get(heisigTag);
StringBuilder result = new StringBuilder();
result.append(HtmlEntryUtils.wrapColor(kanjiColor, this.getKanji().toString()));
result.append(" [").append(HtmlEntryUtils.wrapColor(kanaColor, this.getYomi())).append("]");
result.append(HtmlEntryUtils.wrapColor(Color.BLACK, this.getKanji().toString()));
result.append(" [").append(HtmlEntryUtils.wrapColor(Color.BLACK, this.getYomi())).append("]");
if (heisigNumber != null) {
result.append(" (" + HtmlEntryUtils.wrapColor(indexColor, heisigNumber) + ")");
result.append(" (" + HtmlEntryUtils.wrapColor(Color.BLACK, heisigNumber) + ")");
}
result.append("<br/>");
result.append(HtmlEntryUtils.wrapColor(this.definitionColor, this.getDefinition()));
result.append(HtmlEntryUtils.wrapColor(Color.BLACK, this.getDefinition()));
return result.toString();
}

Expand Down
18 changes: 9 additions & 9 deletions app/src/main/java/org/zorgblub/rikai/DroidWordnetEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class DroidWordnetEntry extends WordnetEntry implements DroidEntry {

private int posColor = -8032;

private int definitionColor = -1;
private int definitionColor = 0;

public DroidWordnetEntry(DeinflectedWord variant, String word, String synset, String reason, String pos, String gloss, String rank, int lexid, int freq) {
super(variant, word, synset, reason, pos, gloss, rank, lexid, freq);
Expand Down Expand Up @@ -84,7 +84,7 @@ public void setPosColor(int posColor) {

@Override
public int getBackgroundColor() {
return Color.BLACK;
return Color.WHITE;
}

@Override
Expand All @@ -97,24 +97,24 @@ public String toStringCompact() {
// TODO change that to a SpannableStringBuilder for efficiency
StringBuilder result = new StringBuilder(this.getLength());

result.append(wrapColor(kanjiColor, this.getWord()));
result.append(wrapColor(Color.BLACK, this.getWord()));
if (this.getPartOfSpeech().length() != 0) {
result.append(" {").append(wrapColor(posColor, this.getPartOfSpeech())).append("}");
result.append(" {").append(wrapColor(Color.BLACK, this.getPartOfSpeech())).append("}");
}
if (this.getReason().length() != 0) {
result.append(" (").append(wrapColor(reasonColor, this.getReason())).append(")");
result.append(" (").append(wrapColor(Color.BLACK, this.getReason())).append(")");
}

List<String> synonyms = this.getSynonyms();
if(!synonyms.isEmpty())
result.append("<br/>").append(wrapColor(synonymColor, synonyms.toString()));
result.append("<br/>").append(wrapColor(definitionColor, this.getGloss()));
result.append("<br/>").append(wrapColor(Color.BLACK, synonyms.toString()));
result.append("<br/>").append(wrapColor(Color.BLACK, this.getGloss()));

List<WordnetExample> examples = this.getExamples();
if(!examples.isEmpty()) {
for (WordnetExample ex : examples) {
result.append("<br> ").append(wrapColor(exampleColor, ex.getNumber()+". "+ex.getJapaneseSentence()));
result.append("<br> ").append(wrapColor(exampleColor, "<i>"+ex.getEnglishSentence()+"</i>"));
result.append("<br> ").append(wrapColor(Color.BLACK, ex.getNumber()+". "+ex.getJapaneseSentence()));
result.append("<br> ").append(wrapColor(Color.BLACK, "<i>"+ex.getEnglishSentence()+"</i>"));
}
}
return result.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ public boolean onPinch(float scale) {
});
mTextColor = getResources().getColor(R.color.default_def_text_color);
/* background color of this view */
mBackgroundColor = Color.BLACK;
mBackgroundColor = Color.WHITE;

setDivider(new ColorDrawable(Color.parseColor("#C7C0C0C0")));
this.setTextColor(Color.WHITE);
this.setBackgroundColor(Color.parseColor("#C7000000"));
this.setBackgroundColor(Color.parseColor("#ffffff"));
this.setPadding(0, 0, 0, getPixels(20));
setDividerHeight(getPixels(3));
}
Expand Down Expand Up @@ -112,4 +112,4 @@ public int getIndex() {
public void setIndex(int index) {
this.index = index;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ public class ViewHolder {
public ProgressBar progressBar;

void startProgress(){
dictionaryListView.setVisibility(View.GONE);
progressBar.setVisibility(View.VISIBLE);
// Don't cause extra flashing on e-Ink display
// dictionaryListView.setVisibility(View.GONE);
// progressBar.setVisibility(View.VISIBLE);
}

void stopProgress(){
// Don't cause extra flashing on e-Ink display
progressBar.setVisibility(View.GONE);
dictionaryListView.setVisibility(View.VISIBLE);
}
Expand Down
Binary file modified app/src/main/res/drawable/shelf_single.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable/shelf_single_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 6 additions & 7 deletions app/src/main/res/layout/definition_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
Date: 2013 04 26
-->
<TextView
android:id="@+id/def"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
/>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/def"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF0000"
android:textSize="20sp" />
32 changes: 16 additions & 16 deletions app/src/main/res/layout/expandable_listview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,32 @@ Date: 2013 04 26
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/control_background"
>

<androidx.viewpager.widget.PagerTabStrip
android:id="@+id/pager_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:paddingBottom="4dp"
android:background="@color/opaque_white"
android:paddingTop="4dp"
android:textColor="#aaffffff"
android:background="@color/opaque_black"/>
android:paddingBottom="4dp"
android:textColor="#000000" />
</androidx.viewpager.widget.ViewPager>
<!-- android:fadeScrollbars="false" always shows scrollbar -->

<Button android:id="@+id/gloss_close"
android:layout_width="30dp"
android:layout_height="30dp"
android:visibility="invisible"
android:text="@string/close_button"
android:textSize="15sp"
android:textColor="#aaffffff"
android:background="@color/transparent"
android:paddingRight="5dp"
android:layout_alignParentTop="true"
android:layout_alignRight="@id/viewpager"
/>
<Button
android:id="@+id/gloss_close"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignRight="@id/viewpager"
android:layout_alignParentTop="true"
android:background="@color/transparent"
android:paddingRight="5dp"
android:text="@string/close_button"
android:textColor="#000000"
android:textSize="15sp"
android:visibility="invisible" />
<Button android:id="@+id/gloss_drag"
android:layout_width="match_parent"
android:layout_height="30dp"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
<color name="control_background">#C7000000</color>
<color name="default_def_bg_color">#C7000000</color>
<color name="default_def_text_color">#ffffff</color>
</resources>
</resources>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0-beta03'
classpath 'com.android.tools.build:gradle:4.0.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down

0 comments on commit faf352e

Please sign in to comment.