Some improvements

This commit is contained in:
tom79 2019-12-18 09:26:21 +01:00
parent 2c60c9d2cf
commit 940c1aa104
6 changed files with 92 additions and 60 deletions

View File

@ -32,7 +32,7 @@ import android.text.Spanned;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.text.style.ForegroundColorSpan; import android.text.style.ForegroundColorSpan;
import android.text.style.UnderlineSpan; import android.text.style.UnderlineSpan;
import android.util.Log; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -52,6 +52,8 @@ import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter; import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager;
@ -73,7 +75,6 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import app.fedilab.android.R; import app.fedilab.android.R;
import app.fedilab.android.asynctasks.DeleteDomainsAsyncTask;
import app.fedilab.android.asynctasks.ManageListsAsyncTask; import app.fedilab.android.asynctasks.ManageListsAsyncTask;
import app.fedilab.android.asynctasks.PostActionAsyncTask; import app.fedilab.android.asynctasks.PostActionAsyncTask;
import app.fedilab.android.asynctasks.RetrieveAccountAsyncTask; import app.fedilab.android.asynctasks.RetrieveAccountAsyncTask;
@ -95,7 +96,7 @@ import app.fedilab.android.client.Entities.RemoteInstance;
import app.fedilab.android.client.Entities.Status; import app.fedilab.android.client.Entities.Status;
import app.fedilab.android.client.Entities.UserNote; import app.fedilab.android.client.Entities.UserNote;
import app.fedilab.android.client.HttpsConnection; import app.fedilab.android.client.HttpsConnection;
import app.fedilab.android.drawers.DomainsListAdapter; import app.fedilab.android.drawers.IdentityProofsAdapter;
import app.fedilab.android.drawers.StatusListAdapter; import app.fedilab.android.drawers.StatusListAdapter;
import app.fedilab.android.fragments.DisplayAccountsFragment; import app.fedilab.android.fragments.DisplayAccountsFragment;
import app.fedilab.android.fragments.DisplayStatusFragment; import app.fedilab.android.fragments.DisplayStatusFragment;
@ -1568,19 +1569,14 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
identity_proofs_indicator.setOnClickListener(v -> { identity_proofs_indicator.setOnClickListener(v -> {
AlertDialog.Builder builder = new AlertDialog.Builder(ShowAccountActivity.this, style); AlertDialog.Builder builder = new AlertDialog.Builder(ShowAccountActivity.this, style);
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(ShowAccountActivity.this, android.R.layout.select_dialog_item); LayoutInflater inflater = getLayoutInflater();
for (IdentityProof identityProof: identityProofs) { View identityProofsView = inflater.inflate(R.layout.popup_identity_proof, new LinearLayout(ShowAccountActivity.this), false);
arrayAdapter.add(String.format("✅ @%s \uD83D\uDD17 %s", identityProof.getProvider_username(), identityProof.getProvider() )); RecyclerView identityProofsRecycler = identityProofsView.findViewById(R.id.identity_proofs_list);
} LinearLayoutManager mLayoutManager = new LinearLayoutManager(ShowAccountActivity.this);
builder.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { identityProofsRecycler.setLayoutManager(mLayoutManager);
@Override IdentityProofsAdapter identityProofsAdapter = new IdentityProofsAdapter(identityProofs);
public void onClick(DialogInterface dialog, int position) { identityProofsRecycler.setAdapter(identityProofsAdapter);
if( identityProofs.size() > position ) { builder.setView(identityProofsView);
String url = identityProofs.get(position).getProfile_url();
Helper.openBrowser(ShowAccountActivity.this, url);
}
}
});
builder builder
.setTitle(R.string.identity_proofs) .setTitle(R.string.identity_proofs)
.setPositiveButton(R.string.close, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {

View File

@ -15,38 +15,34 @@ package app.fedilab.android.drawers;
* see <http://www.gnu.org/licenses>. */ * see <http://www.gnu.org/licenses>. */
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import app.fedilab.android.R; import app.fedilab.android.R;
import app.fedilab.android.activities.HashTagActivity; import app.fedilab.android.client.Entities.IdentityProof;
import app.fedilab.android.helper.Helper;
/** /**
* Created by Thomas on 31/03/2019. * Created by Thomas on 19/12/2019.
* Adapter for tags results * Adapter for identity proofs
*/ */
public class SearchTagsAdapter extends RecyclerView.Adapter { public class IdentityProofsAdapter extends RecyclerView.Adapter {
private Context context; private Context context;
private List<String> tags; private List<IdentityProof> identityProofs;
public SearchTagsAdapter(List<String> tags) { public IdentityProofsAdapter(List<IdentityProof> identityProofs) {
this.tags = (tags != null) ? tags : new ArrayList<>(); this.identityProofs = identityProofs;
} }
public String getItem(int position) { public IdentityProof getItem(int position) {
return tags.get(position); return identityProofs.get(position);
} }
@NonNull @NonNull
@ -54,26 +50,22 @@ public class SearchTagsAdapter extends RecyclerView.Adapter {
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) { public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
context = parent.getContext(); context = parent.getContext();
LayoutInflater layoutInflater = LayoutInflater.from(context); LayoutInflater layoutInflater = LayoutInflater.from(context);
return new ViewHolder(layoutInflater.inflate(R.layout.drawer_tag_search_tab, parent, false)); return new ViewHolder(layoutInflater.inflate(R.layout.drawer_identity_proofs, parent, false));
} }
@Override @Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) { public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
final ViewHolder holder = (ViewHolder) viewHolder; final ViewHolder holder = (ViewHolder) viewHolder;
final String tag = getItem(i); final IdentityProof identityProof = getItem(i);
holder.proof_name.setText(String.format("@%s", identityProof.getProvider_username()));
holder.tag_name.setText(String.format("#%s", tag)); holder.proof_name.setOnClickListener(v -> {
holder.tag_name.setOnClickListener(new View.OnClickListener() { Helper.openBrowser(context, identityProof.getProfile_url());
@Override
public void onClick(View v) {
Intent intent = new Intent(context, HashTagActivity.class);
Bundle b = new Bundle();
b.putString("tag", tag.trim());
intent.putExtras(b);
context.startActivity(intent);
}
}); });
holder.proof_name_network.setText(context.getString(R.string.verified_by, identityProof.getProvider()));
holder.proof_container.setOnClickListener(v -> {
Helper.openBrowser(context, identityProof.getProof_url());
});
holder.proof_date.setText(Helper.shortDateToString(identityProof.getUpdated_at()));
} }
@Override @Override
@ -83,15 +75,19 @@ public class SearchTagsAdapter extends RecyclerView.Adapter {
@Override @Override
public int getItemCount() { public int getItemCount() {
return tags.size(); return identityProofs.size();
} }
class ViewHolder extends RecyclerView.ViewHolder { class ViewHolder extends RecyclerView.ViewHolder {
private TextView tag_name; private TextView proof_name, proof_name_network, proof_date;
private LinearLayout proof_container;
public ViewHolder(@NonNull View itemView) { public ViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
tag_name = itemView.findViewById(R.id.tag_name); proof_name = itemView.findViewById(R.id.proof_name);
proof_name_network = itemView.findViewById(R.id.proof_name_network);
proof_container = itemView.findViewById(R.id.proof_container);
proof_date = itemView.findViewById(R.id.proof_date);
} }
} }

View File

@ -237,7 +237,7 @@
android:layout_width="45dp" android:layout_width="45dp"
android:layout_height="45dp" android:layout_height="45dp"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:contentDescription="Identity proofs" android:contentDescription="@string/identity_proofs"
android:padding="8dp" android:padding="8dp"
android:scaleType="fitCenter" android:scaleType="fitCenter"
android:src="@drawable/ic_verified_user" android:src="@drawable/ic_verified_user"

View File

@ -14,12 +14,50 @@
You should have received a copy of the GNU General Public License along with Fedilab; if not, You should have received a copy of the GNU General Public License along with Fedilab; if not,
see <http://www.gnu.org/licenses>. see <http://www.gnu.org/licenses>.
--> -->
<androidx.recyclerview.widget.RecyclerView <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/identity_proofs_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin" android:orientation="horizontal">
xmlns:android="http://schemas.android.com/apk/res/android" <ImageView
/> android:layout_margin="10dp"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:src="@drawable/ic_verified_user"
android:contentDescription="@string/verified_user" />
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_marginStart="10dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/proof_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp" />
<LinearLayout
android:id="@+id/proof_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/proof_name_network"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<TextView
android:layout_marginTop="10dp"
android:id="@+id/proof_date"
android:textStyle="italic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.recyclerview.widget.RecyclerView
android:orientation="vertical" android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"> android:layout_width="match_parent"
android:id="@+id/identity_proofs_list"
</LinearLayout> android:layout_height="wrap_content"/>

View File

@ -1209,4 +1209,6 @@
<string name="twitter_accounts">Twitter accounts (via Nitter)</string> <string name="twitter_accounts">Twitter accounts (via Nitter)</string>
<string name="list_of_twitter_accounts">Twitter usernames space separated</string> <string name="list_of_twitter_accounts">Twitter usernames space separated</string>
<string name="identity_proofs">Identity proofs</string> <string name="identity_proofs">Identity proofs</string>
<string name="verified_user">Verified identity</string>
<string name="verified_by">Verified by %1$s</string>
</resources> </resources>