完善 setting 界面
This commit is contained in:
1 parent
7684dbeee7
commit
cd393530cb
3 files changed
+37
-91
No files matched your search
@@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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.
|
||||
-->
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/text1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="20sp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingBottom="12dp"
|
||||
android:paddingLeft="24dp"
|
||||
android:paddingRight="24dp"
|
||||
android:minHeight="48dp"
|
||||
android:maxHeight="48dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="@android:color/black" />
|
||||
@@ -30,7 +30,6 @@ import android.app.ActionBar;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -47,6 +46,7 @@ import android.webkit.WebView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TableLayout;
|
||||
@@ -87,26 +87,16 @@ public class SettingsActivity extends AbsPreferenceActivity implements FitWindow
|
||||
private FitWindowView mStandard;
|
||||
private List<TranslucentPreferenceFragment> mFragments;
|
||||
private ListView mListView;
|
||||
private int mThemeColor;
|
||||
|
||||
public void adjustPadding(int paddingTop, int paddingBottom) {
|
||||
mListView.setPadding(mListView.getPaddingLeft(), paddingTop, mListView.getPaddingRight(), paddingBottom);
|
||||
public void adjustPadding(int t, int b) {
|
||||
mListView.setPadding(mListView.getPaddingLeft(), t, mListView.getPaddingRight(), b);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void onOrientationChanged(int paddingTop, int paddingBottom) {
|
||||
// for (TranslucentPreferenceFragment f : mFragments) {
|
||||
// if (f.isVisible()) {
|
||||
// f.adjustPadding(paddingTop, paddingBottom);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
// If no fragment is visible, just headers is shown
|
||||
// adjustPadding(paddingTop, paddingBottom);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onFitSystemWindows(int l, int t, int r, int b) {
|
||||
Ui.translucent(this, mThemeColor, t - Ui.ACTION_BAR_HEIGHT);
|
||||
|
||||
for (TranslucentPreferenceFragment f : mFragments) {
|
||||
if (f.isVisible()) {
|
||||
f.adjustPadding(t, b);
|
||||
@@ -121,12 +111,9 @@ public class SettingsActivity extends AbsPreferenceActivity implements FitWindow
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Set random color
|
||||
int color = Config.getRandomThemeColor() ? Theme.getRandomDarkColor() : Config.getThemeColor();
|
||||
color = color & 0x00ffffff | 0xdd000000;
|
||||
Drawable drawable = new ColorDrawable(color);
|
||||
final ActionBar actionBar = getActionBar();
|
||||
actionBar.setBackgroundDrawable(drawable);
|
||||
Ui.translucent(this, color, 0);
|
||||
mThemeColor = Config.getRandomThemeColor() ? Theme.getRandomDarkColor() : Config.getThemeColor();
|
||||
ActionBar actionBar = getActionBar();
|
||||
actionBar.setBackgroundDrawable(new ColorDrawable(mThemeColor));
|
||||
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
@@ -134,23 +121,13 @@ public class SettingsActivity extends AbsPreferenceActivity implements FitWindow
|
||||
|
||||
mListView = getListView();
|
||||
mListView.setClipToPadding(false);
|
||||
|
||||
int listIndex = -1;
|
||||
ViewGroup p = (ViewGroup) mListView.getParent();
|
||||
int size = p.getChildCount();
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (mListView == p.getChildAt(i)) {
|
||||
listIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (listIndex != -1) {
|
||||
mStandard = new FitWindowView(this);
|
||||
mStandard.addOnFitSystemWindowsListener(this);
|
||||
p.addView(mStandard, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
}
|
||||
|
||||
FrameLayout fl = (FrameLayout) getWindow().getDecorView().findViewById(android.R.id.content);
|
||||
mStandard = new FitWindowView(this);
|
||||
mStandard.addOnFitSystemWindowsListener(this);
|
||||
fl.addView(mStandard, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -222,15 +199,11 @@ public class SettingsActivity extends AbsPreferenceActivity implements FitWindow
|
||||
&& child instanceof ListView) {
|
||||
mListView = (ListView) child;
|
||||
mListView.setClipToPadding(false);
|
||||
|
||||
int[] padding = new int[2];
|
||||
Ui.getWindowPadding(mActivity.getResources(), padding);
|
||||
adjustPadding(padding[0], padding[1]);
|
||||
}
|
||||
}
|
||||
|
||||
public void adjustPadding(int paddingTop, int paddingBottom) {
|
||||
mListView.setPadding(mListView.getPaddingLeft(), paddingTop, mListView.getPaddingRight(), paddingBottom);
|
||||
public void adjustPadding(int t, int b) {
|
||||
mListView.setPadding(mListView.getPaddingLeft(), t, mListView.getPaddingRight(), b);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -344,29 +344,31 @@ public class Ui {
|
||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||
public static void translucent(Activity activity, int color, int height) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
boolean needAdd = false;
|
||||
View statusBarBgView;
|
||||
FrameLayout.LayoutParams lp;
|
||||
ViewGroup decorViewGroup = (ViewGroup) activity.getWindow().getDecorView();
|
||||
|
||||
View statusBarBgView = (View) decorViewGroup.getTag(R.id.translucent_view);
|
||||
if (statusBarBgView == null) {
|
||||
needAdd = true;
|
||||
statusBarBgView = new View(activity);
|
||||
}
|
||||
statusBarBgView.setBackgroundColor(color);
|
||||
|
||||
lp = (FrameLayout.LayoutParams) statusBarBgView.getLayoutParams();
|
||||
if (lp == null)
|
||||
lp = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, height);
|
||||
else
|
||||
// Try to find old translucent view
|
||||
if (decorViewGroup.getChildCount() > 1 &&
|
||||
(statusBarBgView = decorViewGroup.getChildAt(1)) != null &&
|
||||
statusBarBgView.getId() == R.id.translucent_view) {
|
||||
lp = (LayoutParams) statusBarBgView.getLayoutParams();
|
||||
lp.height = height;
|
||||
lp.gravity = Gravity.TOP;
|
||||
|
||||
if (needAdd) {
|
||||
decorViewGroup.addView(statusBarBgView, lp);
|
||||
decorViewGroup.setTag(R.id.translucent_view, statusBarBgView);
|
||||
} else {
|
||||
lp.gravity = Gravity.TOP;
|
||||
statusBarBgView.setBackgroundColor(color);
|
||||
statusBarBgView.setLayoutParams(lp);
|
||||
|
||||
Log.d(TAG, "translucent new");
|
||||
} else {
|
||||
statusBarBgView = new View(activity);
|
||||
statusBarBgView.setId(R.id.translucent_view);
|
||||
statusBarBgView.setBackgroundColor(color);
|
||||
lp = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, height);
|
||||
lp.gravity = Gravity.TOP;
|
||||
decorViewGroup.addView(statusBarBgView, lp);
|
||||
|
||||
|
||||
Log.d(TAG, "translucent update");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user