diff --git a/Android/app/build.gradle b/Android/app/build.gradle index b4ac48a..91c4a06 100644 --- a/Android/app/build.gradle +++ b/Android/app/build.gradle @@ -1,4 +1,18 @@ +buildscript { + repositories { + maven { url 'https://maven.fabric.io/public' } + } + + dependencies { + classpath 'io.fabric.tools:gradle:1.+' + } +} apply plugin: 'com.android.application' +apply plugin: 'io.fabric' + +repositories { + maven { url 'https://maven.fabric.io/public' } +} android { compileSdkVersion 23 @@ -8,8 +22,8 @@ android { applicationId "tw.edu.kuas.wifiautologin" minSdkVersion 9 targetSdkVersion 23 - versionCode 216 - versionName "2.1.6" + versionCode 220 + versionName "2.2.0" } buildTypes { debug { @@ -44,6 +58,9 @@ dependencies { compile 'com.google.android.gms:play-services-analytics:8.4.0' compile 'com.jakewharton:butterknife:7.0.1' compile 'com.squareup.okhttp3:okhttp:3.2.0' + compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') { + transitive = true; + } } apply plugin: 'com.google.gms.google-services' \ No newline at end of file diff --git a/Android/app/fabric.properties b/Android/app/fabric.properties new file mode 100644 index 0000000..49787fb --- /dev/null +++ b/Android/app/fabric.properties @@ -0,0 +1,3 @@ +#Contains API Secret used to validate your application. Commit to internal source control; avoid making secret public. +#Wed Apr 27 18:39:38 GMT+08:00 2016 +apiSecret=39b0b8b1b8917a56de681b4797351226908471199928ed05c553f5e57e1c9056 diff --git a/Android/app/src/main/AndroidManifest.xml b/Android/app/src/main/AndroidManifest.xml index e8bfb35..94c8a24 100644 --- a/Android/app/src/main/AndroidManifest.xml +++ b/Android/app/src/main/AndroidManifest.xml @@ -72,6 +72,9 @@ android:exported="false"/> + diff --git a/Android/app/src/main/java/tw/edu/kuas/wifiautologin/base/SilentApplication.java b/Android/app/src/main/java/tw/edu/kuas/wifiautologin/base/SilentApplication.java index 233a763..c122437 100644 --- a/Android/app/src/main/java/tw/edu/kuas/wifiautologin/base/SilentApplication.java +++ b/Android/app/src/main/java/tw/edu/kuas/wifiautologin/base/SilentApplication.java @@ -2,14 +2,27 @@ import android.app.Application; +import com.crashlytics.android.Crashlytics; +import com.crashlytics.android.core.CrashlyticsCore; import com.google.android.gms.analytics.GoogleAnalytics; import com.google.android.gms.analytics.Tracker; +import io.fabric.sdk.android.Fabric; +import tw.edu.kuas.wifiautologin.BuildConfig; import tw.edu.kuas.wifiautologin.R; public class SilentApplication extends Application { private Tracker mTracker; + @Override + public void onCreate() { + super.onCreate(); + + // Init Fabric + Fabric.with(this, new Crashlytics.Builder() + .core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()).build()); + } + /** * Gets the default {@link Tracker} for this {@link Application}. * diff --git a/Android/app/src/main/java/tw/edu/kuas/wifiautologin/libs/LoginHelper.java b/Android/app/src/main/java/tw/edu/kuas/wifiautologin/libs/LoginHelper.java index e432438..27ec1f3 100644 --- a/Android/app/src/main/java/tw/edu/kuas/wifiautologin/libs/LoginHelper.java +++ b/Android/app/src/main/java/tw/edu/kuas/wifiautologin/libs/LoginHelper.java @@ -5,6 +5,9 @@ import android.support.annotation.NonNull; import android.text.TextUtils; +import com.google.android.gms.analytics.HitBuilders; +import com.google.android.gms.analytics.Tracker; + import java.io.IOException; import java.util.Locale; import java.util.concurrent.TimeUnit; @@ -18,20 +21,28 @@ import okhttp3.Response; import tw.edu.kuas.wifiautologin.MainActivity; import tw.edu.kuas.wifiautologin.R; +import tw.edu.kuas.wifiautologin.base.SilentApplication; import tw.edu.kuas.wifiautologin.callbacks.GeneralCallback; import tw.edu.kuas.wifiautologin.models.UserModel; public class LoginHelper { - private static OkHttpClient client = + private static OkHttpClient mClient = new OkHttpClient().newBuilder().followRedirects(false).followSslRedirects(false) .connectTimeout(7, TimeUnit.SECONDS).writeTimeout(7, TimeUnit.SECONDS) .readTimeout(7, TimeUnit.SECONDS).build(); + private static Tracker mTracker; + private static final String LOGIN_URL = "http://%s/cgi-bin/ace_web_auth.cgi"; private static final String LOGOUT_URL = "http://%s/cgi-bin/ace_web_auth.cgi?logout"; private static final String TEST_LOGOUT_URL = "http://%s"; + private static void initGA(Context context) { + mTracker = ((SilentApplication) context.getApplicationContext()).getDefaultTracker(); + mTracker.setScreenName("Login Helper"); + } + public static void login(final Context context, final UserModel model, final GeneralCallback callback) { if (!checkSSID(context, callback)) { @@ -44,7 +55,7 @@ public static void login(final Context context, final UserModel model, Request request = new Request.Builder().url("http://www.example.com").head().build(); - client.newCall(request).enqueue(new Callback() { + mClient.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { loginFail(context, context.getString(R.string.login_timeout), callback); @@ -99,7 +110,7 @@ private static void login(final Context context, final String location, Request request = new Request.Builder().url(url).post(requestBody) .addHeader("Accept-Encoding", "gzip, deflate").build(); - client.newCall(request).enqueue(new Callback() { + mClient.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { loginFail(context, context.getString(R.string.login_timeout), callback); @@ -141,12 +152,14 @@ public static void logout(final Context context, final boolean recheck, return; } + initGA(context); + String url = String.format(Locale.getDefault(), TEST_LOGOUT_URL, - recheck ? Constant.JIANGONG_WIFI_SERVER : Constant.YANCHAO_WIFI_SERVER); + !recheck ? Constant.JIANGONG_WIFI_SERVER : Constant.YANCHAO_WIFI_SERVER); Request request = new Request.Builder().url(url).head().build(); - client.newCall(request).enqueue(new Callback() { + mClient.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { callback.onFail(context.getString(R.string.failed_to_logout)); @@ -167,7 +180,8 @@ public void onResponse(Call call, Response response) { private static void checkLogoutLocation(Context context, String location, boolean recheck, @NonNull GeneralCallback callback) { if (location.contains("login_online")) { - logout(context, Constant.JIANGONG_WIFI_SERVER, callback); + Uri uri = Uri.parse(location); + logout(context, uri.getAuthority(), callback); } else if (location.contains("login.php") || location.contains("auth_entry.php")) { if (recheck) { logout(context, false, callback); @@ -175,7 +189,11 @@ private static void checkLogoutLocation(Context context, String location, boolea callback.onAlready(); } } else { - logout(context, Constant.YANCHAO_WIFI_SERVER, callback); + mTracker.send( + new HitBuilders.EventBuilder().setCategory("logout").setAction("unknown url") + .setLabel(location).build()); + logout(context, !recheck ? Constant.JIANGONG_WIFI_SERVER : Constant.YANCHAO_WIFI_SERVER, + callback); } } @@ -186,7 +204,7 @@ private static void logout(final Context context, String location, final Request request = new Request.Builder().url(url).get().build(); - client.newCall(request).enqueue(new Callback() { + mClient.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { callback.onFail(context.getString(R.string.failed_to_logout)); diff --git a/Android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/Android/app/src/main/res/mipmap-hdpi/ic_launcher.png index 7e00798..4bde0b1 100644 Binary files a/Android/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/Android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/Android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/Android/app/src/main/res/mipmap-mdpi/ic_launcher.png index cff8086..6af3ef5 100644 Binary files a/Android/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/Android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/Android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/Android/app/src/main/res/mipmap-xhdpi/ic_launcher.png index bcd9711..a799a0c 100644 Binary files a/Android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/Android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/Android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/Android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index b35dc81..3a8cf01 100644 Binary files a/Android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/Android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/Android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/Android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index 08419eb..2c2c0f3 100644 Binary files a/Android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/Android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/Windows/KUAS WiFi/LoginFrm.vb b/Windows/KUAS WiFi/LoginFrm.vb index a40e706..3497cf6 100644 --- a/Windows/KUAS WiFi/LoginFrm.vb +++ b/Windows/KUAS WiFi/LoginFrm.vb @@ -27,7 +27,7 @@ Public Class LoginFrm Private Sub LoginButton_Click(sender As Object, e As EventArgs) Handles LoginButton.Click Try - If (backgroundThread.IsAlive) Then + If (backgroundThread IsNot Nothing AndAlso backgroundThread.IsAlive) Then backgroundThread.Abort() End If Catch ex As Exception @@ -60,7 +60,7 @@ Public Class LoginFrm Private Sub LogoutButton_Click(sender As Object, e As EventArgs) Handles LogoutButton.Click Try - If (backgroundThread.IsAlive) Then + If (backgroundThread IsNot Nothing AndAlso backgroundThread.IsAlive) Then backgroundThread.Abort() End If Catch ex As Exception @@ -102,8 +102,9 @@ Public Class LoginFrm End Sub Private Sub checkLogoutLocation(_location As String, recheck As Boolean) - If (_location.Contains("login_online")) Then - logout(JIANGONG_WIFI_SERVER) + If (_location.Contains("login_online")) Then + Dim uri As New System.Uri(_location) + logout(uri.Host) ElseIf (_location.Contains("login.php") Or _location.Contains("auth_entry.php")) Then If (recheck) Then tryLogout(False) @@ -112,7 +113,7 @@ Public Class LoginFrm enableViews() End If Else - logout(YANCHAO_WIFI_SERVER) + logout(IIf(recheck, YANCHAO_WIFI_SERVER, JIANGONG_WIFI_SERVER)) End If End Sub @@ -177,7 +178,7 @@ Public Class LoginFrm Private Sub LoginFrm_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing SaveSetting() Try - If (backgroundThread.IsAlive) Then + If (backgroundThread IsNot Nothing AndAlso backgroundThread.IsAlive) Then backgroundThread.Abort() End If Catch ex As Exception