Skip to content
This repository was archived by the owner on Sep 15, 2024. It is now read-only.

Commit 9e521d8

Browse files
Main: Clean and simplify code
Signed-off-by: sunilpaulmathew <[email protected]>
1 parent cb5f335 commit 9e521d8

File tree

12 files changed

+79
-189
lines changed

12 files changed

+79
-189
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ android {
4242
dependencies {
4343
implementation 'androidx.preference:preference:1.2.0'
4444
implementation 'androidx.work:work-runtime:2.7.1'
45-
implementation 'com.github.sunilpaulmathew:RootFilePicker:v0.6'
45+
implementation 'com.github.sunilpaulmathew:RootFilePicker:v0.7'
4646
implementation "com.github.topjohnwu.libsu:core:4.0.3"
4747
implementation 'com.google.android.material:material:1.5.0'
4848
implementation 'com.wortise:android-sdk:1.2.1'

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
<uses-permission android:name="android.permission.ACCESS_SUPERUSER" />
88
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
99
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
10-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
11-
tools:ignore="ScopedStorage" />
1210

1311
<application
1412
android:allowBackup="true"

app/src/main/assets/privacy-policy.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ <h3 style="color: blue">Policy<h3>
1414

1515
<h3 style="color: blue">Permissions explained</h3>
1616

17-
<p style="text-align: justify;"><tab1>NFS Manager shall request/access the following permissions to handle the below-explained situations.<br><br><b>ACCESS_SUPERUSER</b><br>Executing module script, changing settings, module flashing, etc.<br><br><b>WRITE_EXTERNAL_STORAGE</b><br>Downloading app updates, generating internal files for module flashing, exporting log files, etc.<br><br><b>INTERNET</b> and <b>ACCESS_NETWORK_STATE</b><br>Downloading app updates, checking network state before attempting to open web links, etc.<br><br><b>REQUEST_INSTALL_PACKAGES</b><br>Installing new versions of NFS Manager.</tab1></p>
17+
<p style="text-align: justify;"><tab1>NFS Manager shall request/access the following permissions to handle the below-explained situations.<br><br><b>ACCESS_SUPERUSER</b><br>Executing module script, changing settings, module flashing, etc.<br><br><b>INTERNET</b> and <b>ACCESS_NETWORK_STATE</b><br>Downloading app updates, checking network state before attempting to open web links, etc.<br><br><b>REQUEST_INSTALL_PACKAGES</b><br>Installing new versions of NFS Manager.</tab1></p>
1818

1919
<h3 style="color: blue">Changes<h3>
2020

app/src/main/java/com/nfs/nfsmanager/MainActivity.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.annotation.SuppressLint;
44
import android.content.Intent;
55
import android.content.res.Configuration;
6+
import android.graphics.drawable.Drawable;
67
import android.os.Bundle;
78
import android.os.Environment;
89
import android.os.Handler;
@@ -14,6 +15,7 @@
1415

1516
import androidx.annotation.NonNull;
1617
import androidx.appcompat.app.AppCompatActivity;
18+
import androidx.appcompat.app.AppCompatDelegate;
1719
import androidx.appcompat.widget.AppCompatImageButton;
1820
import androidx.appcompat.widget.AppCompatImageView;
1921
import androidx.appcompat.widget.PopupMenu;
@@ -24,24 +26,25 @@
2426
import com.google.android.material.checkbox.MaterialCheckBox;
2527
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
2628
import com.google.android.material.textview.MaterialTextView;
27-
import com.nfs.nfsmanager.utils.CPUTimes;
28-
import com.nfs.nfsmanager.utils.Flasher;
29-
import com.nfs.nfsmanager.utils.NFS;
30-
import com.nfs.nfsmanager.utils.UpdateCheck;
31-
import com.nfs.nfsmanager.utils.Utils;
3229
import com.nfs.nfsmanager.activities.CPUTimesActivity;
3330
import com.nfs.nfsmanager.activities.DeviceInfoActivity;
3431
import com.nfs.nfsmanager.activities.LogsActivity;
3532
import com.nfs.nfsmanager.fragments.AboutFragment;
3633
import com.nfs.nfsmanager.fragments.DashBoardFragment;
3734
import com.nfs.nfsmanager.fragments.NFSFragment;
35+
import com.nfs.nfsmanager.utils.CPUTimes;
36+
import com.nfs.nfsmanager.utils.Flasher;
37+
import com.nfs.nfsmanager.utils.NFS;
38+
import com.nfs.nfsmanager.utils.UpdateCheck;
39+
import com.nfs.nfsmanager.utils.Utils;
3840
import com.wortise.ads.AdError;
3941
import com.wortise.ads.AdSize;
4042
import com.wortise.ads.WortiseSdk;
4143
import com.wortise.ads.banner.BannerAd;
4244
import com.wortise.ads.consent.ConsentManager;
4345

4446
import java.io.File;
47+
import java.util.Objects;
4548

4649
import in.sunilpaulmathew.rootfilepicker.activities.FilePickerActivity;
4750
import in.sunilpaulmathew.rootfilepicker.utils.FilePicker;
@@ -68,7 +71,7 @@ public class MainActivity extends AppCompatActivity {
6871
@Override
6972
protected void onCreate(Bundle savedInstanceState) {
7073
// Initialize App Theme
71-
Utils.initializeAppTheme();
74+
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
7275
super.onCreate(savedInstanceState);
7376
setContentView(R.layout.activity_main);
7477

@@ -95,7 +98,9 @@ protected void onCreate(Bundle savedInstanceState) {
9598
if (!Utils.rootAccess() || !NFS.magiskSupported() || !NFS.illegalAppsList(this).isEmpty() || NFS.isNFSSleeping()) {
9699
mBottomMenu.setVisibility(View.GONE);
97100
mUnsupportedLayout.setVisibility(View.VISIBLE);
98-
mUnsupportedImage.setImageDrawable(Utils.getColoredIcon(R.drawable.ic_help, this));
101+
Drawable helpDrawable = ContextCompat.getDrawable(this, R.drawable.ic_help);
102+
Objects.requireNonNull(helpDrawable).setTint(ContextCompat.getColor(this, R.color.ColorBlue));
103+
mUnsupportedImage.setImageDrawable(helpDrawable);
99104
mUnsupportedText.setText(!Utils.rootAccess() ? getString(R.string.no_root) : !NFS.magiskSupported() ?
100105
getString(R.string.no_magisk) : !NFS.illegalAppsList(this).isEmpty() ?
101106
getString(R.string.illegal_apps) : getString(R.string.sleeping));
@@ -104,6 +109,8 @@ protected void onCreate(Bundle savedInstanceState) {
104109
Utils.launchUrl(mBottomMenu, "https://www.google.com/search?site=&source=hp&q=android+rooting+magisk", this);
105110
} else {
106111
new MaterialAlertDialogBuilder(this)
112+
.setIcon(R.mipmap.ic_launcher)
113+
.setTitle(R.string.app_name)
107114
.setMessage(mSleeping ? getString(R.string.sleeping_message) : getString (
108115
R.string.illegal_apps_summary, NFS.illegalAppsList(this)))
109116
.setCancelable(false)

app/src/main/java/com/nfs/nfsmanager/activities/FlashingActivity.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.annotation.SuppressLint;
44
import android.os.Bundle;
5+
import android.os.Environment;
56
import android.view.KeyEvent;
67
import android.view.View;
78
import android.widget.LinearLayout;
@@ -17,6 +18,8 @@
1718
import com.nfs.nfsmanager.utils.Common;
1819
import com.nfs.nfsmanager.utils.Utils;
1920

21+
import java.io.File;
22+
2023
/*
2124
* Created by sunilpaulmathew <[email protected]> on November 13, 2020
2225
*/
@@ -48,9 +51,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
4851
refreshStatus();
4952
mBack.setOnClickListener(v -> finish());
5053
mSave.setOnClickListener(v -> {
51-
Utils.create(Common.getFlashingResult().toString(), Utils.getInternalDataStorage(this) + "/flasher_log-" +
54+
Utils.mkdir(new File(Environment.getExternalStorageDirectory(),"NFSManager").getAbsolutePath());
55+
Utils.create(Common.getFlashingResult().toString(), new File(Environment.getExternalStorageDirectory(),"NFSManager") + "/flasher_log-" +
5256
Common.getZipName().replace(".zip",""));
53-
Utils.longSnackbar(mSave, getString(R.string.flash_log, Utils.getInternalDataStorage(this) + "/flasher_log-" +
57+
Utils.longSnackbar(mSave, getString(R.string.flash_log, new File(Environment.getExternalStorageDirectory(),"NFSManager") + "/flasher_log-" +
5458
Common.getZipName().replace(".zip","")));
5559
});
5660
mReboot.setOnClickListener(v -> {

app/src/main/java/com/nfs/nfsmanager/adapters/AboutAdapter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import androidx.annotation.NonNull;
1313
import androidx.appcompat.widget.AppCompatImageButton;
1414
import androidx.appcompat.widget.AppCompatTextView;
15+
import androidx.core.content.ContextCompat;
1516
import androidx.recyclerview.widget.RecyclerView;
1617

1718
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
@@ -49,7 +50,7 @@ public AboutAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType
4950
public void onBindViewHolder(@NonNull AboutAdapter.ViewHolder holder, int position) {
5051
holder.mTitle.setText(this.data.get(position).getTitle());
5152
if (Utils.isDarkTheme(holder.mTitle.getContext())) {
52-
holder.mTitle.setTextColor(Utils.getThemeAccentColor(holder.mTitle.getContext()));
53+
holder.mTitle.setTextColor(ContextCompat.getColor(holder.mTitle.getContext(), R.color.ColorBlue));
5354
}
5455
holder.mDescription.setText(this.data.get(position).getDescription());
5556
holder.mIcon.setImageDrawable(this.data.get(position).getIcon());

app/src/main/java/com/nfs/nfsmanager/adapters/CreditsAdapter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import androidx.annotation.NonNull;
99
import androidx.appcompat.widget.AppCompatImageView;
1010
import androidx.appcompat.widget.AppCompatTextView;
11+
import androidx.core.content.ContextCompat;
1112
import androidx.recyclerview.widget.RecyclerView;
1213

1314
import com.nfs.nfsmanager.R;
@@ -38,7 +39,7 @@ public CreditsAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewTy
3839
public void onBindViewHolder(@NonNull CreditsAdapter.ViewHolder holder, int position) {
3940
holder.mTitle.setText(this.data.get(position).getTitle());
4041
if (Utils.isDarkTheme(holder.mTitle.getContext())) {
41-
holder.mTitle.setTextColor(Utils.getThemeAccentColor(holder.mTitle.getContext()));
42+
holder.mTitle.setTextColor(ContextCompat.getColor(holder.mTitle.getContext(), R.color.ColorBlue));
4243
}
4344
holder.mDescription.setText(this.data.get(position).getDescription());
4445
holder.mIcon.setImageDrawable(this.data.get(position).getIcon());

app/src/main/java/com/nfs/nfsmanager/adapters/DashBoardAdapter.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
import androidx.annotation.NonNull;
99
import androidx.appcompat.widget.AppCompatImageButton;
10+
import androidx.core.content.ContextCompat;
1011
import androidx.recyclerview.widget.RecyclerView;
1112

1213
import com.google.android.material.textview.MaterialTextView;
1314
import com.nfs.nfsmanager.R;
14-
import com.nfs.nfsmanager.utils.SerializableItems;
1515
import com.nfs.nfsmanager.utils.NFS;
16-
import com.nfs.nfsmanager.utils.Utils;
16+
import com.nfs.nfsmanager.utils.SerializableItems;
1717

1818
import java.util.ArrayList;
1919

@@ -44,27 +44,27 @@ public void onBindViewHolder(@NonNull DashBoardAdapter.ViewHolder holder, int po
4444
holder.mIcon.setImageDrawable(this.data.get(position).getIcon());
4545
if (NFS.getNFSMode() == 0) {
4646
if (position == 0) {
47-
holder.mLinearLayout.setBackgroundColor(Utils.getThemeAccentColor(holder.mLinearLayout.getContext()));
47+
holder.mLinearLayout.setBackgroundColor(ContextCompat.getColor(holder.mLinearLayout.getContext(), R.color.ColorBlue));
4848
} else {
49-
holder.mLinearLayout.setBackgroundColor(Utils.getCardBackground(holder.mLinearLayout.getContext()));
49+
holder.mLinearLayout.setBackgroundColor(ContextCompat.getColor(holder.mLinearLayout.getContext(), R.color.ColorTeal));
5050
}
5151
} else if (NFS.getNFSMode() == 1) {
5252
if (position == 1) {
53-
holder.mLinearLayout.setBackgroundColor(Utils.getThemeAccentColor(holder.mLinearLayout.getContext()));
53+
holder.mLinearLayout.setBackgroundColor(ContextCompat.getColor(holder.mLinearLayout.getContext(), R.color.ColorBlue));
5454
} else {
55-
holder.mLinearLayout.setBackgroundColor(Utils.getCardBackground(holder.mLinearLayout.getContext()));
55+
holder.mLinearLayout.setBackgroundColor(ContextCompat.getColor(holder.mLinearLayout.getContext(), R.color.ColorTeal));
5656
}
5757
} else if (NFS.getNFSMode() == 2) {
5858
if (position == 2) {
59-
holder.mLinearLayout.setBackgroundColor(Utils.getThemeAccentColor(holder.mLinearLayout.getContext()));
59+
holder.mLinearLayout.setBackgroundColor(ContextCompat.getColor(holder.mLinearLayout.getContext(), R.color.ColorBlue));
6060
} else {
61-
holder.mLinearLayout.setBackgroundColor(Utils.getCardBackground(holder.mLinearLayout.getContext()));
61+
holder.mLinearLayout.setBackgroundColor(ContextCompat.getColor(holder.mLinearLayout.getContext(), R.color.ColorTeal));
6262
}
6363
} else {
6464
if (position == 3) {
65-
holder.mLinearLayout.setBackgroundColor(Utils.getThemeAccentColor(holder.mLinearLayout.getContext()));
65+
holder.mLinearLayout.setBackgroundColor(ContextCompat.getColor(holder.mLinearLayout.getContext(), R.color.ColorBlue));
6666
} else {
67-
holder.mLinearLayout.setBackgroundColor(Utils.getCardBackground(holder.mLinearLayout.getContext()));
67+
holder.mLinearLayout.setBackgroundColor(ContextCompat.getColor(holder.mLinearLayout.getContext(), R.color.ColorTeal));
6868
}
6969
}
7070
} catch (NullPointerException ignored) {}

app/src/main/java/com/nfs/nfsmanager/fragments/MagiskLogFragment.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.content.Intent;
66
import android.net.Uri;
77
import android.os.Bundle;
8+
import android.os.Environment;
89
import android.view.LayoutInflater;
910
import android.view.View;
1011
import android.view.ViewGroup;
@@ -57,30 +58,30 @@ public void exportMagiskLog(Context context) {
5758
@Override
5859
public void onPreExecute() {
5960
mProgressLayout.setVisibility(View.VISIBLE);
60-
mProgressMessage.setText(context.getString(R.string.exporting, Utils.getInternalDataStorage(context) + "/magisk.log") + "...");
61+
mProgressMessage.setText(context.getString(R.string.exporting, new File(Environment.getExternalStorageDirectory(),"NFSManager") + "/magisk.log") + "...");
6162
}
6263

6364
@Override
6465
public void doInBackground() {
65-
NFS.makeAppFolder(context);
66+
Utils.mkdir(new File(Environment.getExternalStorageDirectory(),"NFSManager").getAbsolutePath());
6667
Utils.runCommand("sleep 2");
67-
Utils.copy("/cache/magisk.log", Utils.getInternalDataStorage(context) + "/magisk.log");
68+
Utils.copy("/cache/magisk.log", new File(Environment.getExternalStorageDirectory(),"NFSManager") + "/magisk.log");
6869
}
6970

7071
@Override
7172
public void onPostExecute() {
7273
mProgressLayout.setVisibility(View.GONE);
73-
if (Utils.exist(Utils.getInternalDataStorage(context) + "/magisk.log")) {
74+
if (Utils.exist(new File(Environment.getExternalStorageDirectory(),"NFSManager") + "/magisk.log")) {
7475
new MaterialAlertDialogBuilder(context)
7576
.setIcon(R.mipmap.ic_launcher)
7677
.setTitle(R.string.app_name)
77-
.setMessage(context.getString(R.string.export_completed, Utils.getInternalDataStorage(context)))
78+
.setMessage(context.getString(R.string.export_completed, new File(Environment.getExternalStorageDirectory(),"NFSManager")))
7879
.setCancelable(false)
7980
.setNegativeButton(context.getString(R.string.cancel), (dialog, id) -> {
8081
})
8182
.setPositiveButton(context.getString(R.string.share), (dialog, id) -> {
8283
Uri uriFile = FileProvider.getUriForFile(context,
83-
BuildConfig.APPLICATION_ID + ".provider", new File(Utils.getInternalDataStorage(context) + "/magisk.log"));
84+
BuildConfig.APPLICATION_ID + ".provider", new File(new File(Environment.getExternalStorageDirectory(),"NFSManager") + "/magisk.log"));
8485
Intent shareScript = new Intent(Intent.ACTION_SEND);
8586
shareScript.setType("text/x-log");
8687
shareScript.putExtra(Intent.EXTRA_TEXT, context.getString(R.string.share_by, context.getString(R.string.magisk_log)));

app/src/main/java/com/nfs/nfsmanager/fragments/NFSLogFragment.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.content.Intent;
66
import android.net.Uri;
77
import android.os.Bundle;
8+
import android.os.Environment;
89
import android.view.LayoutInflater;
910
import android.view.View;
1011
import android.view.ViewGroup;
@@ -57,30 +58,30 @@ public void exportNFSLog(Context context) {
5758
@Override
5859
public void onPreExecute() {
5960
mProgressLayout.setVisibility(View.VISIBLE);
60-
mProgressMessage.setText(context.getString(R.string.exporting, Utils.getInternalDataStorage(context) + "/nfs.log") + "...");
61+
mProgressMessage.setText(context.getString(R.string.exporting, new File(Environment.getExternalStorageDirectory(),"NFSManager") + "/nfs.log") + "...");
6162
}
6263

6364
@Override
6465
public void doInBackground() {
65-
NFS.makeAppFolder(context);
66+
Utils.mkdir(new File(Environment.getExternalStorageDirectory(),"NFSManager").getAbsolutePath());
6667
Utils.runCommand("sleep 2");
67-
Utils.copy("/data/NFS/nfs.log", Utils.getInternalDataStorage(context) + "/nfs.log");
68+
Utils.copy("/data/NFS/nfs.log", new File(Environment.getExternalStorageDirectory(),"NFSManager") + "/nfs.log");
6869
}
6970

7071
@Override
7172
public void onPostExecute() {
7273
mProgressLayout.setVisibility(View.GONE);
73-
if (Utils.exist(Utils.getInternalDataStorage(context) + "/nfs.log")) {
74+
if (Utils.exist(new File(Environment.getExternalStorageDirectory(),"NFSManager") + "/nfs.log")) {
7475
new MaterialAlertDialogBuilder(context)
7576
.setIcon(R.mipmap.ic_launcher)
7677
.setTitle(R.string.app_name)
77-
.setMessage(context.getString(R.string.export_completed, Utils.getInternalDataStorage(context)))
78+
.setMessage(context.getString(R.string.export_completed, new File(Environment.getExternalStorageDirectory(),"NFSManager")))
7879
.setCancelable(false)
7980
.setNegativeButton(context.getString(R.string.cancel), (dialog, id) -> {
8081
})
8182
.setPositiveButton(context.getString(R.string.share), (dialog, id) -> {
8283
Uri uriFile = FileProvider.getUriForFile(context,
83-
BuildConfig.APPLICATION_ID + ".provider", new File(Utils.getInternalDataStorage(context) + "/nfs.log"));
84+
BuildConfig.APPLICATION_ID + ".provider", new File(new File(Environment.getExternalStorageDirectory(),"NFSManager") + "/nfs.log"));
8485
Intent shareScript = new Intent(Intent.ACTION_SEND);
8586
shareScript.setType("text/x-log");
8687
shareScript.putExtra(Intent.EXTRA_TEXT, context.getString(R.string.share_by, context.getString(R.string.nfs_log)));

0 commit comments

Comments
 (0)