diff --git a/app/src/main/java/com/herbron/moodl/Activities/HomeActivity.java b/app/src/main/java/com/herbron/moodl/Activities/HomeActivity.java
index ad5ce1f..68e0d93 100644
--- a/app/src/main/java/com/herbron/moodl/Activities/HomeActivity.java
+++ b/app/src/main/java/com/herbron/moodl/Activities/HomeActivity.java
@@ -4,6 +4,7 @@ import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
+import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
@@ -19,11 +20,13 @@ import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.app.AppCompatDelegate;
import android.util.Log;
+import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;
import android.widget.CompoundButton;
+import android.widget.ImageView;
import android.widget.Switch;
import android.widget.TextView;
@@ -61,6 +64,8 @@ public class HomeActivity extends AppCompatActivity implements BalanceUpdateInte
private Fragment overviewFragment;
private Fragment currentFragment;
+ private DatabaseManager databaseManager;
+ private TextView alertTextView;
private BalanceSwitchManagerInterface switchInterface;
@@ -81,6 +86,7 @@ public class HomeActivity extends AppCompatActivity implements BalanceUpdateInte
drawerLayout = findViewById(R.id.drawer_layout);
NavigationView navigationView = findViewById(R.id.nav_view);
+ databaseManager = new DatabaseManager(this);
setListener((BalanceSwitchManagerInterface) holdingsFragment);
@@ -123,9 +129,35 @@ public class HomeActivity extends AppCompatActivity implements BalanceUpdateInte
}
});
+ setupSettingsAlert(navigationView);
+
setupBalanceSwitch();
}
+ private void setupSettingsAlert(NavigationView navigationView)
+ {
+ alertTextView = (TextView) navigationView.getMenu().findItem(R.id.navigation_settings).getActionView();
+ alertTextView.setTextColor(getResources().getColor(R.color.decreaseCandle));
+ alertTextView.setGravity(Gravity.CENTER);
+ alertTextView.setTypeface(null, Typeface.BOLD);
+
+ updateSettingsAlertNumber();
+ }
+
+ private void updateSettingsAlertNumber()
+ {
+ int disabledNumber = databaseManager.getDisabledExchangeAccountsNumber();
+
+ if(disabledNumber > 0)
+ {
+ alertTextView.setText(String.valueOf(disabledNumber));
+ }
+ else
+ {
+ alertTextView.setText("");
+ }
+ }
+
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void setStatusBarGradiant(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
@@ -197,6 +229,7 @@ public class HomeActivity extends AppCompatActivity implements BalanceUpdateInte
protected void onResume() {
super.onResume();
+ updateSettingsAlertNumber();
}
@Override
diff --git a/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java b/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java
index 5fbdf7e..3a5abf0 100644
--- a/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java
+++ b/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java
@@ -22,6 +22,7 @@ import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
+import android.preference.PreferenceScreen;
import android.preference.SwitchPreference;
import android.security.keystore.KeyGenParameterSpec;
import android.security.keystore.KeyPermanentlyInvalidatedException;
@@ -811,7 +812,16 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
}
});
- findPreference("exchange").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
+ DatabaseManager databaseManager = new DatabaseManager(getActivity().getBaseContext());
+ int disabledAcount = databaseManager.getDisabledExchangeAccountsNumber();
+ PreferenceScreen preferenceScreen = (PreferenceScreen) findPreference("exchange");
+
+ if(disabledAcount > 0)
+ {
+ preferenceScreen.setWidgetLayoutResource(R.layout.alert_layout);
+ }
+
+ preferenceScreen.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/DatabaseManager.java b/app/src/main/java/com/herbron/moodl/DataManagers/DatabaseManager.java
index 2d073a3..053ba92 100644
--- a/app/src/main/java/com/herbron/moodl/DataManagers/DatabaseManager.java
+++ b/app/src/main/java/com/herbron/moodl/DataManagers/DatabaseManager.java
@@ -211,6 +211,17 @@ public class DatabaseManager extends SQLiteOpenHelper{
return result.getInt(0);
}
+ public int getDisabledExchangeAccountsNumber()
+ {
+ SQLiteDatabase db = this.getWritableDatabase();
+ String countQuerry = "SELECT COUNT() FROM " + TABLE_EXCHANGE_KEYS + " WHERE " + KEY_EXCHANGE_IS_ENABLED + "=0";
+ Cursor result = db.rawQuery(countQuerry, null);
+
+ result.moveToFirst();
+
+ return result.getInt(0);
+ }
+
public void deleteExchangeAccountFromId(int id)
{
SQLiteDatabase db = this.getWritableDatabase();
diff --git a/app/src/main/res/layout/alert_layout.xml b/app/src/main/res/layout/alert_layout.xml
new file mode 100644
index 0000000..71e40bb
--- /dev/null
+++ b/app/src/main/res/layout/alert_layout.xml
@@ -0,0 +1,6 @@
+
+