Skip to content

Commit

Permalink
Update version to 2.2.0, Fixed logout logic, Update app icon, Add cra…
Browse files Browse the repository at this point in the history
…shlystic
  • Loading branch information
hearsilent committed Apr 27, 2016
1 parent 233cc37 commit 115818c
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 16 deletions.
21 changes: 19 additions & 2 deletions Android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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'
3 changes: 3 additions & 0 deletions Android/app/fabric.properties
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions Android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
android:exported="false"/>
<service android:name="com.google.android.gms.analytics.CampaignTrackingService"/>

<meta-data
android:name="io.fabric.ApiKey"
android:value="e15d6071bb62dddcb64d4b3ac3bbc9a870c2b90b"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)) {
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand All @@ -167,15 +180,20 @@ 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);
} else {
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);
}
}

Expand All @@ -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));
Expand Down
Binary file modified Android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 7 additions & 6 deletions Windows/KUAS WiFi/LoginFrm.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 115818c

Please sign in to comment.