diff --git a/app/.gitignore b/app/.gitignore index 796b96d1c..aceae4974 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1 +1,2 @@ /build +manifest-merger-release-report.txt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index fd56d05d0..5396edd52 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -22,6 +22,16 @@ android:label="@string/app_name" android:theme="@style/AppTheme" > + + + + + + + diff --git a/app/src/main/java/com/hippo/ehviewer/ui/AbsActionBarActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/AbsActionBarActivity.java new file mode 100644 index 000000000..b2f59f1d1 --- /dev/null +++ b/app/src/main/java/com/hippo/ehviewer/ui/AbsActionBarActivity.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2014-2015 Hippo Seven + * + * 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 + * 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 com.hippo.ehviewer.ui; + +import android.support.v7.app.ActionBarActivity; +import android.view.View; +import android.view.Window; + +public abstract class AbsActionBarActivity extends ActionBarActivity { + + public boolean post(Runnable action) { + Window w = getWindow(); + if (w != null) { + View v = w.getDecorView(); + return v != null && v.post(action); + } else { + return false; + } + } + + public boolean postDelayed(Runnable action, long delayMillis) { + Window w = getWindow(); + if (w != null) { + View v = w.getDecorView(); + return v != null && v.postDelayed(action, delayMillis); + } else { + return false; + } + } + +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/StartActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/StartActivity.java new file mode 100644 index 000000000..f4d9bcf1a --- /dev/null +++ b/app/src/main/java/com/hippo/ehviewer/ui/StartActivity.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2014-2015 Hippo Seven + * + * 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 + * 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 com.hippo.ehviewer.ui; + +import android.os.Bundle; + +import com.hippo.ehviewer.R; + +public class StartActivity extends AbsActionBarActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_start); + } +} diff --git a/app/src/main/java/com/hippo/ehviewer/util/EhUtils.java b/app/src/main/java/com/hippo/ehviewer/util/EhUtils.java index 87c84970c..567c599eb 100644 --- a/app/src/main/java/com/hippo/ehviewer/util/EhUtils.java +++ b/app/src/main/java/com/hippo/ehviewer/util/EhUtils.java @@ -78,6 +78,4 @@ public final class EhUtils { } return CATEGORY_STRINGS[i][0]; } - - } diff --git a/app/src/main/java/com/hippo/util/Log.java b/app/src/main/java/com/hippo/util/Log.java new file mode 100644 index 000000000..155aa85d7 --- /dev/null +++ b/app/src/main/java/com/hippo/util/Log.java @@ -0,0 +1,193 @@ +/* + * Copyright (C) 2014-2015 Hippo Seven + * + * 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 + * 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 com.hippo.util; + +import com.hippo.ehviewer.BuildConfig; + +public class Log { + + public static final String avoidNull(String str) { + return str == null ? TextUtils.STRING_NULL : str; + } + + /** + * It is {@link android.util.Log#v(String, String)}, only work when debug. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param msg The message you would like logged. + */ + public static int v(String tag, String msg) { + if (BuildConfig.DEBUG) { + return android.util.Log.v(tag, avoidNull(msg)); + } else { + return 0; + } + } + + /** + * It is {@link android.util.Log#v(String, String, Throwable)}, only work when debug. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param msg The message you would like logged. + * @param tr An exception to log + */ + public static int v(String tag, String msg, Throwable tr) { + if (BuildConfig.DEBUG) { + return android.util.Log.v(tag, avoidNull(msg), tr); + } else { + return 0; + } + } + + /** + * It is {@link android.util.Log#d(String, String)}, only work when debug. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param msg The message you would like logged. + */ + public static int d(String tag, String msg) { + if (BuildConfig.DEBUG) { + return android.util.Log.d(tag, avoidNull(msg)); + } else { + return 0; + } + } + + /** + * It is {@link android.util.Log#d(String, String, Throwable)}, only work when debug. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param msg The message you would like logged. + * @param tr An exception to log + */ + public static int d(String tag, String msg, Throwable tr) { + if (BuildConfig.DEBUG) { + return android.util.Log.d(tag, avoidNull(msg), tr); + } else { + return 0; + } + } + + /** + * It is {@link android.util.Log#i(String, String)}, only work when debug. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param msg The message you would like logged. + */ + public static int i(String tag, String msg) { + if (BuildConfig.DEBUG) { + return android.util.Log.i(tag, avoidNull(msg)); + } else { + return 0; + } + } + + /** + * It is {@link android.util.Log#i(String, String, Throwable)}, only work when debug. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param msg The message you would like logged. + * @param tr An exception to log + */ + public static int i(String tag, String msg, Throwable tr) { + if (BuildConfig.DEBUG) { + return android.util.Log.i(tag, avoidNull(msg), tr); + } else { + return 0; + } + } + + /** + * It is {@link android.util.Log#w(String, String)}, only work when debug. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param msg The message you would like logged. + */ + public static int w(String tag, String msg) { + if (BuildConfig.DEBUG) { + return android.util.Log.w(tag, avoidNull(msg)); + } else { + return 0; + } + } + + /** + * It is {@link android.util.Log#w(String, String, Throwable)}, only work when debug. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param msg The message you would like logged. + * @param tr An exception to log + */ + public static int w(String tag, String msg, Throwable tr) { + if (BuildConfig.DEBUG) { + return android.util.Log.w(tag, avoidNull(msg), tr); + } else { + return 0; + } + } + + /** + * It is {@link android.util.Log#w(String, Throwable)}, only work when debug. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param tr An exception to log + */ + public static int w(String tag, Throwable tr) { + if (BuildConfig.DEBUG) { + return android.util.Log.w(tag, tr); + } else { + return 0; + } + } + + /** + * It is {@link android.util.Log#e(String, String)}, only work when debug. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param msg The message you would like logged. + */ + public static int e(String tag, String msg) { + if (BuildConfig.DEBUG) { + return android.util.Log.e(tag, avoidNull(msg)); + } else { + return 0; + } + } + + /** + * It is {@link android.util.Log#e(String, String, Throwable)}, only work when debug. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param msg The message you would like logged. + * @param tr An exception to log + */ + public static int e(String tag, String msg, Throwable tr) { + if (BuildConfig.DEBUG) { + return android.util.Log.e(tag, avoidNull(msg), tr); + } else { + return 0; + } + } + + /** + * It is {@link android.util.Log#getStackTraceString(Throwable)}.
+ * Handy function to get a loggable stack trace from a Throwable + * @param tr An exception to log + */ + public static String getStackTraceString(Throwable tr) { + return android.util.Log.getStackTraceString(tr); + } +} diff --git a/app/src/main/java/com/hippo/util/TextUtils.java b/app/src/main/java/com/hippo/util/TextUtils.java new file mode 100644 index 000000000..94103b116 --- /dev/null +++ b/app/src/main/java/com/hippo/util/TextUtils.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2015 Hippo Seven + * + * 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 + * 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 com.hippo.util; + +public class TextUtils { + + public static final String STRING_EMPTY = ""; + public static final String STRING_NULL = "null"; + +} diff --git a/app/src/main/res/layout/activity_start.xml b/app/src/main/res/layout/activity_start.xml new file mode 100644 index 000000000..c70cc508d --- /dev/null +++ b/app/src/main/res/layout/activity_start.xml @@ -0,0 +1,21 @@ + + + + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 000000000..11c997bb0 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,31 @@ + + + + + #ff009688 + #ff00796b + + #ffff5722 + + #ffff9800 + + #ffffc107 + + @color/material_teal_500 + @color/material_teal_700 + #ffff6977 + + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index abbc72c71..fb763db78 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -15,9 +15,4 @@ --> - - - diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 000000000..8eff99c64 --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,26 @@ + + + + + + +