From e4cd1e147bd326133cd8d525054f1a132ddbf040 Mon Sep 17 00:00:00 2001 From: M M Arif Date: Fri, 12 Aug 2022 04:01:51 +0200 Subject: [PATCH] New UI for profile screens (#1183) As title. It is part of the ongoing UI enhancements from M3 and will continue in the next few releases to overhaul the app. Co-authored-by: M M Arif Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1183 --- .../activities/AddNewAccountActivity.java | 25 ++- .../mian/gitnex/activities/LoginActivity.java | 29 ++-- .../mian/gitnex/activities/MainActivity.java | 10 +- .../activities/SettingsGeneralActivity.java | 4 + .../mian/gitnex/activities/WikiActivity.java | 11 +- .../fragments/MyProfileEmailsFragment.java | 4 - .../fragments/MyProfileFollowersFragment.java | 3 - .../fragments/MyProfileFollowingFragment.java | 3 - .../gitnex/fragments/MyProfileFragment.java | 2 +- .../org/mian/gitnex/helpers/ChangeLog.java | 16 +- .../res/layout/activity_add_new_account.xml | 4 +- .../main/res/layout/activity_create_file.xml | 4 +- .../main/res/layout/activity_create_issue.xml | 4 +- .../main/res/layout/activity_create_label.xml | 4 +- .../res/layout/activity_create_milestone.xml | 4 +- .../res/layout/activity_create_new_user.xml | 4 +- .../layout/activity_create_organization.xml | 4 +- .../main/res/layout/activity_create_pr.xml | 4 +- .../res/layout/activity_create_release.xml | 8 +- .../main/res/layout/activity_create_repo.xml | 4 +- .../layout/activity_create_team_by_org.xml | 4 +- .../main/res/layout/activity_deeplinks.xml | 37 +++-- .../main/res/layout/activity_edit_issue.xml | 4 +- app/src/main/res/layout/activity_login.xml | 5 +- .../layout/activity_merge_pull_request.xml | 4 +- .../res/layout/activity_profile_email.xml | 4 +- .../main/res/layout/custom_about_dialog.xml | 4 +- .../custom_assignees_selection_dialog.xml | 1 - .../custom_pr_update_strategy_dialog.xml | 10 +- .../custom_repository_delete_dialog.xml | 4 +- ...stom_repository_edit_properties_dialog.xml | 4 +- .../custom_repository_transfer_dialog.xml | 4 +- .../layout/custom_user_accounts_dialog.xml | 4 +- app/src/main/res/layout/fragment_profile.xml | 137 +++++++++++------ .../res/layout/fragment_profile_detail.xml | 145 ++++++++++-------- .../res/layout/fragment_profile_emails.xml | 7 +- .../fragment_profile_followers_following.xml | 9 +- .../main/res/layout/fragment_repo_info.xml | 38 +++-- .../main/res/layout/list_profile_emails.xml | 55 +++++-- app/src/main/res/layout/list_users.xml | 96 +++++++----- app/src/main/res/values-v23/themes.xml | 3 + app/src/main/res/values/colors.xml | 2 + app/src/main/res/values/dimens.xml | 2 + app/src/main/res/values/settings.xml | 1 + app/src/main/res/values/themes.xml | 30 +++- 45 files changed, 446 insertions(+), 319 deletions(-) diff --git a/app/src/main/java/org/mian/gitnex/activities/AddNewAccountActivity.java b/app/src/main/java/org/mian/gitnex/activities/AddNewAccountActivity.java index 208cde8c..1940fb73 100644 --- a/app/src/main/java/org/mian/gitnex/activities/AddNewAccountActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/AddNewAccountActivity.java @@ -7,7 +7,7 @@ import android.util.Log; import android.view.View; import android.widget.ArrayAdapter; import androidx.annotation.NonNull; -import androidx.appcompat.app.AlertDialog; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; import org.gitnex.tea4j.v2.models.GeneralAPISettings; import org.gitnex.tea4j.v2.models.ServerVersion; import org.gitnex.tea4j.v2.models.User; @@ -152,22 +152,17 @@ public class AddNewAccountActivity extends BaseActivity { if(giteaVersion.less(getString(R.string.versionLow))) { - AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx).setTitle(getString(R.string.versionAlertDialogHeader)) - .setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion())).setIcon(R.drawable.ic_warning) - .setCancelable(true); + MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx) + .setTitle(getString(R.string.versionAlertDialogHeader)) + .setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion())) + .setNeutralButton(getString(R.string.cancelButton), null) + .setPositiveButton(getString(R.string.textContinue), (dialog, which) -> { - alertDialogBuilder.setNeutralButton(getString(R.string.cancelButton), (dialog, which) -> { + dialog.dismiss(); + login(instanceUrl, loginToken); + }); - dialog.dismiss(); - }); - - alertDialogBuilder.setPositiveButton(getString(R.string.textContinue), (dialog, which) -> { - - dialog.dismiss(); - login(instanceUrl, loginToken); - }); - - alertDialogBuilder.create().show(); + materialAlertDialogBuilder.create().show(); } else if(giteaVersion.lessOrEqual(getString(R.string.versionHigh))) { diff --git a/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java b/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java index 7ed4fbb5..cc9d499c 100644 --- a/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java @@ -9,7 +9,7 @@ import android.widget.Button; import android.widget.EditText; import android.widget.RadioGroup; import androidx.annotation.NonNull; -import androidx.appcompat.app.AlertDialog; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; import org.gitnex.tea4j.v2.models.AccessToken; import org.gitnex.tea4j.v2.models.CreateAccessTokenOption; import org.gitnex.tea4j.v2.models.GeneralAPISettings; @@ -277,24 +277,21 @@ public class LoginActivity extends BaseActivity { if(giteaVersion.less(getString(R.string.versionLow))) { - AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx).setTitle(getString(R.string.versionAlertDialogHeader)) - .setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion())).setIcon(R.drawable.ic_warning) - .setCancelable(true); + MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx) + .setTitle(getString(R.string.versionAlertDialogHeader)) + .setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion())) + .setNeutralButton(getString(R.string.cancelButton), (dialog, which) -> { - alertDialogBuilder.setNeutralButton(getString(R.string.cancelButton), (dialog, which) -> { + dialog.dismiss(); + enableProcessButton(); + }) + .setPositiveButton(getString(R.string.textContinue), (dialog, which) -> { - dialog.dismiss(); - enableProcessButton(); - }); - - alertDialogBuilder.setPositiveButton(getString(R.string.textContinue), (dialog, which) -> { - - dialog.dismiss(); - login(loginType, loginUid, loginPass, loginOTP, loginToken); - }); - - alertDialogBuilder.create().show(); + dialog.dismiss(); + login(loginType, loginUid, loginPass, loginOTP, loginToken); + }); + materialAlertDialogBuilder.create().show(); } else if(giteaVersion.lessOrEqual(getString(R.string.versionHigh))) { diff --git a/app/src/main/java/org/mian/gitnex/activities/MainActivity.java b/app/src/main/java/org/mian/gitnex/activities/MainActivity.java index f9930a85..bbda8be3 100644 --- a/app/src/main/java/org/mian/gitnex/activities/MainActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/MainActivity.java @@ -12,7 +12,6 @@ import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.appcompat.app.ActionBarDrawerToggle; -import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.core.view.GravityCompat; @@ -21,6 +20,7 @@ import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.card.MaterialCardView; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.navigation.NavigationView; import org.gitnex.tea4j.v2.models.GeneralAPISettings; import org.gitnex.tea4j.v2.models.NotificationCount; @@ -406,6 +406,11 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyIssuesFragment()).commit(); navigationView.setCheckedItem(R.id.nav_my_issues); break; + case 9: + toolbarTitle.setText(getResources().getString(R.string.navMostVisited)); + getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MostVisitedReposFragment()).commit(); + navigationView.setCheckedItem(R.id.nav_most_visited); + break; default: toolbarTitle.setText(getResources().getString(R.string.navMyRepos)); @@ -475,9 +480,8 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig if(frag != null) { - new AlertDialog.Builder(ctx) + new MaterialAlertDialogBuilder(ctx) .setTitle(R.string.deleteAllDrafts) - .setIcon(R.drawable.ic_delete) .setCancelable(false) .setMessage(R.string.deleteAllDraftsDialogMessage) .setPositiveButton(R.string.menuDeleteText, (dialog, which) -> { diff --git a/app/src/main/java/org/mian/gitnex/activities/SettingsGeneralActivity.java b/app/src/main/java/org/mian/gitnex/activities/SettingsGeneralActivity.java index 496dba49..1e162652 100644 --- a/app/src/main/java/org/mian/gitnex/activities/SettingsGeneralActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/SettingsGeneralActivity.java @@ -93,6 +93,10 @@ public class SettingsGeneralActivity extends BaseActivity { viewBinding.homeScreenSelected.setText(getResources().getString(R.string.navMyIssues)); } + else if(homeScreenSelectedChoice == 9) { + + viewBinding.homeScreenSelected.setText(getResources().getString(R.string.navMostVisited)); + } viewBinding.homeScreenFrame.setOnClickListener(setDefaultHomeScreen -> { diff --git a/app/src/main/java/org/mian/gitnex/activities/WikiActivity.java b/app/src/main/java/org/mian/gitnex/activities/WikiActivity.java index 36ebf8ac..4352ba4a 100644 --- a/app/src/main/java/org/mian/gitnex/activities/WikiActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/WikiActivity.java @@ -8,7 +8,7 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import androidx.annotation.NonNull; -import androidx.appcompat.app.AlertDialog; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.vdurmont.emoji.EmojiParser; import org.gitnex.tea4j.v2.models.CreateWikiPageOptions; import org.gitnex.tea4j.v2.models.WikiPage; @@ -269,10 +269,10 @@ public class WikiActivity extends BaseActivity implements BottomSheetListener { private void deleteWiki(final String owner, final String repo, final String pageName) { - new AlertDialog.Builder(ctx) + MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx) .setTitle(String.format(ctx.getString(R.string.deleteGenericTitle), pageName)) .setMessage(ctx.getString(R.string.deleteWikiPageMessage, pageName)) - .setIcon(R.drawable.ic_delete) + .setNeutralButton(R.string.cancelButton, null) .setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> RetrofitClient .getApiInterface(ctx).repoDeleteWikiPage(owner, repo, pageName).enqueue(new Callback<>() { @@ -297,8 +297,9 @@ public class WikiActivity extends BaseActivity implements BottomSheetListener { Toasty.error(ctx, ctx.getString(R.string.genericError)); } - })) - .setNeutralButton(R.string.cancelButton, null).show(); + })); + + materialAlertDialogBuilder.create().show(); } @Override diff --git a/app/src/main/java/org/mian/gitnex/fragments/MyProfileEmailsFragment.java b/app/src/main/java/org/mian/gitnex/fragments/MyProfileEmailsFragment.java index 388de758..07ea45a0 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/MyProfileEmailsFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/MyProfileEmailsFragment.java @@ -11,7 +11,6 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProvider; -import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; @@ -48,11 +47,8 @@ public class MyProfileEmailsFragment extends Fragment { noDataEmails = fragmentProfileEmailsBinding.noDataEmails; mRecyclerView = fragmentProfileEmailsBinding.recyclerView; - DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL); - mRecyclerView.setHasFixedSize(true); mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); - mRecyclerView.addItemDecoration(dividerItemDecoration); mProgressBar = fragmentProfileEmailsBinding.progressBar; diff --git a/app/src/main/java/org/mian/gitnex/fragments/MyProfileFollowersFragment.java b/app/src/main/java/org/mian/gitnex/fragments/MyProfileFollowersFragment.java index 0f5a8a8a..6fe9f7af 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/MyProfileFollowersFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/MyProfileFollowersFragment.java @@ -10,7 +10,6 @@ import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; -import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import org.gitnex.tea4j.v2.models.User; import org.mian.gitnex.R; @@ -64,9 +63,7 @@ public class MyProfileFollowersFragment extends Fragment { } })); - DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(context, DividerItemDecoration.VERTICAL); viewBinding.recyclerView.setHasFixedSize(true); - viewBinding.recyclerView.addItemDecoration(dividerItemDecoration); viewBinding.recyclerView.setLayoutManager(new LinearLayoutManager(context)); viewBinding.recyclerView.setAdapter(adapter); diff --git a/app/src/main/java/org/mian/gitnex/fragments/MyProfileFollowingFragment.java b/app/src/main/java/org/mian/gitnex/fragments/MyProfileFollowingFragment.java index ca7a3383..4a160af2 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/MyProfileFollowingFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/MyProfileFollowingFragment.java @@ -10,7 +10,6 @@ import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; -import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import org.gitnex.tea4j.v2.models.User; import org.mian.gitnex.R; @@ -63,9 +62,7 @@ public class MyProfileFollowingFragment extends Fragment { } })); - DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(context, DividerItemDecoration.VERTICAL); viewBinding.recyclerView.setHasFixedSize(true); - viewBinding.recyclerView.addItemDecoration(dividerItemDecoration); viewBinding.recyclerView.setLayoutManager(new LinearLayoutManager(context)); viewBinding.recyclerView.setAdapter(adapter); diff --git a/app/src/main/java/org/mian/gitnex/fragments/MyProfileFragment.java b/app/src/main/java/org/mian/gitnex/fragments/MyProfileFragment.java index 642f6d9c..5ff6811f 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/MyProfileFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/MyProfileFragment.java @@ -156,7 +156,7 @@ public class MyProfileFragment extends Fragment { userFullName.setText(Html.fromHtml(account.getFullName())); userLogin.setText(getString(R.string.usernameWithAt, account.getAccount().getUserName())); - int avatarRadius = AppUtil.getPixelsFromDensity(ctx, 3); + int avatarRadius = AppUtil.getPixelsFromDensity(ctx, 60); PicassoService.getInstance(ctx).get().load(account.getUserInfo().getAvatarUrl()).transform(new RoundedTransformation(avatarRadius, 0)).placeholder(R.drawable.loader_animated).resize(120, 120).centerCrop().into(userAvatar); diff --git a/app/src/main/java/org/mian/gitnex/helpers/ChangeLog.java b/app/src/main/java/org/mian/gitnex/helpers/ChangeLog.java index ff8c3ce4..ebecff2d 100644 --- a/app/src/main/java/org/mian/gitnex/helpers/ChangeLog.java +++ b/app/src/main/java/org/mian/gitnex/helpers/ChangeLog.java @@ -5,8 +5,8 @@ import android.content.pm.PackageManager; import android.content.res.Resources; import android.content.res.XmlResourceParser; import android.util.Log; -import androidx.appcompat.app.AlertDialog; import androidx.core.text.HtmlCompat; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; import org.mian.gitnex.R; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @@ -90,15 +90,13 @@ public class ChangeLog { String changelogMessage = getChangelog(resId, res); - AlertDialog.Builder builder = new AlertDialog.Builder(changelogActivity); - - builder.setTitle(R.string.changelogTitle); - builder.setMessage(HtmlCompat.fromHtml("" + changelogMessage + "", HtmlCompat.FROM_HTML_MODE_LEGACY)); - builder.setNeutralButton(R.string.close, null); - builder.setCancelable(false); - - builder.create().show(); + MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(changelogActivity) + .setTitle(R.string.changelogTitle) + .setMessage(HtmlCompat.fromHtml("" + changelogMessage + "", HtmlCompat.FROM_HTML_MODE_LEGACY)) + .setCancelable(false) + .setNeutralButton(R.string.close, null); + materialAlertDialogBuilder.create().show(); } } diff --git a/app/src/main/res/layout/activity_add_new_account.xml b/app/src/main/res/layout/activity_add_new_account.xml index 64205504..4fb96245 100644 --- a/app/src/main/res/layout/activity_add_new_account.xml +++ b/app/src/main/res/layout/activity_add_new_account.xml @@ -139,10 +139,10 @@ -