summaryrefslogtreecommitdiff
path: root/samples/known-bugs/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'samples/known-bugs/src/com')
-rw-r--r--samples/known-bugs/src/com/actionbarsherlock/sample/knownbugs/Issue331.java47
-rw-r--r--samples/known-bugs/src/com/actionbarsherlock/sample/knownbugs/Issue435.java88
-rw-r--r--samples/known-bugs/src/com/actionbarsherlock/sample/knownbugs/SampleList.java134
3 files changed, 269 insertions, 0 deletions
diff --git a/samples/known-bugs/src/com/actionbarsherlock/sample/knownbugs/Issue331.java b/samples/known-bugs/src/com/actionbarsherlock/sample/knownbugs/Issue331.java
new file mode 100644
index 0000000..f442ce4
--- /dev/null
+++ b/samples/known-bugs/src/com/actionbarsherlock/sample/knownbugs/Issue331.java
@@ -0,0 +1,47 @@
+package com.actionbarsherlock.sample.knownbugs;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.Button;
+import android.widget.ImageView;
+import com.actionbarsherlock.app.SherlockActivity;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuItem;
+
+import static android.view.View.OnClickListener;
+
+public class Issue331 extends SherlockActivity {
+ boolean mShow = true;
+
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Button b = new Button(this);
+ b.setText("Click action item and then this button twice on pre-ICS");
+ b.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ mShow = !mShow;
+ invalidateOptionsMenu();
+ }
+ });
+ setContentView(b);
+ }
+
+ public boolean onCreateOptionsMenu(Menu menu) {
+ if (mShow) {
+ menu.add("Refresh").setIcon(R.drawable.ic_refresh).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+ }
+ return true;
+ }
+
+ public boolean onMenuItemSelected(int featureId, MenuItem item) {
+ ImageView iv = (ImageView) LayoutInflater.from(this).inflate(R.layout.issue331_action_view, null);
+ Animation r = AnimationUtils.loadAnimation(this, R.anim.issue331_refresh);
+ r.setRepeatCount(Animation.INFINITE);
+ iv.startAnimation(r);
+ item.setActionView(iv);
+ return true;
+ }
+}
diff --git a/samples/known-bugs/src/com/actionbarsherlock/sample/knownbugs/Issue435.java b/samples/known-bugs/src/com/actionbarsherlock/sample/knownbugs/Issue435.java
new file mode 100644
index 0000000..6b26565
--- /dev/null
+++ b/samples/known-bugs/src/com/actionbarsherlock/sample/knownbugs/Issue435.java
@@ -0,0 +1,88 @@
+package com.actionbarsherlock.sample.knownbugs;
+
+import android.graphics.drawable.GradientDrawable;
+import android.os.Bundle;
+import android.support.v4.app.FragmentTransaction;
+import android.view.View;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.app.SherlockActivity;
+import com.actionbarsherlock.view.ActionMode;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuItem;
+
+import static android.graphics.drawable.GradientDrawable.Orientation.TOP_BOTTOM;
+
+public class Issue435 extends SherlockActivity implements View.OnClickListener, ActionBar.TabListener {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ LinearLayout layout = new LinearLayout(this);
+ layout.setOrientation(LinearLayout.VERTICAL);
+
+ TextView t = new TextView(this);
+ t.setText("Must be on a portrait device where the tabs are stacked. Stacked background will disappear when action mode is triggered.");
+ layout.addView(t);
+
+ Button b = new Button(this);
+ b.setText("Start ActionMode");
+ b.setOnClickListener(this);
+ layout.addView(b);
+
+ setContentView(layout);
+
+ ActionBar ab = getSupportActionBar();
+ ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+ ab.addTab(ab.newTab().setText("One").setTabListener(this));
+ ab.addTab(ab.newTab().setText("One").setTabListener(this));
+ ab.addTab(ab.newTab().setText("One").setTabListener(this));
+
+ ab.setBackgroundDrawable(new GradientDrawable(TOP_BOTTOM, new int[] { 0xFF004400, 0xFF002200 }));
+ ab.setStackedBackgroundDrawable(new GradientDrawable(TOP_BOTTOM, new int[] { 0xFF440000, 0xFF220000 }));
+ }
+
+ @Override public void onClick(View v) {
+ ActionMode am = startActionMode(new SuperSweetActionModeOfScience());
+ am.setTitle("Hello, Broken?");
+ }
+
+ @Override
+ public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
+ /* Empty */
+ }
+
+ @Override
+ public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
+ /* Empty */
+ }
+
+ @Override
+ public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
+ /* Empty */
+ }
+
+ private static final class SuperSweetActionModeOfScience implements ActionMode.Callback {
+ @Override
+ public boolean onCreateActionMode(ActionMode mode, Menu menu) {
+ return true;
+ }
+
+ @Override
+ public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
+ return false;
+ }
+
+ @Override
+ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
+ return false;
+ }
+
+ @Override
+ public void onDestroyActionMode(ActionMode mode) {
+ /* Empty */
+ }
+ }
+}
diff --git a/samples/known-bugs/src/com/actionbarsherlock/sample/knownbugs/SampleList.java b/samples/known-bugs/src/com/actionbarsherlock/sample/knownbugs/SampleList.java
new file mode 100644
index 0000000..4289a02
--- /dev/null
+++ b/samples/known-bugs/src/com/actionbarsherlock/sample/knownbugs/SampleList.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2012 Jake Wharton
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.actionbarsherlock.sample.knownbugs;
+
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.os.Bundle;
+import android.support.v4.app.FragmentTransaction;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.app.SherlockListActivity;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static android.content.Intent.ACTION_MAIN;
+import static com.actionbarsherlock.app.ActionBar.NAVIGATION_MODE_TABS;
+import static java.util.Locale.ENGLISH;
+
+public class SampleList extends SherlockListActivity implements ActionBar.TabListener {
+ private final IntentAdapter mAdapter = new IntentAdapter();
+ private String mCategory = "OPEN";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ final ActionBar actionBar = getSupportActionBar();
+ actionBar.setNavigationMode(NAVIGATION_MODE_TABS);
+ actionBar.addTab(actionBar.newTab().setText("Open").setTabListener(this));
+ actionBar.addTab(actionBar.newTab().setText("Closed").setTabListener(this));
+
+ setListAdapter(mAdapter);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ protected void onListItemClick(ListView l, View v, int position, long id) {
+ startActivity(mAdapter.getItem(position));
+ }
+
+ @Override
+ public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
+ mCategory = tab.getText().toString().toUpperCase(ENGLISH);
+ mAdapter.refresh();
+ }
+
+ @Override
+ public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
+ /* Empty */
+ }
+
+ @Override
+ public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
+ /* Empty */
+ }
+
+ private class IntentAdapter extends BaseAdapter {
+ private final List<CharSequence> mNames;
+ private final Map<CharSequence, Intent> mIntents;
+
+ IntentAdapter() {
+ mNames = new ArrayList<CharSequence>();
+ mIntents = new HashMap<CharSequence, Intent>();
+ }
+
+ void refresh() {
+ mNames.clear();
+ mIntents.clear();
+
+ final Intent mainIntent = new Intent(ACTION_MAIN, null);
+ mainIntent.addCategory("com.actionbarsherlock.sample.knownbugs." + mCategory);
+
+ PackageManager pm = getPackageManager();
+ final List<ResolveInfo> matches = pm.queryIntentActivities(mainIntent, 0);
+ for (ResolveInfo match : matches) {
+ Intent intent = new Intent();
+ intent.setClassName(match.activityInfo.packageName, match.activityInfo.name);
+ final CharSequence name = match.loadLabel(pm);
+ mNames.add(name);
+ mIntents.put(name, intent);
+ }
+
+ notifyDataSetChanged();
+ }
+
+ @Override
+ public int getCount() {
+ return mNames.size();
+ }
+
+ @Override
+ public Intent getItem(int position) {
+ return mIntents.get(mNames.get(position));
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ TextView tv = (TextView)convertView;
+ if (convertView == null) {
+ tv = (TextView) LayoutInflater.from(SampleList.this).inflate(android.R.layout.simple_list_item_1, parent, false);
+ }
+ tv.setText(mNames.get(position));
+ return tv;
+ }
+ }
+}