Skip to content

Commit

Permalink
- you can choose if you want the richtexteditor or plain android edi…
Browse files Browse the repository at this point in the history
…tor in settings

  - richtext editor can format text with bubble list
  - richtext editor can format text with number list
  • Loading branch information
konradrenner committed Mar 16, 2016
1 parent 95fd23b commit 4fbc4c1
Show file tree
Hide file tree
Showing 31 changed files with 90 additions and 23 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "org.kore.kolabnotes.android"
minSdkVersion 16
targetSdkVersion 23
versionCode 60
versionName "1.8.2"
versionCode 61
versionName "1.9.0"

//Running test
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/org/kore/kolabnotes/android/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,16 @@ public static boolean getShowMetainformation(Context context) {

}

public static boolean getUseRicheditor(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if(prefs == null){
Log.d("getUseRicheditor","PreferenceManager prefs are null");
return true;
}
return prefs.getBoolean("pref_richeditor", true);

}

public static boolean getShowSyncNotifications(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if(prefs == null){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.Html;
import android.text.Spanned;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
Expand Down Expand Up @@ -105,6 +106,8 @@ public class DetailFragment extends Fragment{
private String startNotebook;

private RichEditor editor;

private EditText editText;

private AppCompatActivity activity;

Expand Down Expand Up @@ -156,23 +159,31 @@ public void onActivityCreated(Bundle savedInstanceState) {

setHasOptionsMenu(true);

editor = (RichEditor)activity.findViewById(R.id.detail_description);
editor.setBackgroundColor(getResources().getColor(R.color.background_material_light));
editor.setEditorHeight(300);
editor.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean b) {
final View bar = activity.findViewById(R.id.editor_bar);
final int visibility = bar.getVisibility();
if(visibility == View.GONE){
bar.setVisibility(View.VISIBLE);
}else{
bar.setVisibility(View.GONE
);
boolean useRicheditor = Utils.getUseRicheditor(activity);

if(useRicheditor) {
editor = (RichEditor) activity.findViewById(R.id.detail_description);
editor.setVisibility(View.VISIBLE);
editor.setBackgroundColor(getResources().getColor(R.color.background_material_light));
editor.setEditorHeight(300);
editor.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean b) {
final View bar = activity.findViewById(R.id.editor_bar);
final int visibility = bar.getVisibility();
if (visibility == View.GONE) {
bar.setVisibility(View.VISIBLE);
} else {
bar.setVisibility(View.GONE
);
}
}
}
});
initEditor();
});
initEditor();
}else{
editText = (EditText) activity.findViewById(R.id.detail_description_plain);
editText.setVisibility(View.VISIBLE);
}

// Handle Back Navigation :D
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
Expand Down Expand Up @@ -291,7 +302,12 @@ void setToolbarColor(){

void setHtml(String text){
final String stripped = stripBody(text);
editor.setHtml(stripped);
if(editor != null){
editor.setHtml(stripped);
}else{
Spanned fromHtml = Html.fromHtml(stripped);
editText.setText(fromHtml, TextView.BufferType.SPANNABLE);
}
}

String stripBody(String html){
Expand Down Expand Up @@ -947,11 +963,18 @@ public void onClick(DialogInterface dialog, int id) {
}

String getDescriptionFromView(){
final String html = editor.getHtml();
if(TextUtils.isEmpty(html)){
return null;
if(editor != null){
final String html = editor.getHtml();
if(TextUtils.isEmpty(html)){
return null;
}
return html;
}
return html;

StringBuilder sb = new StringBuilder(HTMLSTART);
sb.append(Html.toHtml(editText.getText()));
sb.append(HTMLEND);
return sb.toString();
}

private AlertDialog createNotebookDialog(){
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions app/src/main/res/layout/fragment_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@
</FrameLayout>

<jp.wasabeef.richeditor.RichEditor
android:visibility="gone"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="4dp"
Expand All @@ -285,5 +286,20 @@
android:editable="true"
/>

<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/detail_description_plain"
android:visibility="gone"
android:gravity="top"
android:inputType="textMultiLine|textWebEditText"
android:autoText="false"
android:textColor="@color/primary_text_default_material_light"
android:textColorHint="@color/secondary_text_default_material_light"
android:hint="@string/description_hint"
android:editable="true"
android:bufferType="spannable"
android:enabled="true" />

</LinearLayout>
</FrameLayout>
2 changes: 2 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,6 @@
<string name="importing">Importiere</string>
<string name="import_canceled">Import abgebrochen</string>
<string name="imported">Noitizbuch importiert</string>
<string name="pref_richeditor">Richtexteditor aktivieren</string>
<string name="pref_desc_richeditor">Aktiviert den Richtexteditor zum Erstellen von formattierten Notizen</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,6 @@
<string name="importing"> Importation</string>
<string name="import_canceled">Importation annulée</string>
<string name="imported"> Notebook importés</string>
<string name="pref_richeditor"> Activer RichTextEditor</string>
<string name="pref_desc_richeditor"> Active le RichTextEditor pour les notes formatées</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,6 @@
<string name="importing"> Importazione</string>
<string name="import_canceled"> Import cancellato</string>
<string name="imported">Notebook importati</string>
<string name="pref_richeditor"> Abilita RichTextEditor</string>
<string name="pref_desc_richeditor"> Attiva la RichTextEditor per le note formattati</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,7 @@
<string name="importing">Импорт</string>
<string name="import_canceled">Импорт блокнота отменён</string>
<string name="imported">Блокнот импортирован</string>
<string name="pref_richeditor"> Включить RichTextEditor</string>
<string name="pref_desc_richeditor"> Включает RichTextEditor для отформатированных нот</string>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-vi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,6 @@
<string name="importing"> nhập khẩu</string>
<string name="import_canceled">nhập hủy</string>
<string name="imported"> Máy tính xách tay nhập khẩu</string>
<string name="pref_richeditor"> Kích hoạt tính năng RichTextEditor</string>
<string name="pref_desc_richeditor">Cho phép các RichTextEditor cho các ghi chú được định dạng</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,7 @@
<string name="importing">Importing</string>
<string name="import_canceled">Notebook import canceled</string>
<string name="imported">Notebook imported</string>
<string name="pref_richeditor">Enable Richtexteditor</string>
<string name="pref_desc_richeditor">Enables the Richtexteditor for formatted notes</string>

</resources>
6 changes: 6 additions & 0 deletions app/src/main/res/xml/pref_general.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
android:summary="@string/pref_desc_metainformation"
android:defaultValue="true" />

<SwitchPreference
android:key="pref_richeditor"
android:title="@string/pref_richeditor"
android:summary="@string/pref_desc_richeditor"
android:defaultValue="true" />

<PreferenceCategory android:key="sorting_category" android:title="@string/pref_sorting_category" >

<ListPreference
Expand Down

0 comments on commit 4fbc4c1

Please sign in to comment.