Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support immersive mode to hide the navigation buttons.
Add Android TV support.
- Loading branch information
Devesh Parekh
committed
Apr 19, 2015
1 parent
7d50e29
commit c32d47e
Showing
6 changed files
with
98 additions
and
18 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,38 +1,53 @@ | ||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:0.5.+' | ||
classpath 'com.android.tools.build:gradle:1.1.3' | ||
} | ||
} | ||
apply plugin: 'android' | ||
apply plugin: 'com.android.application' | ||
|
||
task wrapper(type: Wrapper) { | ||
gradleVersion '1.6' | ||
gradleVersion '2.3' | ||
} | ||
|
||
android { | ||
compileSdkVersion 17 | ||
buildToolsVersion '17.0.0' | ||
compileSdkVersion 22 | ||
buildToolsVersion '22.0.1' | ||
|
||
defaultConfig { | ||
minSdkVersion 3 | ||
targetSdkVersion 17 | ||
targetSdkVersion 22 | ||
} | ||
|
||
productFlavors { | ||
cupcake { | ||
versionCode 3000 | ||
} | ||
immersive { | ||
versionCode 11000 | ||
minSdkVersion 11 | ||
} | ||
} | ||
|
||
signingConfigs { | ||
release { | ||
storeFile file('devesh.keystore') | ||
keyAlias 'deveshandroid' | ||
storePassword System.getenv("KSTOREPWD") | ||
keyPassword System.getenv("KEYPWD") | ||
keyAlias 'flashlight' | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
runProguard true | ||
proguardFile 'proguard.cfg' | ||
minifyEnabled true | ||
proguardFiles getDefaultProguardFile('proguard-android.txt') | ||
signingConfig signingConfigs.release | ||
} | ||
debug { | ||
debuggable true | ||
} | ||
} | ||
} | ||
} |
Binary file not shown.
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Fri May 17 02:12:17 PDT 2013 | ||
#Sat Apr 18 19:19:04 PDT 2015 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=http\://services.gradle.org/distributions/gradle-1.6-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-bin.zip |
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
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,56 @@ | ||
/* | ||
* Copyright 2012 Devesh Parekh | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package devesh.flashlight; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.view.Window; | ||
import android.view.WindowManager; | ||
|
||
public class Flashlight extends Activity { | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
Window window = getWindow(); | ||
window.getDecorView().setSystemUiVisibility( | ||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE | ||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | ||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | ||
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | ||
| View.SYSTEM_UI_FLAG_FULLSCREEN | ||
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | ||
); | ||
// Flashlights should be bright. | ||
WindowManager.LayoutParams params = window.getAttributes(); | ||
params.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL; | ||
// params.buttonBrightness was added in API level 8. The additional brightness is not worth the added code size. | ||
// The screen will go to max brightness even without the following line, but the API doesn't guarantee it. | ||
window.setAttributes(params); | ||
window.addFlags( | ||
// Use the power button to turn flashlight off and on, even if you have a lock screen. | ||
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | ||
// We won't do anything with touch events. Don't bother sending them to us. | ||
// Unfortunately, there is a platform bug that still exists in 4.2 (!) that causes ANRs if this | ||
// flag is set. | ||
// | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | ||
// A flashlight that turns itself off isn't a good flashlight. | ||
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | ||
// Turn the screen on if it isn't already on when launching (e.g., from ADB). | ||
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); | ||
} | ||
} |
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