[Android Software/Hacking General [Developers Only]] Unr3aL67:
Hey Guys,

I am currently running the latest CM7.2 nightly by maniac103 on my Motorola Defy.

CM7 usually has a special modified Nexus One Torch integrated, whose packagename is "net.cactii.flash2".

As I would like to assign a torch-toggle to a slider in widgetlocker, I need the torch-app to provide a shortcut/activity since it only offers a toggle-widget.

I am talking about the app-specific shortcuts not the shortcuts that directly link to an app.

EDIT: The reason why I haven't put this in Q&A is that this is hopefully going to be a mod, so it may save the mods some time for not needing to push it to another forum...

I may have already found out that the receiver the torch uses is called "net.cactii.flash2.TorchSwitch" and the intent it expects is "net.cactii.flash2.TOGGLE_FLASHLIGHT".

I am not sure though, if I got this whole Intent-/Receiver-thingy right... Any corrections are appreciated.

From this tutorial I have learnt, that apps provide these shortcut-entries in their AndroidManifest.xml. I should be able to modify, recompile and sign this apk.

I just don't know exactly, how I have to add this to the AndroidManifest.xml in terms of syntax and language. That's where I need help...

EDIT: Here's the code of the AndroidManifest.xml for quick review:

<?xml version="1.0" encoding="utf-8"?>
<manifest android:versionCode="10" android:versionName="2.3.7" package="net.cactii.flash2"
xmlns:android="http://schemas.android.com/apk/res/android">
<application android:label="@string/app_name" android:icon="@drawable/icon">
<activity android:label="@string/app_name" android:name=".MainActivity" android:launchMode="singleTask" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".WidgetOptionsActivity">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
<receiver android:label="Torch" android:name="TorchWidgetProvider">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="net.cactii.flash2.TORCH_STATE_CHANGED" />
</intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="@xml/appwidget_info" />
</receiver>
<service android:name=".TorchService" android:enabled="true" />
<receiver android:label="@string/app_name" android:name="TorchSwitch" android:enabled="true">
<intent-filter>
<action android:name="net.cactii.flash2.TOGGLE_FLASHLIGHT" />
</intent-filter>
</receiver>
</application>
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.flash" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
</manifest>

Before you tell me now, that I should use a different flashlight-app: I was already using TeslaLED which runs well with WidgetLocker.

However, the in-built torch offers a high brightness-mode that I want to use. Additionally, TeslaLED always needs 2-3 seconds to activate the flashlight, unlike Torch, which usually toggles instantly...

I have appended the torch-apk, as well as the AndroidManifest.xml I want to modify.

Here is an additional link (from another dev), which shows shortly, how the torch app works together with a statusbar-toggle, if that helps in any way...

Summary of what is needed: A mod for net.cactii.flash2's AndroidManifest.xml which provides a high brightness flashlight toggle-shortcut

If you potentially know how to write this short piece of code and you just want to know how android handles these shortcuts, please read this tutorial. It's very short and helpful.

EDIT: It seems that we have to modify the app as well, not just the AndroidManifest.xml, because it would place a shortcut in the menu, but Torch wouldn't know what to do when I select this item. Feel free to post your ideas and/or corrections

EDIT: Alternatively we could try to make Torch listen to TeslaLED's intents, but I think that would be more sophisticated and could lead to problems, when both apps are installed...

Thanks for any help in advance!

Greetz, Unr3aL67