diff --git a/safeDispatch/src/main/java/com/safemobile/dispatch/HistoryActivity.java b/safeDispatch/src/main/java/com/safemobile/dispatch/HistoryActivity.java index 87de241..5397cfa 100644 --- a/safeDispatch/src/main/java/com/safemobile/dispatch/HistoryActivity.java +++ b/safeDispatch/src/main/java/com/safemobile/dispatch/HistoryActivity.java @@ -9,12 +9,18 @@ import com.safemobile.lib.SM; public class HistoryActivity extends AppCompatActivity { public Bundle savedInstanceState; + private TabLayoutActivity parentTab; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.savedInstanceState = savedInstanceState; setContentView(R.layout.tabhistory); + + parentTab = (TabLayoutActivity) getParent(); + parentTab.historyActivity = this; + } public void UpdateMap() { diff --git a/safeDispatch/src/main/java/com/safemobile/dispatch/TabLayoutActivity.java b/safeDispatch/src/main/java/com/safemobile/dispatch/TabLayoutActivity.java index 423b978..7f1968c 100644 --- a/safeDispatch/src/main/java/com/safemobile/dispatch/TabLayoutActivity.java +++ b/safeDispatch/src/main/java/com/safemobile/dispatch/TabLayoutActivity.java @@ -12,7 +12,6 @@ import java.util.Locale; import java.util.Timer; import java.util.TimerTask; -/** fix import */ import com.safemobile.activities.AbstractEmptyActivity; import com.safemobile.activities.AbstractLiveActivity; import com.safemobile.activities.AbstractMessagesActivity; @@ -267,11 +266,11 @@ public class TabLayoutActivity extends AbstractSDParentActivity{ tabHost = getTabHost(); // The activity TabHost tabHost.setTag("Tab Panel"); - tabWidget = (TabWidget) findViewById(android.R.id.tabs); + tabWidget = findViewById(android.R.id.tabs); tabWidget.setVisibility(View.GONE); - intent = new Intent[7]; - tabspecs = new TabSpec[7]; + intent = new Intent[8]; + tabspecs = new TabSpec[8]; // add live tab try @@ -290,23 +289,6 @@ public class TabLayoutActivity extends AbstractSDParentActivity{ .setContent(intent[0]); } - // add history tab - try - { - //intent[1] = new Intent(context, HistoryActivity.class); - //tabspecs[1] = tabHost.newTabSpec("History") - // .setIndicator("History", res.getDrawable(R.drawable.ic_tab_history_selected)) - // .setContent(intent[1]); - } - catch(NoClassDefFoundError e) - { - // exception when GoogleApi not exists - //intent[1] = new Intent(context, AbstractEmptyActivity.class); - //tabspecs[1] = tabHost.newTabSpec("History") - // .setIndicator("History", res.getDrawable(R.drawable.ic_tab_history_selected)) - // .setContent(intent[1]); - } - // add text tab intent[1] = new Intent(context, MessagesActivity.class); tabspecs[1] = tabHost.newTabSpec("Text") @@ -342,6 +324,21 @@ public class TabLayoutActivity extends AbstractSDParentActivity{ tabspecs[6] = tabHost.newTabSpec("SafeMobile") .setIndicator("SafeMobile", res.getDrawable(AppParams.DEMO ? R.drawable.icon_demo : R.drawable.ic_launcher)) .setContent(intent[6]); + + // add history tab + try + { + intent[7] = new Intent(context, HistoryActivity.class); + tabspecs[7] = tabHost.newTabSpec("History") + .setIndicator("History", res.getDrawable(R.drawable.ic_tab_history_selected)) + .setContent(intent[7]); + } catch(NoClassDefFoundError e) { +// exception when GoogleApi not exists + intent[7] = new Intent(context, AbstractEmptyActivity.class); + tabspecs[7] = tabHost.newTabSpec("History") + .setIndicator("History", res.getDrawable(R.drawable.ic_tab_history_selected)) + .setContent(intent[1]); + } // add tab in tabHost // for(int i=0;i<7;i++ @@ -355,76 +352,64 @@ public class TabLayoutActivity extends AbstractSDParentActivity{ imageViewSlideMenu = (ImageView) findViewById(R.id.imageViewSlideMenu); // get Live Button - buttonLive = (ImageButton) findViewById(R.id.buttonLive); - buttonLive.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - if(!buttonLive.isSelected()) - { - // select button - buttonLive.setSelected(true); - // deselect other buttons - buttonAlarms.setSelected(false); - buttonHistory.setSelected(false); - buttonRadio.setSelected(false); - buttonRecordings.setSelected(false); - buttonSetup.setSelected(false); - buttonText.setSelected(false); - // select tab - tabHost.setCurrentTabByTag("Live"); - AppParams.crtTab = AppParams.Tabs.live; - } + buttonLive = findViewById(R.id.buttonLive); + buttonLive.setOnClickListener(v -> { + if (!buttonLive.isSelected()) { + // select button + buttonLive.setSelected(true); + // deselect other buttons + buttonAlarms.setSelected(false); + buttonHistory.setSelected(false); + buttonRadio.setSelected(false); + buttonRecordings.setSelected(false); + buttonSetup.setSelected(false); + buttonText.setSelected(false); + // select tab + tabHost.setCurrentTabByTag("Live"); + AppParams.crtTab = AppParams.Tabs.live; } }); // get History Button - buttonHistory = (ImageButton) findViewById(R.id.buttonHistory); - buttonHistory.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - if(!buttonHistory.isSelected()) - { - // select button - buttonHistory.setSelected(true); - // deselect other buttons - buttonAlarms.setSelected(false); - buttonLive.setSelected(false); - buttonRadio.setSelected(false); - buttonRecordings.setSelected(false); - buttonSetup.setSelected(false); - buttonText.setSelected(false); - // select tab - tabHost.setCurrentTabByTag("History"); - AppParams.crtTab = AppParams.Tabs.history; - } + buttonHistory = findViewById(R.id.buttonHistory); + buttonHistory.setOnClickListener(v -> { + if (!buttonHistory.isSelected()) { + // select button + buttonHistory.setSelected(true); + // deselect other buttons + buttonAlarms.setSelected(false); + buttonLive.setSelected(false); + buttonRadio.setSelected(false); + buttonRecordings.setSelected(false); + buttonSetup.setSelected(false); + buttonText.setSelected(false); + // select tab + tabHost.setCurrentTabByTag("History"); + AppParams.crtTab = AppParams.Tabs.history; } }); // get Text Button - buttonText= (ImageButton) findViewById(R.id.buttonText); - buttonText.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - if(!buttonText.isSelected()) + buttonText= findViewById(R.id.buttonText); + buttonText.setOnClickListener(v -> { + if (!buttonText.isSelected()) { + // select button + buttonText.setSelected(true); + // deselect other buttons + buttonAlarms.setSelected(false); + buttonLive.setSelected(false); + buttonRadio.setSelected(false); + buttonRecordings.setSelected(false); + buttonSetup.setSelected(false); + buttonHistory.setSelected(false); + // select tab + tabHost.setCurrentTabByTag("Text"); + AppParams.crtTab = AppParams.Tabs.message; + + if(AppParams.DEMO && messageActivity.allVehicle.size()== 0) { - // select button - buttonText.setSelected(true); - // deselect other buttons - buttonAlarms.setSelected(false); - buttonLive.setSelected(false); - buttonRadio.setSelected(false); - buttonRecordings.setSelected(false); - buttonSetup.setSelected(false); - buttonHistory.setSelected(false); - // select tab - tabHost.setCurrentTabByTag("Text"); - AppParams.crtTab = AppParams.Tabs.message; - - if(AppParams.DEMO && messageActivity.allVehicle.size()== 0) - { - messageActivity.UpdateVehs(allVehicle); - messageActivity.UpdateSMS(listSMS); - } + messageActivity.UpdateVehs(allVehicle); + messageActivity.UpdateSMS(listSMS); } } }); @@ -611,24 +596,21 @@ public class TabLayoutActivity extends AbstractSDParentActivity{ }); // get About Button - buttonLogo = (ImageButton) findViewById(R.id.buttonLogo); - buttonLogo.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - // create dialog - final Dialog dialog = new Dialog(context); - dialog.setTitle(AppParams.DEMO ? getString(R.string.app_name_demo) : getString(R.string.app_name)); - dialog.setContentView(R.layout.dialog); - ImageView image = (ImageView) dialog.findViewById(R.id.image); - image.setImageResource(AppParams.DEMO ? R.drawable.icon_demo : R.drawable.ic_launcher); - TextView text = (TextView) dialog.findViewById(R.id.text); - TextView text2 = (TextView) dialog.findViewById(R.id.text2); - text.setText(getString(R.string.version) + "1.0.8"); - text2.setText(getString(R.string.email) + ": support@safemobile.com"); - dialog.setCancelable(true); - dialog.setCanceledOnTouchOutside(true); - dialog.show(); - } + buttonLogo = findViewById(R.id.buttonLogo); + buttonLogo.setOnClickListener(v -> { + // create dialog + final Dialog dialog = new Dialog(context); + dialog.setTitle(AppParams.DEMO ? getString(R.string.app_name_demo) : getString(R.string.app_name)); + dialog.setContentView(R.layout.dialog); + ImageView image = dialog.findViewById(R.id.image); + image.setImageResource(AppParams.DEMO ? R.drawable.icon_demo : R.drawable.ic_launcher); + TextView text = dialog.findViewById(R.id.text); + TextView text2 = dialog.findViewById(R.id.text2); + text.setText(getString(R.string.version) + "1.0.8"); + text2.setText(getString(R.string.email) + ": support@safemobile.com"); + dialog.setCancelable(true); + dialog.setCanceledOnTouchOutside(true); + dialog.show(); }); imageViewClose.setOnTouchListener(new OnTouchListener() { @@ -1457,28 +1439,19 @@ public class TabLayoutActivity extends AbstractSDParentActivity{ } // if tab is not TextTab - if(tabHost.getCurrentTab() != 2) - { + if(tabHost.getCurrentTab() != 2) { myHandler.post(UpdateResults); //mHandler.dispatchMessage(new Message()); - } - else - myHandler.post(new Runnable() { - - @Override - public void run() { - // create Notification - createNotification(AppParams.messageNotif); - } + } else + myHandler.post(() -> { + // create Notification + createNotification(AppParams.messageNotif); }); //list for SMS - if(AppParams.crtTab == AppParams.Tabs.message && messageActivity!= null) - { + if(AppParams.crtTab == AppParams.Tabs.message && messageActivity!= null) { SM.Debug("currentActivity instanceof MessagesActivity - NewSMS | " + tempArr[0] + " | " + tempArr[1]); messageActivity.NewSMS(tempArr[0], tempArr[1], time); } - - } @Override diff --git a/safeDispatch/src/main/res/layout/tabhistory.xml b/safeDispatch/src/main/res/layout/tabhistory.xml index 10a0b62..f952944 100644 --- a/safeDispatch/src/main/res/layout/tabhistory.xml +++ b/safeDispatch/src/main/res/layout/tabhistory.xml @@ -5,337 +5,328 @@ android:id="@+id/tab1Layout" android:orientation="horizontal" style="?bg"> - + - + - - + + - + - + - + - + - + - - - - - + + + - + - - - - - - + + + + - + android:id="@+id/LayoutSpinner" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" + android:paddingTop="10dp" + android:gravity="top" + android:layout_weight="1"> + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + -