forked from Quarx2k/android_frameworks_base
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patchset 2 : New torch drawables (Björn Lundén) Change-Id: I0831266d503195ee249a85d0d728bdae321e56cd
- Loading branch information
Showing
8 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
Binary file modified
BIN
+109 Bytes
(100%)
packages/SystemUI/res/drawable-hdpi/ic_qs_flashlight_off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-67 Bytes
(98%)
packages/SystemUI/res/drawable-hdpi/ic_qs_flashlight_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+76 Bytes
(100%)
packages/SystemUI/res/drawable-mdpi/ic_qs_flashlight_off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-31 Bytes
(99%)
packages/SystemUI/res/drawable-mdpi/ic_qs_flashlight_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+128 Bytes
(100%)
packages/SystemUI/res/drawable-xhdpi/ic_qs_flashlight_off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-135 Bytes
(96%)
packages/SystemUI/res/drawable-xhdpi/ic_qs_flashlight_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions
66
packages/SystemUI/src/com/android/systemui/quicksettings/FlashLightTile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.android.systemui.quicksettings; | ||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.ComponentName; | ||
import android.content.ContentResolver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.IntentFilter; | ||
import android.database.ContentObserver; | ||
import android.os.Handler; | ||
import android.provider.Settings; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
|
||
import com.android.systemui.R; | ||
import com.android.systemui.statusbar.phone.QuickSettingsController; | ||
import com.android.systemui.statusbar.phone.QuickSettingsContainerView; | ||
|
||
public class FlashLightTile extends QuickSettingsTile { | ||
|
||
public FlashLightTile(Context context, LayoutInflater inflater, | ||
QuickSettingsContainerView container, | ||
QuickSettingsController qsc, Handler handler) { | ||
super(context, inflater, container, qsc); | ||
TorchObserver observer = new TorchObserver(handler); | ||
observer.startObserving(); | ||
updateTileState(); | ||
|
||
onClick = new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Intent i = new Intent("net.cactii.flash2.TOGGLE_FLASHLIGHT"); | ||
mContext.sendBroadcast(i); | ||
} | ||
}; | ||
} | ||
|
||
private void updateTileState() { | ||
boolean enabled = Settings.System.getInt(mContext.getContentResolver(), | ||
Settings.System.TORCH_STATE, 0) == 1; | ||
if(enabled) { | ||
mDrawable = R.drawable.ic_qs_flashlight_on; | ||
} else { | ||
mDrawable = R.drawable.ic_qs_flashlight_off; | ||
} | ||
} | ||
|
||
private class TorchObserver extends ContentObserver { | ||
public TorchObserver(Handler handler) { | ||
super(handler); | ||
} | ||
|
||
@Override | ||
public void onChange(boolean selfChange) { | ||
updateTileState(); | ||
updateQuickSettings(); | ||
} | ||
|
||
public void startObserving() { | ||
final ContentResolver cr = mContext.getContentResolver(); | ||
cr.registerContentObserver( | ||
Settings.System.getUriFor(Settings.System.TORCH_STATE), false, this); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters