1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-23 16:53:04 +02:00

- 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.
This commit is contained in:
OliE
2018-02-04 13:45:30 +01:00
parent 77486eb859
commit 7bff693926
17 changed files with 37 additions and 16 deletions

View File

@@ -66,13 +66,13 @@ import java.lang.reflect.Field;
import cat.ereza.customactivityoncrash.config.CaocConfig;
public class MainActivity extends AppCompatActivity {
private static boolean firstAppStart = true;
private static boolean valueOfCountModified = false;
private static int bluetoothStatusIcon = R.drawable.ic_bluetooth_disabled;
private static MenuItem bluetoothStatus;
private Fragment currentFragment;
private DrawerLayout drawerLayout;
private Toolbar toolbar;
private NavigationView navDrawer;
@@ -95,6 +95,8 @@ public class MainActivity extends AppCompatActivity {
setContentView(R.layout.activity_main);
currentFragment = null;
// Set a Toolbar to replace the ActionBar.
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
@@ -250,7 +252,6 @@ public class MainActivity extends AppCompatActivity {
public void selectDrawerItem(int menuItemId) {
// Create a new fragment and specify the fragment to show based on nav item clicked
Fragment fragment = null;
Class fragmentClass;
String fragmentTitle;
@@ -282,22 +283,37 @@ public class MainActivity extends AppCompatActivity {
settingsIntent.putExtra(SettingsActivity.EXTRA_TINT_COLOR, navDrawer.getItemTextColor().getDefaultColor());
startActivityForResult(settingsIntent, 1);
return;
case R.id.nav_help:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/oliexdev/openScale/wiki")));
return;
default:
fragmentClass = OverviewFragment.class;
fragmentTitle = getResources().getString(R.string.title_overview);
prefs.edit().putInt("lastFragmentId", menuItemId).commit();
}
try {
fragment = (Fragment) fragmentClass.newInstance();
FragmentManager fragmentManager = getSupportFragmentManager();
} catch (Exception e) {
e.printStackTrace();
// hide previous fragment if it available
if (currentFragment != null) {
fragmentManager.beginTransaction().hide(currentFragment).commit();
}
// Insert the fragment by replacing any existing fragment
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.fragment_content, fragment).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) {
e.printStackTrace();
}
fragmentManager.beginTransaction().add(R.id.fragment_content, currentFragment, "" + menuItemId).commit();
} else { // otherwise show fragment
fragmentManager.beginTransaction().show(currentFragment).commit();
}
// Set action bar title
setTitle(fragmentTitle);
@@ -468,10 +484,10 @@ public class MainActivity extends AppCompatActivity {
BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i);
//noinspection RestrictedApi
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
//noinspection RestrictedApi
item.setChecked(item.getItemData().isChecked());
//item.setChecked(item.getItemData().isChecked());
}
} catch (NoSuchFieldException e) {
Log.e("BNVHelper", "Unable to get shift mode field", e);

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 780 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:id="@+id/menu_top"
android:checkableBehavior="single">
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_overview"
android:icon="@drawable/ic_preferences_home"
@@ -10,7 +8,7 @@
<item
android:id="@+id/nav_graph"
android:icon="@drawable/ic_preferences_graph"
android:icon="@drawable/ic_preferences_nav_graph"
android:title="@string/title_graph" />
<item

View File

@@ -10,7 +10,7 @@
<item
android:id="@+id/nav_graph"
android:icon="@drawable/ic_preferences_graph"
android:icon="@drawable/ic_preferences_nav_graph"
android:title="@string/title_graph" />
<item
@@ -31,5 +31,10 @@
android:id="@+id/nav_settings"
android:icon="@drawable/ic_preferences_settings"
android:title="@string/action_settings" />
<item
android:id="@+id/nav_help"
android:icon="@drawable/ic_preferences_help"
android:title="@string/label_help" />
</group>
</menu>

View File

@@ -184,4 +184,5 @@
<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_bluetooth_searching_finished">Suche beendet nach Bluetooth Waagen</string>
<string name="label_help">Hilfe</string>
</resources>

View File

@@ -189,6 +189,7 @@
<string name="label_regression_line">Regression weight line</string>
<string name="label_regression_line_degree">Regression polynom degree</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_rate_app">How about a rating on GooglePlay or on GitHub, then?</string>