#834 Improve files ui and bug fix encoding in names

Merged
opyale merged 4 commits from files-ui-improvement into master 2 months ago
  1. +2
    -1
      app/src/main/java/org/mian/gitnex/activities/MainActivity.java
  2. +1
    -1
      app/src/main/java/org/mian/gitnex/activities/OrganizationDetailActivity.java
  3. +6
    -1
      app/src/main/java/org/mian/gitnex/adapters/AdminGetUsersAdapter.java
  4. +4
    -1
      app/src/main/java/org/mian/gitnex/adapters/CollaboratorsAdapter.java
  5. +16
    -21
      app/src/main/java/org/mian/gitnex/adapters/FilesAdapter.java
  6. +4
    -1
      app/src/main/java/org/mian/gitnex/adapters/MembersByOrgAdapter.java
  7. +4
    -1
      app/src/main/java/org/mian/gitnex/adapters/ProfileFollowersAdapter.java
  8. +4
    -1
      app/src/main/java/org/mian/gitnex/adapters/ProfileFollowingAdapter.java
  9. +6
    -3
      app/src/main/java/org/mian/gitnex/adapters/TeamMembersByOrgAdapter.java
  10. +7
    -4
      app/src/main/java/org/mian/gitnex/adapters/UserSearchAdapter.java
  11. +6
    -1
      app/src/main/java/org/mian/gitnex/adapters/UserSearchForTeamMemberAdapter.java
  12. +2
    -1
      app/src/main/java/org/mian/gitnex/fragments/ProfileFragment.java
  13. +38
    -62
      app/src/main/res/layout/list_files.xml

+ 2
- 1
app/src/main/java/org/mian/gitnex/activities/MainActivity.java View File

@ -5,6 +5,7 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
@ -268,7 +269,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
if(!userFullNameNav.equals("")) {
userFullName.setText(userFullNameNav);
userFullName.setText(Html.fromHtml(userFullNameNav));
}
if(!userAvatarNav.equals("")) {


+ 1
- 1
app/src/main/java/org/mian/gitnex/activities/OrganizationDetailActivity.java View File

@ -212,7 +212,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
@Override
public int getCount() {
return 4;
return 5;
}
}
}

+ 6
- 1
app/src/main/java/org/mian/gitnex/adapters/AdminGetUsersAdapter.java View File

@ -1,6 +1,7 @@
package org.mian.gitnex.adapters;
import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -68,18 +69,22 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<AdminGetUsersAdap
UserInfo currentItem = usersList.get(position);
if(!currentItem.getFullname().equals("")) {
holder.userFullName.setText(currentItem.getFullname());
holder.userFullName.setText(Html.fromHtml(currentItem.getFullname()));
holder.userName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
}
else {
holder.userFullName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
holder.userName.setVisibility(View.GONE);
}
if(!currentItem.getEmail().equals("")) {
holder.userEmail.setText(currentItem.getEmail());
}
else {
holder.userEmail.setVisibility(View.GONE);
}


+ 4
- 1
app/src/main/java/org/mian/gitnex/adapters/CollaboratorsAdapter.java View File

@ -2,6 +2,7 @@ package org.mian.gitnex.adapters;
import android.annotation.SuppressLint;
import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -80,9 +81,11 @@ public class CollaboratorsAdapter extends BaseAdapter {
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(180, 180).centerCrop().into(viewHolder.collaboratorAvatar);
if(!currentItem.getFull_name().equals("")) {
viewHolder.collaboratorName.setText(currentItem.getFull_name());
viewHolder.collaboratorName.setText(Html.fromHtml(currentItem.getFull_name()));
}
else {
viewHolder.collaboratorName.setText(currentItem.getLogin());
}


+ 16
- 21
app/src/main/java/org/mian/gitnex/adapters/FilesAdapter.java View File

@ -9,6 +9,7 @@ import android.widget.Filterable;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.recyclerview.widget.RecyclerView;
import org.apache.commons.io.FileUtils;
import org.gitnex.tea4j.models.Files;
@ -26,7 +27,7 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
private final List<Files> originalFiles = new ArrayList<>();
private final List<Files> alteredFiles = new ArrayList<>();
private Context mCtx;
private final Context mCtx;
private final FilesAdapterListener filesListener;
@ -37,21 +38,18 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
class FilesViewHolder extends RecyclerView.ViewHolder {
private final ImageView fileTypeImage;
private final ImageView dirTypeImage;
private final ImageView unknownTypeImage;
private String fileType;
private final ImageView fileTypeIs;
private final TextView fileName;
private final TextView fileType;
private final TextView fileInfo;
private FilesViewHolder(View itemView) {
super(itemView);
fileName = itemView.findViewById(R.id.fileName);
fileTypeImage = itemView.findViewById(R.id.fileImage);
dirTypeImage = itemView.findViewById(R.id.dirImage);
unknownTypeImage = itemView.findViewById(R.id.unknownImage);
fileType = itemView.findViewById(R.id.fileType);
fileTypeIs = itemView.findViewById(R.id.fileTypeIs);
fileInfo = itemView.findViewById(R.id.fileInfo);
//ImageView filesDropdownMenu = itemView.findViewById(R.id.filesDropdownMenu);
@ -60,10 +58,10 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
Context context = v.getContext();
if(fileType.getText().toString().equals("file")) {
if(fileType.equals("file")) {
filesListener.onClickFile(fileName.getText().toString());
}
else if(fileType.getText().toString().equals("dir")) {
else if(fileType.equals("dir")) {
filesListener.onClickDir(fileName.getText().toString());
}
else {
@ -171,26 +169,23 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
Files currentItem = alteredFiles.get(position);
holder.fileType.setText(currentItem.getType());
holder.fileType = currentItem.getType();
holder.fileName.setText(currentItem.getName());
if(currentItem.getType().equals("file")) {
holder.fileTypeImage.setVisibility(View.VISIBLE);
holder.dirTypeImage.setVisibility(View.GONE);
holder.unknownTypeImage.setVisibility(View.GONE);
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(mCtx, R.drawable.ic_file));
holder.fileInfo.setVisibility(View.VISIBLE);
holder.fileInfo.setText(FileUtils.byteCountToDisplaySize(currentItem.getSize()));
}
else if(currentItem.getType().equals("dir")) {
holder.dirTypeImage.setVisibility(View.VISIBLE);
holder.unknownTypeImage.setVisibility(View.GONE);
holder.fileTypeImage.setVisibility(View.GONE);
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(mCtx, R.drawable.ic_directory));
holder.fileInfo.setVisibility(View.GONE);
}
else {
holder.unknownTypeImage.setVisibility(View.VISIBLE);
holder.dirTypeImage.setVisibility(View.GONE);
holder.fileTypeImage.setVisibility(View.GONE);
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(mCtx, R.drawable.ic_question));
}
}


+ 4
- 1
app/src/main/java/org/mian/gitnex/adapters/MembersByOrgAdapter.java View File

@ -2,6 +2,7 @@ package org.mian.gitnex.adapters;
import android.annotation.SuppressLint;
import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -86,9 +87,11 @@ public class MembersByOrgAdapter extends BaseAdapter implements Filterable {
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(viewHolder.memberAvatar);
if(!currentItem.getFullname().equals("")) {
viewHolder.memberName.setText(currentItem.getFullname());
viewHolder.memberName.setText(Html.fromHtml(currentItem.getFullname()));
}
else {
viewHolder.memberName.setText(currentItem.getLogin());
}


+ 4
- 1
app/src/main/java/org/mian/gitnex/adapters/ProfileFollowersAdapter.java View File

@ -1,6 +1,7 @@
package org.mian.gitnex.adapters;
import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -57,10 +58,12 @@ public class ProfileFollowersAdapter extends RecyclerView.Adapter<ProfileFollowe
UserInfo currentItem = followersList.get(position);
if(!currentItem.getFullname().equals("")) {
holder.userFullName.setText(currentItem.getFullname());
holder.userFullName.setText(Html.fromHtml(currentItem.getFullname()));
holder.userName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
}
else {
holder.userFullName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
holder.userName.setVisibility(View.GONE);
}


+ 4
- 1
app/src/main/java/org/mian/gitnex/adapters/ProfileFollowingAdapter.java View File

@ -1,6 +1,7 @@
package org.mian.gitnex.adapters;
import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -57,10 +58,12 @@ public class ProfileFollowingAdapter extends RecyclerView.Adapter<ProfileFollowi
UserInfo currentItem = followingList.get(position);
if(!currentItem.getFullname().equals("")) {
holder.userFullName.setText(currentItem.getFullname());
holder.userFullName.setText(Html.fromHtml(currentItem.getFullname()));
holder.userName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
}
else {
holder.userFullName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
holder.userName.setVisibility(View.GONE);
}


+ 6
- 3
app/src/main/java/org/mian/gitnex/adapters/TeamMembersByOrgAdapter.java View File

@ -3,6 +3,7 @@ package org.mian.gitnex.adapters;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Typeface;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -102,13 +103,15 @@ public class TeamMembersByOrgAdapter extends BaseAdapter {
}
if(!currentItem.getFullname().equals("")) {
viewHolder.memberName.setText(currentItem.getFullname());
viewHolder.memberName.setTypeface(myTypeface);
viewHolder.memberName.setText(Html.fromHtml(currentItem.getFullname()));
}
else {
viewHolder.memberName.setText(currentItem.getLogin());
viewHolder.memberName.setTypeface(myTypeface);
}
viewHolder.memberName.setTypeface(myTypeface);
}
}

+ 7
- 4
app/src/main/java/org/mian/gitnex/adapters/UserSearchAdapter.java View File

@ -2,6 +2,7 @@ package org.mian.gitnex.adapters;
import android.content.Context;
import android.content.DialogInterface;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@ -132,15 +133,17 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
holder.userNameMain.setText(currentItem.getUsername());
if (!currentItem.getFullname().equals("")) {
holder.userFullName.setText(currentItem.getFullname());
holder.userName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
holder.userFullName.setText(Html.fromHtml(currentItem.getFullname()));
}
else {
holder.userFullName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
holder.userName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
}
if (!currentItem.getAvatar().equals("")) {
holder.userName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
if (!currentItem.getAvatar().equals("")) {
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
}


+ 6
- 1
app/src/main/java/org/mian/gitnex/adapters/UserSearchForTeamMemberAdapter.java View File

@ -1,6 +1,7 @@
package org.mian.gitnex.adapters;
import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -103,11 +104,15 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
holder.teamId_.setText(String.valueOf(teamId));
if (!currentItem.getFullname().equals("")) {
holder.userFullName.setText(currentItem.getFullname());
holder.userFullName.setText(Html.fromHtml(currentItem.getFullname()));
}
else {
holder.userFullName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
}
holder.userName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
if (!currentItem.getAvatar().equals("")) {


+ 2
- 1
app/src/main/java/org/mian/gitnex/fragments/ProfileFragment.java View File

@ -4,6 +4,7 @@ import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@ -75,7 +76,7 @@ public class ProfileFragment extends Fragment {
userLanguage.setText(R.string.notSupported);
}
userFullName.setText(tinyDb.getString("userFullname"));
userFullName.setText(Html.fromHtml(tinyDb.getString("userFullname")));
userLogin.setText(getString(R.string.usernameWithAt, tinyDb.getString("userLogin")));
PicassoService.getInstance(ctx).get()


+ 38
- 62
app/src/main/res/layout/list_files.xml View File

@ -1,91 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayoutFilesFrame"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:background="?attr/primaryBackgroundColor">
android:background="?attr/primaryBackgroundColor"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/fileType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible" />
<RelativeLayout
android:id="@+id/imageTypes"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/fileImage"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_marginEnd="15dp"
android:contentDescription="@string/generalImgContentText"
android:visibility="gone"
android:src="@drawable/ic_file" />
<ImageView
android:id="@+id/dirImage"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_marginEnd="15dp"
android:contentDescription="@string/generalImgContentText"
android:visibility="gone"
android:src="@drawable/ic_directory" />
<ImageView
android:id="@+id/unknownImage"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_marginEnd="15dp"
android:contentDescription="@string/generalImgContentText"
android:visibility="gone"
android:src="@drawable/ic_question" />
</RelativeLayout>
<ImageView
android:id="@+id/fileTypeIs"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_marginEnd="15dp"
android:contentDescription="@string/generalImgContentText"
android:src="@drawable/ic_file" />
<LinearLayout
android:id="@+id/infoSection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/imageTypes"
android:orientation="horizontal">
android:orientation="vertical">
<TextView
android:id="@+id/fileName"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".80"
android:layout_marginBottom="0dp"
android:text="@string/defaultFilename"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp" />
<TextView
android:id="@+id/fileInfo"
android:layout_width="0dp"
<LinearLayout
android:id="@+id/infoRow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".20"
android:layout_marginBottom="0dp"
android:text="@string/sizeCopy"
android:visibility="gone"
android:textColor="?attr/primaryTextColor"
android:textSize="12sp" />
android:orientation="horizontal">
<TextView
android:id="@+id/fileInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sizeCopy"
android:textColor="?attr/primaryTextColor"
android:textSize="12sp"
android:visibility="gone"
tools:visibility="visible" />
</LinearLayout>
<!--
<ImageView
android:id="@+id/filesDropdownMenu"
android:layout_width="0dp"
android:layout_weight=".0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:contentDescription="@string/menuContentDesc"
android:scaleType="fitEnd"
android:visibility="gone"
android:src="@drawable/ic_dotted_menu_horizontal"
android:contentDescription="@string/menuContentDesc" />
android:visibility="gone" />
-->
</LinearLayout>
</RelativeLayout>
</LinearLayout>

Loading…
Cancel
Save