diff options
author | lado <herrlado@gmail.com> | 2013-02-14 23:40:49 +0100 |
---|---|---|
committer | lado <herrlado@gmail.com> | 2013-02-14 23:40:49 +0100 |
commit | c1397b21b2952184d1262f94cde4d183f9408584 (patch) | |
tree | dc9c649a871c519456581ac047bca0d15854972f | |
parent | f07838d27a0da1ab0dedd6a638b6e095b3190477 (diff) | |
download | vdr-manager-c1397b21b2952184d1262f94cde4d183f9408584.tar.gz vdr-manager-c1397b21b2952184d1262f94cde4d183f9408584.tar.bz2 |
git push Switch overall to ActionBarSherlock
7 files changed, 103 insertions, 81 deletions
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java index f402ed7..36c7633 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java @@ -34,7 +34,7 @@ public abstract class BaseActivity<Result, T extends ListView> extends ICSBaseAc public static final int MENU_REFRESH = 99; protected T listView; - + @Override public boolean onSearchRequested() { // TODO Auto-generated method stub @@ -135,7 +135,7 @@ public abstract class BaseActivity<Result, T extends ListView> extends ICSBaseAc Preferences.setLocale(this); progress = new ProgressDialog(this); getApp().addActivityToFinish(this); - + initActionBar(); // your logic for click listner @@ -150,14 +150,14 @@ public abstract class BaseActivity<Result, T extends ListView> extends ICSBaseAc } @Override - public boolean onCreateOptionsMenu(final Menu menu) { + public boolean onCreateOptionsMenu(final com.actionbarsherlock.view.Menu menu) { // MenuItem item; // item = menu.add(MENU_GROUP_REFRESH, MENU_REFRESH, 0, // R.string.refresh); // item.setIcon(R.drawable.ic_menu_refresh); // item.setAlphabeticShortcut('r'); - MenuInflater inf = getMenuInflater(); + com.actionbarsherlock.view.MenuInflater inf = getSupportMenuInflater(); inf.inflate(R.menu.refresh_menu, menu); // SearchView searchView = (SearchView) @@ -174,7 +174,7 @@ public abstract class BaseActivity<Result, T extends ListView> extends ICSBaseAc abstract protected SvdrpClient<Result> getClient(); @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(final com.actionbarsherlock.view.MenuItem item) { switch (item.getItemId()) { case R.id.list_refresh: backupViewSelection(); diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java index c054b3d..e78c3b8 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java @@ -46,6 +46,11 @@ public abstract class BaseEventListActivity<T extends Event> extends public static final int MENU_SHARE = 90; + public static final int MENU_GROUP_TO_CAL = 91; + + public static final int MENU_TO_CAL = 91; + + private SimpleGestureFilter detector; protected EpgClient epgClient; @@ -104,10 +109,10 @@ public abstract class BaseEventListActivity<T extends Event> extends * .view.Menu) */ @Override - public boolean onCreateOptionsMenu(final Menu menu) { + public boolean onCreateOptionsMenu(final com.actionbarsherlock.view.Menu menu) { super.onCreateOptionsMenu(menu); - final MenuInflater inflater = getMenuInflater(); + final com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater(); inflater.inflate(R.menu.epg_list_menu, menu); return true; } @@ -146,6 +151,11 @@ public abstract class BaseEventListActivity<T extends Event> extends break; } + case MENU_TO_CAL: { + Utils.addCalendarEvent(this, event); + break; + } + case R.id.epg_item_menu_switchto: { Utils.switchTo(this, event.getChannelId(), event.getChannelName()); break; @@ -172,7 +182,7 @@ public abstract class BaseEventListActivity<T extends Event> extends * de.bjusystems.vdrmanager.gui.BaseActivity#onOptionsItemSelected(android * .view.MenuItem) */ - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(final com.actionbarsherlock.view.MenuItem item) { switch (item.getItemId()) { case R.id.epg_list_menu_channels: @@ -243,6 +253,7 @@ public abstract class BaseEventListActivity<T extends Event> extends mi.setVisible(false); } menu.add(MENU_GROUP_SHARE, MENU_SHARE, 0, R.string.share); + menu.add(MENU_GROUP_TO_CAL, MENU_TO_CAL, 0, R.string.addtocal); super.onCreateContextMenu(menu, v, menuInfo); } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BasePreferencesActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BasePreferencesActivity.java index ced04c7..eedb3f9 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BasePreferencesActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BasePreferencesActivity.java @@ -9,9 +9,10 @@ import android.text.TextUtils; import android.view.inputmethod.EditorInfo; import android.widget.EditText; import de.bjusystems.vdrmanager.R; +import de.bjusystems.vdrmanager.data.MacFetchEditTextPreference; /** - * + * * Basis class for PreferencesActivities with some goodies in it * @author lado * @@ -23,12 +24,28 @@ public abstract class BasePreferencesActivity extends PreferenceActivity { updateSummary((EditTextPreference) ep); } else if (ep instanceof ListPreference) { updateSummary((ListPreference) ep); + } else if(ep instanceof MacFetchEditTextPreference){ + updateSummary((MacFetchEditTextPreference)ep); + } + } + + /** + * If text set add it to the summary + * + * @param ep + */ + protected void updateSummary(MacFetchEditTextPreference ep) { + String text = ep.getText(); + if (text == null) { + text = ""; } + + setSummary(text, ep); } /** * If text set add it to the summary - * + * * @param ep */ protected void updateSummary(EditTextPreference ep) { @@ -36,11 +53,11 @@ public abstract class BasePreferencesActivity extends PreferenceActivity { if (text == null) { return; } - + if(isPassword(ep.getEditText())){ text = text.replaceAll(".", "*"); } - + setSummary(text, ep); } @@ -50,7 +67,7 @@ public abstract class BasePreferencesActivity extends PreferenceActivity { } return false; } - + protected void setSummary(CharSequence text, DialogPreference ep){ CharSequence sm = ep.getSummary(); String sum; @@ -61,11 +78,11 @@ public abstract class BasePreferencesActivity extends PreferenceActivity { } else { sum = ""; } - + if(TextUtils.isEmpty(text)){ text = getString(R.string.prefs_current_value_not_set); } - + if (isBlank(sum)) { sum = getString(R.string.prefs_current_value_template, text); } else { @@ -74,7 +91,7 @@ public abstract class BasePreferencesActivity extends PreferenceActivity { } ep.setSummary(sum); } - + protected void updateSummary(ListPreference ep) { CharSequence text = ep.getEntry(); @@ -89,13 +106,13 @@ public abstract class BasePreferencesActivity extends PreferenceActivity { * Gets the substring before the last occurrence of a separator. The * separator is not returned. * </p> - * + * * <p> * A <code>null</code> string input will return <code>null</code>. An empty * ("") string input will return the empty string. An empty or * <code>null</code> separator will return the input string. * </p> - * + * * <pre> * StringUtils.substringBeforeLast(null, *) = null * StringUtils.substringBeforeLast("", *) = "" @@ -106,7 +123,7 @@ public abstract class BasePreferencesActivity extends PreferenceActivity { * StringUtils.substringBeforeLast("a", null) = "a" * StringUtils.substringBeforeLast("a", "") = "a" * </pre> - * + * * @param str * the String to get a substring from, may be null * @param separator @@ -132,7 +149,7 @@ public abstract class BasePreferencesActivity extends PreferenceActivity { * <p> * Checks if a String is empty ("") or null. * </p> - * + * * <pre> * StringUtils.isEmpty(null) = true * StringUtils.isEmpty("") = true @@ -140,12 +157,12 @@ public abstract class BasePreferencesActivity extends PreferenceActivity { * StringUtils.isEmpty("bob") = false * StringUtils.isEmpty(" bob ") = false * </pre> - * + * * <p> * NOTE: This method changed in Lang version 2.0. It no longer trims the * String. That functionality is available in isBlank(). * </p> - * + * * @param str * the String to check, may be null * @return <code>true</code> if the String is empty or null @@ -158,7 +175,7 @@ public abstract class BasePreferencesActivity extends PreferenceActivity { * <p> * Checks if a String is whitespace, empty ("") or null. * </p> - * + * * <pre> * StringUtils.isBlank(null) = true * StringUtils.isBlank("") = true @@ -166,7 +183,7 @@ public abstract class BasePreferencesActivity extends PreferenceActivity { * StringUtils.isBlank("bob") = false * StringUtils.isBlank(" bob ") = false * </pre> - * + * * @param str * the String to check, may be null * @return <code>true</code> if the String is null, empty or whitespace diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java index b4c71d6..d83ca5b 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java @@ -14,10 +14,8 @@ import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.text.TextUtils; -import android.util.Log; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; -import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; @@ -34,16 +32,13 @@ import de.bjusystems.vdrmanager.data.Channel; import de.bjusystems.vdrmanager.data.Preferences; import de.bjusystems.vdrmanager.tasks.VoidAsyncTask; import de.bjusystems.vdrmanager.utils.svdrp.ChannelClient; -import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncListener; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncTask; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpClient; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent; -import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException; -import de.bjusystems.vdrmanager.utils.svdrp.SwitchChannelClient; /** * This class is used for showing what's current running on all channels - * + * * @author bju */ public class ChannelListActivity extends @@ -65,7 +60,7 @@ public class ChannelListActivity extends public static final int MENU_NAME = 2; private int groupBy = MENU_GROUP; - + private int groupByInverse = 0; final static ArrayList<String> ALL_CHANNELS_GROUP = new ArrayList<String>(1); @@ -119,7 +114,7 @@ public class ChannelListActivity extends } else { channelClient.removeSvdrpListener(this); } - + if(useCache == false){ ChannelClient.clearCache(); } @@ -135,25 +130,25 @@ public class ChannelListActivity extends static RecentChannelsAdapter RECENT_ADAPTER = null; - + static class RecentChannelsAdapter extends ArrayAdapter<Channel>{ private Activity context; int resId; - + public RecentChannelsAdapter(Activity context, List<Channel> list) { super(context, android.R.layout.simple_list_item_1, list); this.context = context; showChannelNumbers = Preferences.get().isShowChannelNumbers(); - + if (Build.VERSION.SDK_INT < 11) { resId = android.R.layout.select_dialog_item; } else { resId = android.R.layout.simple_list_item_1; } } - + public boolean showChannelNumbers; - + public View getView(int position, View convertView, ViewGroup parent) { // recycle view? TextView text1; @@ -182,7 +177,7 @@ public class ChannelListActivity extends RECENT_ADAPTER.notifyDataSetChanged(); return RECENT_ADAPTER; } - + RECENT_ADAPTER = new RecentChannelsAdapter(this, RECENT); return RECENT_ADAPTER; @@ -229,16 +224,15 @@ public class ChannelListActivity extends } } - public boolean onPrepareOptionsMenu(Menu menu) { - + public boolean onPrepareOptionsMenu(com.actionbarsherlock.view.Menu menu) { return super.onPrepareOptionsMenu(menu); } @Override - public final boolean onCreateOptionsMenu(final Menu menu) { + public final boolean onCreateOptionsMenu(final com.actionbarsherlock.view.Menu menu) { super.onCreateOptionsMenu(menu); - final MenuInflater inflater = getMenuInflater(); + final com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater(); inflater.inflate(R.menu.channellist, menu); return true; @@ -257,7 +251,7 @@ public class ChannelListActivity extends AlertDialog groupByDialog = null; @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(final com.actionbarsherlock.view.MenuItem item) { switch (item.getItemId()) { case R.id.channels_groupby: @@ -292,7 +286,7 @@ public class ChannelListActivity extends say(R.string.recent_channels_no_history); return true; } - + new AlertDialog.Builder(this) .setTitle(R.string.recent_channels) .setAdapter(getRecentAdapter(), new DialogInterface.OnClickListener() { @@ -369,12 +363,12 @@ public class ChannelListActivity extends case R.id.channel_item_menu_hide_permanent: // TODO http://projects.vdr-developer.org/issues/722 break; - + case R.id.channel_item_menu_switch: Utils.switchTo(this, channel); break; } - + return true; @@ -525,7 +519,7 @@ public class ChannelListActivity extends protected SvdrpClient<Channel> getClient() { return channelClient; } - + public void svdrpEvent(SvdrpEvent event, Channel result){ super.svdrpEvent(event, result); } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java index a375bb9..33a2fc9 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java @@ -16,9 +16,6 @@ import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; import android.util.Log; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.ArrayAdapter; @@ -564,11 +561,13 @@ public class EpgDetailsActivity extends ICSBaseActivity implements OnClickListen } + + @Override - public final boolean onCreateOptionsMenu(final Menu menu) { + public final boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) { super.onCreateOptionsMenu(menu); - final MenuInflater inflater = getMenuInflater(); + final com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater(); inflater.inflate(R.menu.epg_details, menu); // mShareActionProvider = (ShareActionProvider) @@ -583,11 +582,16 @@ public class EpgDetailsActivity extends ICSBaseActivity implements OnClickListen } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { if (item.getItemId() == R.id.epg_details_menu_share) { shareEvent(cEvent); return true; } + + if(item.getItemId() == R.id.epg_details_menu_add_to_cal){ + Utils.addCalendarEvent(this, cEvent); + } + if (item.getItemId() == R.id.epg_details_menu_search_repeat) { Intent intent = new Intent(this, EpgSearchListActivity.class); intent.setAction(Intent.ACTION_SEARCH); diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ICSBaseActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ICSBaseActivity.java index 39047ff..ce44ef0 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ICSBaseActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ICSBaseActivity.java @@ -1,22 +1,18 @@ package de.bjusystems.vdrmanager.gui; -import android.app.ActionBar; -import android.app.Activity; -import android.os.Build; +import com.actionbarsherlock.app.SherlockActivity; -public abstract class ICSBaseActivity extends Activity{ +public abstract class ICSBaseActivity extends SherlockActivity{ public void initActionBar() { - int api = Build.VERSION.SDK_INT; - if (api < 14) { - return; - } - - ActionBar actionBar = getActionBar(); +// int api = Build.VERSION.SDK_INT; + // if (api < 14) { + // return; + //} + com.actionbarsherlock.app.ActionBar actionBar = getSupportActionBar(); if(actionBar == null){ return; } - //this is since 14 enabled actionBar.setHomeButtonEnabled(true); } } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java index 4f59d8d..7d921df 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java @@ -33,7 +33,7 @@ import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent; /** * This class is used for showing what's current running on all channels - * + * * @author bju */ public class RecordingListActivity extends BaseEventListActivity<Recording> @@ -46,13 +46,13 @@ public class RecordingListActivity extends BaseEventListActivity<Recording> public static final int MENU_CHANNEL = 2; public static final int ASC = 0; - + public static final int DESC = 1; - + private int groupBy = MENU_DATE; - + private int ASC_DESC = ASC; - + @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -75,7 +75,7 @@ public class RecordingListActivity extends BaseEventListActivity<Recording> // start query startRecordingQuery(); } - + private String[] getAvailableGroupByEntries() { ArrayList<String> entries = new ArrayList<String>(2); @@ -88,7 +88,7 @@ public class RecordingListActivity extends BaseEventListActivity<Recording> AlertDialog groupByDialog = null; @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(final com.actionbarsherlock.view.MenuItem item) { switch (item.getItemId()) { case R.id.menu_groupby: @@ -124,19 +124,19 @@ public class RecordingListActivity extends BaseEventListActivity<Recording> } /* * (non-Javadoc) - * + * * @see * de.bjusystems.vdrmanager.gui.BaseActivity#onCreateOptionsMenu(android * .view.Menu) */ @Override - public boolean onCreateOptionsMenu(final Menu menu) { - final MenuInflater inflater = getMenuInflater(); + public boolean onCreateOptionsMenu(final com.actionbarsherlock.view.Menu menu) { + final com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater(); inflater.inflate(R.menu.recording_list_menu, menu); return super.onCreateOptionsMenu(menu); } - + @Override protected SvdrpClient<Recording> getClient() { return this.recordingClient; @@ -172,18 +172,18 @@ public class RecordingListActivity extends BaseEventListActivity<Recording> inflater.inflate(R.menu.recording_list_item_menu, menu); if(Preferences.get().isEnableRecStream() == false){ menu.removeItem(R.id.recording_item_menu_stream); - } + } } - + super.onCreateContextMenu(menu, v, menuInfo); // // http://projects.vdr-developer.org/issues/863 if(Utils.isLive(item)){ - menu.removeItem(R.id.epg_item_menu_live_tv); + menu.removeItem(R.id.epg_item_menu_live_tv); } } - + @Override public boolean onContextItemSelected(final MenuItem item) { @@ -217,7 +217,7 @@ public class RecordingListActivity extends BaseEventListActivity<Recording> } private void startRecordingQuery() { - + if (checkInternetConnection() == false) { return; @@ -231,7 +231,7 @@ public class RecordingListActivity extends BaseEventListActivity<Recording> recordingClient); // create progress dialog - + task.addListener(this); // start task |