diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index ccca5bcb22..fc58a81a0b 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -3,7 +3,6 @@ package info.nightscout.androidaps; import android.Manifest; import android.content.ActivityNotFoundException; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Rect; @@ -17,9 +16,6 @@ import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewPager; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.Menu; -import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; import android.view.inputmethod.InputMethodManager; @@ -32,17 +28,13 @@ import com.squareup.otto.Subscribe; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.tabs.SlidingTabLayout; import info.nightscout.androidaps.tabs.TabPageAdapter; -import info.nightscout.utils.ImportExportPrefs; import info.nightscout.utils.LocaleHelper; -import info.nightscout.utils.LogDialog; import info.nightscout.utils.OKDialog; -import info.nightscout.utils.PasswordProtection; import info.nightscout.utils.SP; import info.nightscout.utils.ToastUtils; @@ -69,23 +61,7 @@ public class MainActivity extends AppCompatActivity { if (Config.logFunctionCalls) log.debug("onCreate"); - // show version in toolbar - setTitle(getString(R.string.app_name) + " " + BuildConfig.VERSION); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); registerBus(); - - try { - getSupportActionBar().setDisplayShowHomeEnabled(true); - if (BuildConfig.NSCLIENTOLNY) - getSupportActionBar().setIcon(R.mipmap.yellowowl); - else - getSupportActionBar().setIcon(R.mipmap.blueowl); - } catch (NullPointerException e) { - // no action - } - - setUpTabs(false); } @@ -119,79 +95,6 @@ public class MainActivity extends AppCompatActivity { mPager.setCurrentItem(pageAdapter.getCount() - 1, false); } - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.menu_main, menu); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - int id = item.getItemId(); - switch (id) { - case R.id.nav_preferences: - PasswordProtection.QueryPassword(this, R.string.settings_password, "settings_password", new Runnable() { - @Override - public void run() { - Intent i = new Intent(getApplicationContext(), PreferencesActivity.class); - startActivity(i); - } - }, null); - break; - case R.id.nav_resetdb: - new AlertDialog.Builder(this) - .setTitle(R.string.nav_resetdb) - .setMessage(R.string.reset_db_confirm) - .setNegativeButton(android.R.string.cancel, null) - .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - MainApp.getDbHelper().resetDatabases(); - } - }) - .create() - .show(); - break; - case R.id.nav_export: - ImportExportPrefs.verifyStoragePermissions(this); - ImportExportPrefs.exportSharedPreferences(this); - break; - case R.id.nav_import: - ImportExportPrefs.verifyStoragePermissions(this); - ImportExportPrefs.importSharedPreferences(this); - break; - case R.id.nav_show_logcat: - LogDialog.showLogcat(this); - break; -// case R.id.nav_test_alarm: -// final int REQUEST_CODE_ASK_PERMISSIONS = 2355; -// int permission = ActivityCompat.checkSelfPermission(this, Manifest.permission.SYSTEM_ALERT_WINDOW); -// if (permission != PackageManager.PERMISSION_GRANTED) { -// // We don't have permission so prompt the user -// // On Android 6 give permission for alarming in Settings -> Apps -> Draw over other apps -// ActivityCompat.requestPermissions( -// this, -// new String[]{Manifest.permission.SYSTEM_ALERT_WINDOW}, -// REQUEST_CODE_ASK_PERMISSIONS -// ); -// } -// Intent alertServiceIntent = new Intent(getApplicationContext(), AlertService.class); -// alertServiceIntent.putExtra("alertText", getString(R.string.nav_test_alert)); -// getApplicationContext().startService(alertServiceIntent); -// break; - case R.id.nav_exit: - log.debug("Exiting"); - MainApp.instance().stopKeepAliveService(); - MainApp.bus().post(new EventAppExit()); - MainApp.closeDbHelper(); - finish(); - System.runFinalization(); - System.exit(0); - break; - } - return super.onOptionsItemSelected(item); - } - private void registerBus() { try { MainApp.bus().unregister(this); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index 78f20b6d24..f3139dcf94 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.Overview; import android.annotation.SuppressLint; import android.app.Activity; import android.content.DialogInterface; +import android.content.Intent; import android.graphics.Color; import android.graphics.DashPathEffect; import android.graphics.Paint; @@ -15,16 +16,19 @@ import android.support.v4.content.ContextCompat; import android.support.v7.app.AlertDialog; import android.support.v7.widget.CardView; import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.PopupMenu; import android.support.v7.widget.RecyclerView; import android.view.ContextMenu; import android.view.HapticFeedbackConstants; import android.view.LayoutInflater; +import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; +import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; @@ -55,9 +59,11 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; +import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.PreferencesActivity; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.GlucoseStatus; import info.nightscout.androidaps.data.IobTotal; @@ -66,6 +72,7 @@ import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.TempBasal; import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.db.Treatment; +import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventNewBG; import info.nightscout.androidaps.events.EventNewBasalProfile; @@ -103,7 +110,9 @@ import info.nightscout.androidaps.plugins.TempTargetRange.events.EventTempTarget import info.nightscout.utils.BolusWizard; import info.nightscout.utils.DateUtil; import info.nightscout.utils.DecimalFormatter; -import info.nightscout.utils.Profiler; +import info.nightscout.utils.ImportExportPrefs; +import info.nightscout.utils.LogDialog; +import info.nightscout.utils.PasswordProtection; import info.nightscout.utils.Round; import info.nightscout.utils.SP; import info.nightscout.utils.ToastUtils; @@ -136,6 +145,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, GraphView bgGraph; GraphView iobGraph; RelativeLayout iobGraphLayout; + ImageButton menuButton; CheckBox showPredictionView; CheckBox showBasalsView; @@ -199,6 +209,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph); iobGraphLayout = (RelativeLayout) view.findViewById(R.id.overview_iobgraphlayout); + menuButton = (ImageButton) view.findViewById(R.id.overview_menuButton); + menuButton.setOnClickListener(this); + cancelTempButton = (Button) view.findViewById(R.id.overview_canceltempbutton); cancelTempButton.setOnClickListener(this); treatmentButton = (Button) view.findViewById(R.id.overview_treatmentbutton); @@ -441,6 +454,76 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } }); break; + case R.id.overview_menuButton: + PopupMenu popup = new PopupMenu(getContext(), v); + MenuInflater inflater = popup.getMenuInflater(); + inflater.inflate(R.menu.menu_main, popup.getMenu()); + popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + int id = item.getItemId(); + switch (id) { + case R.id.nav_preferences: + PasswordProtection.QueryPassword(getContext(), R.string.settings_password, "settings_password", new Runnable() { + @Override + public void run() { + Intent i = new Intent(getContext(), PreferencesActivity.class); + startActivity(i); + } + }, null); + break; + case R.id.nav_resetdb: + new AlertDialog.Builder(getContext()) + .setTitle(R.string.nav_resetdb) + .setMessage(R.string.reset_db_confirm) + .setNegativeButton(android.R.string.cancel, null) + .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + MainApp.getDbHelper().resetDatabases(); + } + }) + .create() + .show(); + break; + case R.id.nav_export: + ImportExportPrefs.verifyStoragePermissions(getActivity()); + ImportExportPrefs.exportSharedPreferences(getActivity()); + break; + case R.id.nav_import: + ImportExportPrefs.verifyStoragePermissions(getActivity()); + ImportExportPrefs.importSharedPreferences(getActivity()); + break; + case R.id.nav_show_logcat: + LogDialog.showLogcat(getContext()); + break; + case R.id.nav_about: + AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); + builder.setTitle(getString(R.string.app_name) + " " + BuildConfig.VERSION); + if (BuildConfig.NSCLIENTOLNY) + builder.setIcon(R.mipmap.yellowowl); + else + builder.setIcon(R.mipmap.blueowl); + builder.setMessage("Build: " + BuildConfig.BUILDVERSION); + builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null); + AlertDialog alertDialog = builder.create(); + alertDialog.show(); + break; + case R.id.nav_exit: + log.debug("Exiting"); + MainApp.instance().stopKeepAliveService(); + MainApp.bus().post(new EventAppExit()); + MainApp.closeDbHelper(); + getActivity().finish(); + System.runFinalization(); + System.exit(0); + break; + } + return false; + } + }); + popup.show(); + break; } } diff --git a/app/src/main/java/info/nightscout/androidaps/tabs/SlidingTabLayout.java b/app/src/main/java/info/nightscout/androidaps/tabs/SlidingTabLayout.java index 5c1ef3b25f..80424a04f7 100644 --- a/app/src/main/java/info/nightscout/androidaps/tabs/SlidingTabLayout.java +++ b/app/src/main/java/info/nightscout/androidaps/tabs/SlidingTabLayout.java @@ -29,6 +29,8 @@ import android.widget.HorizontalScrollView; import android.widget.LinearLayout; import android.widget.TextView; +import info.nightscout.androidaps.R; + /** * To be used with ViewPager to provide a tab indicator component which give constant feedback as to * the user's scroll progress. @@ -95,6 +97,7 @@ public class SlidingTabLayout extends HorizontalScrollView { mTabStrip = new SlidingTabStrip(context); addView(mTabStrip, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); + setBackgroundColor(context.getResources().getColor(R.color.tabBgColor)); } /** diff --git a/app/src/main/java/info/nightscout/utils/ImportExportPrefs.java b/app/src/main/java/info/nightscout/utils/ImportExportPrefs.java index 0c582ba8bd..1e501fbdf0 100644 --- a/app/src/main/java/info/nightscout/utils/ImportExportPrefs.java +++ b/app/src/main/java/info/nightscout/utils/ImportExportPrefs.java @@ -3,7 +3,6 @@ package info.nightscout.utils; import android.Manifest; import android.app.Activity; import android.app.AlertDialog; -import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; import android.content.pm.PackageManager; @@ -23,7 +22,6 @@ import java.io.IOException; import java.io.PrintWriter; import java.util.Map; -import info.nightscout.androidaps.MainActivity; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.events.EventAppExit; @@ -58,7 +56,7 @@ public class ImportExportPrefs { } } - public static void exportSharedPreferences(final MainActivity c) { + public static void exportSharedPreferences(final Activity c) { new AlertDialog.Builder(c) .setMessage(MainApp.sResources.getString(R.string.export_to) + " " + file + " ?") @@ -88,7 +86,7 @@ public class ImportExportPrefs { .show(); } - public static void importSharedPreferences(final MainActivity c) { + public static void importSharedPreferences(final Activity c) { new AlertDialog.Builder(c) .setMessage(MainApp.sResources.getString(R.string.import_from) + " " + file + " ?") .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { diff --git a/app/src/main/res/drawable/ic_more_vert_black_24dp.xml b/app/src/main/res/drawable/ic_more_vert_black_24dp.xml new file mode 100644 index 0000000000..5176d8a4b1 --- /dev/null +++ b/app/src/main/res/drawable/ic_more_vert_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 930d3f897b..91681d5ef2 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -11,20 +11,19 @@ android:layout_height="match_parent" android:orientation="vertical"> - + android:layout_marginBottom="10dp" /> + android:layout_weight="1" /> + \ No newline at end of file diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml index 041a248bc0..2bac2cb13e 100644 --- a/app/src/main/res/layout/overview_fragment.xml +++ b/app/src/main/res/layout/overview_fragment.xml @@ -72,6 +72,7 @@ android:text="TempTarget" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@color/mdtp_white" /> + - + android:orientation="horizontal"> - + + + + + + + + + + + + diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 58a8da3cc4..17af068120 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -543,4 +543,5 @@ Superbolus Povolit superbolus Povolení superbolusu v kalkulátoru. Nepovolujte, dokud se nenaučíte, co to opravdu dělá. MŮŽE ZPŮSOBIT PŘEDÁVKOVÁNÍ INZULÍNEM PŘI NESPRÁVNÉM POUŽITÍ! + O aplikaci diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 16b5cecb98..6c3aaebf16 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -8,6 +8,7 @@ #FF0000 #FFFF00 #505050 + #f0003f59 #3F51B5 #303F9F diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 09bd43f2a4..8a868dfef3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -597,4 +597,5 @@ Firmware Last connection Bluetooh status + About