Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions AndroidShowCaseApp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
1 change: 1 addition & 0 deletions AndroidShowCaseApp/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions AndroidShowCaseApp/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions AndroidShowCaseApp/.idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions AndroidShowCaseApp/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions AndroidShowCaseApp/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions AndroidShowCaseApp/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions AndroidShowCaseApp/.idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions AndroidShowCaseApp/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions AndroidShowCaseApp/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
28 changes: 28 additions & 0 deletions AndroidShowCaseApp/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.navneet"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.squareup.okhttp:okhttp:2.5.0'
}
17 changes: 17 additions & 0 deletions AndroidShowCaseApp/app/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 /home/navneet/Documents/android-sdk-linux/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,13 @@
package com.navneet;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
24 changes: 24 additions & 0 deletions AndroidShowCaseApp/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.navneet">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".ListingActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".AddNewDevices" android:label="@string/add_devices"/>
</application>

</manifest>
118 changes: 118 additions & 0 deletions AndroidShowCaseApp/app/src/main/java/com/navneet/AddNewDevices.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
package com.navneet;

import android.app.Activity;
import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Toast;

import com.network.NetworkClassHandler;
import com.network.NetworkInterface;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;

/**
* Created by root on 1/8/16.
*/
public class AddNewDevices extends Activity implements View.OnClickListener, NetworkInterface{
private ProgressBar progressBar;
private SQLiteDatabase database;
private Button submit;
private EditText name, version, codename, target, distribution;
private String err = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.add_new_layout);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
submit = (Button) findViewById(R.id.submit);
name = (EditText) findViewById(R.id.name);
version = (EditText) findViewById(R.id.version);
codename = (EditText) findViewById(R.id.codename);
target = (EditText) findViewById(R.id.target);
distribution = (EditText) findViewById(R.id.distribution);
submit.setOnClickListener(this);
}
private boolean Validation(){
if(TextUtils.isEmpty(name.getText().toString().trim())) {
err = "Enter the Name";
return false;
} else if(TextUtils.isEmpty(version.getText().toString().trim())) {
err = "Enter the Version";
return false;
} else if(TextUtils.isEmpty(codename.getText().toString().trim())) {
err = "Enter the Code name";
return false;
} else if(TextUtils.isEmpty(target.getText().toString().trim())) {
err = "Enter the Target";
return false;
} else if(TextUtils.isEmpty(distribution.getText().toString().trim())) {
err = "Enter the Distribution";
return false;
}
return true;
}
@Override
public void onClick(View v) {
if(Validation()){
progressBar.setVisibility(View.VISIBLE);
HashMap<String, Object> map = new HashMap<>();
map.put("name", name.getText().toString().trim());
map.put("version", version.getText().toString().trim());
map.put("codename", codename.getText().toString().trim());
map.put("target", target.getText().toString().trim());
map.put("distribution", distribution.getText().toString().trim());
new NetworkClassHandler().OnPostRequestWithParams(this, 5, map,"http://mobilesandboxdev.azurewebsites.net/android");
} else {
Toast.makeText(this, err,Toast.LENGTH_SHORT).show();
}
}

@Override
public void onResponse(String response, int requestCode) {
try {
JSONObject json = new JSONObject(response);
MyDatabaseHelper mMyDatabaseHelper = new MyDatabaseHelper(AddNewDevices.this);
database = mMyDatabaseHelper.getWritableDatabase();
ContentValues cv = new ContentValues();
if (json.has(MyDatabaseHelper.COLUMN_ID))
cv.put(MyDatabaseHelper.COLUMN_ID, json.getInt(MyDatabaseHelper.COLUMN_ID));
if (json.has(MyDatabaseHelper.NAME))
cv.put(MyDatabaseHelper.NAME, json.getString(MyDatabaseHelper.NAME));
else
cv.put(MyDatabaseHelper.NAME, "Information Not Available");
if (json.has(MyDatabaseHelper.VERSION))
cv.put(MyDatabaseHelper.VERSION, json.getString(MyDatabaseHelper.VERSION));
else
cv.put(MyDatabaseHelper.VERSION, "Information Not Available");
if (json.has(MyDatabaseHelper.CODE_NAME))
cv.put(MyDatabaseHelper.CODE_NAME, json.getString(MyDatabaseHelper.CODE_NAME));
else
cv.put(MyDatabaseHelper.CODE_NAME, "Information Not Available");
if (json.has(MyDatabaseHelper.TARGET))
cv.put(MyDatabaseHelper.TARGET, json.getString(MyDatabaseHelper.TARGET));
else
cv.put(MyDatabaseHelper.TARGET, "Information Not Available");
if (json.has(MyDatabaseHelper.DISTRIBUTION))
cv.put(MyDatabaseHelper.DISTRIBUTION, json.getString(MyDatabaseHelper.DISTRIBUTION));
else
cv.put(MyDatabaseHelper.DISTRIBUTION, "Information Not Available");
database.insert(MyDatabaseHelper.TABLE_DEVICES, null, cv);
progressBar.setVisibility(View.GONE);
Toast.makeText(this, "Device info added successfully!",Toast.LENGTH_SHORT).show();
setResult(RESULT_OK);
finish();
} catch (JSONException e) {
e.printStackTrace();
}
}
}
Loading