aboutsummaryrefslogtreecommitdiffstats
path: root/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2013-09-09 13:19:43 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2013-09-09 13:19:43 +0200
commitaae87b894f72a719a850ec32ad6944bd5c743331 (patch)
treeb5a221fcb529c07b309f5bde0563155df28a472c /libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java
parent5b6880d2e34f4c8a4bfba87b5ce53d3c6727b744 (diff)
downloadopen-keychain-aae87b894f72a719a850ec32ad6944bd5c743331.tar.gz
open-keychain-aae87b894f72a719a850ec32ad6944bd5c743331.tar.bz2
open-keychain-aae87b894f72a719a850ec32ad6944bd5c743331.zip
Update actionbarsherlock from 4.2 to 4.4
Diffstat (limited to 'libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java')
-rw-r--r--libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java87
1 files changed, 2 insertions, 85 deletions
diff --git a/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java
index 4636de17f..61e55b0a2 100644
--- a/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/ActionBarView.java
@@ -16,16 +16,14 @@
package com.actionbarsherlock.internal.widget;
-import org.xmlpull.v1.XmlPullParser;
+import com.actionbarsherlock.internal.ResourcesCompat;
import android.app.Activity;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.TypedArray;
-import android.content.res.XmlResourceParser;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcel;
@@ -49,7 +47,6 @@ import android.widget.TextView;
import com.actionbarsherlock.R;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.ActionBar.OnNavigationListener;
-import com.actionbarsherlock.internal.ActionBarSherlockCompat;
import com.actionbarsherlock.internal.view.menu.ActionMenuItem;
import com.actionbarsherlock.internal.view.menu.ActionMenuPresenter;
import com.actionbarsherlock.internal.view.menu.ActionMenuView;
@@ -70,7 +67,6 @@ import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoo
*/
public class ActionBarView extends AbsActionBarView {
private static final String TAG = "ActionBarView";
- private static final boolean DEBUG = false;
/**
* Display options applied by default
@@ -190,7 +186,7 @@ public class ActionBarView extends AbsActionBarView {
if (context instanceof Activity) {
//Even though native methods existed in API 9 and 10 they don't work
//so just parse the manifest to look for the logo pre-Honeycomb
- final int resId = loadLogoFromManifest((Activity) context);
+ final int resId = ResourcesCompat.loadLogoFromManifest((Activity) context);
if (resId != 0) {
mLogo = context.getResources().getDrawable(resId);
}
@@ -265,85 +261,6 @@ public class ActionBarView extends AbsActionBarView {
mHomeLayout.setFocusable(true);
}
- /**
- * Attempt to programmatically load the logo from the manifest file of an
- * activity by using an XML pull parser. This should allow us to read the
- * logo attribute regardless of the platform it is being run on.
- *
- * @param activity Activity instance.
- * @return Logo resource ID.
- */
- private static int loadLogoFromManifest(Activity activity) {
- int logo = 0;
- try {
- final String thisPackage = activity.getClass().getName();
- if (DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage);
-
- final String packageName = activity.getApplicationInfo().packageName;
- final AssetManager am = activity.createPackageContext(packageName, 0).getAssets();
- final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml");
-
- int eventType = xml.getEventType();
- while (eventType != XmlPullParser.END_DOCUMENT) {
- if (eventType == XmlPullParser.START_TAG) {
- String name = xml.getName();
-
- if ("application".equals(name)) {
- //Check if the <application> has the attribute
- if (DEBUG) Log.d(TAG, "Got <application>");
-
- for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
- if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));
-
- if ("logo".equals(xml.getAttributeName(i))) {
- logo = xml.getAttributeResourceValue(i, 0);
- break; //out of for loop
- }
- }
- } else if ("activity".equals(name)) {
- //Check if the <activity> is us and has the attribute
- if (DEBUG) Log.d(TAG, "Got <activity>");
- Integer activityLogo = null;
- String activityPackage = null;
- boolean isOurActivity = false;
-
- for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
- if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));
-
- //We need both uiOptions and name attributes
- String attrName = xml.getAttributeName(i);
- if ("logo".equals(attrName)) {
- activityLogo = xml.getAttributeResourceValue(i, 0);
- } else if ("name".equals(attrName)) {
- activityPackage = ActionBarSherlockCompat.cleanActivityName(packageName, xml.getAttributeValue(i));
- if (!thisPackage.equals(activityPackage)) {
- break; //on to the next
- }
- isOurActivity = true;
- }
-
- //Make sure we have both attributes before processing
- if ((activityLogo != null) && (activityPackage != null)) {
- //Our activity, logo specified, override with our value
- logo = activityLogo.intValue();
- }
- }
- if (isOurActivity) {
- //If we matched our activity but it had no logo don't
- //do any more processing of the manifest
- break;
- }
- }
- }
- eventType = xml.nextToken();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- if (DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(logo));
- return logo;
- }
-
/*
* Must be public so we can dispatch pre-2.2 via ActionBarImpl.
*/