Commits

Wolfram Rittmeyer committed c563bcd

Migrated from ActionBarSherlock to ActionBarCompat

  • Participants
  • Parent commits f9f8004

Comments (0)

Files changed (19)

File AndroidManifest.xml

 
         <activity
             android:name=".ActionViewActivity"
-            android:label="" >
+            android:label="@string/title_activity_actionview"
+            android:uiOptions="splitActionBarWhenNarrow" >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />

File libs/android-support-v4.jar

Binary file removed.

File res/menu/activity_about_item.xml

      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
 
     <item
         android:id="@+id/about"
         android:icon="@drawable/ic_action_info"
         android:orderInCategory="9999"
-        android:showAsAction="never"
+        app:showAsAction="never"
         android:title="@string/about"/>
 
 </menu>

File res/menu/menu_fragment_expandable.xml

      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
 
     <item
         android:id="@+id/actionViewLayout"
-        android:actionLayout="@layout/expandable_actionview_edittext"
+        app:actionLayout="@layout/expandable_actionview_edittext"
         android:icon="@drawable/ic_action_add_inverse"
-        android:showAsAction="ifRoom|collapseActionView"
+        app:showAsAction="ifRoom|collapseActionView"
         android:title="@string/add_item"/>
 
 </menu>

File res/menu/menu_fragment_placeholder.xml

      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
 
     <item
         android:id="@+id/progress"
         android:icon="@drawable/ic_action_reload_inverse"
-        android:showAsAction="ifRoom"
+        app:showAsAction="ifRoom"
         android:title="@string/progress"/>
 
 </menu>

File res/menu/menu_fragment_preexpanded.xml

      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
 
     <item
         android:id="@+id/actionViewLayout"
-        android:actionLayout="@layout/expandable_actionview_edittext"
+        app:actionLayout="@layout/expandable_actionview_edittext"
         android:icon="@drawable/ic_action_add_inverse"
-        android:showAsAction="ifRoom"
+        app:showAsAction="ifRoom"
         android:title="@string/add_item"/>
 
 </menu>

File res/menu/menu_fragment_searchview.xml

      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
 
     <item
         android:id="@+id/searchView"
-        android:actionViewClass="com.actionbarsherlock.widget.SearchView"
+        app:actionViewClass="android.support.v7.widget.SearchView"
         android:icon="@drawable/ic_action_search_inverse"
-        android:showAsAction="ifRoom|collapseActionView"
+        app:showAsAction="ifRoom|collapseActionView"
         android:title="@string/search"/>
 
 </menu>

File res/values/styles.xml

         Base application theme, dependent on API level. This theme is replaced
         by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
     -->
-    <style name="AppBaseTheme" parent="@style/Theme.Sherlock.Light.DarkActionBar">
+    <style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
         <!-- nothing API level dependent yet -->
     </style>
 

File src/com/grokkingandroid/sampleapp/samples/actionbar/actionviews/AboutFragment.java

 package com.grokkingandroid.sampleapp.samples.actionbar.actionviews;
 
 import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
 import android.text.Html;
 import android.text.Spanned;
 import android.text.method.LinkMovementMethod;
 import android.view.ViewGroup;
 import android.widget.TextView;
 
-import com.actionbarsherlock.app.SherlockDialogFragment;
-import com.grokkingandroid.sampleapp.samples.actionbar.actionviews.R;
 
-
-public class AboutFragment extends SherlockDialogFragment {
+public class AboutFragment extends DialogFragment {
 
    @Override
    public void onCreate(Bundle savedInstanceState) {

File src/com/grokkingandroid/sampleapp/samples/actionbar/actionviews/ActionViewActivity.java

 import android.os.Build;
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.ActionBar.OnNavigationListener;
 import android.widget.ArrayAdapter;
 
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.app.ActionBar.OnNavigationListener;
-import com.grokkingandroid.sampleapp.samples.actionbar.actionviews.R;
-
 
 public class ActionViewActivity extends BaseActivity {
 
       if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
          resId = R.array.spinner_with_searchview;
       }
-      mSpinnerArray = getResources().getStringArray(resId);      
-      ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(getSupportActionBar().getThemedContext(), resId, R.layout.sherlock_spinner_item);
-      spinnerAdapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
+      mSpinnerArray = getResources().getStringArray(resId);
+      ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(getSupportActionBar().getThemedContext(), resId, android.R.layout.simple_spinner_item);
+      spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
       getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
       getSupportActionBar().setListNavigationCallbacks(spinnerAdapter,
             new OnNavigationListener() {

File src/com/grokkingandroid/sampleapp/samples/actionbar/actionviews/BaseActivity.java

 
 import android.os.Bundle;
 import android.support.v4.app.DialogFragment;
+import android.support.v7.app.ActionBarActivity;
+import android.view.Menu;
+import android.view.MenuItem;
 
-import com.actionbarsherlock.app.SherlockFragmentActivity;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuItem;
-import com.grokkingandroid.sampleapp.samples.actionbar.actionviews.R;
 
 
-public class BaseActivity extends SherlockFragmentActivity {
+public class BaseActivity extends ActionBarActivity {
    
    @Override
    protected void onCreate(Bundle icicle) {
 
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
-      getSupportMenuInflater().inflate(R.menu.activity_about_item, menu);
+      getMenuInflater().inflate(R.menu.activity_about_item, menu);
       return true;
    }
 

File src/com/grokkingandroid/sampleapp/samples/actionbar/actionviews/DemoBaseFragment.java

 import android.annotation.SuppressLint;
 import android.os.Build;
 import android.os.Bundle;
+import android.support.v4.app.Fragment;
 import android.text.Html;
 import android.text.Spanned;
 import android.text.method.LinkMovementMethod;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
-import com.actionbarsherlock.app.SherlockFragment;
-import com.grokkingandroid.sampleapp.samples.actionbar.actionviews.R;
 
-
-public abstract class DemoBaseFragment extends SherlockFragment {
+public abstract class DemoBaseFragment extends Fragment {
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
       StringBuilder link = null;
       for (int i = 0; i < linkTexts.length; i++)  {
          // TODO: Use an inflater
-         TextView tv = new TextView(getSherlockActivity());
+         TextView tv = new TextView(getActivity());
          LinearLayout.LayoutParams params = null;
          params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
          if (i != linkTexts.length -1) {
          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
             tv.setTextIsSelectable(true);
          }
-         tv.setTextAppearance(getSherlockActivity(), android.R.style.TextAppearance_Medium);
+         tv.setTextAppearance(getActivity(), android.R.style.TextAppearance_Medium);
          link = new StringBuilder(100);
          link.append("<a href=\"");
          link.append(linkTargets[i]);

File src/com/grokkingandroid/sampleapp/samples/actionbar/actionviews/ExpandableActionViewFragment.java

  */
 package com.grokkingandroid.sampleapp.samples.actionbar.actionviews;
 
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.grokkingandroid.sampleapp.samples.actionbar.actionviews.R;
+import android.view.Menu;
+import android.view.MenuInflater;
 
 
 public class ExpandableActionViewFragment extends DemoBaseFragment {

File src/com/grokkingandroid/sampleapp/samples/actionbar/actionviews/PlaceholderActionViewFragment.java

 
 import android.os.AsyncTask;
 import android.os.SystemClock;
-
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-import com.grokkingandroid.sampleapp.samples.actionbar.actionviews.R;
+import android.support.v4.view.MenuItemCompat;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
 
 
 public class PlaceholderActionViewFragment extends DemoBaseFragment {
 		@Override
 		protected void onPostExecute(Void result) {
 			super.onPostExecute(result);
-			PlaceholderActionViewFragment.this.mProgress.setActionView(null);
+			MenuItemCompat.setActionView(
+			      PlaceholderActionViewFragment.this.mProgress, 
+			      null);
 		}
 
 		@Override
 		protected void onPreExecute() {
 			super.onPreExecute();
-			PlaceholderActionViewFragment.this.mProgress
-					.setActionView(R.layout.actionview_progress);
+			MenuItemCompat.setActionView(
+			      PlaceholderActionViewFragment.this.mProgress, 
+			      R.layout.actionview_progress);
 		}
 
 	}

File src/com/grokkingandroid/sampleapp/samples/actionbar/actionviews/PreExpandedActionViewFragment.java

  */
 package com.grokkingandroid.sampleapp.samples.actionbar.actionviews;
 
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.grokkingandroid.sampleapp.samples.actionbar.actionviews.R;
+import android.view.Menu;
+import android.view.MenuInflater;
 
 
 public class PreExpandedActionViewFragment extends DemoBaseFragment {

File src/com/grokkingandroid/sampleapp/samples/actionbar/actionviews/SearchViewFragment.java

 import android.app.SearchableInfo;
 import android.content.Context;
 import android.os.Build;
-
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-import com.actionbarsherlock.widget.SearchView;
-import com.grokkingandroid.sampleapp.samples.actionbar.actionviews.R;
+import android.support.v4.view.MenuItemCompat;
+import android.support.v7.widget.SearchView;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
 
 
 @TargetApi(Build.VERSION_CODES.FROYO)
       inflater.inflate(R.menu.menu_fragment_searchview, menu);
       MenuItem item = menu.findItem(R.id.searchView);
       
-      SearchView searchView = (SearchView)item.getActionView();
+      SearchView searchView = (SearchView)MenuItemCompat.getActionView(item);
       
-      SearchManager searchManager = (SearchManager)getSherlockActivity().getSystemService(Context.SEARCH_SERVICE);
-      SearchableInfo info = searchManager.getSearchableInfo(getSherlockActivity().getComponentName());
+      SearchManager searchManager = (SearchManager)getActivity().getSystemService(Context.SEARCH_SERVICE);
+      SearchableInfo info = searchManager.getSearchableInfo(getActivity().getComponentName());
       searchView.setSearchableInfo(info);      
    }
    

File src/com/grokkingandroid/sampleapp/samples/search/BaseSearchActivity.java

 import android.content.Intent;
 import android.os.Bundle;
 import android.support.v4.app.NavUtils;
+import android.view.MenuItem;
 
-import com.actionbarsherlock.view.MenuItem;
-import com.grokkingandroid.sampleapp.samples.actionbar.actionviews.R;
 import com.grokkingandroid.sampleapp.samples.actionbar.actionviews.ActionViewActivity;
 import com.grokkingandroid.sampleapp.samples.actionbar.actionviews.BaseActivity;
+import com.grokkingandroid.sampleapp.samples.actionbar.actionviews.R;
 
 public abstract class BaseSearchActivity extends BaseActivity {
 

File src/com/grokkingandroid/sampleapp/samples/search/SearchDetailsActivity.java

 import android.content.Intent;
 import android.os.Bundle;
 import android.support.v4.app.NavUtils;
+import android.view.MenuItem;
 import android.widget.TextView;
 
-import com.actionbarsherlock.view.MenuItem;
-import com.grokkingandroid.sampleapp.samples.actionbar.actionviews.R;
 import com.grokkingandroid.sampleapp.samples.actionbar.actionviews.ActionViewActivity;
 import com.grokkingandroid.sampleapp.samples.actionbar.actionviews.BaseActivity;
+import com.grokkingandroid.sampleapp.samples.actionbar.actionviews.R;
 
 public class SearchDetailsActivity extends BaseActivity {
 

File src/com/grokkingandroid/sampleapp/samples/search/SearchFragment.java

 
 import android.content.Intent;
 import android.os.Bundle;
+import android.support.v4.app.ListFragment;
 import android.view.View;
 import android.widget.ArrayAdapter;
 import android.widget.ListView;
 
-import com.actionbarsherlock.app.SherlockListFragment;
 import com.grokkingandroid.sampleapp.samples.actionbar.actionviews.R;
 
 
-public class SearchFragment extends SherlockListFragment {
+public class SearchFragment extends ListFragment {
 
    private String[] searchTerms = {"one", "two", "three"};
    private static final String KEY_QUERY = "query"; 
             results.add(searchTerms[i]);
          }         
       }
-      ArrayAdapter<String> adapter = new ArrayAdapter<String>(getSherlockActivity(), android.R.layout.simple_list_item_1, results);
+      ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, results);
       setListAdapter(adapter);
       setEmptyText(getString(R.string.nothing_found, queryStr));
    }
 
    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {
-      Intent detailsIntent = new Intent(getSherlockActivity(),
+      Intent detailsIntent = new Intent(getActivity(),
             SearchDetailsActivity.class);
       String selectedResult = (String)getListAdapter().getItem(position);
       detailsIntent.putExtra(SearchDetailsActivity.KEY_WORD, selectedResult);