diff --git a/app/build.gradle b/app/build.gradle index 272c767ed..1273fd41b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "fr.gouv.etalab.mastodon" minSdkVersion 15 targetSdkVersion 27 - versionCode 127 - versionName "1.10.3" + versionCode 128 + versionName "1.10.4-beta-1" } flavorDimensions "default" buildTypes { @@ -24,7 +24,10 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } - + lintOptions { + checkReleaseBuilds false + abortOnError false + } productFlavors { fdroid { } diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java index cfc3d685f..f363358aa 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java @@ -1583,32 +1583,68 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct }); - holder.status_account_profile.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { + if( type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE) { + holder.status_account_profile.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { - if( targetedId == null || !targetedId.equals(status.getAccount().getId())){ - Intent intent = new Intent(context, ShowAccountActivity.class); - Bundle b = new Bundle(); - b.putString("accountId", status.getAccount().getId()); - intent.putExtras(b); - context.startActivity(intent); + if (targetedId == null || !targetedId.equals(status.getAccount().getId())) { + Intent intent = new Intent(context, ShowAccountActivity.class); + Bundle b = new Bundle(); + b.putString("accountId", status.getAccount().getId()); + intent.putExtras(b); + context.startActivity(intent); + } } - } - }); + }); - holder.status_account_profile_boost.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if( targetedId == null || !targetedId.equals(status.getReblog().getAccount().getId())){ - Intent intent = new Intent(context, ShowAccountActivity.class); - Bundle b = new Bundle(); - b.putString("accountId", status.getReblog().getAccount().getId()); - intent.putExtras(b); - context.startActivity(intent); + holder.status_account_profile_boost.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (targetedId == null || !targetedId.equals(status.getReblog().getAccount().getId())) { + Intent intent = new Intent(context, ShowAccountActivity.class); + Bundle b = new Bundle(); + b.putString("accountId", status.getReblog().getAccount().getId()); + intent.putExtras(b); + context.startActivity(intent); + } } - } - }); + }); + }else{ + holder.status_account_profile.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + if (targetedId == null || !targetedId.equals(status.getAccount().getId())) { + Account account = status.getAccount(); + Pattern instanceHost = Pattern.compile("https?:\\/\\/([\\da-z\\.-]+\\.[a-z\\.]{2,6})"); + Matcher matcher = instanceHost.matcher(status.getUrl()); + String instance = null; + while (matcher.find()){ + instance = matcher.group(1); + } + account.setInstance(instance); + CrossActions.doCrossProfile(context, account); + } + } + }); + holder.status_account_profile_boost.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (targetedId == null || !targetedId.equals(status.getReblog().getAccount().getId())) { + Account account = status.getReblog().getAccount(); + Pattern instanceHost = Pattern.compile("https?:\\/\\/([\\da-z\\.-]+\\.[a-z\\.]{2,6})"); + Matcher matcher = instanceHost.matcher(status.getUrl()); + String instance = null; + while (matcher.find()){ + instance = matcher.group(1); + } + account.setInstance(instance); + CrossActions.doCrossProfile(context, account); + } + } + }); + } if( status.getApplication() != null && getItemViewType(position) == FOCUSED_STATUS){ Application application = status.getApplication(); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/helper/CrossActions.java b/app/src/main/java/fr/gouv/etalab/mastodon/helper/CrossActions.java index 4bf90479f..ed3402696 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/helper/CrossActions.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/helper/CrossActions.java @@ -33,10 +33,12 @@ import java.util.List; import fr.gouv.etalab.mastodon.activities.BaseActivity; import fr.gouv.etalab.mastodon.activities.MainActivity; +import fr.gouv.etalab.mastodon.activities.ShowAccountActivity; import fr.gouv.etalab.mastodon.activities.ShowConversationActivity; import fr.gouv.etalab.mastodon.activities.TootActivity; import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask; import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask; +import fr.gouv.etalab.mastodon.asynctasks.RetrieveRemoteDataAsyncTask; import fr.gouv.etalab.mastodon.client.API; import fr.gouv.etalab.mastodon.client.Entities.Account; import fr.gouv.etalab.mastodon.client.Entities.Mention; @@ -196,6 +198,38 @@ public class CrossActions { } + public static void doCrossProfile(final Context context, Account remoteAccount){ + SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE); + String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); + SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); + Account account = new AccountDAO(context, db).getAccountByID(userId); + new AsyncTask() { + private WeakReference contextReference = new WeakReference<>(context); + Results response; + @Override + protected Void doInBackground(Void... voids) { + API api = new API(contextReference.get(), account.getInstance(), account.getToken()); + String url = "@" + remoteAccount.getAcct() + "@" + remoteAccount.getInstance(); + response = api.search(url); + return null; + } + @Override + protected void onPostExecute(Void result) { + List remoteAccounts = response.getAccounts(); + if( remoteAccounts != null && remoteAccounts.size() > 0) { + Intent intent = new Intent(context, ShowAccountActivity.class); + Bundle b = new Bundle(); + b.putString("accountId", remoteAccounts.get(0).getId()); + intent.putExtras(b); + context.startActivity(intent); + } + } + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR ); + } + + + + public static void doCrossReply(final Context context, final Status status, final RetrieveFeedsAsyncTask.Type type, boolean limitedToOwner){ List accounts = connectedAccounts(context, status, limitedToOwner);