summaryrefslogtreecommitdiff
path: root/vdrmanager
diff options
context:
space:
mode:
authorlado <herrlado@gmail.com>2011-10-20 14:43:27 +0200
committerlado <herrlado@gmail.com>2011-10-20 14:43:27 +0200
commit1a5c307940d0e94be9503192cba5bc69d7f2c06e (patch)
treeb66c062f2968fc86212ed928bcfb04af4cd05cb6 /vdrmanager
parent35a9ac736e37ef6b8e2032d4aec014fcb1f5bff8 (diff)
downloadvdr-manager-1a5c307940d0e94be9503192cba5bc69d7f2c06e.tar.gz
vdr-manager-1a5c307940d0e94be9503192cba5bc69d7f2c06e.tar.bz2
map special characters in Utils
Diffstat (limited to 'vdrmanager')
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/data/EventFormatter.java14
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java100
2 files changed, 72 insertions, 42 deletions
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/EventFormatter.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/EventFormatter.java
index f4dc41e..6cc7151 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/data/EventFormatter.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/EventFormatter.java
@@ -1,5 +1,6 @@
package de.bjusystems.vdrmanager.data;
+import de.bjusystems.vdrmanager.gui.Utils;
import de.bjusystems.vdrmanager.utils.date.DateFormatter;
public class EventFormatter {
@@ -29,16 +30,9 @@ public class EventFormatter {
if(onlyStartTime == false){
this.time += " - " + stop;
}
- this.title = mapSpecialChars(event.getTitle());
- this.shortText = mapSpecialChars(event.getShortText());
- this.description = mapSpecialChars(event.getDescription());
- }
-
- private static String mapSpecialChars(String src){
- if(src == null){
- return "";
- }
- return src.replace("|##", ":").replace("||#", "\n");
+ this.title = Utils.mapSpecialChars(event.getTitle());
+ this.shortText = Utils.mapSpecialChars(event.getShortText());
+ this.description = Utils.mapSpecialChars(event.getDescription());
}
public String getShortText() {
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java
index ff51637..4690032 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java
@@ -16,50 +16,49 @@ import android.util.Pair;
import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.data.Channel;
import de.bjusystems.vdrmanager.data.Event;
+import de.bjusystems.vdrmanager.data.EventFormatter;
import de.bjusystems.vdrmanager.data.Preferences;
public class Utils {
public static final ForegroundColorSpan HIGHLIGHT_TEXT = new ForegroundColorSpan(
Color.RED);
-
-
- public static CharSequence highlight(String where, String what){
- if(TextUtils.isEmpty(what)){
+ public static CharSequence highlight(String where, String what) {
+ if (TextUtils.isEmpty(what)) {
return where;
}
-
+
String str = where.toLowerCase();
- what = what.toLowerCase();
- int idx = str.indexOf(what);
- if(idx == -1){
- return where;
- }
- SpannableString ss = new SpannableString(where);
- ss.setSpan(HIGHLIGHT_TEXT, idx, idx + what.length(),
- Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- return ss;
+ what = what.toLowerCase();
+ int idx = str.indexOf(what);
+ if (idx == -1) {
+ return where;
+ }
+ SpannableString ss = new SpannableString(where);
+ ss.setSpan(HIGHLIGHT_TEXT, idx, idx + what.length(),
+ Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ return ss;
}
-
- public static Pair<Boolean,CharSequence> highlight2(String where, String what){
- if(TextUtils.isEmpty(what)){
- return Pair.create(Boolean.FALSE, (CharSequence)where);
+
+ public static Pair<Boolean, CharSequence> highlight2(String where,
+ String what) {
+ if (TextUtils.isEmpty(what)) {
+ return Pair.create(Boolean.FALSE, (CharSequence) where);
}
-
+
String str = where.toLowerCase();
- what = what.toLowerCase();
- int idx = str.indexOf(what);
- if(idx == -1){
- return Pair.create(Boolean.FALSE, (CharSequence)where);
- }
- SpannableString ss = new SpannableString(where);
- ss.setSpan(HIGHLIGHT_TEXT, idx, idx + what.length(),
- Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- return Pair.create(Boolean.TRUE, (CharSequence)ss);
+ what = what.toLowerCase();
+ int idx = str.indexOf(what);
+ if (idx == -1) {
+ return Pair.create(Boolean.FALSE, (CharSequence) where);
+ }
+ SpannableString ss = new SpannableString(where);
+ ss.setSpan(HIGHLIGHT_TEXT, idx, idx + what.length(),
+ Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ return Pair.create(Boolean.TRUE, (CharSequence) ss);
}
-
-
+
public static int getProgress(Date start, Date stop) {
long now = System.currentTimeMillis();
return getProgress(now, start.getTime(), stop.getTime());
@@ -130,11 +129,18 @@ public class Utils {
String sf = Preferences.get().getStreamFormat();
String ext = activity.getString(R.string.remux_title);
new AlertDialog.Builder(activity)
- .setTitle(R.string.stream_via_as)//
+ .setTitle(R.string.stream_via_as)
+ //
.setItems(
new String[] {
activity.getString(R.string.stream_as, sf),
- activity.getString(R.string.stream_via, ext) },//TODO add here what will be used
+ activity.getString(R.string.stream_via, ext) },// TODO
+ // add
+ // here
+ // what
+ // will
+ // be
+ // used
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
@@ -164,4 +170,34 @@ public class Utils {
return minuts;
}
+ public static void shareEvent(Activity activity, Event event) {
+ final Intent share = new Intent(android.content.Intent.ACTION_SEND);
+ share.setType("text/plain");
+ StringBuilder sb = new StringBuilder();
+ sb.append(event.getTitle());
+ sb.append("\n");
+ EventFormatter ef = new EventFormatter(event, false);
+ sb.append(ef.getDate()).append(" ").append(ef.getTime());
+ String title = sb.toString();
+ share.putExtra(android.content.Intent.EXTRA_SUBJECT, sb.toString());
+ sb = new StringBuilder();
+ sb.append(title).append("\n\n");
+ sb.append(ef.getShortText());
+ sb.append("\n\n");
+ sb.append(ef.getDescription());
+ sb.append("\n");
+ share.putExtra(android.content.Intent.EXTRA_TEXT, sb.toString());
+ activity.startActivity(Intent.createChooser(share,
+ activity.getString(R.string.share_chooser)));
+ }
+
+
+ public static String mapSpecialChars(String src){
+ if(src == null){
+ return "";
+ }
+ return src.replace("|##", ":").replace("||#", "\n");
+ }
+
+
}