diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java
index fc58a81a0b..9ae5081dbc 100644
--- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java
@@ -1,8 +1,10 @@
package info.nightscout.androidaps;
import android.Manifest;
+import android.app.Activity;
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;
@@ -16,10 +18,15 @@ 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.PopupMenu;
+import android.util.AttributeSet;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
+import android.widget.ImageButton;
import com.joanzapata.iconify.Iconify;
import com.joanzapata.iconify.fonts.FontAwesomeModule;
@@ -28,17 +35,21 @@ 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;
-public class MainActivity extends AppCompatActivity {
+public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(MainActivity.class);
static final int CASE_STORAGE = 0x1;
@@ -46,12 +57,18 @@ public class MainActivity extends AppCompatActivity {
private boolean askForSMS = false;
+ ImageButton menuButton;
+
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Iconify.with(new FontAwesomeModule());
LocaleHelper.onCreate(this, "en");
setContentView(R.layout.activity_main);
+ menuButton = (ImageButton) findViewById(R.id.overview_menuButton);
+ menuButton.setOnClickListener(this);
+
checkEula();
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
askForPermission(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
@@ -228,4 +245,81 @@ public class MainActivity extends AppCompatActivity {
}
return super.dispatchTouchEvent(event);
}
+
+ @Override
+ public void onClick(final View v) {
+ final Activity activity = this;
+ switch (v.getId()) {
+ case R.id.overview_menuButton:
+ PopupMenu popup = new PopupMenu(v.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(v.getContext(), R.string.settings_password, "settings_password", new Runnable() {
+ @Override
+ public void run() {
+ Intent i = new Intent(v.getContext(), PreferencesActivity.class);
+ startActivity(i);
+ }
+ }, null);
+ break;
+ case R.id.nav_resetdb:
+ new AlertDialog.Builder(v.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(activity);
+ ImportExportPrefs.exportSharedPreferences(activity);
+ break;
+ case R.id.nav_import:
+ ImportExportPrefs.verifyStoragePermissions(activity);
+ ImportExportPrefs.importSharedPreferences(activity);
+ break;
+ case R.id.nav_show_logcat:
+ LogDialog.showLogcat(v.getContext());
+ break;
+ case R.id.nav_about:
+ AlertDialog.Builder builder = new AlertDialog.Builder(v.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();
+ finish();
+ System.runFinalization();
+ System.exit(0);
+ break;
+ }
+ return false;
+ }
+ });
+ popup.show();
+ break;
+ }
+ }
}
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 747c9c067c..dd3e1d33e7 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
@@ -148,7 +148,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
GraphView bgGraph;
GraphView iobGraph;
RelativeLayout iobGraphLayout;
- ImageButton menuButton;
CheckBox showPredictionView;
CheckBox showBasalsView;
@@ -225,9 +224,6 @@ 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);
@@ -470,76 +466,6 @@ 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/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 91681d5ef2..75b54a74cb 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -6,24 +6,41 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
-
+ android:layout_height="match_parent">
-
-
+
+
+
+
+
+
+
+
+
+ android:layout_alignParentEnd="true"
+ android:layout_alignParentTop="true"
+ android:background="@color/tabBgColor"
+ android:paddingTop="5dp"
+ app:srcCompat="@drawable/ic_more_vert_black_24dp" />
-
-
-
+
\ 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 3200fe5014..2297d2590f 100644
--- a/app/src/main/res/layout/overview_fragment.xml
+++ b/app/src/main/res/layout/overview_fragment.xml
@@ -122,39 +122,23 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
- android:orientation="horizontal">
+ android:orientation="vertical">
-
-
-
-
-
-
-
-
-
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+