remove actionbar

This commit is contained in:
Milos Kozak 2017-04-29 20:16:50 +02:00
parent 974e5e0098
commit 4dd9281276
11 changed files with 145 additions and 118 deletions

View file

@ -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);

View file

@ -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;
}
}

View file

@ -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));
}
/**

View file

@ -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() {

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
</vector>

View file

@ -11,20 +11,19 @@
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/app_bar" />
<info.nightscout.androidaps.tabs.SlidingTabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tabs"/>
android:layout_marginBottom="10dp" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
android:layout_weight="1" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>

View file

@ -72,6 +72,7 @@
android:text="TempTarget"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/mdtp_white" />
</LinearLayout>
<LinearLayout
@ -130,20 +131,45 @@
android:gravity="top"
android:orientation="vertical">
<TextView
android:id="@+id/overview_timeago"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:textAppearance="?android:attr/textAppearanceMedium" />
android:orientation="horizontal">
<TextView
android:id="@+id/overview_delta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:orientation="vertical">
<TextView
android:id="@+id/overview_timeago"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="0.5"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/overview_delta"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="0.5"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<ImageButton
android:id="@+id/overview_menuButton"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_weight="0.5"
app:srcCompat="@drawable/ic_more_vert_black_24dp" />
</LinearLayout>
<TextView
android:id="@+id/overview_avgdelta"

View file

@ -16,6 +16,9 @@
<item
android:id="@+id/nav_show_logcat"
android:title="@string/nav_show_logcat" />
<item
android:id="@+id/nav_about"
android:title="@string/nav_about" />
<item
android:id="@+id/nav_exit"
android:title="@string/nav_exit" />

View file

@ -543,4 +543,5 @@
<string name="superbolus">Superbolus</string>
<string name="enablesuperbolus">Povolit superbolus</string>
<string name="enablesuperbolus_summary">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Í!</string>
<string name="nav_about">O aplikaci</string>
</resources>

View file

@ -8,6 +8,7 @@
<color name="low">#FF0000</color>
<color name="high">#FFFF00</color>
<color name="listdelimiter">#505050</color>
<color name="tabBgColor">#f0003f59</color>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>

View file

@ -597,4 +597,5 @@
<string name="virtualpump_firmware_label">Firmware</string>
<string name="virtualpump_lastconnection_label">Last connection</string>
<string name="danar_bluetooth_status">Bluetooh status</string>
<string name="nav_about">About</string>
</resources>