Move about and rate to settings screen (#714)
Move about and rate to settings screen Co-authored-by: M M Arif <mmarif@swatian.com> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/714
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Typeface;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
@@ -33,7 +31,6 @@ import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.fragments.AboutFragment;
|
||||
import org.mian.gitnex.fragments.AdministrationFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetDraftsFragment;
|
||||
import org.mian.gitnex.fragments.DraftsFragment;
|
||||
@@ -188,9 +185,6 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
else if(fragmentById instanceof ProfileFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleProfile));
|
||||
}
|
||||
else if(fragmentById instanceof AboutFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleAbout));
|
||||
}
|
||||
else if(fragmentById instanceof DraftsFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
||||
}
|
||||
@@ -455,6 +449,11 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
}
|
||||
}
|
||||
|
||||
public void setActionBarTitle(String title) {
|
||||
|
||||
toolbarTitle.setText(title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onButtonClicked(String text) {
|
||||
|
||||
@@ -544,15 +543,6 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||
break;
|
||||
|
||||
case R.id.nav_about:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleAbout));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new AboutFragment()).commit();
|
||||
break;
|
||||
|
||||
case R.id.nav_rate_app:
|
||||
rateThisApp();
|
||||
break;
|
||||
|
||||
case R.id.nav_starred_repos:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleStarredRepos));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new StarredRepositoriesFragment()).commit();
|
||||
@@ -584,16 +574,6 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
return true;
|
||||
}
|
||||
|
||||
public void rateThisApp() {
|
||||
|
||||
try {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName())));
|
||||
}
|
||||
catch(ActivityNotFoundException e) {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + getPackageName())));
|
||||
}
|
||||
}
|
||||
|
||||
public static void logout(Activity activity, Context ctx) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(ctx.getApplicationContext());
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.MainActivity;
|
||||
import org.mian.gitnex.databinding.FragmentAboutBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
@@ -29,6 +30,8 @@ public class AboutFragment extends Fragment {
|
||||
viewBinding.userServerVersion.setText(tinyDb.getString("giteaVersion"));
|
||||
viewBinding.appBuild.setText(String.valueOf(AppUtil.getAppBuildNo(requireContext())));
|
||||
|
||||
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.pageTitleAbout));
|
||||
|
||||
viewBinding.donationLinkLiberapay.setOnClickListener(v1 -> {
|
||||
|
||||
Intent intent = new Intent();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.mian.gitnex.fragments;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -17,7 +19,6 @@ import org.mian.gitnex.activities.SettingsReportsActivity;
|
||||
import org.mian.gitnex.activities.SettingsSecurityActivity;
|
||||
import org.mian.gitnex.activities.SettingsTranslationActivity;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@@ -37,6 +38,8 @@ public class SettingsFragment extends Fragment {
|
||||
LinearLayout securityFrame = v.findViewById(R.id.securityFrame);
|
||||
LinearLayout languagesFrame = v.findViewById(R.id.languagesFrame);
|
||||
LinearLayout reportsFrame = v.findViewById(R.id.reportsFrame);
|
||||
LinearLayout rateAppFrame = v.findViewById(R.id.rateAppFrame);
|
||||
LinearLayout aboutAppFrame = v.findViewById(R.id.aboutAppFrame);
|
||||
|
||||
appearanceFrame.setOnClickListener(v1 -> startActivity(new Intent(getContext(), SettingsAppearanceActivity.class)));
|
||||
|
||||
@@ -50,10 +53,24 @@ public class SettingsFragment extends Fragment {
|
||||
|
||||
reportsFrame.setOnClickListener(v1 -> startActivity(new Intent(getContext(), SettingsReportsActivity.class)));
|
||||
|
||||
rateAppFrame.setOnClickListener(aboutApp -> rateThisApp());
|
||||
|
||||
aboutAppFrame.setOnClickListener(aboutApp -> requireActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new AboutFragment()).commit());
|
||||
|
||||
return v;
|
||||
|
||||
}
|
||||
|
||||
public void rateThisApp() {
|
||||
|
||||
try {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + requireActivity().getPackageName())));
|
||||
}
|
||||
catch(ActivityNotFoundException e) {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + requireActivity().getPackageName())));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
||||
@@ -62,8 +79,8 @@ public class SettingsFragment extends Fragment {
|
||||
TinyDB tinyDb = new TinyDB(getContext());
|
||||
|
||||
if(tinyDb.getBoolean("refreshParent")) {
|
||||
Objects.requireNonNull(getActivity()).recreate();
|
||||
getActivity().overridePendingTransition(0, 0);
|
||||
requireActivity().recreate();
|
||||
requireActivity().overridePendingTransition(0, 0);
|
||||
tinyDb.putBoolean("refreshParent", false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user