From e5f6aee60c56a2a59f211e2496199c2b14e0bc0e Mon Sep 17 00:00:00 2001 From: skyforce Date: Mon, 29 Jul 2019 17:51:40 +0800 Subject: [PATCH] add reset bt function --- .../bt-spp-library/bt-spp-library.iml | 70 ++++++--------- GoogleMaps_HUD/gmaps_hud/gmaps_hud.iml | 90 +++++++------------ .../sky4s/garminhud/app/MainActivity.java | 64 +++++++------ .../java/sky4s/garminhud/hud/DummyHUD.java | 34 ++++--- .../src/main/res/layout/fragment_page1.xml | 35 +++++--- GoogleMaps_HUD/gmaps_hud/version.properties | 6 +- 6 files changed, 143 insertions(+), 156 deletions(-) diff --git a/GoogleMaps_HUD/bt-spp-library/bt-spp-library.iml b/GoogleMaps_HUD/bt-spp-library/bt-spp-library.iml index 8e5db5a..ac6717e 100644 --- a/GoogleMaps_HUD/bt-spp-library/bt-spp-library.iml +++ b/GoogleMaps_HUD/bt-spp-library/bt-spp-library.iml @@ -8,16 +8,16 @@ - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + @@ -94,6 +81,7 @@ + diff --git a/GoogleMaps_HUD/gmaps_hud/gmaps_hud.iml b/GoogleMaps_HUD/gmaps_hud/gmaps_hud.iml index 69a9914..7e9cff6 100644 --- a/GoogleMaps_HUD/gmaps_hud/gmaps_hud.iml +++ b/GoogleMaps_HUD/gmaps_hud/gmaps_hud.iml @@ -10,15 +10,13 @@ - @@ -33,60 +31,47 @@ - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + @@ -113,23 +98,14 @@ - - - - - - - - - @@ -137,12 +113,9 @@ - - - @@ -184,5 +157,6 @@ + \ No newline at end of file diff --git a/GoogleMaps_HUD/gmaps_hud/src/main/java/sky4s/garminhud/app/MainActivity.java b/GoogleMaps_HUD/gmaps_hud/src/main/java/sky4s/garminhud/app/MainActivity.java index 8e48e33..ba2c8c8 100644 --- a/GoogleMaps_HUD/gmaps_hud/src/main/java/sky4s/garminhud/app/MainActivity.java +++ b/GoogleMaps_HUD/gmaps_hud/src/main/java/sky4s/garminhud/app/MainActivity.java @@ -312,33 +312,7 @@ void loadOptions() { private DrawerLayout mDrawerLayout; // private ActionBarDrawerToggle mDrawerToggle; - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - //======================================================================================= - // tabs - //======================================================================================== - // Connect the ViewPager to our custom PagerAdapter. The PagerAdapter supplies the pages - // (fragments) to the ViewPager, which the ViewPager needs to display. - mViewPager = (ViewPager) findViewById(R.id.viewpager); - mViewPager.setAdapter(new MyPagerAdapter(getFragmentManager())); - - // Connect the tabs with the ViewPager (the setupWithViewPager method does this for us in - // both directions, i.e. when a new tab is selected, the ViewPager switches to this page, - // and when the ViewPager switches to a new page, the corresponding tab is selected) - TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout); - tabLayout.setupWithViewPager(mViewPager); - //======================================================================================== - - - startService(new Intent(this, NotificationCollectorMonitorService.class)); - - sharedPref = this.getPreferences(Context.MODE_PRIVATE); - //======================================================================================== - // BT related - //======================================================================================== + private String init_bt() { String bt_status = ""; if (!IGNORE_BT_DEVICE) { bt = new BluetoothSPP(this); @@ -370,7 +344,40 @@ protected void onCreate(Bundle savedInstanceState) { } else { bt_status = "(NO BT)"; + NotificationMonitor.hud = hud; } + + return bt_status; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + //======================================================================================= + // tabs + //======================================================================================== + // Connect the ViewPager to our custom PagerAdapter. The PagerAdapter supplies the pages + // (fragments) to the ViewPager, which the ViewPager needs to display. + mViewPager = (ViewPager) findViewById(R.id.viewpager); + mViewPager.setAdapter(new MyPagerAdapter(getFragmentManager())); + + // Connect the tabs with the ViewPager (the setupWithViewPager method does this for us in + // both directions, i.e. when a new tab is selected, the ViewPager switches to this page, + // and when the ViewPager switches to a new page, the corresponding tab is selected) + TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout); + tabLayout.setupWithViewPager(mViewPager); + //======================================================================================== + + + startService(new Intent(this, NotificationCollectorMonitorService.class)); + + sharedPref = this.getPreferences(Context.MODE_PRIVATE); + //======================================================================================== + // BT related + //======================================================================================== + String bt_status = init_bt(); //======================================================================================== //======================================================================================= @@ -609,6 +616,9 @@ public void buttonOnClicked(View view) { case R.id.btnResetBT: log("Reset Bluetooth..."); + if (!IGNORE_BT_DEVICE) { + init_bt(); + } break; case R.id.switchShowSpeed: diff --git a/GoogleMaps_HUD/gmaps_hud/src/main/java/sky4s/garminhud/hud/DummyHUD.java b/GoogleMaps_HUD/gmaps_hud/src/main/java/sky4s/garminhud/hud/DummyHUD.java index 4b3d935..49bf48a 100644 --- a/GoogleMaps_HUD/gmaps_hud/src/main/java/sky4s/garminhud/hud/DummyHUD.java +++ b/GoogleMaps_HUD/gmaps_hud/src/main/java/sky4s/garminhud/hud/DummyHUD.java @@ -1,10 +1,18 @@ package sky4s.garminhud.hud; +import android.util.Log; + import sky4s.garminhud.eOutAngle; import sky4s.garminhud.eOutType; import sky4s.garminhud.eUnits; public class DummyHUD implements HUDInterface { + private static final String TAG = DummyHUD.class.getSimpleName(); + + private void log(Object object) { + Log.i(TAG, object.toString()); + } + @Override public void setMaxUpdatePerSecond(int max) { @@ -22,42 +30,42 @@ public boolean getSendResult() { @Override public void SetTime(int nH, int nM, boolean bH, boolean bFlag) { - + log("Time: " + nH + ":" + nM + (bH ? "h" : "") + " " + bFlag); } @Override public void SetTime(int nH, int nM, boolean bH) { - + log("Time: " + nH + ":" + nM + (bH ? "h" : "")); } @Override public void SetTime(int nH, int nM, boolean bFlag, boolean bTraffic, boolean bColon, boolean bH) { - + log("Time: " + nH + (bColon ? ":" : " ") + nM + (bH ? "h" : "") + " " + bFlag + " " + bTraffic); } @Override public void SetRemainTime(int nH, int nM) { - + log("Remain Time: " + nH + ":" + nM); } @Override public void ClearTime() { - + log("Clear Time"); } @Override public void SetDistance(int nDist, eUnits unit) { - + log("Distance: " + nDist + " " + unit); } @Override public void SetDistance(int nDist, eUnits unit, boolean bDecimal, boolean bLeadingZero) { - + log("Distance: " + nDist + " " + unit + " " + bDecimal + " " + bLeadingZero); } @Override public void ClearDistance() { - + log("Clear Distance"); } @Override @@ -82,22 +90,22 @@ public void SetLanes(char nArrow, char nOutline) { @Override public void SetSpeed(int nSpeed, boolean bIcon) { - + log("Speed: " + nSpeed + " " + bIcon); } @Override public void SetSpeedAndWarning(int nSpeed, int nLimit) { - + log("Speed: " + nSpeed + " / " + nLimit); } @Override public void SetSpeedWarning(int nSpeed, int nLimit, boolean bSpeeding, boolean bIcon, boolean bSlash) { - + log("Speed: " + nSpeed + " / " + nLimit + " " + bSpeeding + " " + bIcon + " " + bSlash); } @Override public void ClearSpeedandWarning() { - + log("Clear Speed & Warning"); } @Override @@ -132,6 +140,6 @@ public void SetBrightness(int brightness) { @Override public void clear() { - + log("Clear"); } } diff --git a/GoogleMaps_HUD/gmaps_hud/src/main/res/layout/fragment_page1.xml b/GoogleMaps_HUD/gmaps_hud/src/main/res/layout/fragment_page1.xml index 59fe84e..162b644 100644 --- a/GoogleMaps_HUD/gmaps_hud/src/main/res/layout/fragment_page1.xml +++ b/GoogleMaps_HUD/gmaps_hud/src/main/res/layout/fragment_page1.xml @@ -19,23 +19,30 @@ android:layout_height="wrap_content" android:orientation="vertical"> -