Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
Code Updates
Browse files Browse the repository at this point in the history
Updated Readme.md
Removed Third Party button element
Updated gradle and code
  • Loading branch information
pishangujeniya committed Mar 7, 2019
1 parent 88724c7 commit 0a02a74
Show file tree
Hide file tree
Showing 29 changed files with 937 additions and 546 deletions.
66 changes: 66 additions & 0 deletions AndroidAppCode/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/caches
.idea/

# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
#*.jks

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild

# Google Services (e.g. APIs or Firebase)
google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
1 change: 1 addition & 0 deletions AndroidAppCode/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
127 changes: 81 additions & 46 deletions AndroidAppCode/app/app.iml

Large diffs are not rendered by default.

22 changes: 10 additions & 12 deletions AndroidAppCode/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
compileSdkVersion 28
buildToolsVersion "28.0.3"

defaultConfig {
applicationId "com.example.pishang.pishanggui"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
targetSdkVersion 28
versionCode 11
versionName "1.1"
}
buildTypes {
release {
Expand All @@ -20,11 +20,9 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.github.justzak:dilatingdotsprogressbar:1.0.1'
compile 'com.github.dmytrodanylyk.circular-progress-button:library:1.1.3'
compile 'com.android.support:design:23.0.0'

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.github.justzak:dilatingdotsprogressbar:1.0.1'
// implementation 'com.github.dmytrodanylyk.circular-progress-button:library:1.1.3'
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
package com.example.pishang.pishanggui;

import android.Manifest;
import android.app.ProgressDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.AsyncTask;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
Expand All @@ -28,27 +22,27 @@

public class BlueList extends AppCompatActivity {

private Set<BluetoothDevice> pairedDevices;
private ListView lv;
static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
BluetoothAdapter BA;
String address = null;
private ProgressDialog progress;
BluetoothSocket btSocket;
Globalshare mAppl;
Boolean isBtConnected = false;
static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
private Set<BluetoothDevice> pairedDevices;
private ListView lv;
private ProgressDialog progress;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_blue_list);

lv = (ListView)findViewById(R.id.BlueListView);
lv = (ListView) findViewById(R.id.BlueListView);

BA = BluetoothAdapter.getDefaultAdapter();
btSocket = null;
btSocket = null;

// Snackbar.make(findViewById(android.R.id.content),"HELLO THIS IS SCNAK", Snackbar.LENGTH_LONG).show();
// Snackbar.make(findViewById(android.R.id.content),"HELLO THIS IS SCNAK", Snackbar.LENGTH_LONG).show();

// if (ContextCompat.checkSelfPermission(BlueList.this,
// Manifest.permission.BLUETOOTH)
Expand Down Expand Up @@ -81,17 +75,17 @@ protected void onCreate(Bundle savedInstanceState) {
pairedDevices = BA.getBondedDevices();
ArrayList list = new ArrayList();

for(BluetoothDevice bt : pairedDevices)
list.add(bt.getName()+bt.getAddress());
Toast.makeText(getApplicationContext(),"Showing Paired Devices",Toast.LENGTH_SHORT).show();
for (BluetoothDevice bt : pairedDevices)
list.add(bt.getName() + bt.getAddress());
Toast.makeText(getApplicationContext(), "Showing Paired Devices", Toast.LENGTH_SHORT).show();

final ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1, list);
final ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, list);
lv.setAdapter(adapter);

lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
int itemindex = position;
int itemindex = position;
String itemvalue = (String) lv.getItemAtPosition(itemindex);
// BA.cancelDiscovery();
// Toast.makeText(getApplicationContext(),"Connecting to : "+itemvalue, Toast.LENGTH_SHORT).show();
Expand All @@ -105,81 +99,69 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
});



}

// public void listvisible(View v) {



// }




//Cpde emds

private class ConnectBT extends AsyncTask<Void, Void, Void> // UI thread
{
private boolean ConnectSuccess = true; //if it's here, it's almost connected

@Override
protected void onPreExecute()
{
protected void onPreExecute() {
progress = ProgressDialog.show(BlueList.this, "Connecting...", "Please wait!!!"); //show a progress dialogue
}

@Override
protected Void doInBackground(Void... devices) //while the progress dialog is shown, the connection is done in background
{
try
{
try {

if (btSocket == null || !isBtConnected)
{
if (btSocket == null || !isBtConnected) {
BA = BluetoothAdapter.getDefaultAdapter();//get the mobile bluetooth device
BluetoothDevice dispositivo = BA.getRemoteDevice(address);//connects to the device's address and checks if it's available
btSocket = dispositivo.createInsecureRfcommSocketToServiceRecord(MY_UUID);//create a RFCOMM (SPP) connection
BluetoothAdapter.getDefaultAdapter().cancelDiscovery();
btSocket.connect();//start connection
}
}
catch (IOException e)
{
} catch (IOException e) {
ConnectSuccess = false;//if the try failed, you can check the exception here
}
return null;
}

@Override
protected void onPostExecute(Void result) //after the doInBackground, it checks if everything went fine
{
super.onPostExecute(result);

Globalshare mApp = ((Globalshare) getApplicationContext());

if (!ConnectSuccess)
{
Toast.makeText(getApplicationContext(),"Connection Failed. Is it a SPP Bluetooth? Try again.",Toast.LENGTH_SHORT).show();
try{
if (!ConnectSuccess) {
Toast.makeText(getApplicationContext(), "Connection Failed. Is it a SPP Bluetooth? Try again.", Toast.LENGTH_SHORT).show();
try {
btSocket.close();
BA.disable();
}catch (Exception e)
{
} catch (Exception e) {
BA.disable();
//this.finishAffinity();
finish();
System.exit(0);
}
Intent iagain = new Intent(BlueList.this,Connect.class);
Intent iagain = new Intent(BlueList.this, Connect.class);
startActivity(iagain);

}
else
{
Toast.makeText(getApplicationContext(),"Connected",Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(), "Connected", Toast.LENGTH_SHORT).show();
isBtConnected = true;
mApp.setGlobalSocketValue(btSocket);
Intent i = new Intent(BlueList.this,StatusGet.class);
Intent i = new Intent(BlueList.this, StatusGet.class);
startActivity(i);
}
progress.dismiss();
Expand Down
Loading

0 comments on commit 0a02a74

Please sign in to comment.