卧槽
This commit is contained in:
1 parent
f340279e57
commit
ab949d5567
8 files changed
+179
-89
No files matched your search
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user