Permalink
Browse files

Fix `get-launcher-activity`

Now it handles both package-qualified and simple activity names in the manifest.
  • Loading branch information...
1 parent 4833652 commit c91bfa025096e54c15e5c5c3db06eb739ac2ec2d @alexander-yakushev alexander-yakushev committed Jun 9, 2012
Showing with 11 additions and 10 deletions.
  1. +1 −1 sample/AndroidManifest.xml
  2. +10 −9 src/leiningen/droid/manifest.clj
@@ -9,7 +9,7 @@
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
- <activity android:name="MainActivity">
+ <activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
@@ -52,18 +52,19 @@
(first (xml-> (load-manifest manifest-path) (attr :package))))
(defn get-launcher-activity
- "Returns the package name and the name of the first activity from the
+ "Returns the package-qualified name of the first activity from the
manifest that belongs to the _launcher_ category."
[manifest-path]
(let [manifest (load-manifest manifest-path)
- [package-name] (xml-> manifest (attr :package))]
- (str package-name "/."
- (-> manifest
- get-all-launcher-activities
- first
- up up
- (xml-> (attr :android:name))
- first))))
+ [activity-name] (-> manifest
+ get-all-launcher-activities
+ first
+ up up
+ (xml-> (attr :android:name)))]
+ (let [[_ pkg-name simple-name] (re-matches #"(.*\.)?(.+)" activity-name)]
+ (if (and pkg-name (> (count pkg-name) 1))
+ activity-name
+ (str (first (xml-> manifest (attr :package))) "." simple-name)))))
(defn write-manifest-with-internet-permission
"Updates the manifest on disk guaranteed to have the Internet permission."

0 comments on commit c91bfa0

Please sign in to comment.