Skip to content

Commit adfc80a

Browse files
committed
'minor_fixes'
1 parent 5d91f3a commit adfc80a

File tree

3 files changed

+32
-39
lines changed

3 files changed

+32
-39
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ android {
1010
minSdkVersion 21
1111
multiDexEnabled true
1212
targetSdkVersion 33
13-
versionCode 108
14-
versionName "8.8.1"
13+
versionCode 109
14+
versionName "9.0.0"
1515
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
1616
}
1717
buildTypes {

app/src/main/java/swati4star/createpdf/fragment/RemoveDuplicatePagesFragment.java

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@
4848
import swati4star.createpdf.util.RemoveDuplicates;
4949
import swati4star.createpdf.util.StringUtils;
5050

51-
public class RemoveDuplicatePagesFragment extends Fragment implements MergeFilesAdapter.OnClickListener,
52-
FilesListAdapter.OnFileItemClickedListener, BottomSheetPopulate, OnPDFCreatedInterface, OnBackPressedInterface {
51+
public class RemoveDuplicatePagesFragment extends Fragment
52+
implements MergeFilesAdapter.OnClickListener, FilesListAdapter.OnFileItemClickedListener,
53+
BottomSheetPopulate, OnPDFCreatedInterface, OnBackPressedInterface {
5354

5455
private static final int INTENT_REQUEST_PICKFILE_CODE = 10;
5556
BottomSheetBehavior mSheetBehavior;
@@ -79,8 +80,7 @@ public class RemoveDuplicatePagesFragment extends Fragment implements MergeFiles
7980
private MaterialDialog mMaterialDialog;
8081

8182
@Override
82-
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
83-
Bundle savedInstanceState) {
83+
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
8484
View rootview = inflater.inflate(R.layout.fragment_remove_duplicate_pages, container, false);
8585
ButterKnife.bind(this, rootview);
8686
mSheetBehavior = BottomSheetBehavior.from(layoutBottomSheet);
@@ -102,30 +102,29 @@ void onViewFilesClick(View view) {
102102
*/
103103
@OnClick(R.id.selectFile)
104104
public void showFileChooser() {
105-
startActivityForResult(mFileUtils.getFileChooser(),
106-
INTENT_REQUEST_PICKFILE_CODE);
105+
startActivityForResult(mFileUtils.getFileChooser(), INTENT_REQUEST_PICKFILE_CODE);
107106
}
108-
109-
// Refactor onActivityResult() method to handle possible NullPointerExceptions
107+
108+
// Refactor onActivityResult() method to handle possible NullPointerExceptions
110109
// when accessing data.getData(). Added try-catch blocks to handle exceptions
111110
// in a better way(imo) to prevent app crashes.
112-
@Override
113-
public void onActivityResult(int requestCode, int resultCode, Intent data) {
114-
if (resultCode != RESULT_OK || data == null || data.getData() == null) {
115-
return;
116-
}
117-
118-
if (requestCode == INTENT_REQUEST_PICKFILE_CODE) {
119-
try {
120-
// Attempt to get the real path of the selected file and update the UI
121-
String path = RealPathUtil.getInstance().getRealPath(getContext(), data.getData());
122-
setTextAndActivateButtons(path);
123-
} catch (NullPointerException e) {
124-
// If a NullPointerException occurs, log it to the console and continue
125-
e.printStackTrace();
111+
@Override
112+
public void onActivityResult(int requestCode, int resultCode, Intent data) {
113+
if (resultCode != RESULT_OK || data == null || data.getData() == null) {
114+
return;
115+
}
116+
117+
if (requestCode == INTENT_REQUEST_PICKFILE_CODE) {
118+
try {
119+
// Attempt to get the real path of the selected file and update the UI
120+
String path = RealPathUtil.getInstance().getRealPath(getContext(), data.getData());
121+
setTextAndActivateButtons(path);
122+
} catch (NullPointerException e) {
123+
// If a NullPointerException occurs, log it to the console and continue
124+
e.printStackTrace();
125+
}
126126
}
127127
}
128-
}
129128

130129
//On click remove duplicate button
131130
@OnClick(R.id.remove)
@@ -140,14 +139,12 @@ private void resetValues() {
140139

141140
private void setTextAndActivateButtons(String path) {
142141
mPath = path;
143-
mMorphButtonUtility.setTextAndActivateButtons(path,
144-
selectFileButton, removeDuplicateButton);
142+
mMorphButtonUtility.setTextAndActivateButtons(path, selectFileButton, removeDuplicateButton);
145143
}
146144

147145
@Override
148146
public void onPopulate(ArrayList<String> paths) {
149-
CommonCodeUtils.getInstance().populateUtil(mActivity, paths,
150-
this, mLayout, mLottieProgress, mRecyclerViewFiles);
147+
CommonCodeUtils.getInstance().populateUtil(mActivity, paths, this, mLayout, mLottieProgress, mRecyclerViewFiles);
151148
}
152149

153150
@Override
@@ -191,9 +188,9 @@ public void onPDFCreated(boolean isNewPdfCreated, String path) {
191188
return;
192189
}
193190
new DatabaseHelper(mActivity).insertRecord(path, mActivity.getString(R.string.created));
194-
StringUtils.getInstance().getSnackbarwithAction(mActivity, R.string.snackbar_duplicate_removed)
195-
.setAction(R.string.snackbar_viewAction,
196-
v -> mFileUtils.openFile(path, FileUtils.FileType.e_PDF)).show();
191+
StringUtils.getInstance().getSnackbarwithAction(mActivity,
192+
R.string.snackbar_duplicate_removed)
193+
.setAction(R.string.snackbar_viewAction, v -> mFileUtils.openFile(path, FileUtils.FileType.e_PDF)).show();
197194
viewPdfButton(path);
198195
resetValues();
199196
}
@@ -212,8 +209,6 @@ public boolean checkSheetBehaviour() {
212209
* check runtime permissions for storage and camera
213210
***/
214211
private void getRuntimePermissions() {
215-
PermissionsUtils.getInstance().requestRuntimePermissions(this,
216-
WRITE_PERMISSIONS,
217-
REQUEST_CODE_FOR_WRITE_PERMISSION);
212+
PermissionsUtils.getInstance().requestRuntimePermissions(this, WRITE_PERMISSIONS, REQUEST_CODE_FOR_WRITE_PERMISSION);
218213
}
219214
}

app/src/main/java/swati4star/createpdf/util/CommonCodeUtils.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import static swati4star.createpdf.R.id.add_watermark_fav;
3030
import static swati4star.createpdf.R.id.compress_pdf;
3131
import static swati4star.createpdf.R.id.compress_pdf_fav;
32-
import static swati4star.createpdf.R.id.excel_to_pdf;
3332
import static swati4star.createpdf.R.id.excel_to_pdf_fav;
3433
import static swati4star.createpdf.R.id.extract_images;
3534
import static swati4star.createpdf.R.id.extract_images_fav;
@@ -84,7 +83,6 @@
8483
import static swati4star.createpdf.R.id.view_history;
8584
import static swati4star.createpdf.R.id.view_history_fav;
8685
import static swati4star.createpdf.R.id.zip_to_pdf_fav;
87-
import static swati4star.createpdf.R.string.qr_barcode_pdf;
8886

8987
import android.app.Activity;
9088
import android.view.View;
@@ -193,9 +191,9 @@ public Map<Integer, HomePageItem> fillNavigationItemsMap(boolean homePageItems)
193191
addFragmentPosition(homePageItems, R.id.images_to_pdf,
194192
images_to_pdf_fav, nav_camera, ic_menu_camera, R.string.images_to_pdf);
195193
addFragmentPosition(homePageItems, qr_barcode_to_pdf,
196-
qr_barcode_to_pdf_fav, nav_qrcode, ic_qrcode_24dp, qr_barcode_pdf);
194+
qr_barcode_to_pdf_fav, nav_qrcode, ic_qrcode_24dp, R.string.qr_barcode_pdf);
197195
addFragmentPosition(homePageItems, R.id.excel_to_pdf,
198-
excel_to_pdf_fav, nav_excel_to_pdf, ic_excel, excel_to_pdf);
196+
excel_to_pdf_fav, nav_excel_to_pdf, ic_excel, R.string.excel_to_pdf);
199197
addFragmentPosition(homePageItems, view_files, view_files_fav,
200198
nav_gallery, ic_menu_gallery, R.string.viewFiles);
201199
addFragmentPosition(homePageItems, rotate_pages, rotate_pages_fav,

0 commit comments

Comments
 (0)