Skip to content

Commit

Permalink
Rename Lib
Browse files Browse the repository at this point in the history
  • Loading branch information
mazenrashed committed Oct 23, 2018
1 parent fb7e015 commit 119deeb
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 20 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 28
defaultConfig {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.mazenrashed.universalbluetoothprinter

import android.app.Application
import com.mazenrashed.universalbluethootprinter.BluetoothPrinter
import com.mazenrashed.universalbluethootprinter.Printooth

class ApplicationClass : Application(){

override fun onCreate() {
super.onCreate()
BluetoothPrinter.init(this)
Printooth.init(this)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import android.app.Activity
import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import com.mazenrashed.universalbluethootprinter.BluetoothPrinter
import com.mazenrashed.universalbluethootprinter.Printooth
import com.mazenrashed.universalbluethootprinter.data.DefaultPrinter
import com.mazenrashed.universalbluethootprinter.data.PairedPrinter
import com.mazenrashed.universalbluethootprinter.data.Printable
import com.mazenrashed.universalbluethootprinter.ui.ScanningActivity
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

Expand All @@ -18,17 +16,17 @@ class MainActivity : AppCompatActivity() {
setContentView(R.layout.activity_main)

print.setOnClickListener {
if (!BluetoothPrinter.hasPairedPrinter())
if (!Printooth.hasPairedPrinter())
startActivityForResult(Intent(this, ScanningActivity::class.java), ScanningActivity.SCANNING_FOR_PRINTER)
else
printSomePrintables()
}

piarUnpair.text = if (BluetoothPrinter.hasPairedPrinter()) "Unpair ${BluetoothPrinter.getPairedPrinter()?.name}" else "Pair with printer"
piarUnpair.text = if (Printooth.hasPairedPrinter()) "Unpair ${Printooth.getPairedPrinter()?.name}" else "Pair with printer"

piarUnpair.setOnClickListener {
if (BluetoothPrinter.hasPairedPrinter())
BluetoothPrinter.removeCurrentPrinter()
if (Printooth.hasPairedPrinter())
Printooth.removeCurrentPrinter()
else
startActivityForResult(Intent(this, ScanningActivity::class.java), ScanningActivity.SCANNING_FOR_PRINTER)
}
Expand Down Expand Up @@ -82,7 +80,7 @@ class MainActivity : AppCompatActivity() {
.build()
)

BluetoothPrinter.printer(this).print(printables)
Printooth.printer(this).print(printables)


}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
Expand All @@ -25,4 +25,4 @@
app:layout_constraintEnd_toEndOf="parent"
/>

</android.support.constraint.ConstraintLayout>
</RelativeLayout>
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.2.71'
ext.kotlin_version = '1.2.60'
repositories {
google()
mavenCentral()
jcenter()
}
dependencies {
Expand All @@ -18,6 +19,7 @@ buildscript {
allprojects {
repositories {
google()
mavenCentral()
jcenter()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.mazenrashed.universalbluethootprinter.data.Printer
import com.mazenrashed.universalbluethootprinter.utilities.Printing
import io.paperdb.Paper

object BluetoothPrinter {
object Printooth {

fun init(context: Context) = Paper.init(context)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import android.widget.Toast
import kotlinx.android.synthetic.main.activity_scanning.*
import com.mazenrashed.universalbluethootprinter.data.DiscoveryCallback
import com.mazenrashed.universalbluethootprinter.utilities.Bluetooth
import com.mazenrashed.universalbluethootprinter.BluetoothPrinter
import com.mazenrashed.universalbluethootprinter.Printooth
import com.mazenrashed.universalbluethootprinter.R

class ScanningActivity : AppCompatActivity() {
Expand Down Expand Up @@ -62,7 +62,7 @@ class ScanningActivity : AppCompatActivity() {
}

override fun onDevicePaired(device: BluetoothDevice) {
BluetoothPrinter.setPrinter(device.name, device.address)
Printooth.setPrinter(device.name, device.address)
Toast.makeText(this@ScanningActivity, "Device Paired", Toast.LENGTH_SHORT).show()
adapter.notifyDataSetChanged()
setResult(Activity.RESULT_OK)
Expand All @@ -71,9 +71,9 @@ class ScanningActivity : AppCompatActivity() {

override fun onDeviceUnpaired(device: BluetoothDevice) {
Toast.makeText(this@ScanningActivity, "Device unpaired", Toast.LENGTH_SHORT).show()
var pairedPrinter = BluetoothPrinter.getPairedPrinter()
var pairedPrinter = Printooth.getPairedPrinter()
if (pairedPrinter != null && pairedPrinter.address == device.address)
BluetoothPrinter.removeCurrentPrinter()
Printooth.removeCurrentPrinter()
devices.remove(device)
adapter.notifyDataSetChanged()
bluetooth.startScanning()
Expand All @@ -91,7 +91,7 @@ class ScanningActivity : AppCompatActivity() {
printers.setOnItemClickListener { _, _, i, _ ->
var device = devices[i]
if (device.bondState == BluetoothDevice.BOND_BONDED) {
BluetoothPrinter.setPrinter(device.name, device.address)
Printooth.setPrinter(device.name, device.address)
setResult(Activity.RESULT_OK)
this@ScanningActivity.finish()
}
Expand Down Expand Up @@ -139,7 +139,7 @@ class ScanningActivity : AppCompatActivity() {
BluetoothDevice.BOND_BONDING -> "Pairing.."
else -> ""
}
findViewById<ImageView>(R.id.pairedPrinter).visibility = if (BluetoothPrinter.getPairedPrinter()?.address == devices[position].address) View.VISIBLE else View.GONE
findViewById<ImageView>(R.id.pairedPrinter).visibility = if (Printooth.getPairedPrinter()?.address == devices[position].address) View.VISIBLE else View.GONE
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("NAME_SHADOWING")

package com.mazenrashed.universalbluethootprinter.utilities

import android.graphics.Bitmap
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("NAME_SHADOWING")

package com.mazenrashed.universalbluethootprinter.utilities

object StringUtils {
Expand Down

0 comments on commit 119deeb

Please sign in to comment.