From 350e26d64f8e24c278f22f0ba055ea75a3e3890f Mon Sep 17 00:00:00 2001 From: tom79 Date: Sun, 11 Jun 2017 11:58:46 +0200 Subject: [PATCH] Some improvements --- app/src/main/AndroidManifest.xml | 1 - .../mastodon/activities/HashTagActivity.java | 2 +- .../mastodon/activities/MainActivity.java | 44 ++++++++++++++----- .../gouv/etalab/mastodon/helper/Helper.java | 29 +++++++++++- app/src/main/res/anim/fadein.xml | 8 ++++ app/src/main/res/anim/fadeout.xml | 8 ++++ app/src/main/res/layout/activity_privacy.xml | 26 +++++++++++ app/src/main/res/values/strings.xml | 8 ++++ 8 files changed, 112 insertions(+), 14 deletions(-) create mode 100644 app/src/main/res/anim/fadein.xml create mode 100644 app/src/main/res/anim/fadeout.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7f3b7683e..5cd512436 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -77,7 +77,6 @@ 3 || currentScreen < 1) return super.dispatchTouchEvent(event); + switch(event.getAction()){ case MotionEvent.ACTION_DOWN: { downX = event.getX(); @@ -568,12 +592,12 @@ public class MainActivity extends AppCompatActivity float deltaX = downX - upX; float deltaY = downY - upY; // swipe horizontal - - if(Math.abs(deltaX) > MIN_DISTANCE && Math.abs(deltaY) < MIN_DISTANCE){ - DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); + if( downX > MIN_DISTANCE & (Math.abs(deltaX) > MIN_DISTANCE && Math.abs(deltaY) < MIN_DISTANCE)){ drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); if(deltaX < 0) { switchOnSwipe(actionSwipe.LEFT_TO_RIGHT); drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);return true; } if(deltaX > 0) { switchOnSwipe(actionSwipe.RIGHT_TO_LEFT); drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);return true; } + }else{ + currentAction = actionSwipe.POP; } } } diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java index 9ff3df229..f12fbd9e2 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java @@ -35,6 +35,7 @@ import android.net.NetworkInfo; import android.net.Uri; import android.os.AsyncTask; import android.os.Build; +import android.os.Bundle; import android.os.Environment; import android.support.design.widget.NavigationView; import android.support.v4.app.NotificationCompat; @@ -64,6 +65,7 @@ import java.util.Locale; import java.util.TimeZone; import fr.gouv.etalab.mastodon.activities.LoginActivity; +import fr.gouv.etalab.mastodon.activities.ShowAccountActivity; import fr.gouv.etalab.mastodon.asynctasks.RemoveAccountAsyncTask; import fr.gouv.etalab.mastodon.client.Entities.Account; import fr.gouv.etalab.mastodon.sqlite.AccountDAO; @@ -578,7 +580,17 @@ public class Helper { arrow.setImageResource(R.drawable.ic_arrow_drop_down); navigationView.getMenu().clear(); navigationView.inflateMenu(R.menu.activity_main_drawer); - + final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); + SQLiteDatabase db = Sqlite.getInstance(activity, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); + String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); + Account account = new AccountDAO(activity, db).getAccountByID(userId); + if( account != null) { + if (account.isLocked()) { + navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(true); + } else { + navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(false); + } + } } menuAccountsOpened = !menuAccountsOpened; @@ -626,7 +638,7 @@ public class Helper { * @param imageLoader ImageLoader - instance of ImageLoader * @param options DisplayImageOptions - current configuration of ImageLoader */ - public static void updateHeaderAccountInfo(Activity activity, Account account, View headerLayout, ImageLoader imageLoader, DisplayImageOptions options){ + public static void updateHeaderAccountInfo(final Activity activity, final Account account, View headerLayout, ImageLoader imageLoader, DisplayImageOptions options){ ImageView profilePicture = (ImageView) headerLayout.findViewById(R.id.profilePicture); TextView username = (TextView) headerLayout.findViewById(R.id.username); TextView displayedName = (TextView) headerLayout.findViewById(R.id.displayedName); @@ -647,5 +659,18 @@ public class Helper { displayedName.setText(account.getDisplay_name()); imageLoader.displayImage(account.getAvatar(), profilePicture, options); } + profilePicture.setOnClickListener(null); + profilePicture.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (account != null) { + Intent intent = new Intent(activity, ShowAccountActivity.class); + Bundle b = new Bundle(); + b.putString("accountId", account.getId()); + intent.putExtras(b); + activity.startActivity(intent); + } + } + }); } } diff --git a/app/src/main/res/anim/fadein.xml b/app/src/main/res/anim/fadein.xml new file mode 100644 index 000000000..40560da83 --- /dev/null +++ b/app/src/main/res/anim/fadein.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/fadeout.xml b/app/src/main/res/anim/fadeout.xml new file mode 100644 index 000000000..69e4eedb0 --- /dev/null +++ b/app/src/main/res/anim/fadeout.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_privacy.xml b/app/src/main/res/layout/activity_privacy.xml index fedd6508f..579920a7c 100644 --- a/app/src/main/res/layout/activity_privacy.xml +++ b/app/src/main/res/layout/activity_privacy.xml @@ -51,6 +51,32 @@ android:layout_height="wrap_content" /> + + + + + + + + + + Données enregistrées + + Seules les informations de base des comptes connectés sont enregistrées sur l\'appareil. + Ces données sont strictement confidentielles et ne sont utilisables que par l\'application. La suppression de l\'application entraîne immédiatement la suppression de ces données.\n + ⚠ Les identifiants et les mots de passe ne sont jamais enregistrés, ils ne sont utilisés que lors de l\'authentification sécurisée (SSL) vers l\'instance. + + + Autorisations de l\'application - ACCESS_NETWORK_STATE : Utilisée pour savoir si l\'appareil est connecté au WIFI.\n