diff --git a/README.md b/README.md
index eeae53827..7213645f2 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,8 @@ Just import into Eclipse and build. Do it youself if you prefer Android Studio.
- 按钮控件
- [GIFLIB](http://giflib.sourceforge.net)
- gif 解码
+- [Gloria Hallelujah](https://www.google.com/fonts/specimen/Gloria+Hallelujah)
+ - 启动界面字体
- [libjpeg-turbo](http://www.libjpeg-turbo.org)
- jpge 解码
- [libpng](http://www.libpng.org/pub/png/libpng.html)
@@ -37,11 +39,13 @@ Just import into Eclipse and build. Do it youself if you prefer Android Studio.
- [OpenCC](https://github.com/BYVoid/OpenCC)
- 繁化工作
- [Slabo](https://github.com/TiroTypeworks/Slabo)
- - 字体
+ - 图标字体
- [SlidingMenu](https://github.com/jfeinstein10/SlidingMenu)
- 曾作为抽屉控件
- [source-code-pro](https://github.com/adobe/source-code-pro)
- - 字体
+ - 刷新控件字体
+- [svg-android](https://code.google.com/p/svg-android/)
+ - svg 解析
- [SystemBarTint](https://github.com/jgilfelt/SystemBarTint)
- 状态栏背景设置
- [zlib](http://www.zlib.net)
diff --git a/assets/fonts/GloriaHallelujah.ttf b/assets/fonts/GloriaHallelujah.ttf
new file mode 100644
index 000000000..3b42f5b38
Binary files /dev/null and b/assets/fonts/GloriaHallelujah.ttf differ
diff --git a/libs/svg-android.jar b/libs/svg-android.jar
new file mode 100644
index 000000000..c3281abb1
Binary files /dev/null and b/libs/svg-android.jar differ
diff --git a/res/drawable/default_avatar.png b/res/drawable/default_avatar.png
deleted file mode 100644
index 5d003c6e0..000000000
Binary files a/res/drawable/default_avatar.png and /dev/null differ
diff --git a/res/drawable/welcome.png b/res/drawable/welcome.png
deleted file mode 100644
index e4e349274..000000000
Binary files a/res/drawable/welcome.png and /dev/null differ
diff --git a/res/layout-land/start_activity.xml b/res/layout-land/start_activity.xml
new file mode 100644
index 000000000..60e8ea5f6
--- /dev/null
+++ b/res/layout-land/start_activity.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/start_activity.xml b/res/layout/start_activity.xml
new file mode 100644
index 000000000..0d38bf707
--- /dev/null
+++ b/res/layout/start_activity.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/raw/default_avatar.svg b/res/raw/default_avatar.svg
new file mode 100644
index 000000000..54d839775
--- /dev/null
+++ b/res/raw/default_avatar.svg
@@ -0,0 +1,12 @@
+
+
+
diff --git a/res/raw/sad_pandroid.svg b/res/raw/sad_pandroid.svg
new file mode 100644
index 000000000..e251b136b
--- /dev/null
+++ b/res/raw/sad_pandroid.svg
@@ -0,0 +1,16 @@
+
+
+
diff --git a/res/raw/thanks.html b/res/raw/thanks.html
index ad71dbcbe..8f723e3f7 100644
--- a/res/raw/thanks.html
+++ b/res/raw/thanks.html
@@ -23,6 +23,8 @@
FloatingActionButton
+Gloria Hallelujah
+
GIFLIB
libjpeg-turbo
@@ -39,6 +41,8 @@
source-code-pro
+svg-android
+
SystemBarTint
zlib
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 4f3ed1d6f..dd7949a74 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -51,6 +51,7 @@
8.0dip
+ 24sp
22sp
20sp
18sp
diff --git a/res/values/strings.xml b/res/values/strings.xml
index b0b4a8116..3c38c9d3c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -17,6 +17,7 @@
EhViewer
+ Do not be a\nsad pandroid
Waring
diff --git a/src/com/hippo/ehviewer/AppContext.java b/src/com/hippo/ehviewer/AppContext.java
index 0bc3d8eda..b66d7b6a9 100644
--- a/src/com/hippo/ehviewer/AppContext.java
+++ b/src/com/hippo/ehviewer/AppContext.java
@@ -23,9 +23,11 @@ import java.io.IOException;
import java.lang.Thread.UncaughtExceptionHandler;
import android.app.Application;
+import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.view.ContextThemeWrapper;
import com.hippo.ehviewer.cache.ImageCache;
import com.hippo.ehviewer.data.Data;
@@ -69,16 +71,18 @@ public class AppContext extends Application implements UncaughtExceptionHandler
Intent it = new Intent(this, DownloadService.class);
bindService(it, mServiceConn, BIND_AUTO_CREATE);
+ Context mContextThemeWrapper = new ContextThemeWrapper(this, R.style.AppTheme);
+
// Init everything
- Config.init(this);
- Log.init(this);
- Ui.init(this);
- Crash.init(this);
- EhClient.createInstance(this);
- Favorite.init(this);
- Data.createInstance(this);
- ExDownloaderManager.createInstance(this);
- MaterialToast.setContext(this);
+ Config.init(mContextThemeWrapper);
+ Log.init(mContextThemeWrapper);
+ Ui.init(mContextThemeWrapper);
+ Crash.init(mContextThemeWrapper);
+ EhClient.createInstance(mContextThemeWrapper);
+ Favorite.init(mContextThemeWrapper);
+ Data.createInstance(mContextThemeWrapper);
+ ExDownloaderManager.createInstance(mContextThemeWrapper);
+ MaterialToast.setContext(mContextThemeWrapper);
// Set drawer margin
SlidingDrawerLayout.setDefaultMinDrawerMargin(Ui.ACTION_BAR_HEIGHT * 2);
@@ -94,13 +98,13 @@ public class AppContext extends Application implements UncaughtExceptionHandler
}
// Update proxy urls
- HttpHelper.updateProxyUrls(this);
+ HttpHelper.updateProxyUrls(mContextThemeWrapper);
String keyVersionCode = "version_code";
int oldVersion = Config.getInt(keyVersionCode, Integer.MAX_VALUE);
// Fix <=22 login error
if (oldVersion <= 22)
- EhInfo.getInstance(this).logout();
+ EhInfo.getInstance(mContextThemeWrapper).logout();
// Fix <=25 Update
if (oldVersion <= 25) {
diff --git a/src/com/hippo/ehviewer/StartActivity.java b/src/com/hippo/ehviewer/StartActivity.java
index 955b9009d..7f6b1dfc4 100644
--- a/src/com/hippo/ehviewer/StartActivity.java
+++ b/src/com/hippo/ehviewer/StartActivity.java
@@ -17,25 +17,29 @@
package com.hippo.ehviewer;
import android.annotation.SuppressLint;
-import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
+import android.graphics.Typeface;
import android.net.Uri;
-import android.os.Build;
import android.os.Bundle;
import android.text.util.Linkify;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
+import android.view.animation.DecelerateInterpolator;
+import android.widget.ImageView;
+import android.widget.TextView;
import com.hippo.ehviewer.app.MaterialAlertDialog;
import com.hippo.ehviewer.network.Network;
+import com.hippo.ehviewer.ui.AbsActivity;
import com.hippo.ehviewer.ui.GalleryListActivity;
import com.hippo.ehviewer.util.Config;
import com.hippo.ehviewer.util.Crash;
+import com.larvalabs.svgandroid.SVGParser;
-public class StartActivity extends Activity {
+public class StartActivity extends AbsActivity {
@SuppressWarnings("unused")
private static final String TAG = StartActivity.class.getSimpleName();
@@ -183,24 +187,19 @@ public class StartActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- View wellcome = new View(this);
- wellcome.setBackgroundDrawable(getResources().getDrawable(
- R.drawable.welcome));
- setContentView(wellcome);
+ setContentView(R.layout.start_activity);
- // For fullscreen
- if (Build.VERSION.SDK_INT >= 19) {
- wellcome.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);
- }
+ View main = findViewById(R.id.main);
+ TextView text = (TextView) findViewById(R.id.text);
+ text.setTypeface(Typeface.createFromAsset(getAssets(),"fonts/GloriaHallelujah.ttf"));
+ ImageView image = (ImageView) findViewById(R.id.image);
+ image.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
+ image.setImageDrawable(SVGParser.getSVGFromResource(getResources(), R.raw.sad_pandroid).createPictureDrawable());
// Show welcome in progress
AlphaAnimation aa = new AlphaAnimation(0.3f, 1.0f);
aa.setDuration(2000);
+ aa.setInterpolator(new DecelerateInterpolator(3.0f));
aa.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationEnd(Animation arg0) {
@@ -217,7 +216,7 @@ public class StartActivity extends Activity {
public void onAnimationStart(Animation animation) {
}
});
- wellcome.startAnimation(aa);
+ main.startAnimation(aa);
check(CHECK_WARING);
}
diff --git a/src/com/hippo/ehviewer/ehclient/EhClient.java b/src/com/hippo/ehviewer/ehclient/EhClient.java
index 0ab5708e8..b2c5a0a5c 100644
--- a/src/com/hippo/ehviewer/ehclient/EhClient.java
+++ b/src/com/hippo/ehviewer/ehclient/EhClient.java
@@ -30,6 +30,8 @@ import org.json.JSONObject;
import android.content.Context;
import android.graphics.Bitmap;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Process;
@@ -283,7 +285,7 @@ public class EhClient {
/**
* Return avatar, if not return default avatar
*/
- public Bitmap getAvatar() {
+ public Drawable getAvatar() {
return mInfo.getAvatar();
}
@@ -394,7 +396,7 @@ public class EhClient {
Bitmap avatar = hp.getImage(avatarUrl);
// Set avatar if not null
if (avatar != null)
- mInfo.setAvatar(avatar);
+ mInfo.setAvatar(new BitmapDrawable(EhClient.this.mContext.getResources(), avatar));
// notification
listener.onGetAvatar(GET_AVATAR_OK);
}
diff --git a/src/com/hippo/ehviewer/ehclient/EhInfo.java b/src/com/hippo/ehviewer/ehclient/EhInfo.java
index 04684b18b..ec8e0e455 100644
--- a/src/com/hippo/ehviewer/ehclient/EhInfo.java
+++ b/src/com/hippo/ehviewer/ehclient/EhInfo.java
@@ -28,11 +28,13 @@ import java.util.List;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.util.Config;
import com.hippo.ehviewer.util.Utils;
+import com.larvalabs.svgandroid.SVGParser;
/**
*
@@ -46,7 +48,7 @@ public class EhInfo {
private static final String DIR_NAME = "file";
private static final String AVATAR_NAME = "avatar.png";
private static final Bitmap.CompressFormat AVATAR_FORMAT = Bitmap.CompressFormat.PNG;
- private static Bitmap DEFAULT_AVATAR;
+ private static Drawable DEFAULT_AVATAR;
public static final String EX_HOST = "exhentai.org";
public static final String[] COOKIABLE_HOSTS = {"exhentai.org",
@@ -69,14 +71,14 @@ public class EhInfo {
private boolean mIsLogin;
private String mUsername;
private String mDisplayname;
- private Bitmap mAvatar;
+ private BitmapDrawable mAvatar;
private int mDefaultCat;
private String mPreviewMode;
private int mExculdeTagGroup;
private String mExculdeLanguage;
private static EhInfo sInstance;
- private Bitmap getAvatarFromFile() {
+ private BitmapDrawable getAvatarFromFile() {
File dir = mContext.getDir(DIR_NAME, 0);
File avatarFile = new File(dir, AVATAR_NAME);
if (!avatarFile.exists())
@@ -85,7 +87,7 @@ public class EhInfo {
InputStream is = null;
try {
is = new FileInputStream(avatarFile);
- return BitmapFactory.decodeStream(is);
+ return (BitmapDrawable) BitmapDrawable.createFromStream(is, null);
} catch (FileNotFoundException e) {
return null;
} finally {
@@ -97,8 +99,7 @@ public class EhInfo {
mContext = context;
mInfoPref = mContext.getSharedPreferences(PREF_NAME, 0);
if (DEFAULT_AVATAR == null)
- DEFAULT_AVATAR = BitmapFactory.decodeStream(
- context.getResources().openRawResource(R.drawable.default_avatar));
+ DEFAULT_AVATAR = SVGParser.getSVGFromResource(context.getResources(), R.raw.default_avatar).createPictureDrawable();
mIsLogin = mInfoPref.getBoolean(KEY_LOGIN, DEFAULT_LOGIN);
mUsername = mInfoPref.getString(KEY_USERNAME, DEFAULT_NAME);
@@ -201,7 +202,7 @@ public class EhInfo {
mIsLogin = false;
// Remove avatar
if (mAvatar != null) {
- mAvatar.recycle();
+ mAvatar.getBitmap().recycle();
mAvatar = null;
File dir = mContext.getDir(DIR_NAME, 0);
File avatarFile = new File(dir, AVATAR_NAME);
@@ -221,11 +222,11 @@ public class EhInfo {
return mDisplayname;
}
- public Bitmap getAvatar() {
+ public Drawable getAvatar() {
return isLogin() && mAvatar != null ? mAvatar : DEFAULT_AVATAR;
}
- public void setAvatar(Bitmap avatar) {
+ public void setAvatar(BitmapDrawable avatar) {
mAvatar = avatar;
File dir = mContext.getDir(DIR_NAME, 0);
@@ -233,7 +234,7 @@ public class EhInfo {
OutputStream os = null;
try {
os = new FileOutputStream(avatarFile);
- avatar.compress(AVATAR_FORMAT, 100, os);
+ avatar.getBitmap().compress(AVATAR_FORMAT, 100, os);
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
diff --git a/src/com/hippo/ehviewer/ui/GalleryListActivity.java b/src/com/hippo/ehviewer/ui/GalleryListActivity.java
index 8c7bcbd84..0706e7d46 100644
--- a/src/com/hippo/ehviewer/ui/GalleryListActivity.java
+++ b/src/com/hippo/ehviewer/ui/GalleryListActivity.java
@@ -1545,7 +1545,7 @@ public class GalleryListActivity extends AbsTranslucentActivity implements View.
switch (state) {
case LOGIN:
- mAvatar.setImageBitmap(mClient.getAvatar());
+ mAvatar.setImageDrawable(mClient.getAvatar());
mUsernameView.setVisibility(View.GONE);
mLoginButton.setVisibility(View.VISIBLE);
mRegisterButton.setVisibility(View.VISIBLE);
@@ -1553,7 +1553,7 @@ public class GalleryListActivity extends AbsTranslucentActivity implements View.
mWaitLogView.setVisibility(View.GONE);
break;
case LOGOUT:
- mAvatar.setImageBitmap(mClient.getAvatar());
+ mAvatar.setImageDrawable(mClient.getAvatar());
mUsernameView.setText(mClient.getDisplayname());
mUsernameView.setVisibility(View.VISIBLE);
mLoginButton.setVisibility(View.GONE);
@@ -1562,7 +1562,7 @@ public class GalleryListActivity extends AbsTranslucentActivity implements View.
mWaitLogView.setVisibility(View.GONE);
break;
case WAIT:
- mAvatar.setImageBitmap(mClient.getAvatar());
+ mAvatar.setImageDrawable(mClient.getAvatar());
mUsernameView.setVisibility(View.GONE);
mLoginButton.setVisibility(View.GONE);
mRegisterButton.setVisibility(View.GONE);
diff --git a/src/com/hippo/ehviewer/widget/MaterialToast.java b/src/com/hippo/ehviewer/widget/MaterialToast.java
index 16ce4fd49..ae8803361 100644
--- a/src/com/hippo/ehviewer/widget/MaterialToast.java
+++ b/src/com/hippo/ehviewer/widget/MaterialToast.java
@@ -18,7 +18,6 @@ package com.hippo.ehviewer.widget;
import android.annotation.SuppressLint;
import android.content.Context;
-import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
@@ -31,7 +30,7 @@ public class MaterialToast extends Toast {
private static Context sContext;
public static void setContext(Context context) {
- sContext = new ContextThemeWrapper(context, R.style.AppTheme);
+ sContext = context;
}
@SuppressLint("InflateParams")