Permalink
Browse files

Added white and monochrome themes for OutlineList

Font size in outline viewer
  • Loading branch information...
1 parent 11bfaf4 commit da6eef33d0898d94ad739185a889ed6fbd8703c7 @kvj committed Jun 17, 2012
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+ <solid android:color="#00ffffff"/>
+
+ <stroke android:width="1dp"
+ android:color="#77777777"/>
+
+ <padding
+ android:left="0dp"
+ android:top="0dp"
+ android:right="0dp"
+ android:bottom="1dp"/>
+</shape>
View
@@ -94,4 +94,14 @@
<item>80% Black</item>
<item>Black</item>
</string-array>
+ <string-array name="themes">
+ <item>Black (default)</item>
+ <item>White</item>
+ <item>Monochrome</item>
+ </string-array>
+ <string-array name="themeVals">
+ <item>black</item>
+ <item>white</item>
+ <item>mono</item>
+ </string-array>
</resources>
View
@@ -14,4 +14,9 @@
<string name="searchHint">Search outline, text</string>
<string name="searchDesctiption">Outline, text</string>
<string name="canExpandAll">canExpandAll</string>
+ <string name="useWhite">useWhite</string>
+ <string name="theme">theme</string>
+ <string name="themeDefault">black</string>
+ <string name="docFontSize">docFontSize</string>
+ <string name="docFontSizeDefault">14</string>
</resources>
View
@@ -2,7 +2,7 @@
<resources>
<style name="edit_text_mono" parent="@android:style/Widget.EditText">
<item name="android:typeface">monospace</item>
- <item name="android:textSize">14dp</item>
+ <item name="android:textSize">16dp</item>
<item name="android:autoText">true</item>
<item name="android:inputType">text|textAutoCorrect|textLongMessage</item>
</style>
View
@@ -62,7 +62,22 @@
android:summary="Expand All in outline viewer (for new panes)"
android:title="Expand All feature"
android:defaultValue="true"/>
- </PreferenceCategory>
+ <ListPreference
+ android:defaultValue="@string/themeDefault"
+ android:entries="@array/themes"
+ android:entryValues="@array/themeVals"
+ android:key="@string/theme"
+ android:summary="Theme for outline list"
+ android:title="Theme" />
+ <ListPreference
+ android:defaultValue="@string/docFontSizeDefault"
+ android:entries="@array/docFontSizes"
+ android:entryValues="@array/docFontSizesVals"
+ android:key="@string/docFontSize"
+ android:summary="Text size for outline list"
+ android:title="Text size" />
+
+ </PreferenceCategory>
<PreferenceCategory android:title="Other" >
@@ -17,6 +17,7 @@
import com.matburt.mobileorg.ng.service.DataController.TodoState;
import com.matburt.mobileorg.ng.ui.adapter.OutlineViewerAdapter;
import com.matburt.mobileorg.ng.ui.adapter.OutlineViewerAdapter.TextViewParts;
+import com.matburt.mobileorg.ng.ui.theme.DefaultTheme;
public class SearchProvider extends ContentProvider {
@@ -72,7 +73,7 @@ public Cursor query(Uri uri, String[] projection, String selection,
List<NoteNG> result = controller.search(query, limit, todos,
priorities);
OutlineViewerAdapter adapter = new OutlineViewerAdapter(
- getContext(), null);
+ getContext(), null, new DefaultTheme());
adapter.setController(-2, controller, null);
for (int i = 0; i < result.size(); i++) {
NoteNG note = result.get(i);
@@ -17,6 +17,7 @@
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
+import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
@@ -80,6 +81,11 @@ protected void onCreate(Bundle savedInstanceState) {
getMenuInflater().inflate(R.menu.editor_menu, bar.asMenu());
}
edit = (EditText) findViewById(R.id.data_edit_text);
+ edit.setTextSize(
+ TypedValue.COMPLEX_UNIT_DIP,
+ App.getInstance().getIntPreference(R.string.docFontSize,
+ R.string.docFontSizeDefault));
+
togglePanel = (ImageButton) findViewById(R.id.data_edit_button);
panel = (DataEditOptionsPanel) getSupportFragmentManager()
.findFragmentById(R.id.data_edit_panel);
@@ -7,13 +7,15 @@
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.InputType;
+import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
+import com.matburt.mobileorg.ng.App;
import com.matburt.mobileorg.ng.R;
import com.matburt.mobileorg.ng.service.DataController;
import com.matburt.mobileorg.ng.service.DataController.TodoState;
@@ -43,6 +45,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
tagsText = (EditText) view.findViewById(R.id.data_panel_tags);
tagsText.setInputType(InputType.TYPE_CLASS_TEXT
| InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
+ tagsText.setTextSize(
+ TypedValue.COMPLEX_UNIT_DIP,
+ App.getInstance().getIntPreference(R.string.docFontSize,
+ R.string.docFontSizeDefault));
return view;
}
@@ -16,6 +16,7 @@
import com.matburt.mobileorg.ng.service.NoteNG;
import com.matburt.mobileorg.ng.ui.adapter.OutlineViewerAdapter;
import com.matburt.mobileorg.ng.ui.adapter.OutlineViewerAdapter.OutlineViewerAdapterListener;
+import com.matburt.mobileorg.ng.ui.theme.DefaultTheme;
public class OutlineViewerFragment extends ListFragment {
@@ -41,7 +42,8 @@ public boolean onKeyPress(int keyCode, OutlineViewerFragment fragment,
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
- adapter = new OutlineViewerAdapter(getActivity(), null);
+ adapter = new OutlineViewerAdapter(getActivity(), null,
+ DefaultTheme.loadTheme());
setListAdapter(adapter);
adapter.setListener(dataListener);
getListView().setOnItemLongClickListener(new OnItemLongClickListener() {
@@ -82,6 +84,8 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
});
canExpandAll = App.getInstance().getBooleanPreference(
R.string.canExpandAll, true);
+ Log.i(TAG, "BG: " + adapter.getTheme().c0Black);
+ getListView().setBackgroundColor(adapter.getTheme().c0Black);
}
public boolean keyListener(int keyCode, KeyEvent event) {
@@ -16,6 +16,7 @@
import com.matburt.mobileorg.ng.service.DataController;
import com.matburt.mobileorg.ng.service.DataService;
import com.matburt.mobileorg.ng.ui.adapter.OutlineViewerAdapter;
+import com.matburt.mobileorg.ng.ui.theme.DefaultTheme;
public class SearchActivity extends
SuperActivity<App, DataController, DataService> {
@@ -55,7 +56,7 @@ protected void onCreate(Bundle savedInstanceState) {
}
setContentView(R.layout.search_outline);
listView = (ListView) findViewById(R.id.search_outline_list);
- adapter = new OutlineViewerAdapter(this, null);
+ adapter = new OutlineViewerAdapter(this, null, new DefaultTheme());
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
@@ -16,50 +16,42 @@
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.text.SpannableStringBuilder;
-import android.text.style.BackgroundColorSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.text.style.UnderlineSpan;
import android.util.Log;
+import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
import android.widget.TextView;
import android.widget.TextView.BufferType;
+import com.matburt.mobileorg.ng.App;
import com.matburt.mobileorg.ng.R;
import com.matburt.mobileorg.ng.service.DataController;
import com.matburt.mobileorg.ng.service.DataController.TodoState;
import com.matburt.mobileorg.ng.service.DataWriter;
import com.matburt.mobileorg.ng.service.NoteNG;
import com.matburt.mobileorg.ng.service.OrgNGParser;
-import com.matburt.mobileorg.ng.ui.theme.Default;
+import com.matburt.mobileorg.ng.ui.theme.DefaultTheme;
public class OutlineViewerAdapter implements ListAdapter {
Integer id = null;
NoteNG clicked = null;
- static Default theme = new Default();
- static int[] levelColors = new int[0];
- static Map<Integer, Integer> tagMapping = new HashMap<Integer, Integer>();
+ DefaultTheme theme = null;
+ int[] levelColors = new int[0];
+ Map<Integer, Integer> tagMapping = new HashMap<Integer, Integer>();
PlainTextFormatter textFormatter = null;
PlainTextFormatter sublistFormatter = null;
+ private int textSize = 14;
private static final int MAX_DATA_SIZE = 200;
private static final int MAX_EXPAND_ALL_DEPTH = 3;
static {
- levelColors = new int[] { theme.ccLBlue, theme.c3Yellow, theme.ceLCyan,
- theme.c1Red, theme.c2Green, theme.c5Purple, theme.ccLBlue,
- theme.c2Green, theme.ccLBlue, theme.c3Yellow, theme.ceLCyan };
- tagMapping.put(theme.c1Red, theme.c9LRed);
- tagMapping.put(theme.c2Green, theme.caLGreen);
- tagMapping.put(theme.c3Yellow, theme.cbLYellow);
- tagMapping.put(theme.c4Blue, theme.ccLBlue);
- tagMapping.put(theme.c5Purple, theme.cdLPurple);
- tagMapping.put(theme.c6Cyan, theme.ceLCyan);
- tagMapping.put(theme.c7White, theme.cfLWhite);
}
public static interface OutlineViewerAdapterListener {
@@ -72,7 +64,18 @@
}
public OutlineViewerAdapter(Context context,
- OutlineViewerAdapterListener listener) {
+ OutlineViewerAdapterListener listener, DefaultTheme theme) {
+ this.theme = theme;
+ levelColors = new int[] { theme.ccLBlue, theme.c3Yellow, theme.ceLCyan,
+ theme.c1Red, theme.c2Green, theme.c5Purple, theme.ccLBlue,
+ theme.c2Green, theme.ccLBlue, theme.c3Yellow, theme.ceLCyan };
+ tagMapping.put(theme.c1Red, theme.c9LRed);
+ tagMapping.put(theme.c2Green, theme.caLGreen);
+ tagMapping.put(theme.c3Yellow, theme.cbLYellow);
+ tagMapping.put(theme.c4Blue, theme.ccLBlue);
+ tagMapping.put(theme.c5Purple, theme.cdLPurple);
+ tagMapping.put(theme.c6Cyan, theme.ceLCyan);
+ tagMapping.put(theme.c7White, theme.cfLWhite);
wide = context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
this.listener = listener;
DateTextFormatter dateTextFormatter = new DateTextFormatter();
@@ -81,6 +84,8 @@ public OutlineViewerAdapter(Context context,
textFormatter = new PlainTextFormatter(dateTextFormatter, linkFormatter);
sublistFormatter = new PlainTextFormatter(checkBoxFormatter,
dateTextFormatter, linkFormatter);
+ textSize = App.getInstance().getIntPreference(R.string.docFontSize,
+ R.string.docFontSizeDefault);
}
private OutlineViewerAdapterListener listener = null;
@@ -175,14 +180,7 @@ public void format(NoteNG note, SpannableStringBuilder sb, Matcher m,
String text, boolean selected) {
note.checkboxState = "X".equals(m.group(1)) ? NoteNG.CBOX_CHECKED
: NoteNG.CBOX_UNCHECKED;
- // Log.i(TAG, "Ckeckbox detected[" + selected + "]: " + m.group()
- // + ", " + m.group(1));
- // if (!selected) {
- // addSpan(sb, text);
- // } else {
- addSpan(sb, text, new BackgroundColorSpan(theme.c7White),
- new ForegroundColorSpan(theme.cfLWhite));
- // }
+ addSpan(sb, text, new ForegroundColorSpan(theme.cfLWhite));
}
}
@@ -400,6 +398,8 @@ public View getView(int position, View convertView, ViewGroup parent) {
.findViewById(R.id.outline_viewer_item_text);
TextView tags = (TextView) convertView
.findViewById(R.id.outline_viewer_item_tags);
+ title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize);
+ tags.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize);
// convertView.setBackgroundColor(isselected
// ? theme.c2Green
// : isclicked
@@ -767,4 +767,8 @@ public void setListener(OutlineViewerAdapterListener listener) {
this.listener = listener;
}
+ public DefaultTheme getTheme() {
+ return theme;
+ }
+
}
@@ -1,9 +1,14 @@
package com.matburt.mobileorg.ng.ui.theme;
import android.graphics.Color;
+import android.util.Log;
-public class Default {
+import com.matburt.mobileorg.ng.App;
+import com.matburt.mobileorg.ng.R;
+public class DefaultTheme {
+
+ private static final String TAG = "Theme";
public int c0Black = Color.rgb(0x00, 0x00, 0x00);
public int c1Red = Color.rgb(0xd0, 0x00, 0x00);
public int c2Green = Color.rgb(0x00, 0xa0, 0x00);
@@ -20,4 +25,17 @@
public int cdLPurple = Color.rgb(0xff, 0x00, 0xff);
public int ceLCyan = Color.rgb(0x00, 0xff, 0xff);
public int cfLWhite = Color.rgb(0xff, 0xff, 0xff);
+
+ public static DefaultTheme loadTheme() {
+ String theme = App.getInstance().getStringPreference(R.string.theme,
+ R.string.themeDefault);
+ Log.i(TAG, "Use theme: " + theme);
+ if ("white".equals(theme)) {
+ return new WhiteTheme();
+ }
+ if ("mono".equals(theme)) {
+ return new MonoTheme();
+ }
+ return new DefaultTheme();
+ }
}
@@ -0,0 +1,26 @@
+package com.matburt.mobileorg.ng.ui.theme;
+
+import android.graphics.Color;
+
+public class MonoTheme extends DefaultTheme {
+
+ public MonoTheme() {
+ super();
+ c0Black = Color.rgb(0xff, 0xff, 0xff);
+ c1Red = Color.rgb(0x00, 0x00, 0x00);
+ c2Green = Color.rgb(0x00, 0x00, 0x00);
+ c3Yellow = Color.rgb(0x00, 0x00, 0x00);
+ c4Blue = Color.rgb(0x00, 0x00, 0x00);
+ c5Purple = Color.rgb(0x00, 0x00, 0x00);
+ c6Cyan = Color.rgb(0x00, 0x00, 0x00);
+ c7White = Color.rgb(0x00, 0x00, 0x00);
+
+ c9LRed = Color.rgb(0x00, 0x00, 0x00);
+ caLGreen = Color.rgb(0x00, 0x00, 0x00);
+ cbLYellow = Color.rgb(0x00, 0x00, 0x00);
+ ccLBlue = Color.rgb(0x00, 0x00, 0x00);
+ cdLPurple = Color.rgb(0x00, 0x00, 0x00);
+ ceLCyan = Color.rgb(0x00, 0x00, 0x00);
+ cfLWhite = Color.rgb(0x00, 0x00, 0x00);
+ }
+}
@@ -0,0 +1,27 @@
+package com.matburt.mobileorg.ng.ui.theme;
+
+import android.graphics.Color;
+
+public class WhiteTheme extends DefaultTheme {
+
+ public WhiteTheme() {
+ super();
+ c0Black = Color.rgb(0xff, 0xff, 0xff);
+ c1Red = Color.rgb(0x20, 0x00, 0x00);
+ c2Green = Color.rgb(0x00, 0x20, 0x00);
+ c3Yellow = Color.rgb(0x20, 0x20, 0x00);
+ c4Blue = Color.rgb(0x0, 0x0, 0x20);
+ c5Purple = Color.rgb(0x20, 0x00, 0x20);
+ c6Cyan = Color.rgb(0x00, 0x20, 0x20);
+ c7White = Color.rgb(0x10, 0x10, 0x10);
+
+ c9LRed = Color.rgb(0xa0, 0x0, 0x0);
+ caLGreen = Color.rgb(0x20, 0xa0, 0x20);
+ cbLYellow = Color.rgb(0x80, 0x80, 0x00);
+ ccLBlue = Color.rgb(0x00, 0x00, 0x80);
+ cdLPurple = Color.rgb(0x80, 0x00, 0x80);
+ ceLCyan = Color.rgb(0x00, 0x80, 0x80);
+ cfLWhite = Color.rgb(0x00, 0x00, 0x00);
+ }
+
+}
Oops, something went wrong.

0 comments on commit da6eef3

Please sign in to comment.