Commit 95cef713 by Kim Jinsung

1.ホームアプリとしての使用するように仕様変更

2.ログ出力判断処理変更
3.アプリ自動起動(BroadcastReceiver)処理変更
parent 1040d40c
......@@ -21,6 +21,8 @@
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT"/>
<!-- The following two intent-filters are the key to set homescreen -->
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
......@@ -33,10 +35,10 @@
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"/>
<receiver android:name=".receiver.OnBootReceiver">
<receiver android:enabled="true" android:name=".receiver.OnBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
......
......@@ -27,12 +27,10 @@ public class ToiletApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Logger logger = new Logger();
// File downloadFilePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
// String logPath = downloadFilePath.getPath() + "/" + APP_LOG_PATH;
// logger.setLogPathFormat(logPath);
// FileUtil.createParentDirectory(logPath);
Logger logger = new Logger();
File downloadFilePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
String logPath = downloadFilePath.getPath() + "/" + APP_LOG_PATH;
logger.setLogPathFormat(logPath);
Logger.i(TAG, "onCreate");
}
......@@ -56,6 +54,9 @@ public class ToiletApplication extends Application {
}
}
public Timer getUpdateToiletInfoTimer() {
return updateToiletInfoTimer;
}
public boolean isForeground(Context context) {
ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
assert am != null;
......
......@@ -17,6 +17,7 @@ public class Logger extends AbstractLogger {
private static String logPathFormat;
private String currentDay;
private int retentionPeriod = 1;
private static boolean isLog = false;
public Logger() {
}
......@@ -27,6 +28,7 @@ public class Logger extends AbstractLogger {
public void setLogPathFormat(String logPathFormat) {
this.logPathFormat = logPathFormat;
if (isLog) FileUtil.createParentDirectory(logPathFormat);
}
public static void setLogger(AbstractLogger abstractLogger) {
......@@ -68,6 +70,7 @@ public class Logger extends AbstractLogger {
// }
public static void d(String tag, String log) {
Log.d(tag,log);
if (isDebugEnabled()) {
logger.debug(tag, log);
}
......@@ -84,6 +87,7 @@ public class Logger extends AbstractLogger {
// }
public static void d(String tag, String log, Throwable t) {
Log.d(tag,log, t);
if (isDebugEnabled()) {
logger.debug(tag, log, t);
}
......@@ -94,6 +98,7 @@ public class Logger extends AbstractLogger {
// }
public static void i(String tag, String log) {
Log.i(tag,log);
if (isInfoEnabled()) {
logger.info(tag, log);
}
......@@ -110,6 +115,7 @@ public class Logger extends AbstractLogger {
// }
public static void i(String tag, String log, Throwable t) {
Log.i(tag,log, t);
if (isInfoEnabled()) {
logger.info(tag, log, t);
}
......@@ -120,6 +126,7 @@ public class Logger extends AbstractLogger {
// }
public static void w(String tag, String log) {
Log.w(tag,log);
if (isWarnEnabled()) {
logger.warn(tag, log);
}
......@@ -136,6 +143,7 @@ public class Logger extends AbstractLogger {
// }
public static void w(String tag, String log, Throwable t) {
Log.w(tag,log);
if (isWarnEnabled()) {
logger.warn(tag, log, t);
}
......@@ -146,6 +154,7 @@ public class Logger extends AbstractLogger {
// }
public static void e(String tag, String log) {
Log.e(tag,log);
if (isErrorEnabled()) {
logger.error(tag, log);
}
......@@ -162,6 +171,7 @@ public class Logger extends AbstractLogger {
// }
public static void e(String tag, String log, Throwable t) {
Log.e(tag,log, t);
if (isErrorEnabled()) {
logger.error(tag, log, t);
}
......@@ -224,85 +234,75 @@ public class Logger extends AbstractLogger {
@Override
protected void verbose(String tag, String log) {
log("VERBOSE", tag, log);
Log.w(tag,log);
}
@Override
protected void verbose(String tag, String log, Throwable t) {
log("VERBOSE", tag, log, t);
Log.w(tag,log,t);
}
@Override
protected void debug(String tag, String log) {
log("DEBUG", tag, log);
Log.d(tag,log);
}
@Override
protected void debug(String tag, String log, Throwable t) {
log("DEBUG", tag, log, t);
Log.d(tag,log,t);
}
@Override
protected void info(String tag, String log) {
log("INFO", tag, log);
Log.i(tag, log);
}
@Override
protected void info(String tag, String log, Throwable t) {
log("INFO", tag, log, t);
Log.i(tag, log, t);
}
@Override
protected void warn(String tag, String log) {
log("WARN", tag, log);
Log.w(tag, log);
}
@Override
protected void warn(String tag, String log, Throwable t) {
log("WARN", tag, log, t);
Log.w(tag,log, t);
}
@Override
protected void error(String tag, String log) {
log("ERROR", tag, log);
Log.e(tag,log);
}
@Override
protected void error(String tag, String log, Throwable t) {
log("ERROR", tag, log, t);
Log.e(tag,log,t);
}
private static boolean isLoggable(int level) {
return false;
return isLog;
}
public static boolean isVerboseEnabled() {
return false;
return isLog;
}
public static boolean isDebugEnabled() {
return false;
return isLog;
}
public static boolean isInfoEnabled() {
return false;
return isLog;
}
public static boolean isWarnEnabled() {
return false;
return isLog;
}
public static boolean isErrorEnabled() {
return false;
return isLog;
}
}
......@@ -3,9 +3,10 @@ package jp.odakyu.toiletsignage.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import jp.odakyu.toiletsignage.activity.MainActivity;
import jp.odakyu.toiletsignage.log.Logger;
import jp.odakyu.toiletsignage.application.ToiletApplication;
/**
* 端末の電源がONしたときに自動的にアプリを起動させるレシーバー
......@@ -16,9 +17,15 @@ public class OnBootReceiver extends BroadcastReceiver {
public static final String TAG = "OnBootReceiver";
@Override
public void onReceive(Context context, Intent intent) {
Logger.i(TAG, "Power ON");
Log.i(TAG, "Power ON");
ToiletApplication application = (ToiletApplication)context.getApplicationContext();
Log.i(TAG, "application = " + application + "application.getUpdateToiletInfoTimer() = " + application.getUpdateToiletInfoTimer());
if (application == null || application.getUpdateToiletInfoTimer() == null) {
Intent i = new Intent(context, MainActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
} else {
Log.i(TAG, "Starting Application");
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment