author | kejun.gao <kejun.gao@amlogic.com> | 2011-10-19 08:29:27 (GMT) |
---|---|---|
committer | kejun.gao <kejun.gao@amlogic.com> | 2011-10-19 08:29:27 (GMT) |
commit | 61c436f2e732550495e2f299efc16a95b63e43f2 (patch) | |
tree | 8730a0537fe95ffa0ce7409957f887bfc06d22b4 | |
download | PPPoE-61c436f2e732550495e2f299efc16a95b63e43f2.zip PPPoE-61c436f2e732550495e2f299efc16a95b63e43f2.tar.gz PPPoE-61c436f2e732550495e2f299efc16a95b63e43f2.tar.bz2 |
Add PPPoE APK
-rwxr-xr-x | Android.mk | 14 | ||||
-rwxr-xr-x | AndroidManifest.xml | 63 | ||||
-rwxr-xr-x | res/drawable-hdpi/icon.png | 17 | ||||
-rwxr-xr-x | res/drawable-ldpi/icon.png | 11 | ||||
-rwxr-xr-x | res/drawable-mdpi/icon.png | 12 | ||||
-rwxr-xr-x | res/layout/main.xml | 11 | ||||
-rwxr-xr-x | res/layout/pppoe_configure.xml | 50 | ||||
-rwxr-xr-x | res/values-zh-rCN/strings.xml | 20 | ||||
-rwxr-xr-x | res/values-zh-rTW/strings.xml | 20 | ||||
-rwxr-xr-x | res/values/strings.xml | 20 | ||||
-rwxr-xr-x | src/com/amlogic/PPPoE/PPPoEActivity.java | 19 | ||||
-rwxr-xr-x | src/com/amlogic/PPPoE/PppoeConfigDialog.java | 330 |
12 files changed, 587 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk new file mode 100755 index 0000000..fb0af7e --- a/dev/null +++ b/Android.mk @@ -0,0 +1,14 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional +LOCAL_JAVA_LIBRARIES := amlogic.pppoe + +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_PACKAGE_NAME := PPPoE + +include $(BUILD_PACKAGE) + +# Use the folloing include to make our test apk. +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/AndroidManifest.xml b/AndroidManifest.xml new file mode 100755 index 0000000..4786f1a --- a/dev/null +++ b/AndroidManifest.xml @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.amlogic.PPPoE" + android:versionCode="1" + android:versionName="1.0"> + <uses-sdk android:minSdkVersion="8" /> + + <uses-permission android:name="com.google.android.gm.permission.WRITE_GMAIL" /> + <uses-permission android:name="com.google.android.gm.permission.READ_GMAIL" /> + <uses-permission android:name="android.permission.WRITE_SETTINGS" /> + <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> + <uses-permission android:name="android.permission.DEVICE_POWER" /> + <uses-permission android:name="android.permission.CHANGE_CONFIGURATION" /> + <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> + <uses-permission android:name="android.permission.VIBRATE" /> + <uses-permission android:name="android.permission.BLUETOOTH" /> + <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> + <uses-permission android:name="android.permission.NFC" /> + <uses-permission android:name="android.permission.HARDWARE_TEST" /> + <uses-permission android:name="android.permission.CALL_PHONE" /> + <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> + <uses-permission android:name="android.permission.MASTER_CLEAR" /> + <uses-permission android:name="android.permission.USE_CREDENTIALS" /> + <uses-permission android:name="com.google.android.googleapps.permission.GOOGLE_AUTH" /> + <uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER" /> + <uses-permission android:name="android.permission.READ_CONTACTS" /> + <uses-permission android:name="android.permission.WRITE_CONTACTS" /> + <uses-permission android:name="android.permission.ACCESS_WIMAX_STATE" /> + <uses-permission android:name="android.permission.CHANGE_WIMAX_STATE" /> + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> + <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> + <uses-permission android:name="android.permission.INTERNET" /> + <uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" /> + <uses-permission android:name="android.permission.READ_PHONE_STATE" /> + <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" /> + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> + <uses-permission android:name="android.permission.WRITE_APN_SETTINGS"/> + <uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES"/> + <uses-permission android:name="android.permission.READ_USER_DICTIONARY"/> + <uses-permission android:name="android.permission.WRITE_USER_DICTIONARY"/> + <uses-permission android:name="android.permission.FORCE_STOP_PACKAGES"/> + <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"/> + <uses-permission android:name="android.permission.BATTERY_STATS"/> + <uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" /> + <uses-permission android:name="com.android.launcher.permission.WRITE_SETTINGS" /> + <uses-permission android:name="android.permission.MOVE_PACKAGE" /> + <uses-permission android:name="android.permission.MANAGE_USB" /> + + <application android:icon="@drawable/icon" android:label="@string/app_name"> + <uses-library + android:name="AmlogicPPPoE"> + </uses-library> + + <activity android:name=".PPPoEActivity" + android:label="@string/app_name"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + + </application> +</manifest>
\ No newline at end of file diff --git a/res/drawable-hdpi/icon.png b/res/drawable-hdpi/icon.png new file mode 100755 index 0000000..8074c4c --- a/dev/null +++ b/res/drawable-hdpi/icon.png @@ -0,0 +1,17 @@ +PNG
+ + + +B4 +wOPOPB * +W$mx/JWuCX)cic:u1FKIUΖu\{;:$dә@9n'j\(90Xk݉V,:TJa* (Q|DRFCV +JXgl9ge.cEde_bב)H< HEK?Oɕjww)1P7c9n:3ւ5 +$pϑY GİVsxl/JÂr!J,ܛ<.LWދHEe+JK2ěTieB7%Qv1 +\s-$Xb^W}5
,.>ow=AZ?AXZA`uhmjZkU>
muX}Zku5cJ2Q~طLM˪m`FTFѺUT0o?e'@'MǗ?ǡ6#
0#
:P©}Fj!RX̸c0V}fBkь4ڵ16~5G3a(*z:[4fl-<.:h:sMDSKJx7mEkhQ.Rx<yn&DŽČm"đ T<i-㠔СCe٬uh28#C
kmºH\.X̱t'{q* +v"CRZfU5YC-W&peS$EJ{b5Lpۈ9i(SX}\T*HLӪonyXk=.FJ)G,#\-:S`yGXi .ˌ㺓)Ąē8"+c^d{.Xw2ʶJ%_dE(- !PJov +HB2œ)fжwXtUA +bx!}H몢: 9gK]IOz#Gر}'zqrqv4 P@raYu+C7n]¡/"`Ԥ{TtEsXu-^T8R86F{@aGir>6S
c5J Tduk-2S'x2UPs8ҿڳk-
Io1%+un"$8U8#üc+ ftcB<'# }K|w{c/`ǧ}mW&p23es8Agő *s=2p?`) +2wkGx{0ü1!)lbǑ_qWX~
}c/_d҇/S~!qF)]fmgY~
T?\տw];91 +յӆE`"1:D.MF'/$$ +A`'0 +Un2m7k Uͼ8GhSeܠrfD],`XSCMX +8R+Dq1]0Iw!uL%, diff --git a/res/drawable-ldpi/icon.png b/res/drawable-ldpi/icon.png new file mode 100755 index 0000000..1095584 --- a/dev/null +++ b/res/drawable-ldpi/icon.png @@ -0,0 +1,11 @@ +PNG
+ + +|*D +'U3uz!d2#X +A0i34ZVÒ[>kꟅ1e8XҦ<Ngt.kjF[w4>.շ<PQ%-8}y?L݈Wy*P[zTLq"DzE!C y`q] N"U\j~4b=8eϢwy Y8Ҿue+UQU^zY-4ʤSyS HV6,^gљ-@e:dAT3/LfY# lgːf3ql\;/H̖ +XLkĎוgwهHzǺAWym&X?'!H Yj(+C6;ZS0,|2kC;TUJ)~Zt$~}8MoWǣDCFVώ'u$@Y_־/`:Yb4l*,_u6-F_RVUyJj% V[5OYcm{\A~˕!c?4,Z +'*b_Edǃe~K4n|g!(mj]!4D1B$0MVJ#Ƃa=1;X6Eޯ1'rDI +2+nkj]G][4#H G2ۇ;1{wh +%#NP@ @%ŧ'Ph=p%lU( +sTa?/{)ze.~:.h~ɋh:tA>EɼtV}uKC02 W٧R(ujŜH3>ld4vF9lq*^nGTqYo=<\ѶȂwפ 9ǏޑsPx\j,vkx +/aEs+6XJO29VoJ5X`\ȤC6'Rʠ\x/MEsS>9z-I@/f>5B7JyP[}g&JhϿLU^S}h 96/dH:CX\FdD diff --git a/res/drawable-mdpi/icon.png b/res/drawable-mdpi/icon.png new file mode 100755 index 0000000..a07c69f --- a/dev/null +++ b/res/drawable-mdpi/icon.png @@ -0,0 +1,12 @@ +PNG
+ + +jIIʒ1%/ +[~Hb +#Dh*R$>
& +Aϕ=Hi+v^$1$1džwGPUH&$,7~ɩ5d|OEBr!5-[tQF +DR Vp@/`(ndYuzg(-Hݔr&MP
MKdBSaEld,꾱yq.ꁇGD[v"$1YFx9z/x<DTx^CӘH^v}BP9߉F_?jpߠ~ͪE߰h<+xg+^2X?Dcfie/gVtWѸN9]Hnb4n)4167jB^$ b!VDv./P6A_>E";>lں*L!\3=>wzԆn41r['\c2,Ar{49 ]ݸ
Mx4P1^l^ssO#G%=21嶂qlkHd@,$M@rLLeE-+Z]1Xݸ'H(**7?Zz2gNX,X8Z@V(Ts8+CNQ8;w\勸PVӚb震pNykIDa +|89\D.i;$wm@1W5%@5?j~՞:3'BK-7 F8c~GeoYrڀh.
ɯd6<gܐ=߷}*כ9ffU,u"
W+JD, (&~F^n
߁M~>?|;U"r0þЏ]v@}ߕJn05aq^G..cRQ +HJ_ +p#1di=9ex>_Q{1U +{DUFJY@E@3)hZ*9n diff --git a/res/layout/main.xml b/res/layout/main.xml new file mode 100755 index 0000000..7e4a852 --- a/dev/null +++ b/res/layout/main.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + > +<TextView + android:layout_width="fill_parent" + android:layout_height="wrap_content" + /> +</LinearLayout> diff --git a/res/layout/pppoe_configure.xml b/res/layout/pppoe_configure.xml new file mode 100755 index 0000000..0e4e6b0 --- a/dev/null +++ b/res/layout/pppoe_configure.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="utf-8"?> +<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="wrap_content"> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:padding="8dip" + android:orientation="vertical"> + + <LinearLayout android:id="@+id/pppoe_config" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:padding="0dip" + android:orientation="vertical"> + <TextView android:id="@+id/user_pppoe_text" + style="?android:attr/textAppearanceSmallInverse" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_marginTop="8dip" + android:text="@string/pppoe_user_name" /> + <EditText android:id="@+id/pppoe_name_edit" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_marginTop="2dip" + android:singleLine="true" /> + <TextView android:id="@+id/passwd_pppoe_text" + style="?android:attr/textAppearanceSmallInverse" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_marginTop="8dip" + android:text="@string/pppoe_passwd" /> + <EditText android:id="@+id/pppoe_passwd_edit" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_marginTop="2dip" + android:password="true"/> + <CheckBox + android:id="@+id/auto_dial" + style="?android:attr/textAppearanceSmallInverse" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/pppoe_auto_dial" /> + + </LinearLayout> + + </LinearLayout> + +</ScrollView> diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml new file mode 100755 index 0000000..4069e80 --- a/dev/null +++ b/res/values-zh-rCN/strings.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<resources> + <string name="app_name">宽带拨号</string> + + <string name="menu_cancel">取消</string> + <string name="pppoe_conf_perf_title">宽带拨号配置</string> + <string name="pppoe_config_title">宽带拨号配置</string> + <string name="pppoe_user_name">用户帐号</string> + <string name="pppoe_passwd">密码</string> + <string name="pppoe_dial">拨号</string> + <string name="pppoe_disconnect">断开</string> + <string name="pppoe_waiting_msg">正在拨号,请稍等...</string> + <string name="pppoe_conf_summary">宽带拨号配置</string> + <string name="pppoe_connect_ok">宽带拨号成功</string> + <string name="pppoe_connect_failed">宽带拨号失败</string> + <string name="pppoe_disconnect_ok">宽带拨号断开成功</string> + <string name="pppoe_disconnect_failed">宽带拨号断开失败</string> + <string name="amlogic_ok">确定</string> + <string name="pppoe_auto_dial">自动拨号</string> +</resources> diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml new file mode 100755 index 0000000..1bb493f --- a/dev/null +++ b/res/values-zh-rTW/strings.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<resources> + <string name="app_name">寬帶撥號</string> + + <string name="menu_cancel">取消</string> + <string name="pppoe_conf_perf_title">寬帶撥號配置</string> + <string name="pppoe_config_title">寬帶撥號配置</string> + <string name="pppoe_user_name">用戶帳號 </string> + <string name="pppoe_passwd">密碼</string> + <string name="pppoe_dial">撥號</string> + <string name="pppoe_disconnect">斷開</string> + <string name="pppoe_waiting_msg">正在撥號,請稍等...</string> + <string name="pppoe_conf_summary">寬帶撥號配置</string> + <string name="pppoe_connect_ok">寬帶撥號成功</string> + <string name="pppoe_connect_failed">寬帶撥號失败</string> + <string name="pppoe_disconnect_ok">寬帶撥號断开成功</string> + <string name="pppoe_disconnect_failed">寬帶撥號断开失败</string> + <string name="amlogic_ok">確定</string> + <string name="pppoe_auto_dial">自动撥號</string> +</resources> diff --git a/res/values/strings.xml b/res/values/strings.xml new file mode 100755 index 0000000..1393114 --- a/dev/null +++ b/res/values/strings.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="app_name">PPPoE</string> + + <string name="menu_cancel">Discard</string> + <string name="pppoe_conf_perf_title">Pppoe Configure</string> + <string name="pppoe_config_title">Configure Pppoe</string> + <string name="pppoe_user_name">User name</string> + <string name="pppoe_passwd">Password</string> + <string name="pppoe_dial">Dial</string> + <string name="pppoe_disconnect">Disconnect</string> + <string name="pppoe_waiting_msg">Please wait for dial...</string> + <string name="pppoe_conf_summary">Configure dial</string> + <string name="pppoe_connect_ok">Connect Ok!</string> + <string name="pppoe_connect_failed">Connect failed!</string> + <string name="pppoe_disconnect_ok">Disconnect OK!</string> + <string name="pppoe_disconnect_failed">Disconnect failed!</string> + <string name="amlogic_ok">OK</string> + <string name="pppoe_auto_dial">automatic dial</string> +</resources> diff --git a/src/com/amlogic/PPPoE/PPPoEActivity.java b/src/com/amlogic/PPPoE/PPPoEActivity.java new file mode 100755 index 0000000..28a0827 --- a/dev/null +++ b/src/com/amlogic/PPPoE/PPPoEActivity.java @@ -0,0 +1,19 @@ +package com.amlogic.PPPoE; + +import com.amlogic.PPPoE.R; + +import android.app.Activity; +import android.os.Bundle; + +public class PPPoEActivity extends Activity { + private PppoeConfigDialog mPppoeConfigDialog; + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.main); + + mPppoeConfigDialog = new PppoeConfigDialog(this); + mPppoeConfigDialog.show(); + } +}
\ No newline at end of file diff --git a/src/com/amlogic/PPPoE/PppoeConfigDialog.java b/src/com/amlogic/PPPoE/PppoeConfigDialog.java new file mode 100755 index 0000000..cbaaf97 --- a/dev/null +++ b/src/com/amlogic/PPPoE/PppoeConfigDialog.java @@ -0,0 +1,330 @@ +package com.amlogic.PPPoE;
+
+import java.util.Timer;
+import java.util.TimerTask;
+import com.amlogic.PPPoE.R;
+import android.app.AlertDialog;
+import android.app.ProgressDialog;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.SharedPreferences;
+import android.view.KeyEvent;
+import android.view.View;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import com.amlogic.pppoe.PppoeOperation;
+
+public class PppoeConfigDialog extends AlertDialog implements DialogInterface.OnClickListener
+{
+ private View mView;
+ private EditText mPppoeName;
+ private EditText mPppoePasswd;
+ private String user_name = null;
+ private String user_passwd = null;
+ private ProgressDialog waitDialog = null;
+ private PppoeOperation operation = null;
+ Context context = null;
+ private AlertDialog alertDia = null;
+ private dialRslReceiver dialRsl = null;
+
+ private boolean dia_action_failed = false;
+ private CheckBox mCbAutoDial;
+
+ public PppoeConfigDialog(Context context)
+ {
+ super(context);
+ this.context = context;
+ operation = new PppoeOperation();
+ buildDialog(context);
+ waitDialog = new ProgressDialog(this.context);
+ }
+
+ private void buildDialog(Context context)
+ {
+ setTitle(R.string.pppoe_config_title);
+ this.setView(mView = getLayoutInflater().inflate(R.layout.pppoe_configure, null));
+ mPppoeName = (EditText)mView.findViewById(R.id.pppoe_name_edit);
+ mPppoePasswd = (EditText)mView.findViewById(R.id.pppoe_passwd_edit);
+ mCbAutoDial = (CheckBox)mView.findViewById(R.id.auto_dial);
+ mPppoeName.setEnabled(true);
+ mPppoePasswd.setEnabled(true);
+ mCbAutoDial.setVisibility(View.GONE);
+ this.setInverseBackgroundForced(true);
+ if(connectStatus() != PppoeOperation.PPP_STATUS_CONNECTED)
+ this.setButton(BUTTON_POSITIVE, context.getText(R.string.pppoe_dial), this);
+ else{
+ mView.findViewById(R.id.user_pppoe_text).setVisibility(View.GONE);
+ mPppoeName.setVisibility(View.GONE);
+ mView.findViewById(R.id.passwd_pppoe_text).setVisibility(View.GONE);
+ mPppoePasswd.setVisibility(View.GONE);
+ this.setButton(BUTTON_POSITIVE, context.getText(R.string.pppoe_disconnect), this);
+ }
+ this.setButton(BUTTON_NEGATIVE, context.getText(R.string.menu_cancel), this);
+ mCbAutoDial.setChecked(isAutoDial());
+ }
+
+ @Override
+ public void show()
+ {
+ getInfoData();
+ if(user_name != null
+ && user_passwd != null
+ && user_name.equals("")== false)
+ {
+ mPppoeName.setText(user_name);
+ mPppoePasswd.setText(user_passwd);
+ }
+ else
+ {
+ mPppoeName.setText("");
+ mPppoePasswd.setText("");
+ }
+ super.show();
+ }
+
+ void showWaitDialog()
+ {
+ waitDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
+ waitDialog.setTitle("");
+ waitDialog.setMessage(this.context.getResources().getString(R.string.pppoe_waiting_msg));
+ waitDialog.setIcon(null);
+ waitDialog.setButton(android.content.DialogInterface.BUTTON_POSITIVE,this.context.getResources().getString(R.string.menu_cancel),clickListener);
+ waitDialog.setIndeterminate(false);
+ waitDialog.setCancelable(true);
+ waitDialog.show();
+
+ Button button = waitDialog.getButton(android.content.DialogInterface.BUTTON_POSITIVE);
+ button.setFocusable(true);
+ button.setFocusableInTouchMode(true);
+ button.requestFocus();
+ button.requestFocusFromTouch();
+
+ }
+
+ private void saveInfoData()
+ {
+ SharedPreferences.Editor sharedata = this.context.getSharedPreferences("inputdata", 0).edit();
+ sharedata.clear();
+ sharedata.putString("name",mPppoeName.getText().toString());
+ sharedata.putString("passwd",mPppoePasswd.getText().toString());
+ sharedata.commit();
+ }
+ private void getInfoData()
+ {
+ SharedPreferences sharedata = this.context.getSharedPreferences("inputdata", 0);
+ if(sharedata != null && sharedata.getAll().size() > 0)
+ {
+ user_name = sharedata.getString("name", null);
+ user_passwd = sharedata.getString("passwd", null);
+ }
+ else
+ {
+ user_name = null;
+ user_passwd = null;
+ }
+ }
+
+ private int connectStatus()
+ {
+ return operation.status();
+ }
+
+ private boolean isAutoDial() {
+ return false;//operation.isAutoDial();
+ }
+
+ private void setAutoDial() {
+ boolean ad = mCbAutoDial.isChecked();
+// operation.setAutoDial(ad);
+ }
+
+ private void showAlertDialog(final String msg)
+ {
+ AlertDialog.Builder ab = new AlertDialog.Builder(context);
+ alertDia = ab.create();
+ alertDia.setTitle(" ");
+ alertDia.setMessage(msg);
+ alertDia.setIcon(null);
+
+ alertDia.setButton(android.content.DialogInterface.BUTTON_POSITIVE,this.context.getResources().getString(R.string.amlogic_ok),AlertClickListener);
+
+ alertDia.setCancelable(true);
+ alertDia.setInverseBackgroundForced(true);
+ alertDia.show();
+
+ Button button = alertDia.getButton(android.content.DialogInterface.BUTTON_POSITIVE);
+ button.setFocusable(true);
+ button.setFocusableInTouchMode(true);
+ button.requestFocus();
+ button.requestFocusFromTouch();
+ }
+
+ OnClickListener AlertClickListener = new OnClickListener()
+ {
+ public void onClick(DialogInterface dialog, int which)
+ {
+ switch (which) {
+ case android.content.DialogInterface.BUTTON_POSITIVE:
+ {
+ alertDia.cancel();
+ clearSelf();
+ }
+ break;
+ case android.content.DialogInterface.BUTTON_NEGATIVE:
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ private void handleStartDial()
+ {
+ dia_action_failed = false;
+ dialRsl = new dialRslReceiver();
+ IntentFilter filter = new IntentFilter();
+ filter.addAction("PppoeConfigDialog.Result_Dial");
+ context.registerReceiver(dialRsl, filter);
+
+ String name = mPppoeName.getText().toString();
+ String passwd = mPppoePasswd.getText().toString();
+ if(name != null && passwd != null)
+ {
+ saveInfoData();
+ Timer check_timer = new Timer();
+ TimerTask check_task = new TimerTask()
+ {
+ public void run()
+ {
+ if(connectStatus() != PppoeOperation.PPP_STATUS_CONNECTED)
+ dia_action_failed = true;
+ }
+ };
+ check_timer.schedule(check_task, 30000);
+ showWaitDialog();
+ operation.connect(name, passwd);
+
+ dialThread dial = new dialThread();
+ dial.start();
+ }
+ }
+
+ class dialThread extends Thread
+ {
+ public void run()
+ {
+ while(dia_action_failed == false)
+ {
+ if(connectStatus() == PppoeOperation.PPP_STATUS_CONNECTED)
+ {
+ Intent intent2 = new Intent("PppoeConfigDialog.Result_Dial");
+ intent2.putExtra("dial_result", true);
+ context.sendBroadcast(intent2);
+ return;
+ }
+ waitOk(1000);
+ }
+
+ Intent intent2 = new Intent("PppoeConfigDialog.Result_Dial");
+ intent2.putExtra("dial_result", false);
+ context.sendBroadcast(intent2);
+ }
+ }
+
+ private void waitOk(final int ms)
+ {
+ try {Thread.sleep(ms);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ private void hanleStopDial()
+ {
+ boolean result = operation.disconnect();
+ if(result == true)
+ {
+ showAlertDialog(this.context.getResources().getString(R.string.pppoe_disconnect_ok));
+ }
+ else
+ {
+ showAlertDialog(this.context.getResources().getString(R.string.pppoe_disconnect_failed));
+ }
+
+ }
+ private void hanleCancelDial()
+ {
+ operation.disconnect();
+ }
+
+
+ OnClickListener clickListener = new OnClickListener()
+ {
+ public void onClick(DialogInterface dialog, int which)
+ {
+ hanleCancelDial();
+ waitDialog.cancel();
+ clearSelf();
+ }
+ };
+
+ //@Override
+ public void onClick(DialogInterface dialog, int which)
+ {
+ switch (which) {
+ case BUTTON_POSITIVE:
+ if(connectStatus() == PppoeOperation.PPP_STATUS_CONNECTED)
+ hanleStopDial();
+ else
+ handleStartDial();
+ break;
+ case BUTTON_NEGATIVE:
+ clearSelf();
+ break;
+ default:
+ break;
+ }
+ }
+
+ public class dialRslReceiver extends BroadcastReceiver
+ {
+ @Override
+ public void onReceive(Context context, Intent intent)
+ {
+ if(intent.getBooleanExtra("dial_result", false) == true)
+ {
+ waitDialog.cancel();
+ showAlertDialog(context.getResources().getString(R.string.pppoe_connect_ok));
+ }
+ else
+ {
+ operation.disconnect();
+ waitDialog.cancel();
+ showAlertDialog(context.getResources().getString(R.string.pppoe_connect_failed));
+ }
+ }
+ }
+
+ private void clearSelf()
+ {
+ if(dialRsl != null)
+ context.unregisterReceiver(dialRsl);
+ ((PPPoEActivity)context).finish();
+ }
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ if(keyCode == KeyEvent.KEYCODE_BACK){
+ clearSelf();
+ return true;
+ }
+ return super.onKeyDown(keyCode, event);
+ }
+
+}
|