diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml
index 0d54d38..cadc48e 100644
--- a/res/layout/activity_main.xml
+++ b/res/layout/activity_main.xml
@@ -102,13 +102,22 @@
android:max="255"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
-
+
+
+
+
diff --git a/src/com/hathy/shade/MainActivity.java b/src/com/hathy/shade/MainActivity.java
index 8b89cd0..c07c0b1 100644
--- a/src/com/hathy/shade/MainActivity.java
+++ b/src/com/hathy/shade/MainActivity.java
@@ -11,7 +11,9 @@
import android.support.v4.app.TaskStackBuilder;
import android.view.Menu;
import android.view.View;
+import android.view.View.OnClickListener;
import android.widget.SeekBar;
+import android.widget.CheckBox;
import android.widget.SeekBar.OnSeekBarChangeListener;
/**
@@ -26,8 +28,10 @@ public class MainActivity extends Activity implements OnSeekBarChangeListener {
SeekBar redSeek;
SeekBar greenSeek;
SeekBar blueSeek;
+ CheckBox bblOffCheckBox;
int alpha,red,green,blue;
+ boolean bblOff;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -46,21 +50,30 @@ private void initialize(){
redSeek=(SeekBar)findViewById(R.id.redControl);
greenSeek=(SeekBar)findViewById(R.id.greenControl);
blueSeek=(SeekBar)findViewById(R.id.blueControl);
+ bblOffCheckBox = (CheckBox) findViewById(R.id.bblOff);
alphaSeek.setOnSeekBarChangeListener(this);
redSeek.setOnSeekBarChangeListener(this);
greenSeek.setOnSeekBarChangeListener(this);
blueSeek.setOnSeekBarChangeListener(this);
+ bblOffCheckBox.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ bblOff = ((CheckBox) v).isChecked();
+ }
+ });
alpha=shared.getAlpha();
red=shared.getRed();
green=shared.getGreen();
blue=shared.getBlue();
+ bblOff=shared.getBblOff();
alphaSeek.setProgress(alpha);
redSeek.setProgress(red);
greenSeek.setProgress(green);
blueSeek.setProgress(blue);
+ bblOffCheckBox.setChecked(bblOff);
updateColor();
}
@@ -111,6 +124,7 @@ public void applyClick(View v){
shared.setRed(red);
shared.setGreen(green);
shared.setBlue(blue);
+ shared.setBblOff(bblOff);
Intent i=new Intent(MainActivity.this, MainService.class);
startService(i);
@@ -140,3 +154,4 @@ private void makeNotification(){
mNotificationManager.notify(0x355, nb.build());
}
}
+
diff --git a/src/com/hathy/shade/MainService.java b/src/com/hathy/shade/MainService.java
index 2e3524a..b832f9f 100644
--- a/src/com/hathy/shade/MainService.java
+++ b/src/com/hathy/shade/MainService.java
@@ -5,9 +5,12 @@
import android.graphics.PixelFormat;
import android.os.IBinder;
import android.view.Gravity;
+import android.view.Window;
import android.view.WindowManager;
+import android.view.WindowManager.LayoutParams;
import android.widget.LinearLayout;
import android.widget.Toast;
+import android.util.Log;
/**
* This is the class that is responsible for adding the filter on the
@@ -17,7 +20,7 @@
* @author Hathibelagal
*/
public class MainService extends Service {
-
+ public final static String TAG = "shade.MainService";
LinearLayout mView;
SharedMemory shared;
@@ -45,8 +48,20 @@ public void onCreate() {
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
- 0 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
+ WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
+ | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
+ | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, /* dim statusbar, too */
PixelFormat.TRANSLUCENT);
+ if(shared.getBblOff()) {
+ /* from https://github.com/TomTasche/ScreenFilter.git */
+ try {
+ WindowManager.LayoutParams.class.getField("buttonBrightness").set(params, Integer.valueOf(0));
+ }
+ catch (Exception ex) {
+ Log.w(TAG, "Cannot set button brightness");
+ ex.printStackTrace();
+ }
+ }
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
wm.addView(mView, params);
}
diff --git a/src/com/hathy/shade/SharedMemory.java b/src/com/hathy/shade/SharedMemory.java
index d31d473..cb3cb5e 100644
--- a/src/com/hathy/shade/SharedMemory.java
+++ b/src/com/hathy/shade/SharedMemory.java
@@ -31,6 +31,10 @@ void setBlue(int value){
prefs.edit().putInt("blue", value).commit();
}
+ void setBblOff(boolean value){
+ prefs.edit().putBoolean("bblOff", value).commit();
+ }
+
int getBlue(){
return prefs.getInt("blue", 0x00);
}
@@ -47,6 +51,10 @@ int getAlpha(){
return prefs.getInt("alpha", 0x33);
}
+ boolean getBblOff(){
+ return prefs.getBoolean("bblOff", true);
+ }
+
public static int getColor(int alpha, int red, int green, int blue){
String hex = String.format("%02x%02x%02x%02x", alpha, red, green, blue);
int color=(int)Long.parseLong(hex,16);