FORUMS

[HELP] Modding CM7 Torch to provide a toggle-shortcut

53 posts
Thanks Meter: 34
 
By Unr3aL67, Member on 20th March 2013, 01:16 PM
Post Reply Email Thread
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:
Code:
<?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
Attached Files
File Type: apk net.cactii.flash2.apk - [Click for QR Code] (133.0 KB, 356 views)
File Type: zip AndroidManifest.xml.zip - [Click for QR Code] (2.1 KB, 80 views)
The Following User Says Thank You to Unr3aL67 For This Useful Post: [ View ] Gift Unr3aL67 Ad-Free
8th October 2013, 03:54 PM |#2  
Senior Member
Thanks Meter: 57
 
More
Quote:
Originally Posted by Unr3aL67

"net.cactii.flash2.TOGGLE_FLASHLIGHT"

thanks!
I used this line in Tasker with Send Intent to toggle Torch on my CM10.2.
The Following User Says Thank You to Gawis For This Useful Post: [ View ] Gift Gawis Ad-Free
8th January 2014, 09:18 PM |#3  
Member
Flag Austin
Thanks Meter: 14
 
More
Question
Quote:
Originally Posted by Gawis

thanks!
I used this line in Tasker with Send Intent to toggle Torch on my CM10.2.

Okay, I'm using tasker to make a widget via power toggles... I used the same line in tasker, and it works great! Here's what I'm wondering now...
In power toggles, with regular toggles, you can have the icon change colors, say it would be green when the flashlight is on, and gray when off... Obviously you can't do that by just sending the intent, so anyone have any ideas about how to do this?
I know power toggles uses Tesla by default, but I don't like the delay.. Torch is on immediately, so thats what I want to use.

Any ideas would be greatly appreciated!
8th January 2014, 10:51 PM |#4  
Member
Flag Austin
Thanks Meter: 14
 
More
Exclamation
Quote:
Originally Posted by Gawis

thanks!
I used this line in Tasker with Send Intent to toggle Torch on my CM10.2.

Okay, I figured it out... The following task, paired with power toggles, works great! The button is off when the light is off, and the button is in the "Active" state when the light is on.. For mine its Gray when the light is off, and Green when the light is on....

If %Toggle ~ 1
Send Intent
Action net.cactii.flash2.TOGGLE_FLASHLIGHT
Variable Set
Name %Toggle To 0
Else
Send Intent
Action net.cactii.flash2.TOGGLE_FLASHLIGHT
Variable Set
Name %Toggle To 1
End If
Modify PowerToggle state
Configuration Set current toggle to off
If %Toggle ~ 0
Modify PowerToggle state
Configuration Set current toggle to on
If %Toggle ~ 1

Hope this helps someone figure this out! LOL! If it helped you, please thumbs up... Too busy to be on XDA all the time....
Post Reply Subscribe to Thread

Tags
cactii, mod, toggle, torch, widgetlocker

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes