2016-06-04 17:28:05 +02:00
|
|
|
package info.nightscout.androidaps;
|
|
|
|
|
2017-02-10 14:24:56 +01:00
|
|
|
import android.content.Context;
|
2016-06-19 20:06:00 +02:00
|
|
|
import android.content.Intent;
|
2016-07-03 19:21:41 +02:00
|
|
|
import android.content.pm.PackageManager;
|
2017-02-10 14:24:56 +01:00
|
|
|
import android.graphics.Rect;
|
2016-07-19 11:31:58 +02:00
|
|
|
import android.os.Bundle;
|
2018-06-03 23:28:04 +02:00
|
|
|
import android.os.PersistableBundle;
|
2018-02-10 14:53:43 +01:00
|
|
|
import android.text.SpannableString;
|
|
|
|
import android.text.method.LinkMovementMethod;
|
|
|
|
import android.text.util.Linkify;
|
2018-06-04 21:34:21 +02:00
|
|
|
import android.util.TypedValue;
|
2018-06-03 23:28:04 +02:00
|
|
|
import android.view.Menu;
|
2017-05-04 19:13:56 +02:00
|
|
|
import android.view.MenuItem;
|
2017-02-10 14:24:56 +01:00
|
|
|
import android.view.MotionEvent;
|
|
|
|
import android.view.View;
|
2017-07-03 00:02:54 +02:00
|
|
|
import android.view.WindowManager;
|
2017-02-10 14:24:56 +01:00
|
|
|
import android.view.inputmethod.InputMethodManager;
|
|
|
|
import android.widget.EditText;
|
2018-06-04 21:34:21 +02:00
|
|
|
import android.widget.LinearLayout;
|
2018-02-10 14:53:43 +01:00
|
|
|
import android.widget.TextView;
|
2016-06-04 17:28:05 +02:00
|
|
|
|
2019-10-15 20:44:03 +02:00
|
|
|
import androidx.annotation.NonNull;
|
2019-08-08 18:39:56 +02:00
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.appcompat.app.ActionBarDrawerToggle;
|
|
|
|
import androidx.appcompat.app.AlertDialog;
|
|
|
|
import androidx.appcompat.widget.Toolbar;
|
|
|
|
import androidx.core.app.ActivityCompat;
|
|
|
|
import androidx.drawerlayout.widget.DrawerLayout;
|
|
|
|
import androidx.viewpager.widget.ViewPager;
|
|
|
|
|
|
|
|
import com.google.android.material.navigation.NavigationView;
|
|
|
|
import com.google.android.material.tabs.TabLayout;
|
2016-07-08 00:17:02 +02:00
|
|
|
import com.joanzapata.iconify.Iconify;
|
|
|
|
import com.joanzapata.iconify.fonts.FontAwesomeModule;
|
2016-06-13 22:53:41 +02:00
|
|
|
|
2019-12-27 04:17:49 +01:00
|
|
|
import javax.inject.Inject;
|
|
|
|
|
2019-12-13 02:12:19 +01:00
|
|
|
import dagger.android.AndroidInjection;
|
2019-12-30 13:40:42 +01:00
|
|
|
import info.nightscout.androidaps.historyBrowser.HistoryBrowseActivity;
|
2019-08-08 18:39:56 +02:00
|
|
|
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
2018-07-29 00:08:28 +02:00
|
|
|
import info.nightscout.androidaps.activities.PreferencesActivity;
|
|
|
|
import info.nightscout.androidaps.activities.SingleFragmentActivity;
|
2019-12-09 19:03:26 +01:00
|
|
|
import info.nightscout.androidaps.activities.StatsActivity;
|
2017-05-04 19:13:56 +02:00
|
|
|
import info.nightscout.androidaps.events.EventAppExit;
|
2018-06-23 18:24:04 +02:00
|
|
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
2019-10-15 20:44:03 +02:00
|
|
|
import info.nightscout.androidaps.events.EventRebuildTabs;
|
2016-06-14 23:45:55 +02:00
|
|
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
2019-04-17 22:45:21 +02:00
|
|
|
import info.nightscout.androidaps.interfaces.PluginType;
|
2019-12-28 01:52:20 +01:00
|
|
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
|
|
|
import info.nightscout.androidaps.logging.LTag;
|
2019-04-17 22:45:21 +02:00
|
|
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
2019-12-30 11:35:49 +01:00
|
|
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
2020-01-03 16:29:59 +01:00
|
|
|
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils;
|
2019-02-28 23:16:50 +01:00
|
|
|
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus;
|
2019-12-27 04:17:49 +01:00
|
|
|
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin;
|
2018-05-20 21:55:53 +02:00
|
|
|
import info.nightscout.androidaps.setupwizard.SetupWizardActivity;
|
2016-07-19 11:31:58 +02:00
|
|
|
import info.nightscout.androidaps.tabs.TabPageAdapter;
|
2019-02-26 20:38:27 +01:00
|
|
|
import info.nightscout.androidaps.utils.AndroidPermission;
|
2019-04-05 00:32:26 +02:00
|
|
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
2019-02-26 20:38:27 +01:00
|
|
|
import info.nightscout.androidaps.utils.LocaleHelper;
|
2019-12-22 21:37:26 +01:00
|
|
|
import info.nightscout.androidaps.utils.OKDialog;
|
2019-02-26 20:38:27 +01:00
|
|
|
import info.nightscout.androidaps.utils.PasswordProtection;
|
2019-12-30 11:35:49 +01:00
|
|
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
|
|
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
2019-10-14 23:16:51 +02:00
|
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
|
import io.reactivex.disposables.CompositeDisposable;
|
2016-06-04 17:28:05 +02:00
|
|
|
|
2019-12-28 22:51:04 +01:00
|
|
|
public class MainActivity extends NoSplashAppCompatActivity {
|
2019-12-27 04:17:49 +01:00
|
|
|
|
2019-10-14 23:16:51 +02:00
|
|
|
private CompositeDisposable disposable = new CompositeDisposable();
|
2018-06-03 23:28:04 +02:00
|
|
|
private ActionBarDrawerToggle actionBarDrawerToggle;
|
2018-06-04 21:56:31 +02:00
|
|
|
private MenuItem pluginPreferencesMenuItem;
|
|
|
|
|
2019-12-30 11:35:49 +01:00
|
|
|
@Inject AAPSLogger aapsLogger;
|
|
|
|
@Inject RxBusWrapper rxBus;
|
|
|
|
@Inject SP sp;
|
|
|
|
@Inject ResourceHelper resourceHelper;
|
2020-01-03 16:29:59 +01:00
|
|
|
@Inject VersionCheckerUtils versionCheckerUtils;
|
2019-12-30 11:35:49 +01:00
|
|
|
@Inject SmsCommunicatorPlugin smsCommunicatorPlugin;
|
|
|
|
@Inject LoopPlugin loopPlugin;
|
2020-01-01 23:23:16 +01:00
|
|
|
@Inject NSSettingsStatus nsSettingsStatus;
|
2019-12-27 04:17:49 +01:00
|
|
|
|
2019-12-28 01:52:20 +01:00
|
|
|
|
2016-06-04 17:28:05 +02:00
|
|
|
@Override
|
2019-08-08 18:39:56 +02:00
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
2019-12-13 02:12:19 +01:00
|
|
|
AndroidInjection.inject(this);
|
2016-06-04 17:28:05 +02:00
|
|
|
super.onCreate(savedInstanceState);
|
2018-05-22 20:02:38 +02:00
|
|
|
|
2016-07-08 00:17:02 +02:00
|
|
|
Iconify.with(new FontAwesomeModule());
|
2019-10-25 11:38:23 +02:00
|
|
|
LocaleHelper.INSTANCE.update(getApplicationContext());
|
2018-06-03 23:28:04 +02:00
|
|
|
|
2016-06-04 17:28:05 +02:00
|
|
|
setContentView(R.layout.activity_main);
|
2018-06-03 23:28:04 +02:00
|
|
|
setSupportActionBar(findViewById(R.id.toolbar));
|
|
|
|
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
|
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
|
|
getSupportActionBar().setHomeButtonEnabled(true);
|
|
|
|
|
|
|
|
DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
|
|
|
|
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.open_navigation, R.string.close_navigation);
|
|
|
|
drawerLayout.addDrawerListener(actionBarDrawerToggle);
|
|
|
|
actionBarDrawerToggle.syncState();
|
2017-05-04 19:13:56 +02:00
|
|
|
|
2018-06-23 18:24:04 +02:00
|
|
|
// initialize screen wake lock
|
2020-01-03 10:31:42 +01:00
|
|
|
processPreferenceChange(new EventPreferenceChange(resourceHelper.gs(R.string.key_keep_screen_on)));
|
2018-05-22 23:06:17 +02:00
|
|
|
|
2018-06-04 21:56:31 +02:00
|
|
|
final ViewPager viewPager = findViewById(R.id.pager);
|
|
|
|
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPageSelected(int position) {
|
|
|
|
checkPluginPreferences(viewPager);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPageScrollStateChanged(int state) {
|
|
|
|
}
|
|
|
|
});
|
2019-04-17 22:45:21 +02:00
|
|
|
|
|
|
|
//Check here if loop plugin is disabled. Else check via constraints
|
2019-12-30 11:35:49 +01:00
|
|
|
if (!loopPlugin.isEnabled(PluginType.LOOP))
|
2020-01-03 16:29:59 +01:00
|
|
|
versionCheckerUtils.triggerCheckVersion();
|
2019-04-17 22:45:21 +02:00
|
|
|
|
2020-01-03 14:30:39 +01:00
|
|
|
FabricPrivacy.getInstance().setUserStats();
|
2018-05-22 23:06:17 +02:00
|
|
|
|
2019-10-15 20:44:03 +02:00
|
|
|
setupTabs();
|
|
|
|
setupViews();
|
|
|
|
|
2019-12-30 11:35:49 +01:00
|
|
|
disposable.add(rxBus
|
2019-10-15 20:44:03 +02:00
|
|
|
.toObservable(EventRebuildTabs.class)
|
2019-10-14 23:16:51 +02:00
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
|
.subscribe(event -> {
|
2019-10-25 11:38:23 +02:00
|
|
|
LocaleHelper.INSTANCE.update(getApplicationContext());
|
2019-10-14 23:16:51 +02:00
|
|
|
if (event.getRecreate()) {
|
|
|
|
recreate();
|
|
|
|
} else {
|
2019-10-15 20:44:03 +02:00
|
|
|
setupTabs();
|
|
|
|
setupViews();
|
2019-10-14 23:16:51 +02:00
|
|
|
}
|
2019-10-22 23:01:38 +02:00
|
|
|
setWakeLock();
|
2020-01-03 14:30:39 +01:00
|
|
|
}, exception -> FabricPrivacy.getInstance().logException(exception))
|
2019-10-14 23:16:51 +02:00
|
|
|
);
|
2019-12-30 11:35:49 +01:00
|
|
|
disposable.add(rxBus
|
2019-10-14 23:16:51 +02:00
|
|
|
.toObservable(EventPreferenceChange.class)
|
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
2020-01-03 14:30:39 +01:00
|
|
|
.subscribe(this::processPreferenceChange, exception -> FabricPrivacy.getInstance().logException(exception))
|
2019-10-14 23:16:51 +02:00
|
|
|
);
|
2018-07-29 15:37:28 +02:00
|
|
|
|
2019-12-30 11:35:49 +01:00
|
|
|
if (!sp.getBoolean(R.string.key_setupwizard_processed, false)) {
|
2018-05-11 13:14:59 +02:00
|
|
|
Intent intent = new Intent(this, SetupWizardActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
|
2018-05-22 23:06:17 +02:00
|
|
|
AndroidPermission.notifyForStoragePermission(this);
|
|
|
|
AndroidPermission.notifyForBatteryOptimizationPermission(this);
|
2018-08-07 21:07:43 +02:00
|
|
|
if (Config.PUMPDRIVERS) {
|
2018-06-06 22:58:50 +02:00
|
|
|
AndroidPermission.notifyForLocationPermissions(this);
|
2019-12-27 04:17:49 +01:00
|
|
|
AndroidPermission.notifyForSMSPermissions(this, smsCommunicatorPlugin);
|
2018-06-06 22:58:50 +02:00
|
|
|
}
|
2018-05-22 23:06:17 +02:00
|
|
|
}
|
|
|
|
|
2019-10-25 11:38:23 +02:00
|
|
|
private void checkPluginPreferences(ViewPager viewPager) {
|
|
|
|
if (pluginPreferencesMenuItem == null) return;
|
|
|
|
if (((TabPageAdapter) viewPager.getAdapter()).getPluginAt(viewPager.getCurrentItem()).getPreferencesId() != -1)
|
|
|
|
pluginPreferencesMenuItem.setEnabled(true);
|
|
|
|
else pluginPreferencesMenuItem.setEnabled(false);
|
|
|
|
}
|
|
|
|
|
2018-05-22 23:06:17 +02:00
|
|
|
@Override
|
2019-10-25 11:38:23 +02:00
|
|
|
public void onPostCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
|
|
|
|
super.onPostCreate(savedInstanceState, persistentState);
|
|
|
|
actionBarDrawerToggle.syncState();
|
2016-06-13 22:53:41 +02:00
|
|
|
}
|
|
|
|
|
2019-10-14 23:16:51 +02:00
|
|
|
@Override
|
2019-10-25 11:38:23 +02:00
|
|
|
public void onDestroy() {
|
|
|
|
super.onDestroy();
|
2019-10-14 23:16:51 +02:00
|
|
|
disposable.clear();
|
|
|
|
}
|
|
|
|
|
2019-10-22 23:01:38 +02:00
|
|
|
private void setWakeLock() {
|
2019-12-30 11:35:49 +01:00
|
|
|
boolean keepScreenOn = sp.getBoolean(R.string.key_keep_screen_on, false);
|
2019-10-22 23:01:38 +02:00
|
|
|
if (keepScreenOn)
|
|
|
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
|
|
else
|
|
|
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
|
|
}
|
|
|
|
|
2019-10-15 20:44:03 +02:00
|
|
|
public void processPreferenceChange(final EventPreferenceChange ev) {
|
2020-01-03 10:31:42 +01:00
|
|
|
if (ev.isChanged(resourceHelper, R.string.key_keep_screen_on))
|
2019-10-22 23:01:38 +02:00
|
|
|
setWakeLock();
|
2017-07-03 00:02:54 +02:00
|
|
|
}
|
|
|
|
|
2019-10-15 20:44:03 +02:00
|
|
|
private void setupViews() {
|
2016-08-21 22:14:33 +02:00
|
|
|
TabPageAdapter pageAdapter = new TabPageAdapter(getSupportFragmentManager(), this);
|
2018-06-03 23:28:04 +02:00
|
|
|
NavigationView navigationView = findViewById(R.id.navigation_view);
|
2019-10-15 20:44:03 +02:00
|
|
|
navigationView.setNavigationItemSelectedListener(menuItem -> true);
|
2018-06-03 23:28:04 +02:00
|
|
|
Menu menu = navigationView.getMenu();
|
|
|
|
menu.clear();
|
2016-08-05 23:54:03 +02:00
|
|
|
for (PluginBase p : MainApp.getPluginsList()) {
|
|
|
|
pageAdapter.registerNewFragment(p);
|
2020-01-06 15:51:10 +01:00
|
|
|
if (p.hasFragment() && !p.isFragmentVisible() && p.isEnabled(p.getPluginDescription().getType()) && !p.getPluginDescription().neverVisible) {
|
2018-06-03 23:28:04 +02:00
|
|
|
MenuItem menuItem = menu.add(p.getName());
|
|
|
|
menuItem.setCheckable(true);
|
|
|
|
menuItem.setOnMenuItemClickListener(item -> {
|
|
|
|
Intent intent = new Intent(this, SingleFragmentActivity.class);
|
|
|
|
intent.putExtra("plugin", MainApp.getPluginsList().indexOf(p));
|
|
|
|
startActivity(intent);
|
2018-06-09 13:17:26 +02:00
|
|
|
((DrawerLayout) findViewById(R.id.drawer_layout)).closeDrawers();
|
2018-06-03 23:28:04 +02:00
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
2016-06-13 22:53:41 +02:00
|
|
|
}
|
2018-06-03 23:28:04 +02:00
|
|
|
ViewPager mPager = findViewById(R.id.pager);
|
2016-06-13 22:53:41 +02:00
|
|
|
mPager.setAdapter(pageAdapter);
|
2019-10-15 20:44:03 +02:00
|
|
|
//if (switchToLast)
|
|
|
|
// mPager.setCurrentItem(pageAdapter.getCount() - 1, false);
|
2018-06-04 21:56:31 +02:00
|
|
|
checkPluginPreferences(mPager);
|
2016-06-04 17:28:05 +02:00
|
|
|
}
|
2016-06-05 01:40:35 +02:00
|
|
|
|
2018-06-04 21:34:21 +02:00
|
|
|
private void setupTabs() {
|
|
|
|
ViewPager viewPager = findViewById(R.id.pager);
|
|
|
|
TabLayout normalTabs = findViewById(R.id.tabs_normal);
|
|
|
|
normalTabs.setupWithViewPager(viewPager, true);
|
|
|
|
TabLayout compactTabs = findViewById(R.id.tabs_compact);
|
|
|
|
compactTabs.setupWithViewPager(viewPager, true);
|
|
|
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
2019-12-30 11:35:49 +01:00
|
|
|
if (sp.getBoolean("short_tabtitles", false)) {
|
2018-06-04 21:34:21 +02:00
|
|
|
normalTabs.setVisibility(View.GONE);
|
|
|
|
compactTabs.setVisibility(View.VISIBLE);
|
|
|
|
toolbar.setLayoutParams(new LinearLayout.LayoutParams(Toolbar.LayoutParams.MATCH_PARENT, (int) getResources().getDimension(R.dimen.compact_height)));
|
|
|
|
} else {
|
|
|
|
normalTabs.setVisibility(View.VISIBLE);
|
|
|
|
compactTabs.setVisibility(View.GONE);
|
|
|
|
TypedValue typedValue = new TypedValue();
|
|
|
|
if (getTheme().resolveAttribute(R.attr.actionBarSize, typedValue, true)) {
|
|
|
|
toolbar.setLayoutParams(new LinearLayout.LayoutParams(Toolbar.LayoutParams.MATCH_PARENT,
|
|
|
|
TypedValue.complexToDimensionPixelSize(typedValue.data, getResources().getDisplayMetrics())));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-24 18:46:16 +01:00
|
|
|
@Override
|
2019-10-15 20:44:03 +02:00
|
|
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
2016-11-25 01:47:59 +01:00
|
|
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
2016-11-25 12:49:41 +01:00
|
|
|
if (permissions.length != 0) {
|
|
|
|
if (ActivityCompat.checkSelfPermission(this, permissions[0]) == PackageManager.PERMISSION_GRANTED) {
|
2016-11-25 11:24:56 +01:00
|
|
|
switch (requestCode) {
|
2018-05-22 17:34:09 +02:00
|
|
|
case AndroidPermission.CASE_STORAGE:
|
2016-11-25 11:24:56 +01:00
|
|
|
//show dialog after permission is granted
|
2019-12-30 11:35:49 +01:00
|
|
|
OKDialog.show(this, "", resourceHelper.gs(R.string.alert_dialog_storage_permission_text));
|
2016-11-25 11:24:56 +01:00
|
|
|
break;
|
2018-05-22 17:34:09 +02:00
|
|
|
case AndroidPermission.CASE_LOCATION:
|
|
|
|
case AndroidPermission.CASE_SMS:
|
|
|
|
case AndroidPermission.CASE_BATTERY:
|
2019-08-03 20:01:55 +02:00
|
|
|
case AndroidPermission.CASE_PHONE_STATE:
|
2016-11-25 11:24:56 +01:00
|
|
|
break;
|
|
|
|
}
|
2016-11-25 01:47:59 +01:00
|
|
|
}
|
2016-11-24 18:46:16 +01:00
|
|
|
}
|
|
|
|
}
|
2017-02-10 14:24:56 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean dispatchTouchEvent(MotionEvent event) {
|
|
|
|
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
|
|
|
View v = getCurrentFocus();
|
2017-02-22 14:11:05 +01:00
|
|
|
if (v instanceof EditText) {
|
2017-02-10 14:24:56 +01:00
|
|
|
Rect outRect = new Rect();
|
|
|
|
v.getGlobalVisibleRect(outRect);
|
2017-02-22 14:11:05 +01:00
|
|
|
if (!outRect.contains((int) event.getRawX(), (int) event.getRawY())) {
|
2017-02-10 14:24:56 +01:00
|
|
|
v.clearFocus();
|
|
|
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return super.dispatchTouchEvent(event);
|
|
|
|
}
|
2017-05-04 19:13:56 +02:00
|
|
|
|
|
|
|
@Override
|
2018-06-03 23:28:04 +02:00
|
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
|
getMenuInflater().inflate(R.menu.menu_main, menu);
|
2018-06-04 21:56:31 +02:00
|
|
|
pluginPreferencesMenuItem = menu.findItem(R.id.nav_plugin_preferences);
|
|
|
|
checkPluginPreferences(findViewById(R.id.pager));
|
2018-06-03 23:28:04 +02:00
|
|
|
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", () -> {
|
|
|
|
Intent i = new Intent(this, PreferencesActivity.class);
|
|
|
|
i.putExtra("id", -1);
|
|
|
|
startActivity(i);
|
|
|
|
}, null);
|
|
|
|
return true;
|
|
|
|
case R.id.nav_historybrowser:
|
|
|
|
startActivity(new Intent(this, HistoryBrowseActivity.class));
|
|
|
|
return true;
|
|
|
|
case R.id.nav_setupwizard:
|
|
|
|
startActivity(new Intent(this, SetupWizardActivity.class));
|
|
|
|
return true;
|
|
|
|
case R.id.nav_about:
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
2019-12-30 11:35:49 +01:00
|
|
|
builder.setTitle(resourceHelper.gs(R.string.app_name) + " " + BuildConfig.VERSION);
|
2020-01-02 23:25:29 +01:00
|
|
|
builder.setIcon(resourceHelper.getIcon());
|
2018-06-03 23:28:04 +02:00
|
|
|
String message = "Build: " + BuildConfig.BUILDVERSION + "\n";
|
|
|
|
message += "Flavor: " + BuildConfig.FLAVOR + BuildConfig.BUILD_TYPE + "\n";
|
2020-01-01 23:23:16 +01:00
|
|
|
message += resourceHelper.gs(R.string.configbuilder_nightscoutversion_label) + " " + nsSettingsStatus.getNightscoutVersionName();
|
2018-06-03 23:28:04 +02:00
|
|
|
if (MainApp.engineeringMode)
|
2019-12-30 11:35:49 +01:00
|
|
|
message += "\n" + resourceHelper.gs(R.string.engineering_mode_enabled);
|
|
|
|
message += resourceHelper.gs(R.string.about_link_urls);
|
2018-06-03 23:28:04 +02:00
|
|
|
final SpannableString messageSpanned = new SpannableString(message);
|
|
|
|
Linkify.addLinks(messageSpanned, Linkify.WEB_URLS);
|
|
|
|
builder.setMessage(messageSpanned);
|
2019-12-30 11:35:49 +01:00
|
|
|
builder.setPositiveButton(resourceHelper.gs(R.string.ok), null);
|
2018-06-03 23:28:04 +02:00
|
|
|
AlertDialog alertDialog = builder.create();
|
|
|
|
alertDialog.show();
|
|
|
|
((TextView) alertDialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
|
|
|
|
return true;
|
|
|
|
case R.id.nav_exit:
|
2019-12-28 01:52:20 +01:00
|
|
|
aapsLogger.debug(LTag.CORE, "Exiting");
|
2019-12-30 11:35:49 +01:00
|
|
|
rxBus.send(new EventAppExit());
|
2018-06-03 23:28:04 +02:00
|
|
|
finish();
|
|
|
|
System.runFinalization();
|
|
|
|
System.exit(0);
|
|
|
|
return true;
|
2018-06-04 21:56:31 +02:00
|
|
|
case R.id.nav_plugin_preferences:
|
|
|
|
ViewPager viewPager = findViewById(R.id.pager);
|
|
|
|
final PluginBase plugin = ((TabPageAdapter) viewPager.getAdapter()).getPluginAt(viewPager.getCurrentItem());
|
|
|
|
PasswordProtection.QueryPassword(this, R.string.settings_password, "settings_password", () -> {
|
|
|
|
Intent i = new Intent(this, PreferencesActivity.class);
|
|
|
|
i.putExtra("id", plugin.getPreferencesId());
|
|
|
|
startActivity(i);
|
|
|
|
}, null);
|
|
|
|
return true;
|
2019-12-09 19:22:06 +01:00
|
|
|
/*
|
2019-10-08 21:20:04 +02:00
|
|
|
case R.id.nav_survey:
|
|
|
|
startActivity(new Intent(this, SurveyActivity.class));
|
|
|
|
return true;
|
2019-12-09 19:22:06 +01:00
|
|
|
*/
|
2019-12-09 19:03:26 +01:00
|
|
|
case R.id.nav_stats:
|
|
|
|
startActivity(new Intent(this, StatsActivity.class));
|
|
|
|
return true;
|
2017-05-04 19:13:56 +02:00
|
|
|
}
|
2018-06-03 23:28:04 +02:00
|
|
|
return actionBarDrawerToggle.onOptionsItemSelected(item);
|
2017-05-04 19:13:56 +02:00
|
|
|
}
|
2019-12-27 04:17:49 +01:00
|
|
|
|
2016-11-25 12:00:15 +01:00
|
|
|
}
|