Skip to content

Commit

Permalink
Merge branch 'release/1.1.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
vitas committed Oct 28, 2017
2 parents fc3d736 + 2dcec87 commit 145bcf2
Show file tree
Hide file tree
Showing 20 changed files with 205 additions and 128 deletions.
11 changes: 6 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
compileSdkVersion 27
buildToolsVersion "26.0.2"
defaultConfig {
applicationId 'com.samebits.beacon.locator'
minSdkVersion 18
targetSdkVersion 22
versionCode 116
versionName '1.1.6'
versionCode 117
versionName '1.1.7'
testApplicationId 'com.samebits.beacon.locator.test'
}
buildTypes {
Expand Down Expand Up @@ -49,7 +49,7 @@ android {
}

dependencies {
final SUPPORT_LIBRARY_VERSION = '25.3.1'
final SUPPORT_LIBRARY_VERSION = '27.0.0'
final DAGGER_VERSION = '2.11'
final ALTBEACON_VERSION = '2.12.3'

Expand All @@ -66,5 +66,6 @@ dependencies {
compile "com.google.dagger:dagger:$DAGGER_VERSION"
annotationProcessor "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
provided 'org.glassfish:javax.annotation:10.0-b28'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.jakewharton:butterknife:8.8.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.0'
}
4 changes: 4 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

-keep class **$$ViewBinder { *; }
-keep class **$ViewHolder { *; }
-keep class butterknife.**$Finder { *; }
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,8 @@ public TrackedBeacon getBeacon(String id) {
public boolean updateBeaconDistance(final String id, double distance) {
return mStoreService.updateBeaconDistance(id, distance);
}

public boolean isBeaconExists(String id) {
return mStoreService.isBeaconExists(id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,26 @@ public boolean updateBeacon(TrackedBeacon beacon) {
return (numUpdated == 0) ? false : true;
}

@Override
public boolean isBeaconExists(String id) {

SQLiteDatabase db = getReadableDatabase();
Cursor cursor = db.rawQuery("SELECT EXISTS (SELECT * FROM " + ScanColumns.TABLE_NAME
+ " WHERE " +ScanColumns.COLUMN_ID +"=? LIMIT 1)" , new String[]{id});

if (cursor != null) {
if (cursor.moveToFirst()) {
if (cursor.getInt(0) == 1) {
cursor.close();
return true;
} else {
cursor.close();
}
}
}
return false;
}

@Override
public TrackedBeacon getBeacon(String id) {
TrackedBeacon beacon = new TrackedBeacon();
Expand Down Expand Up @@ -471,6 +491,7 @@ public List<ActionBeacon> getEnabledBeaconActionsByEvent(int eventType, String b
return actions;
}


@Override
public boolean deleteBeacon(String id, boolean cascade) {
SQLiteDatabase db = getWritableDatabase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ public interface StoreService {
boolean updateBeaconActionEnable(final int id, boolean enable);

List<ActionBeacon> getEnabledBeaconActionsByEvent(final int eventType, final String beaconId);

boolean isBeaconExists(String id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@
import com.samebits.beacon.locator.ui.adapter.DetailFragmentPagerAdapter;
import com.samebits.beacon.locator.util.Constants;

import butterknife.Bind;
import butterknife.BindView;
import butterknife.ButterKnife;


public class BeaconActionActivity extends BaseActivity implements ViewPager.OnPageChangeListener {

@Bind(R.id.toolbar)
@BindView(R.id.toolbar)
Toolbar toolbar;
@Bind(R.id.viewpager)
@BindView(R.id.viewpager)
ViewPager viewPager;
@Bind(R.id.sliding_tabs)
@BindView(R.id.sliding_tabs)
TabLayout slidingTabs;

private ActionBeacon mActionBeacon;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.NavigationView;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
Expand All @@ -46,6 +46,7 @@
import com.samebits.beacon.locator.BeaconLocatorApp;
import com.samebits.beacon.locator.R;
import com.samebits.beacon.locator.model.TrackedBeacon;
import com.samebits.beacon.locator.ui.fragment.BeaconFragment;
import com.samebits.beacon.locator.ui.fragment.DetectedBeaconsFragment;
import com.samebits.beacon.locator.ui.fragment.ScanFragment;
import com.samebits.beacon.locator.ui.fragment.ScanRadarFragment;
Expand All @@ -55,29 +56,33 @@

import org.altbeacon.beacon.BeaconManager;

import butterknife.Bind;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

public class MainNavigationActivity extends BaseActivity
implements NavigationView.OnNavigationItemSelectedListener {
implements NavigationView.OnNavigationItemSelectedListener, BeaconFragment.OnTrackedBeaconSelectedListener {

public static final int PERMISSION_REQUEST_COARSE_LOCATION = 1;

@Bind(R.id.fab)
@BindView(R.id.fab)
FloatingActionButton fab;

@Bind(R.id.drawer_layout)
@BindView(R.id.drawer_layout)
DrawerLayout drawer;

@Bind(R.id.toolbar)
@BindView(R.id.toolbar)
Toolbar toolbar;

@Bind(R.id.nav_view)
@BindView(R.id.nav_view)
NavigationView navigationView;

BeaconManager mBeaconManager;
TrackedBeacon mBeacon;


TrackedBeacon mSelectedBeacon;
private Unbinder unbinder;

public static Intent getStartIntent(Context context) {
return new Intent(context, MainNavigationActivity.class);
Expand All @@ -102,7 +107,7 @@ void navAction() {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_navigation);
ButterKnife.bind(this);
unbinder = ButterKnife.bind(this);

setupToolbar();

Expand All @@ -116,7 +121,7 @@ protected void onCreate(Bundle savedInstanceState) {
readExtras();

if (null == savedInstanceState) {
if (mBeacon != null) {
if (mSelectedBeacon != null) {
launchTrackedListView();
} else {
launchScanBeaconView();
Expand All @@ -125,10 +130,16 @@ protected void onCreate(Bundle savedInstanceState) {

}

@Override
protected void onDestroy() {
unbinder.unbind();
super.onDestroy();
}

protected void readExtras() {
Intent intent = getIntent();
if (intent.getExtras() != null) {
mBeacon = intent.getExtras().getParcelable(Constants.ARG_BEACON);
mSelectedBeacon = intent.getExtras().getParcelable(Constants.ARG_BEACON);
}
}

Expand All @@ -145,7 +156,7 @@ private void setupToolbar() {
this, drawer, toolbar,
R.string.nav_drawer_open,
R.string.nav_drawer_close);
drawer.setDrawerListener(toggle);
drawer.addDrawerListener(toggle);
toggle.syncState();

}
Expand Down Expand Up @@ -274,47 +285,55 @@ public boolean onNavigationItemSelected(MenuItem item) {
}


private void addScanBeaconFragment() {
FragmentManager fragmentManager = getSupportFragmentManager();
if (fragmentManager != null) {
if (checkFragmentInstance(R.id.content_frame, DetectedBeaconsFragment.class) == null) {
fragmentManager
.beginTransaction()
.replace(R.id.content_frame, DetectedBeaconsFragment.newInstance(), Constants.TAG_FRAGMENT_SCAN_LIST)
.commit();
private void createOrResumeFragment(String fragmentTag) {
android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction ft = fragmentManager.beginTransaction();
boolean fragmentPopped = false;

Fragment fragment = fragmentManager.findFragmentByTag(fragmentTag);

if (fragmentManager.getBackStackEntryCount() > 0){
fragmentPopped = fragmentManager.popBackStackImmediate(fragmentTag, 0);
}

if(!fragmentPopped && fragment == null){
//Create an new instance if it is null and add it to stack
switch(fragmentTag) {
case Constants.TAG_FRAGMENT_SCAN_LIST:
fragment = DetectedBeaconsFragment.newInstance();
break;
case Constants.TAG_FRAGMENT_SCAN_RADAR:
fragment = ScanRadarFragment.newInstance();
break;
case Constants.TAG_FRAGMENT_TRACKED_BEACON_LIST:
fragment = TrackedBeaconsFragment.newInstance();
if (mSelectedBeacon != null) {
Bundle bundles = new Bundle();
bundles.putParcelable(Constants.ARG_BEACON, mSelectedBeacon);
fragment.setArguments(bundles);
}
break;
}
ft.addToBackStack(fragmentTag);
}
ft.replace(R.id.content_frame, fragment, fragmentTag);

ft.commit();

fragmentManager.executePendingTransactions();

}

private void addScanBeaconFragment() {
createOrResumeFragment(Constants.TAG_FRAGMENT_SCAN_LIST);
}

private void addRadarScanFragment() {
FragmentManager fragmentManager = getSupportFragmentManager();
if (fragmentManager != null) {
if (checkFragmentInstance(R.id.content_frame, ScanRadarFragment.class) == null) {
fragmentManager
.beginTransaction()
.replace(R.id.content_frame, ScanRadarFragment.newInstance(), Constants.TAG_FRAGMENT_SCAN_RADAR)
.commit();
}
}
createOrResumeFragment(Constants.TAG_FRAGMENT_SCAN_RADAR);
}

private void addTrackedListFragment() {
FragmentManager fragmentManager = getSupportFragmentManager();
if (fragmentManager != null) {
Fragment frg = checkFragmentInstance(R.id.content_frame, TrackedBeaconsFragment.class);
if (frg == null) {
TrackedBeaconsFragment tFrg = TrackedBeaconsFragment.newInstance();
if (mBeacon != null) {
Bundle bundles = new Bundle();
bundles.putParcelable(Constants.ARG_BEACON, mBeacon);
tFrg.setArguments(bundles);
}
fragmentManager
.beginTransaction()
.replace(R.id.content_frame, tFrg, Constants.TAG_FRAGMENT_TRACKED_BEACON_LIST)
.commit();
}
}
createOrResumeFragment(Constants.TAG_FRAGMENT_TRACKED_BEACON_LIST);
}

public void hideFab() {
Expand Down Expand Up @@ -365,6 +384,7 @@ public void onHidden(FloatingActionButton fab) {
});
}


private void launchScanBeaconView() {
addScanBeaconFragment();
}
Expand All @@ -377,4 +397,9 @@ private void launchTrackedListView() {
addTrackedListFragment();
}

@Override
public void onBeaconSelected(TrackedBeacon beacon) {
mSelectedBeacon = beacon;
launchTrackedListView();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import android.support.v7.widget.RecyclerView;

import com.samebits.beacon.locator.model.IManagedBeacon;
import com.samebits.beacon.locator.ui.fragment.BaseFragment;
import com.samebits.beacon.locator.ui.fragment.BeaconFragment;
import com.samebits.beacon.locator.util.BeaconUtil;

import java.util.LinkedHashMap;
Expand All @@ -35,7 +35,7 @@
public abstract class BeaconAdapter<VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> {

protected Map<String, IManagedBeacon> mBeacons = new LinkedHashMap();
protected BaseFragment mFragment;
protected BeaconFragment mFragment;
protected OnBeaconLongClickListener onBeaconLongClickListener;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.samebits.beacon.locator.R;
import com.samebits.beacon.locator.databinding.ItemDetectedBeaconBinding;
import com.samebits.beacon.locator.model.DetectedBeacon;
import com.samebits.beacon.locator.ui.fragment.BaseFragment;
import com.samebits.beacon.locator.ui.fragment.BeaconFragment;
import com.samebits.beacon.locator.viewModel.DetectedBeaconViewModel;

import org.altbeacon.beacon.Beacon;
Expand All @@ -40,7 +40,7 @@
*/
public class DetectedBeaconAdapter extends BeaconAdapter<DetectedBeaconAdapter.BindingHolder> {

public DetectedBeaconAdapter(BaseFragment fragment) {
public DetectedBeaconAdapter(BeaconFragment fragment) {
mFragment = fragment;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import com.samebits.beacon.locator.model.ActionBeacon;
import com.samebits.beacon.locator.model.IManagedBeacon;
import com.samebits.beacon.locator.model.TrackedBeacon;
import com.samebits.beacon.locator.ui.fragment.BaseFragment;
import com.samebits.beacon.locator.ui.fragment.BeaconFragment;
import com.samebits.beacon.locator.ui.fragment.TrackedBeaconsFragment;
import com.samebits.beacon.locator.ui.view.WrapLinearLayoutManager;
import com.samebits.beacon.locator.util.Constants;
Expand All @@ -48,7 +48,7 @@ public class TrackedBeaconAdapter extends BeaconAdapter<TrackedBeaconAdapter.Bin

private Map<String, ActionBeaconAdapter> mActionAdapters = new HashMap<>();

public TrackedBeaconAdapter(BaseFragment fragment) {
public TrackedBeaconAdapter(BeaconFragment fragment) {
mFragment = fragment;
}

Expand Down
Loading

0 comments on commit 145bcf2

Please sign in to comment.