Compare commits

...
4 Commits
Author SHA1 Message Date
seven332 09229546c6 log 2014-10-14 21:52:47 +08:00
seven332 03582eb9da 自动调整 gallery list item 高度 2014-10-14 21:49:00 +08:00
seven332 e2e794b85c 计算 gallery list item 高度 2014-10-14 17:14:01 +08:00
seven332 ab949d5567 卧槽 2014-10-14 14:29:06 +08:00
13 changed files with 732 additions and 393 deletions

No files matched your search

+48
View File
@@ -9,6 +9,54 @@
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>?children?</key>
<value>?children?=?name?=entry\\\\\\\|\\\|?name?=entry\\\\\\\|\\\|\|?name?=outputEntries\||</value>
</dictionary>
<dictionary>
<key>?name?</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.append_environment</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
<value>NDK_DEBUG=0</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildCommand</key>
<value>ndk-build</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
<value>clean</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.contents</key>
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
<value>false</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
<value>false</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.stopOnError</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>false</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
+2 -2
View File
@@ -16,8 +16,8 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hippo.ehviewer"
android:versionCode="27"
android:versionName="0.6.6" >
android:versionCode="28"
android:versionName="0.6.7" >
<uses-sdk
android:minSdkVersion="14"
@@ -0,0 +1,56 @@
<?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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/title"
style="@style/CardTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp" />
<TextView
android:id="@+id/uploader"
style="@style/CardMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp" />
<com.hippo.ehviewer.widget.RatingView
android:id="@+id/rate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp" />
<TextView
android:id="@+id/category"
style="@style/CardMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:paddingBottom="2dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="2dp"
android:textColor="@android:color/white" />
</LinearLayout>
+6
View File
@@ -1,3 +1,9 @@
Version 0.6.7 (2014-10-14)
* 修正部分设置修改无效
* 完善网络状态检查
* 移除不和谐字符串
* 调整界面
Version 0.6.6 (2014-10-13)
* 下载目录命名方式恢复为 gid-title,以前的目录名称可在 设置->高级->其他->修正下载文件夹名 处修改
* 避免大量通知
+3 -6
View File
@@ -19,16 +19,14 @@
<!-- Warning -->
<string name="dailog_waring_title">警告</string>
<string name="dailog_waring_plain">该应用内容来自互联网,部分内容可能对您的生理及心理造成难以恢复的伤害。该应用作者不会对由该应用造成的后果负责。您是否愿意继续使用该应用?</string>
<string name="dailog_waring_yes">我愿意</string>
<string name="dailog_waring_no">不!</string>
<!-- Analyics -->
<string name="dailog_analyics_title">数据统计</string>
<string name="dailog_analyics_plain">您是否愿意将使用情况发送给开发者?这对开发者维护该应用有很大帮助。在发送使用情况的同时也会发送部分设备信息(譬如设备型号、系统版本)。开发者承诺不收集任何个人身份信息数据(譬如姓名、电话号码、电邮地址)。\n\n数据收集过程采用 Google Analytics。\nGOOGLE ANALYTICS(分析)服务条款:http://www.google.com/analytics/terms/cn.html\nGoogle隐私权和条款:http://www.google.com/intl/zh-CN/policies\n\n您以后可以在设置中修改选择</string>
<!-- Network -->
<string name="dailog_network_error_yes">我不在意</string>
<string name="dailog_network_error_no">成</string>
<string name="dailog_network_mobile_title">您正在使用移动网络,可能会消耗大量的资费,是否继续使用?</string>
<string name="dailog_network_none_title">未检测到网络连接,是否继续使用?</string>
<!-- Exit -->
<string name="exit_tip">再按一次退出</string>
@@ -62,8 +60,6 @@
<!-- Send Crash -->
<string name="dialog_send_crash_title">这很重要</string>
<string name="dialog_send_crash_plain">上次该应用崩溃了。你愿意把错误日志发送给开发者以便以后得到更好的用户体验么?(以电子邮件的形式发送)</string>
<string name="dialog_send_crash_yes">我愿意</string>
<string name="dialog_send_crash_no">门儿都没有</string>
<string name="dialog_wait_send_crash_msg">请在发送完日志后关闭该窗口</string>
<!-- List item long click -->
@@ -341,6 +337,7 @@
<string name="rating0">…</string>
<!-- Utils -->
<string name="warning">警告</string>
<string name="close">关闭</string>
<string name="select">选择</string>
<string name="click_more">点击查看更多</string>
+3 -6
View File
@@ -7,16 +7,14 @@
<!-- Warning -->
<string name="dailog_waring_title">警告</string>
<string name="dailog_waring_plain">該應用內容來自互聯網,部分內容可能對您的生理及心理造成難以恢復的傷害。該應用作者不會對由該應用造成的後果負責。您是否願意繼續使用該應用?</string>
<string name="dailog_waring_yes">我願意</string>
<string name="dailog_waring_no">不!</string>
<!-- Analyics -->
<string name="dailog_analyics_title">數據統計</string>
<string name="dailog_analyics_plain">您是否願意將使用情況發送給開發者?這對開發者維護該應用有很大幫助。在發送使用情況的同時也會發送部分設備信息(譬如設備型號、系統版本)。開發者承諾不收集任何個人身份信息數據(譬如姓名、電話號碼、電郵地址)。\n\n數據收集過程採用 Google Analytics。\nGOOGLE ANALYTICS(分析)服務條款:http://www.google.com/analytics/terms/cn.html\nGoogle隱私權和條款:http://www.google.com/intl/zh-CN/policies\n\n您以後可以在設置中修改選擇</string>
<!-- Network -->
<string name="dailog_network_error_yes">我不在意</string>
<string name="dailog_network_error_no">成</string>
<string name="dailog_network_mobile_title">您正在使用移動網絡,可能會消耗大量的資費,是否繼續使用?</string>
<string name="dailog_network_none_title">未檢測到網絡連接,是否繼續使用?</string>
<!-- Exit -->
<string name="exit_tip">再按一次退出</string>
@@ -50,8 +48,6 @@
<!-- Send Crash -->
<string name="dialog_send_crash_title">這很重要</string>
<string name="dialog_send_crash_plain">上次該應用崩潰了。你願意把錯誤日誌發送給開發者以便以後得到更好的用戶體驗麼?(以電子郵件的形式發送)</string>
<string name="dialog_send_crash_yes">我願意</string>
<string name="dialog_send_crash_no">門兒都沒有</string>
<string name="dialog_wait_send_crash_msg">請在發送完日誌後關閉該窗口</string>
<!-- List item long click -->
@@ -329,6 +325,7 @@
<string name="rating0">…</string>
<!-- Utils -->
<string name="warning">警告</string>
<string name="close">關閉</string>
<string name="select">選擇</string>
<string name="click_more">點擊查看更多</string>
+3 -6
View File
@@ -7,16 +7,14 @@
<!-- Warning -->
<string name="dailog_waring_title">警告</string>
<string name="dailog_waring_plain">該應用內容來自網際網路,部分內容可能對您的生理及心理造成難以恢復的傷害。該應用作者不會對由該應用造成的後果負責。您是否願意繼續使用該應用?</string>
<string name="dailog_waring_yes">我願意</string>
<string name="dailog_waring_no">不!</string>
<!-- Analyics -->
<string name="dailog_analyics_title">資料統計</string>
<string name="dailog_analyics_plain">您是否願意將使用情況發送給開發者?這對開發者維護該應用有很大幫助。在發送使用情況的同時也會發送部分裝置資訊(譬如裝置型號、系統版本)。開發者承諾不收集任何個人身份資訊資料(譬如姓名、電話號碼、電郵地址)。\n\n資料收集過程採用 Google Analytics。\nGOOGLE ANALYTICS(分析)服務條款:http://www.google.com/analytics/terms/cn.html\nGoogle隱私權和條款:http://www.google.com/intl/zh-CN/policies\n\n您以後可以在設定中修改選擇</string>
<!-- Network -->
<string name="dailog_network_error_yes">我不在意</string>
<string name="dailog_network_error_no">成</string>
<string name="dailog_network_mobile_title">您正在使用移動網路,可能會消耗大量的資費,是否繼續使用?</string>
<string name="dailog_network_none_title">未檢測到網路連線,是否繼續使用?</string>
<!-- Exit -->
<string name="exit_tip">再按一次退出</string>
@@ -50,8 +48,6 @@
<!-- Send Crash -->
<string name="dialog_send_crash_title">這很重要</string>
<string name="dialog_send_crash_plain">上次該應用崩潰了。你願意把錯誤日誌發送給開發者以便以後得到更好的使用者體驗麼?(以電子郵件的形式發送)</string>
<string name="dialog_send_crash_yes">我願意</string>
<string name="dialog_send_crash_no">門兒都沒有</string>
<string name="dialog_wait_send_crash_msg">請在發送完日誌後關閉該視窗</string>
<!-- List item long click -->
@@ -329,6 +325,7 @@
<string name="rating0">…</string>
<!-- Utils -->
<string name="warning">警告</string>
<string name="close">關閉</string>
<string name="select">選擇</string>
<string name="click_more">點選檢視更多</string>
+4 -7
View File
@@ -20,17 +20,15 @@
<!-- Warning -->
<string name="dailog_waring_title">Waring</string>
<string name="dailog_waring_plain">该应用内容来自互联网,部分内容可能对您的生理及心理造成难以恢复的伤害。该应用作者不会对由该应用造成的后果负责。您是否愿意继续使用该应用?</string>
<string name="dailog_waring_yes">Yes, I would</string>
<string name="dailog_waring_no">NO !</string>
<string name="dailog_waring_plain">本应用中内容来自互联网,部分内容可能对您的生理及心理造成难以恢复的伤害。该应用作者不会对由本应用造成的后果负责。您是否愿意继续使用该应用?</string>
<!-- Analyics -->
<string name="dailog_analyics_title">Usage statistics</string>
<string name="dailog_analyics_plain">您是否愿意将使用情况发送给开发者?这对开发者维护该应用有很大帮助。在发送使用情况的同时也会发送部分设备信息(譬如设备型号、系统版本)。开发者承诺不收集任何个人身份信息数据(譬如姓名、电话号码、电邮地址)。\n\n数据收集过程采用 Google Analytics。\nGOOGLE ANALYTICS(分析)服务条款:http://www.google.com/analytics/terms/us.html\nGoogle隐私权和条款:http://www.google.com/intl/us/policies\n\n您以后可以在设置中修改选择</string>
<!-- Network -->
<string name="dailog_network_error_yes">I don\'t care</string>
<string name="dailog_network_error_no">Fine</string>
<string name="dailog_network_mobile_title">You are using the mobile network, it may consume a large amount of charges, whether to continue to use ?</string>
<string name="dailog_network_none_title">Does not detect a network connection, whether to continue to use ?</string>
<!-- Exit -->
<string name="exit_tip">Click again to exit</string>
@@ -65,8 +63,6 @@
<!-- Send Crash -->
<string name="dialog_send_crash_title">It is important</string>
<string name="dialog_send_crash_plain">This application crashed last time. Would you mind to send logcat to the developer for a better user experience in future ? (via e-mail)</string>
<string name="dialog_send_crash_yes">Never mind</string>
<string name="dialog_send_crash_no">Yes, I would</string>
<string name="dialog_wait_send_crash_msg">Please close the dialog after sending logcat</string>
<!-- List item long click -->
@@ -363,6 +359,7 @@
<string name="rating0">DISASTER</string>
<!-- Util -->
<string name="warning">Warning</string>
<string name="close">Close</string>
<string name="select">Select</string>
<string name="click_more">Click for more</string>
+66 -39
View File
@@ -42,6 +42,10 @@ public class StartActivity extends Activity {
@SuppressWarnings("unused")
private static final String TAG = StartActivity.class.getSimpleName();
private static final int NETWORK_STATE_NONE = 0x0;
private static final int NETWORK_STATE_MOBILE = 0x1;
private static final int NETWORK_STATE_WIFI = 0x2;
private static final int CHECK_WARING = 0;
private static final int CHECK_ANALYTICS = 1;
private static final int CHECK_NETWORK = 2;
@@ -55,8 +59,8 @@ public class StartActivity extends Activity {
return new MaterialAlertDialog.Builder(this).setCancelable(false)
.setTitle(R.string.dailog_waring_title)
.setMessage(R.string.dailog_waring_plain)
.setPositiveButton(R.string.dailog_waring_yes)
.setNegativeButton(R.string.dailog_waring_no)
.setPositiveButton(android.R.string.ok)
.setNegativeButton(android.R.string.cancel)
.setButtonListener(new MaterialAlertDialog.OnClickListener() {
@Override
public boolean onClick(MaterialAlertDialog dialog, int which) {
@@ -99,11 +103,22 @@ public class StartActivity extends Activity {
}).create();
}
private AlertDialog createNetworkErrorDialog() {
private AlertDialog createNetworkDialog(int state) {
int mesgId;
switch (state) {
case NETWORK_STATE_MOBILE:
mesgId = R.string.dailog_network_mobile_title;
break;
case NETWORK_STATE_NONE:
default:
mesgId = R.string.dailog_network_none_title;
break;
}
return new MaterialAlertDialog.Builder(this).setCancelable(false)
.setTitle(R.string.error).setMessage(R.string.em_no_network)
.setPositiveButton(R.string.dailog_network_error_yes)
.setNegativeButton(R.string.dailog_network_error_no)
.setTitle(R.string.warning).setMessage(mesgId)
.setPositiveButton(android.R.string.ok)
.setNegativeButton(android.R.string.cancel)
.setButtonListener(new MaterialAlertDialog.OnClickListener() {
@Override
public boolean onClick(MaterialAlertDialog dialog, int which) {
@@ -124,28 +139,34 @@ public class StartActivity extends Activity {
return new MaterialAlertDialog.Builder(this).setCancelable(false)
.setTitle(R.string.dialog_send_crash_title)
.setMessage(R.string.dialog_send_crash_plain)
.setPositiveButton(R.string.dialog_send_crash_yes)
.setNegativeButton(R.string.dialog_send_crash_no)
.setPositiveButton(android.R.string.ok)
.setNegativeButton(android.R.string.cancel)
.setButtonListener(new MaterialAlertDialog.OnClickListener() {
@Override
public boolean onClick(MaterialAlertDialog dialog, int which) {
switch (which) {
case MaterialAlertDialog.POSITIVE:
// A wait dialog
new MaterialAlertDialog.Builder(StartActivity.this).setCancelable(false)
new MaterialAlertDialog.Builder(StartActivity.this)
.setCancelable(false)
.setTitle(R.string.wait)
.setMessage(R.string.dialog_wait_send_crash_msg)
.setMessage(
R.string.dialog_wait_send_crash_msg)
.setPositiveButton(android.R.string.ok)
.setButtonListener(new MaterialAlertDialog.OnClickListener() {
@Override
public boolean onClick(MaterialAlertDialog dialog, int which) {
checkOver();
return true;
}
}).show();
.setButtonListener(
new MaterialAlertDialog.OnClickListener() {
@Override
public boolean onClick(
MaterialAlertDialog dialog,
int which) {
checkOver();
return true;
}
}).show();
Intent i = new Intent(Intent.ACTION_SENDTO);
i.setData(Uri.parse("mailto:ehviewersu@gmail.com"));
i.putExtra(Intent.EXTRA_SUBJECT, "I found a bug in EhViewer !");
i.putExtra(Intent.EXTRA_SUBJECT,
"I found a bug in EhViewer !");
i.putExtra(Intent.EXTRA_TEXT, lastCrash);
startActivity(i);
lastCrash = null;
@@ -166,13 +187,13 @@ public class StartActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View wellcome = new View(this);
wellcome.setBackgroundDrawable(getResources().getDrawable(R.drawable.welcome));
wellcome.setBackgroundDrawable(getResources().getDrawable(
R.drawable.welcome));
setContentView(wellcome);
// For fullscreen
if (Build.VERSION.SDK_INT >= 19) {
wellcome.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
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
@@ -181,7 +202,7 @@ public class StartActivity extends Activity {
}
// Show welcome in progress
AlphaAnimation aa = new AlphaAnimation(0.3f,1.0f);
AlphaAnimation aa = new AlphaAnimation(0.3f, 1.0f);
aa.setDuration(2000);
aa.setAnimationListener(new AnimationListener() {
@Override
@@ -190,22 +211,22 @@ public class StartActivity extends Activity {
redirectTo();
isAnimationOver = true;
}
@Override
public void onAnimationRepeat(Animation animation) {}
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationStart(Animation animation) {}
public void onAnimationStart(Animation animation) {
}
});
wellcome.startAnimation(aa);
check(CHECK_WARING);
}
/**
* Order is
* 1. check waring
* 2. check analyics
* 3. check network
* 4. check crash
* 5. check external storage
* Order is 1. check waring 2. check analyics 3. check network 4. check
* crash 5. check external storage
*
* @param order
*/
@@ -223,8 +244,9 @@ public class StartActivity extends Activity {
return;
}
case CHECK_NETWORK:
if (!isNetworkAvailable()) {
createNetworkErrorDialog().show();
int state = getNetworkState();
if (state != NETWORK_STATE_WIFI) {
createNetworkDialog(state).show();
return;
}
case CHECK_CRASH:
@@ -242,16 +264,21 @@ public class StartActivity extends Activity {
isCheckOver = true;
}
private boolean isNetworkAvailable() {
ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mNetworkInfo = cm.getActiveNetworkInfo();
if (mNetworkInfo == null || !mNetworkInfo.isAvailable())
return false;
private int getNetworkState() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mWifi = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
NetworkInfo mMobile = cm
.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
if (mWifi != null && mWifi.isConnected())
return NETWORK_STATE_WIFI;
else if (mMobile != null && mMobile.isConnected())
return NETWORK_STATE_MOBILE;
else
return true;
return NETWORK_STATE_NONE;
}
private void redirectTo(){
private void redirectTo() {
Intent intent = new Intent(this, GalleryListActivity.class);
startActivity(intent);
finish();
@@ -33,7 +33,8 @@ import android.widget.TextView;
import com.hippo.ehviewer.R;
public class MaterialAlertDialog extends AlertDialog implements View.OnClickListener, AdapterView.OnItemClickListener {
public class MaterialAlertDialog extends AlertDialog implements
View.OnClickListener, AdapterView.OnItemClickListener {
public final static int ACTION = 0;
public final static int POSITIVE = 1;
@@ -52,7 +53,7 @@ public class MaterialAlertDialog extends AlertDialog implements View.OnClickList
private Button mNeutralButton;
private MaterialAlertDialog(Builder builder) {
//super(builder.mContext);
// super(builder.mContext);
super(new ContextThemeWrapper(builder.mContext, R.style.AppTheme_Main));
mContext = builder.mContext;
mBuilder = builder;
@@ -78,14 +79,16 @@ public class MaterialAlertDialog extends AlertDialog implements View.OnClickList
TextView message = null;
ListView list = null;
if (inScrollView) {
mRootView.findViewById(R.id.top_panel_noscroll).setVisibility(View.GONE);
mRootView.findViewById(R.id.top_panel_noscroll).setVisibility(
View.GONE);
mTitle = (TextView) mRootView.findViewById(R.id.title);
topPanel = (LinearLayout) mRootView.findViewById(R.id.top_panel);
message = (TextView) mRootView.findViewById(R.id.message);
} else {
mRootView.findViewById(R.id.scroll_view).setVisibility(View.GONE);
mTitle = (TextView) mRootView.findViewById(R.id.title2);
topPanel = (LinearLayout) mRootView.findViewById(R.id.top_panel_noscroll);
topPanel = (LinearLayout) mRootView
.findViewById(R.id.top_panel_noscroll);
list = (ListView) mRootView.findViewById(R.id.list);
}
// Title
@@ -96,8 +99,10 @@ public class MaterialAlertDialog extends AlertDialog implements View.OnClickList
// Content
if (mBuilder.mCustomView != null) {
// CustomView
if (message != null) message.setVisibility(View.GONE);
if (list != null) list.setVisibility(View.GONE);
if (message != null)
message.setVisibility(View.GONE);
if (list != null)
list.setVisibility(View.GONE);
LinearLayout.LayoutParams lp = mBuilder.mCustomLp;
if (lp == null)
lp = new LinearLayout.LayoutParams(
@@ -107,7 +112,8 @@ public class MaterialAlertDialog extends AlertDialog implements View.OnClickList
topPanel.addView(mBuilder.mCustomView, lp);
} else if (mBuilder.mAdapter != null) {
// List
if (message != null) message.setVisibility(View.GONE);
if (message != null)
message.setVisibility(View.GONE);
list.setAdapter(mBuilder.mAdapter);
list.setOnItemClickListener(this);
if (mBuilder.mIsSingleChoice) {
@@ -119,7 +125,8 @@ public class MaterialAlertDialog extends AlertDialog implements View.OnClickList
}
} else {
// Message
if (list != null) list.setVisibility(View.GONE);
if (list != null)
list.setVisibility(View.GONE);
if (mBuilder.mAutoLinkMask != -1)
message.setAutoLinkMask(mBuilder.mAutoLinkMask);
message.setText(mBuilder.mMessage);
@@ -222,7 +229,6 @@ public class MaterialAlertDialog extends AlertDialog implements View.OnClickList
dismiss();
}
public static interface OnClickListener {
public boolean onClick(MaterialAlertDialog dialog, int which);
}
@@ -314,13 +320,29 @@ public class MaterialAlertDialog extends AlertDialog implements View.OnClickList
return this;
}
/**
* Custom view id will be R.id.custom
*
* @param view
* @param inScrollView
* @return
*/
public Builder setView(View view, boolean inScrollView) {
mCustomView = view;
mInScrollView = inScrollView;
return this;
}
public Builder setView(View view, boolean inScrollView, LinearLayout.LayoutParams lp) {
/**
* Custom view id will be R.id.custom
*
* @param view
* @param inScrollView
* @param lp
* @return
*/
public Builder setView(View view, boolean inScrollView,
LinearLayout.LayoutParams lp) {
mCustomView = view;
mInScrollView = inScrollView;
mCustomLp = lp;
@@ -339,14 +361,15 @@ public class MaterialAlertDialog extends AlertDialog implements View.OnClickList
public Builder setItems(int itemsId, final OnClickListener listener) {
mAdapter = new ArrayAdapter<CharSequence>(mContext,
R.layout.select_dialog_item, android.R.id.text1,
mContext.getResources().getTextArray(itemsId));
R.layout.select_dialog_item, android.R.id.text1, mContext
.getResources().getTextArray(itemsId));
mOnClickListener = listener;
mIsSingleChoice = false;
return this;
}
public Builder setItems(CharSequence[] items, final OnClickListener listener) {
public Builder setItems(CharSequence[] items,
final OnClickListener listener) {
mAdapter = new ArrayAdapter<CharSequence>(mContext,
R.layout.select_dialog_item, android.R.id.text1, items);
mOnClickListener = listener;
@@ -354,7 +377,8 @@ public class MaterialAlertDialog extends AlertDialog implements View.OnClickList
return this;
}
public Builder setAdapter(final ListAdapter adapter, final OnClickListener listener) {
public Builder setAdapter(final ListAdapter adapter,
final OnClickListener listener) {
mAdapter = adapter;
mOnClickListener = listener;
mIsSingleChoice = false;
@@ -372,16 +396,19 @@ public class MaterialAlertDialog extends AlertDialog implements View.OnClickList
return this;
}
public Builder setSingleChoiceItems(CharSequence[] items, int checkedItem, final OnClickListener listener) {
public Builder setSingleChoiceItems(CharSequence[] items,
int checkedItem, final OnClickListener listener) {
mAdapter = new ArrayAdapter<CharSequence>(mContext,
R.layout.select_dialog_singlechoice, android.R.id.text1, items);
R.layout.select_dialog_singlechoice, android.R.id.text1,
items);
mOnClickListener = listener;
mCheckedItem = checkedItem;
mIsSingleChoice = true;
return this;
}
public Builder setSingleChoiceItems(ListAdapter adapter, int checkedItem, final OnClickListener listener) {
public Builder setSingleChoiceItems(ListAdapter adapter,
int checkedItem, final OnClickListener listener) {
mAdapter = adapter;
mOnClickListener = listener;
mCheckedItem = checkedItem;
@@ -43,8 +43,8 @@ public class EditTextPreference extends DialogPreference {
@Override
protected View onCreateDialogView() {
EditText et = new EditText(getContext());
et.setId(R.id.edittextpreference_edittext);
et.setTextColor(getContext().getResources().getColor(R.color.secondary_text_dark));
et.setTextColor(getContext().getResources().getColor(
R.color.secondary_text_dark));
return et;
}
@@ -64,8 +64,10 @@ public class EditTextPreference extends DialogPreference {
}
@Override
protected void onSetInitialValue(boolean restorePersistedValue, Object defaultValue) {
setSummary(restorePersistedValue ? getPersistedString((String) defaultValue) : (String) defaultValue);
protected void onSetInitialValue(boolean restorePersistedValue,
Object defaultValue) {
setSummary(restorePersistedValue ? getPersistedString((String) defaultValue)
: (String) defaultValue);
if (!restorePersistedValue)
persistString((String) defaultValue);
}
@@ -74,10 +76,8 @@ public class EditTextPreference extends DialogPreference {
public boolean onClick(MaterialAlertDialog dialog, int which) {
super.onClick(dialog, which);
if (which == MaterialAlertDialog.POSITIVE) {
EditText et = (EditText) dialog.findViewById(R.id.edittextpreference_edittext);
if (et == null)
return true;
String value = et.getText().toString();
String value = ((EditText) dialog.findViewById(R.id.custom))
.getText().toString();
if (callChangeListener(value)) {
persistString(value);
setSummary(value);
File diff suppressed because it is too large. Load diff
+31 -10
View File
@@ -20,6 +20,7 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import android.view.ViewParent;
@@ -45,7 +46,8 @@ public final class ViewUtils {
*/
public static void getLocationInWindow(View view, int[] location) {
if (location == null || location.length < 2) {
throw new IllegalArgumentException("location must be an array of two integers");
throw new IllegalArgumentException(
"location must be an array of two integers");
}
float[] position = new float[2];
@@ -55,7 +57,7 @@ public final class ViewUtils {
ViewParent viewParent = view.getParent();
while (viewParent instanceof View) {
view = (View)viewParent;
view = (View) viewParent;
if (view.getId() == android.R.id.content) {
break;
}
@@ -67,7 +69,7 @@ public final class ViewUtils {
position[1] += view.getTop();
viewParent = view.getParent();
}
}
location[0] = (int) (position[0] + 0.5f);
location[1] = (int) (position[1] + 0.5f);
@@ -86,11 +88,13 @@ public final class ViewUtils {
/**
* Returns a bitmap showing a screenshot of the view passed in.
*
* @param v
* @return
*/
public static Bitmap getBitmapFromView(View v) {
Bitmap bitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888);
Bitmap bitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(),
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
// TODO I need to know why I need it, when ScrollView
canvas.translate(-v.getScrollX(), -v.getScrollY());
@@ -100,32 +104,49 @@ public final class ViewUtils {
public static boolean isClickAction(MotionEvent event) {
// TODO bad idea to check click
return event.getAction() == MotionEvent.ACTION_UP &&
System.nanoTime() / 1000000 - event.getDownTime() < 200;
return event.getAction() == MotionEvent.ACTION_UP
&& System.nanoTime() / 1000000 - event.getDownTime() < 200;
}
public static void removeFromParent(View view) {
ViewParent vp = view.getParent();
if (vp instanceof ViewGroup)
((ViewGroup)vp).removeView(view);
((ViewGroup) vp).removeView(view);
}
/**
* Method that removes the support for HardwareAcceleration from a {@link View}.<br/>
* Method that removes the support for HardwareAcceleration from a
* {@link View}.<br/>
* <br/>
* Check AOSP notice:<br/>
*
* <pre>
* 'ComposeShader can only contain shaders of different types (a BitmapShader and a
* LinearGradient for instance, but not two instances of BitmapShader)'. But, 'If your
* application is affected by any of these missing features or limitations, you can turn
* off hardware acceleration for just the affected portion of your application by calling
* setLayerType(View.LAYER_TYPE_SOFTWARE, null).'</pre>
* setLayerType(View.LAYER_TYPE_SOFTWARE, null).'
* </pre>
*
* @param v The view
* @param v
* The view
*/
public static void removeHardwareAccelerationSupport(View v) {
if (v.getLayerType() != View.LAYER_TYPE_SOFTWARE) {
v.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
}
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);
}
}