From ee8e57fbc3de7ef133538ba44b2cdb7a1e022af7 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Thu, 22 Nov 2018 17:51:17 +0200 Subject: [PATCH] Minor fixes e.g. Avoid showing consent dialog more than once --- .../gr/thmmy/mthmmy/activities/main/MainActivity.java | 1 + app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java | 8 ++++++-- app/src/main/res/layout/activity_board_sub_board_row.xml | 5 ++--- app/src/main/res/layout/activity_board_topic_row.xml | 7 ++++--- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java index a9842f9c..af1a4cf2 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java @@ -79,6 +79,7 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF startActivity(intent); finish(); overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out); + return; //Avoid executing the code below } //Initialize drawer diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java index 74dda5ee..b953c032 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java @@ -99,6 +99,7 @@ public abstract class BaseActivity extends AppCompatActivity { private MainActivity mainActivity; private boolean isMainActivity; + private boolean isUserConsentDialogShown; //Needed because sometimes onResume is being called twice @Override protected void onCreate(Bundle savedInstanceState) { @@ -128,8 +129,10 @@ public abstract class BaseActivity extends AppCompatActivity { protected void onResume() { super.onResume(); updateDrawer(); - if (!sharedPreferences.getBoolean(getString(R.string.user_consent_shared_preference_key), false)) + if (!sharedPreferences.getBoolean(getString(R.string.user_consent_shared_preference_key), false) && !isUserConsentDialogShown){ + isUserConsentDialogShown=true; showUserConsentDialog(); + } } @Override @@ -389,7 +392,7 @@ public abstract class BaseActivity extends AppCompatActivity { if (!sessionManager.isLoggedIn()) //When logged out or if user is guest startLoginActivity(); else - new LogoutTask().execute(); + new LogoutTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); //Avoid delays between onPreExecute() and doInBackground() } else if (drawerItem.equals(ABOUT_ID)) { if (!(BaseActivity.this instanceof AboutActivity)) { Intent intent = new Intent(BaseActivity.this, AboutActivity.class); @@ -496,6 +499,7 @@ public abstract class BaseActivity extends AppCompatActivity { if (mainActivity != null) mainActivity.updateTabs(); progressDialog.dismiss(); + //TODO: Redirect to Main only for some Activities (e.g. Topic, Board, Downloads) //if (BaseActivity.this instanceof TopicActivity){ Intent intent = new Intent(BaseActivity.this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); diff --git a/app/src/main/res/layout/activity_board_sub_board_row.xml b/app/src/main/res/layout/activity_board_sub_board_row.xml index 880ae31d..bcbe3ec7 100644 --- a/app/src/main/res/layout/activity_board_sub_board_row.xml +++ b/app/src/main/res/layout/activity_board_sub_board_row.xml @@ -20,8 +20,6 @@ diff --git a/app/src/main/res/layout/activity_board_topic_row.xml b/app/src/main/res/layout/activity_board_topic_row.xml index 6c816409..0c9207bf 100644 --- a/app/src/main/res/layout/activity_board_topic_row.xml +++ b/app/src/main/res/layout/activity_board_topic_row.xml @@ -15,8 +15,6 @@ @@ -37,7 +37,8 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_weight="1" - android:paddingBottom="2dp" + android:paddingTop="5dp" + android:paddingBottom="7dp" android:text="@string/topic_subject" android:textColor="@color/primary_text" android:textSize="18sp" />