Merge pull request #16 from AdrianLxM/watchfaces-steampunk

fix build issues and updates from upstream
This commit is contained in:
Andrew Warrington 2018-01-03 14:16:08 +01:00 committed by GitHub
commit 7c73a72c66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 8 deletions

View file

@ -112,12 +112,16 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if(ev.recreate) {
recreate(); recreate();
}else {
try { // activity may be destroyed try { // activity may be destroyed
setUpTabs(true); setUpTabs(true);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
log.error("Unhandled exception", e); log.error("Unhandled exception", e);
} }
}
boolean lockScreen = BuildConfig.NSCLIENTOLNY && SP.getBoolean("lockscreen", false); boolean lockScreen = BuildConfig.NSCLIENTOLNY && SP.getBoolean("lockscreen", false);
if (lockScreen) if (lockScreen)
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps; package info.nightscout.androidaps;
import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.EditTextPreference; import android.preference.EditTextPreference;
@ -58,8 +59,9 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
if (key.equals("language")) { if (key.equals("language")) {
String lang = sharedPreferences.getString("language", "en"); String lang = sharedPreferences.getString("language", "en");
LocaleHelper.setLocale(getApplicationContext(), lang); LocaleHelper.setLocale(getApplicationContext(), lang);
recreate(); MainApp.bus().post(new EventRefreshGui(true));
MainApp.bus().post(new EventRefreshGui()); //recreate() does not update language so better close settings
finish();
} }
if (key.equals("short_tabtitles")) { if (key.equals("short_tabtitles")) {
MainApp.bus().post(new EventRefreshGui()); MainApp.bus().post(new EventRefreshGui());

View file

@ -4,4 +4,11 @@ package info.nightscout.androidaps.events;
* Created by mike on 13.06.2016. * Created by mike on 13.06.2016.
*/ */
public class EventRefreshGui extends Event { public class EventRefreshGui extends Event {
public boolean recreate = false;
public EventRefreshGui(boolean recreate) {
this.recreate = recreate;
}
public EventRefreshGui(){
this(false);
}
} }

View file

@ -533,7 +533,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
if (options.eventType == R.id.careportal_combobolus) { if (options.eventType == R.id.careportal_combobolus) {
Double enteredInsulin = SafeParse.stringToDouble(editInsulin.getText()); Double enteredInsulin = SafeParse.stringToDouble(editInsulin.getText());
data.put("enteredinsulin", enteredInsulin); data.put("enteredinsulin", enteredInsulin);
data.put("insulin", enteredInsulin * SafeParse.stringToDouble(editInsulin.getText()) / 100); data.put("insulin", enteredInsulin * SafeParse.stringToDouble(editSplit.getText()) / 100);
data.put("relative", enteredInsulin * (100 - SafeParse.stringToDouble(editSplit.getText())) / 100 / SafeParse.stringToDouble(editDuration.getText()) * 60); data.put("relative", enteredInsulin * (100 - SafeParse.stringToDouble(editSplit.getText())) / 100 / SafeParse.stringToDouble(editDuration.getText()) * 60);
} }
} catch (JSONException e) { } catch (JSONException e) {

View file

@ -9,8 +9,12 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.ViewGroup; import android.view.ViewGroup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import info.nightscout.androidaps.MainActivity;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
/** /**
@ -22,6 +26,8 @@ public class TabPageAdapter extends FragmentStatePagerAdapter {
Context context; Context context;
private static Logger log = LoggerFactory.getLogger(TabPageAdapter.class);
public TabPageAdapter(FragmentManager fm, Context context) { public TabPageAdapter(FragmentManager fm, Context context) {
super(fm); super(fm);
this.context = context; this.context = context;
@ -40,6 +46,8 @@ public class TabPageAdapter extends FragmentStatePagerAdapter {
super.finishUpdate(container); super.finishUpdate(container);
} catch (NullPointerException nullPointerException){ } catch (NullPointerException nullPointerException){
System.out.println("Catch the NullPointerException in FragmentStatePagerAdapter.finishUpdate"); System.out.println("Catch the NullPointerException in FragmentStatePagerAdapter.finishUpdate");
} catch (IllegalStateException e){
log.error(e.getMessage());
} }
} }