Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedmozaffariGithub committed Jun 13, 2018
0 parents commit f32c829
Show file tree
Hide file tree
Showing 67 changed files with 16,274 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
31 changes: 31 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 25
buildToolsVersion '26.0.2'

defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
testCompile 'junit:junit:4.12'
}
17 changes: 17 additions & 0 deletions proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Users\android\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.neovisionaries.ws.client;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.assertEquals;

/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.neovisionaries.ws.client.test", appContext.getPackageName());
}
}
14 changes: 14 additions & 0 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.neovisionaries.ws.client">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:allowBackup="false"
android:label="@string/app_name"
android:supportsRtl="true">

</application>

</manifest>
52 changes: 52 additions & 0 deletions src/main/java/com/neovisionaries/ws/client/Address.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2016 Neo Visionaries Inc.
*
* 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.
*/
package com.neovisionaries.ws.client;


import java.net.InetSocketAddress;


class Address {
private final String mHost;
private final int mPort;
private transient String mString;


Address(String host, int port) {
mHost = host;
mPort = port;
}


InetSocketAddress toInetSocketAddress() {
return new InetSocketAddress(mHost, mPort);
}


String getHostname() {
return mHost;
}


@Override
public String toString() {
if (mString == null) {
mString = String.format("%s:%d", mHost, mPort);
}

return mString;
}
}
91 changes: 91 additions & 0 deletions src/main/java/com/neovisionaries/ws/client/Base64.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright (C) 2015 Neo Visionaries Inc.
*
* 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.
*/
package com.neovisionaries.ws.client;


class Base64 {
private static final byte[] INDEX_TABLE = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
};


public static String encode(String data) {
if (data == null) {
return null;
}

return encode(Misc.getBytesUTF8(data));
}


public static String encode(byte[] data) {
if (data == null) {
return null;
}

int capacity = (((((data.length * 8) + 5) / 6) + 3) / 4) * 4;

StringBuilder builder = new StringBuilder(capacity);

for (int bitIndex = 0; ; bitIndex += 6) {
int bits = extractBits(data, bitIndex);

if (bits < 0) {
break;
}

builder.append((char) INDEX_TABLE[bits]);
}

for (int i = builder.length(); i < capacity; ++i) {
builder.append('=');
}

return builder.toString();
}


private static int extractBits(byte[] data, int bitIndex) {
int byteIndex = bitIndex / 8;
byte nextByte;

if (data.length <= byteIndex) {
return -1;
} else if (data.length - 1 == byteIndex) {
nextByte = 0;
} else {
nextByte = data[byteIndex + 1];
}

switch ((bitIndex % 24) / 6) {
case 0:
return ((data[byteIndex] >> 2) & 0x3F);

case 1:
return (((data[byteIndex] << 4) & 0x30) | ((nextByte >> 4) & 0x0F));

case 2:
return (((data[byteIndex] << 2) & 0x3C) | ((nextByte >> 6) & 0x03));

case 3:
return (data[byteIndex] & 0x3F);

default:
// Never reach here.
return 0;
}
}
}
Loading

0 comments on commit f32c829

Please sign in to comment.