- fixed memory leak while switching between fragments.
- added help button. - used another graph icon for navigation icons to avoid that the preference tint method is applied to the navigation icon.
@@ -66,13 +66,13 @@ import java.lang.reflect.Field;
|
|||||||
|
|
||||||
import cat.ereza.customactivityoncrash.config.CaocConfig;
|
import cat.ereza.customactivityoncrash.config.CaocConfig;
|
||||||
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
private static boolean firstAppStart = true;
|
private static boolean firstAppStart = true;
|
||||||
private static boolean valueOfCountModified = false;
|
private static boolean valueOfCountModified = false;
|
||||||
private static int bluetoothStatusIcon = R.drawable.ic_bluetooth_disabled;
|
private static int bluetoothStatusIcon = R.drawable.ic_bluetooth_disabled;
|
||||||
private static MenuItem bluetoothStatus;
|
private static MenuItem bluetoothStatus;
|
||||||
|
|
||||||
|
private Fragment currentFragment;
|
||||||
private DrawerLayout drawerLayout;
|
private DrawerLayout drawerLayout;
|
||||||
private Toolbar toolbar;
|
private Toolbar toolbar;
|
||||||
private NavigationView navDrawer;
|
private NavigationView navDrawer;
|
||||||
@@ -95,6 +95,8 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
currentFragment = null;
|
||||||
|
|
||||||
// Set a Toolbar to replace the ActionBar.
|
// Set a Toolbar to replace the ActionBar.
|
||||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
@@ -250,7 +252,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
public void selectDrawerItem(int menuItemId) {
|
public void selectDrawerItem(int menuItemId) {
|
||||||
// Create a new fragment and specify the fragment to show based on nav item clicked
|
// Create a new fragment and specify the fragment to show based on nav item clicked
|
||||||
Fragment fragment = null;
|
|
||||||
Class fragmentClass;
|
Class fragmentClass;
|
||||||
String fragmentTitle;
|
String fragmentTitle;
|
||||||
|
|
||||||
@@ -282,22 +283,37 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
settingsIntent.putExtra(SettingsActivity.EXTRA_TINT_COLOR, navDrawer.getItemTextColor().getDefaultColor());
|
settingsIntent.putExtra(SettingsActivity.EXTRA_TINT_COLOR, navDrawer.getItemTextColor().getDefaultColor());
|
||||||
startActivityForResult(settingsIntent, 1);
|
startActivityForResult(settingsIntent, 1);
|
||||||
return;
|
return;
|
||||||
|
case R.id.nav_help:
|
||||||
|
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/oliexdev/openScale/wiki")));
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
fragmentClass = OverviewFragment.class;
|
fragmentClass = OverviewFragment.class;
|
||||||
fragmentTitle = getResources().getString(R.string.title_overview);
|
fragmentTitle = getResources().getString(R.string.title_overview);
|
||||||
prefs.edit().putInt("lastFragmentId", menuItemId).commit();
|
prefs.edit().putInt("lastFragmentId", menuItemId).commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||||
fragment = (Fragment) fragmentClass.newInstance();
|
|
||||||
|
|
||||||
|
// hide previous fragment if it available
|
||||||
|
if (currentFragment != null) {
|
||||||
|
fragmentManager.beginTransaction().hide(currentFragment).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// try to find selected fragment
|
||||||
|
currentFragment = fragmentManager.findFragmentByTag(""+menuItemId);
|
||||||
|
|
||||||
|
// if fragment not found then add the fragment
|
||||||
|
if (currentFragment == null) {
|
||||||
|
try {
|
||||||
|
currentFragment = (Fragment) fragmentClass.newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert the fragment by replacing any existing fragment
|
fragmentManager.beginTransaction().add(R.id.fragment_content, currentFragment, "" + menuItemId).commit();
|
||||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
} else { // otherwise show fragment
|
||||||
fragmentManager.beginTransaction().replace(R.id.fragment_content, fragment).commit();
|
fragmentManager.beginTransaction().show(currentFragment).commit();
|
||||||
|
}
|
||||||
|
|
||||||
// Set action bar title
|
// Set action bar title
|
||||||
setTitle(fragmentTitle);
|
setTitle(fragmentTitle);
|
||||||
@@ -468,10 +484,10 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i);
|
BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i);
|
||||||
//noinspection RestrictedApi
|
//noinspection RestrictedApi
|
||||||
item.setShiftingMode(false);
|
item.setShiftingMode(false);
|
||||||
item.setPadding(0, 15, 0, 0);
|
//item.setPadding(0, 15, 0, 0);
|
||||||
// set once again checked value, so view will be updated
|
// set once again checked value, so view will be updated
|
||||||
//noinspection RestrictedApi
|
//noinspection RestrictedApi
|
||||||
item.setChecked(item.getItemData().isChecked());
|
//item.setChecked(item.getItemData().isChecked());
|
||||||
}
|
}
|
||||||
} catch (NoSuchFieldException e) {
|
} catch (NoSuchFieldException e) {
|
||||||
Log.e("BNVHelper", "Unable to get shift mode field", e);
|
Log.e("BNVHelper", "Unable to get shift mode field", e);
|
||||||
|
After Width: | Height: | Size: 536 B |
After Width: | Height: | Size: 514 B |
After Width: | Height: | Size: 287 B |
After Width: | Height: | Size: 278 B |
After Width: | Height: | Size: 398 B |
After Width: | Height: | Size: 354 B |
After Width: | Height: | Size: 780 B |
After Width: | Height: | Size: 661 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.4 KiB |
@@ -1,8 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<group android:id="@+id/menu_top"
|
<group android:checkableBehavior="single">
|
||||||
android:checkableBehavior="single">
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/nav_overview"
|
android:id="@+id/nav_overview"
|
||||||
android:icon="@drawable/ic_preferences_home"
|
android:icon="@drawable/ic_preferences_home"
|
||||||
@@ -10,7 +8,7 @@
|
|||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/nav_graph"
|
android:id="@+id/nav_graph"
|
||||||
android:icon="@drawable/ic_preferences_graph"
|
android:icon="@drawable/ic_preferences_nav_graph"
|
||||||
android:title="@string/title_graph" />
|
android:title="@string/title_graph" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/nav_graph"
|
android:id="@+id/nav_graph"
|
||||||
android:icon="@drawable/ic_preferences_graph"
|
android:icon="@drawable/ic_preferences_nav_graph"
|
||||||
android:title="@string/title_graph" />
|
android:title="@string/title_graph" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
@@ -31,5 +31,10 @@
|
|||||||
android:id="@+id/nav_settings"
|
android:id="@+id/nav_settings"
|
||||||
android:icon="@drawable/ic_preferences_settings"
|
android:icon="@drawable/ic_preferences_settings"
|
||||||
android:title="@string/action_settings" />
|
android:title="@string/action_settings" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/nav_help"
|
||||||
|
android:icon="@drawable/ic_preferences_help"
|
||||||
|
android:title="@string/label_help" />
|
||||||
</group>
|
</group>
|
||||||
</menu>
|
</menu>
|
@@ -184,4 +184,5 @@
|
|||||||
<string name="info_app_restart_required">Um die Änderungen zu übernehmen, ist ein App Neustart erforderlich</string>
|
<string name="info_app_restart_required">Um die Änderungen zu übernehmen, ist ein App Neustart erforderlich</string>
|
||||||
<string name="label_share">Teilen</string>
|
<string name="label_share">Teilen</string>
|
||||||
<string name="label_bluetooth_searching_finished">Suche beendet nach Bluetooth Waagen</string>
|
<string name="label_bluetooth_searching_finished">Suche beendet nach Bluetooth Waagen</string>
|
||||||
|
<string name="label_help">Hilfe</string>
|
||||||
</resources>
|
</resources>
|
@@ -189,6 +189,7 @@
|
|||||||
<string name="label_regression_line">Regression weight line</string>
|
<string name="label_regression_line">Regression weight line</string>
|
||||||
<string name="label_regression_line_degree">Regression polynom degree</string>
|
<string name="label_regression_line_degree">Regression polynom degree</string>
|
||||||
<string name="label_goal_line">Goal line</string>
|
<string name="label_goal_line">Goal line</string>
|
||||||
|
<string name="label_help">Help</string>
|
||||||
|
|
||||||
<string name="label_feedback_message_enjoying">Enjoying openScale?</string>
|
<string name="label_feedback_message_enjoying">Enjoying openScale?</string>
|
||||||
<string name="label_feedback_message_rate_app">How about a rating on GooglePlay or on GitHub, then?</string>
|
<string name="label_feedback_message_rate_app">How about a rating on GooglePlay or on GitHub, then?</string>
|
||||||
|