-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f7d3b7
commit 3a8abb7
Showing
38 changed files
with
1,251 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
### BEGIN_SECTION(julioromano) | ||
## julioromano specific additions. | ||
|
||
# Mac OS X specifics | ||
*~ | ||
.DS_Store | ||
|
||
# Idea project files | ||
.idea | ||
*.iml | ||
|
||
keystore.properties | ||
*.jks | ||
|
||
### END_SECTION(julioromano) | ||
|
||
### BEGIN_SECTION(github) | ||
## https://github.com/github/gitignore/blob/master/Android.gitignore | ||
|
||
# Built application files | ||
*.apk | ||
*.ap_ | ||
|
||
# Files for the Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
|
||
# Gradle files | ||
.gradle/ | ||
build/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
|
||
# Log Files | ||
*.log | ||
|
||
# Android Studio Navigation editor temp files | ||
.navigation/ | ||
|
||
# Android Studio captures folder | ||
captures/ | ||
|
||
### END_SECTION(github) |
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,72 @@ | ||
apply plugin: 'com.android.application' | ||
//apply plugin: 'io.fabric' | ||
|
||
def keystorePropertiesFile = rootProject.file("app/keystore.properties") | ||
def keystoreProperties = new Properties() | ||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) | ||
|
||
android { | ||
|
||
compileSdkVersion 25 | ||
buildToolsVersion "25.0.2" | ||
|
||
defaultConfig { | ||
applicationId "net.kjulio.torch" | ||
versionCode 106 | ||
versionName "1.0.6" | ||
targetSdkVersion 25 | ||
minSdkVersion 10 | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
applicationVariants.all { variant -> | ||
variant.resValue "string", "versionName", variant.versionName | ||
} | ||
|
||
signingConfigs { | ||
release { | ||
keyAlias keystoreProperties['keyAlias'] | ||
keyPassword keystoreProperties['keyPassword'] | ||
storeFile file(keystoreProperties['storeFile']) | ||
storePassword keystoreProperties['storePassword'] | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled true | ||
shrinkResources true | ||
signingConfig signingConfigs.release | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
|
||
// Always show the result of every unit test, even if it passes. | ||
testOptions.unitTests.all { | ||
testLogging { | ||
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError' | ||
} | ||
} | ||
|
||
dataBinding { | ||
enabled true | ||
} | ||
|
||
lintOptions { | ||
abortOnError false | ||
} | ||
} | ||
|
||
dependencies { | ||
String daggerVersion = '2.9' | ||
|
||
compile 'com.android.support:design:25.2.0' | ||
compile 'com.jakewharton.timber:timber:4.5.1' | ||
compile "com.google.dagger:dagger:$daggerVersion" | ||
provided "com.google.dagger:dagger-compiler:$daggerVersion" | ||
provided 'javax.annotation:javax.annotation-api:1.3' | ||
|
||
testCompile 'junit:junit:4.12' | ||
testCompile 'org.hamcrest:hamcrest-core:1.3' | ||
testCompile 'org.mockito:mockito-core:2.7.13' | ||
} |
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,28 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Users/julionb/Library/Android/sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile | ||
|
||
-dontobfuscate | ||
-dontwarn dagger.producers.monitoring.internal.** |
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,34 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="net.kjulio.torch"> | ||
|
||
<uses-permission android:name="android.permission.CAMERA" /> | ||
<uses-feature android:name="android.hardware.camera.flash" /> | ||
|
||
<application | ||
android:name=".app.App" | ||
android:allowBackup="true" | ||
android:icon="@drawable/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:name=".ui.main.MainActivity" | ||
android:label="@string/title_activity_main" | ||
android:launchMode="singleInstance" | ||
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=".ui.settings.SettingsActivity" | ||
android:label="@string/title_activity_settings" | ||
android:launchMode="singleInstance" | ||
android:parentActivityName=".ui.main.MainActivity"> | ||
<meta-data | ||
android:name="android.support.PARENT_ACTIVITY" | ||
android:value="net.kjulio.torch.ui.main.MainActivity" /> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
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,34 @@ | ||
package net.kjulio.torch.app; | ||
|
||
import android.app.Application; | ||
import android.content.Context; | ||
|
||
import javax.inject.Singleton; | ||
|
||
import dagger.Module; | ||
import dagger.Provides; | ||
|
||
@Module | ||
public class AndroidModule { | ||
|
||
private final Application application; | ||
private final Context context; | ||
|
||
public AndroidModule(Application application) { | ||
this.application = application; | ||
this.context = application.getApplicationContext(); | ||
} | ||
|
||
@Provides | ||
@Singleton | ||
Context provideContext() { | ||
return context; | ||
} | ||
|
||
@Provides | ||
@Singleton | ||
Application provideApplication() { | ||
return application; | ||
} | ||
|
||
} |
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,79 @@ | ||
package net.kjulio.torch.app; | ||
|
||
import android.app.Application; | ||
import android.app.NotificationManager; | ||
import android.app.PendingIntent; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.res.Resources; | ||
import android.support.v4.app.NotificationCompat; | ||
|
||
import net.kjulio.torch.R; | ||
import net.kjulio.torch.timber.TimberInitializer; | ||
import net.kjulio.torch.ui.main.MainActivity; | ||
|
||
import javax.inject.Inject; | ||
|
||
public class App extends Application { | ||
|
||
@Inject | ||
TimberInitializer timberInitializer; | ||
|
||
private AppComponent appComponent; | ||
|
||
// Global app visibility flag: true if app is really going to background instead of just switching activities | ||
private boolean notify = true; | ||
|
||
// Notification stuff | ||
private NotificationManager notificationManager; | ||
private NotificationCompat.Builder notificationBuilder; | ||
|
||
public void onCreate() { | ||
super.onCreate(); | ||
appComponent = DaggerAppComponent.builder() | ||
.androidModule(new AndroidModule(this)) | ||
.build(); | ||
appComponent.inject(this); | ||
|
||
// Init Intents for notification | ||
Intent NotificationIntent = new Intent(this, MainActivity.class); | ||
PendingIntent NotificationPendingIntent = PendingIntent.getActivity(this, 0, NotificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); | ||
|
||
// Init resources local var for notification text | ||
Resources res = getResources(); | ||
|
||
// Init notification | ||
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); | ||
notificationBuilder = new NotificationCompat.Builder(this) | ||
.setSmallIcon(R.drawable.ic_launcher) | ||
.setContentTitle(res.getString(R.string.notif_title)) | ||
.setContentText(res.getString(R.string.notif_text)) | ||
.setContentIntent(NotificationPendingIntent) | ||
.setAutoCancel(true) // Hide the notification after its selected | ||
.setOngoing(true); // Set notification as ongoing so it can't be cleared | ||
} | ||
|
||
public AppComponent getAppComponent() { | ||
return appComponent; | ||
} | ||
|
||
public boolean isNotify() { | ||
return notify; | ||
} | ||
|
||
public void setNotify(boolean Notify) { | ||
notify = Notify; | ||
} | ||
|
||
// Raise notification if Notify flag is enabled | ||
public void sendNotif() { | ||
if (notify) { | ||
notificationManager.notify(0, notificationBuilder.build()); | ||
} | ||
} | ||
|
||
// Cancels existing notification, if any | ||
public void clearNotif() { | ||
notificationManager.cancel(0); | ||
} | ||
} |
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,14 @@ | ||
package net.kjulio.torch.app; | ||
|
||
|
||
import javax.inject.Singleton; | ||
|
||
import dagger.Component; | ||
|
||
@Singleton | ||
@Component(modules = {AndroidModule.class}) | ||
public interface AppComponent { | ||
|
||
void inject(App app); | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
app/src/main/java/net/kjulio/torch/timber/TimberInitializer.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,19 @@ | ||
package net.kjulio.torch.timber; | ||
|
||
import net.kjulio.torch.BuildConfig; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Singleton; | ||
|
||
import timber.log.Timber; | ||
|
||
@Singleton | ||
public class TimberInitializer { | ||
|
||
@Inject | ||
TimberInitializer() { | ||
if (BuildConfig.DEBUG) { | ||
Timber.plant(new Timber.DebugTree()); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/net/kjulio/torch/torch/TorchFragment.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,13 @@ | ||
package net.kjulio.torch.torch; | ||
|
||
import android.support.v4.app.Fragment; | ||
|
||
public abstract class TorchFragment extends Fragment { | ||
|
||
public static final String TORCH_FRAGMENT_TAG = "torchFragmentTag"; | ||
|
||
public abstract void on(); | ||
|
||
public abstract void off(); | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
app/src/main/java/net/kjulio/torch/torch/TorchFragmentFactory.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,37 @@ | ||
package net.kjulio.torch.torch; | ||
|
||
import android.content.Context; | ||
|
||
import net.kjulio.torch.torch.camera1.Camera1TorchFragment; | ||
import net.kjulio.torch.torch.mock.MockTorchFragment; | ||
import net.kjulio.torch.utils.Utils; | ||
|
||
public class TorchFragmentFactory { | ||
|
||
private final Context context; | ||
|
||
public TorchFragmentFactory(Context context) { | ||
this.context = context; | ||
} | ||
|
||
public TorchFragment create() { | ||
return create(false); | ||
} | ||
|
||
public TorchFragment create(boolean mock) { | ||
if (mock || !Utils.deviceHasCamera(context)) { | ||
return new MockTorchFragment(); | ||
} else { | ||
// TODO: Uncomment when support for different camera APIs is ready. | ||
// if (Build.VERSION.SDK_INT < 21) { | ||
// return new Camera1TorchFragment(); | ||
// } else if (Build.VERSION.SDK_INT < 23) { | ||
// return new Camera2TorchFragment(); | ||
// } else { | ||
// return new FlashlightTorchFragment(); | ||
// } | ||
return new Camera1TorchFragment(); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.