调整启动界面

This commit is contained in:
seven332 committed 2014-12-25 14:23:53 +08:00
1 parent 20e2314560
commit 7d24529831
18 files changed
+303 -53

No files matched your search

+4 -7
View File
@@ -178,21 +178,18 @@ public class StartActivity extends AbsActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
// Disable animate
overridePendingTransition(0, 0);
super.onCreate(savedInstanceState);
setContentView(R.layout.start_activity);
// View decorView = getWindow().getDecorView();
// int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
// decorView.setSystemUiVisibility(uiOptions);
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
AppHandler.getInstance().postDelayed(new Runnable() {
@Override
public void run() {
@@ -200,7 +197,7 @@ public class StartActivity extends AbsActivity {
redirectTo();
isAnimationOver = true;
}
}, 2000);
}, 3000);
check(CHECK_WARING);
}
@@ -44,7 +44,6 @@ import android.provider.MediaStore;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ImageSpan;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@@ -90,7 +89,6 @@ import com.hippo.ehviewer.widget.FitWindowView;
import com.hippo.ehviewer.widget.GalleryListView;
import com.hippo.ehviewer.widget.GalleryListView.OnGetListListener;
import com.hippo.ehviewer.widget.MaterialToast;
import com.hippo.ehviewer.widget.RatingView;
import com.hippo.ehviewer.widget.SearchView;
import com.hippo.ehviewer.widget.SlidingDrawerLayout;
import com.hippo.ehviewer.widget.SuggestionHelper;
@@ -201,9 +199,6 @@ public class GalleryListActivity extends AbsTranslucentActivity implements View.
private String mTitle;
private int mListDetailThumbWidth;
private int mListDetailThumbHeight;
// private int mListModeThumbHeight;
private void toRegister() {
@@ -981,17 +976,6 @@ public class GalleryListActivity extends AbsTranslucentActivity implements View.
mSuggestions = SuggestionHelper.getInstance(GalleryListActivity.this, SimpleSuggestionProvider.AUTHORITY,
SimpleSuggestionProvider.MODE);
// Caculate gallery detail height
LayoutInflater inflater = LayoutInflater.from(this);
View v = inflater.inflate(R.layout.test_gallery_list_detail_thumb, null);
((TextView) v.findViewById(R.id.title)).setText("haha\nhaha");
((TextView) v.findViewById(R.id.uploader)).setText("haha");
((RatingView) v.findViewById(R.id.rate)).setRating(2.3f);
((TextView) v.findViewById(R.id.category)).setText("haha");
ViewUtils.measureView(v);
mListDetailThumbHeight = Math.max(v.getMeasuredHeight(), Ui.dp2pix(120));
mListDetailThumbWidth = mListDetailThumbHeight * 2 / 3;
handleIntent(getIntent());
// Check show drawer or not
if (ACTION_GALLERY_LIST.equals(getIntent().getAction()))
@@ -0,0 +1,61 @@
/*
* Copyright (C) 2014 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
* 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 com.hippo.ehviewer.ui;
import java.util.Arrays;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.View;
import android.widget.ImageView;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.effect.DrawableTransition;
import com.hippo.ehviewer.util.Config;
import com.hippo.ehviewer.util.Ui;
import com.hippo.ehviewer.widget.MaterialToast;
public class SecretActivity extends AbsActivity implements View.OnClickListener {
private final long[] mHits = new long[3];
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int themeColor = Config.getCustomThemeColor() ? Config.getThemeColor() : Ui.THEME_COLOR;
Ui.colorStatusBarL(this, themeColor);
ImageView iv = new ImageView(this);
iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
iv.setImageResource(R.drawable.pandas);
iv.setOnClickListener(this);
iv.setSoundEffectsEnabled(false);
setContentView(iv);
DrawableTransition.transit(iv.getDrawable(), false, 3000);
}
@Override
public void onClick(View v) {
System.arraycopy(mHits, 1, mHits, 0, mHits.length-1);
mHits[mHits.length-1] = SystemClock.uptimeMillis();
if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) {
Arrays.fill(mHits, 0);
MaterialToast.showToast(R.string.photo_footnotes);
}
}
}
@@ -22,16 +22,22 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.SystemClock;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
@@ -726,6 +732,7 @@ public class SettingsActivity extends AbsPreferenceActivity {
private static final String KEY_THANKS = "thanks";
private static final String KEY_WEBSITE = "website";
private static final String KEY_SOURCE = "source";
private static final String KEY_VERSION = "version";
private static final String KEY_CHECK_UPDATE = "check_for_update";
private static final String KEY_CLOUD_DRIVE = "cloud_drive";
private static final String KEY_ABOUT_ANALYICS = "about_analyics";
@@ -736,10 +743,13 @@ public class SettingsActivity extends AbsPreferenceActivity {
private Preference mThanks;
private Preference mWebsite;
private Preference mSource;
private Preference mVersion;
private Preference mCheckUpdate;
private Preference mCloudDrive;
private Preference mAboutAnalyics;
private final long[] mHits = new long[3];
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -757,18 +767,36 @@ public class SettingsActivity extends AbsPreferenceActivity {
mWebsite.setOnPreferenceClickListener(this);
mSource = findPreference(KEY_SOURCE);
mSource.setOnPreferenceClickListener(this);
mVersion = findPreference(KEY_VERSION);
mVersion.setOnPreferenceClickListener(this);
mCheckUpdate = findPreference(KEY_CHECK_UPDATE);
mCheckUpdate.setOnPreferenceClickListener(this);
mCloudDrive = findPreference(KEY_CLOUD_DRIVE);
mCloudDrive.setOnPreferenceClickListener(this);
mAboutAnalyics = findPreference(KEY_ABOUT_ANALYICS);
mAboutAnalyics.setOnPreferenceClickListener(this);
try {
Context c = getActivity().getApplicationContext();
PackageInfo pi= c.getPackageManager().getPackageInfo(c.getPackageName(), 0);
mVersion.setSummary(pi.versionName);
} catch (NameNotFoundException e) {}
}
@Override
public boolean onPreferenceClick(Preference preference) {
final String key = preference.getKey();
if (KEY_AUTHOR.equals(key)) {
if (KEY_VERSION.equals(key)) {
System.arraycopy(mHits, 1, mHits, 0, mHits.length-1);
mHits[mHits.length-1] = SystemClock.uptimeMillis();
if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) {
Arrays.fill(mHits, 0);
Activity a = getActivity();
Intent intent = new Intent(a, SecretActivity.class);
a.startActivity(intent);
getActivity().overridePendingTransition(0, 0);
}
} else if (KEY_AUTHOR.equals(key)) {
Intent i = new Intent(Intent.ACTION_SENDTO);
i.setData(Uri.parse("mailto:ehviewersu@gmail.com"));
i.putExtra(Intent.EXTRA_SUBJECT, "About EhViewer");
+1 -1
View File
@@ -411,7 +411,7 @@ public final class Config {
index = 2;
break;
case 6407:
index = 2;
index = 3;
break;
case 6408:
index = 4;
+24 -12
View File
@@ -115,7 +115,13 @@ public final class ViewUtils {
* @return
*/
public static Bitmap getBitmapFromView(View v) {
Bitmap bitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(),
int width = v.getWidth();
int height = v.getHeight();
if (width == 0 && height == 0) {
width = v.getMeasuredWidth();
height = v.getMeasuredHeight();
}
Bitmap bitmap = Bitmap.createBitmap(width, height,
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
// TODO I need to know why I need it, when ScrollView
@@ -159,17 +165,23 @@ public final class ViewUtils {
}
}
public static void measureView(View v) {
ViewGroup.LayoutParams oldLp = v.getLayoutParams();
ViewGroup.LayoutParams newLp = new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
v.setLayoutParams(newLp);
int measureSpec = MeasureSpec.makeMeasureSpec(0,
MeasureSpec.UNSPECIFIED);
v.measure(measureSpec, measureSpec);
if (oldLp != null)
v.setLayoutParams(oldLp);
public static void measureView(View v, int width, int height) {
int widthMeasureSpec;
int heightMeasureSpec;
if (width == ViewGroup.LayoutParams.WRAP_CONTENT)
widthMeasureSpec = MeasureSpec.makeMeasureSpec(0,
MeasureSpec.UNSPECIFIED);
else
widthMeasureSpec = MeasureSpec.makeMeasureSpec(Math.max(width, 0),
MeasureSpec.EXACTLY);
if (height == ViewGroup.LayoutParams.WRAP_CONTENT)
heightMeasureSpec = MeasureSpec.makeMeasureSpec(0,
MeasureSpec.UNSPECIFIED);
else
heightMeasureSpec = MeasureSpec.makeMeasureSpec(Math.max(height, 0),
MeasureSpec.EXACTLY);
v.measure(widthMeasureSpec, heightMeasureSpec);
}
/**
@@ -176,7 +176,7 @@ public class GalleryListView extends FrameLayout implements RefreshLayout.OnFoot
((TextView) v.findViewById(R.id.uploader)).setText("haha");
((RatingView) v.findViewById(R.id.rate)).setRating(2.3f);
((TextView) v.findViewById(R.id.category)).setText("haha");
ViewUtils.measureView(v);
ViewUtils.measureView(v, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
mListDetailThumbHeight = Math.max(v.getMeasuredHeight(), Ui.dp2pix(120));
mListDetailThumbWidth = mListDetailThumbHeight * 2 / 3;
}
@@ -0,0 +1,87 @@
/*
* Copyright (C) 2014 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
* 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 com.hippo.ehviewer.widget;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import com.hippo.ehviewer.effect.DrawableTransition;
public class TransitionLayout extends LinearLayout {
private Bitmap mBmp;
private int mOldWidth;
private int mOldHeight;
private static final String TAG = TransitionLayout.class.getSimpleName();
public TransitionLayout(Context context) {
super(context);
}
public TransitionLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public TransitionLayout(Context context, AttributeSet attrs,
int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public TransitionLayout(Context context, AttributeSet attrs,
int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
@Override
protected void dispatchDraw(Canvas canvas) {
int width = getWidth();
int height = getHeight();
if (mOldWidth != width || mOldHeight != height || mBmp == null) {
mOldWidth = width;
mOldHeight = height;
if (mBmp != null && !mBmp.isRecycled())
mBmp.recycle();
mBmp = Bitmap.createBitmap(getWidth(), getHeight(),
Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(mBmp);
c.translate(-getScrollX(), -getScrollY());
super.dispatchDraw(c);
BitmapDrawable b = new BitmapDrawable(getResources(), mBmp);
DrawableTransition.transit(b, false, 3000);
setBackgroundDrawable(b);
}
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
setBackgroundDrawable(null);
if (mBmp != null && !mBmp.isRecycled())
mBmp.recycle();
}
}