diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index d291b3d..41871c2 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -1,15 +1,21 @@ + diff --git a/.idea/misc.xml b/.idea/misc.xml index b74cba2..a2bbeb9 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,12 +3,14 @@ - + diff --git a/DEVELOPER.md b/DEVELOPER.md new file mode 100644 index 0000000..0afe578 --- /dev/null +++ b/DEVELOPER.md @@ -0,0 +1,27 @@ +# Developer Notes: + +This project is based upon a customized version of NeutrinosPlatform's scanLibrary at https://github.com/NeutrinosPlatform/scanlibrary . +### Setting up native libraries: + +Uncompress the jniLibs.7z from IScan/app/src/main/ using 7-Zip to IScan/app/src/main/jniLibs. Your directory structure should look something like this: +~~~shell +main\ + +- java + | + +- res + | + +- jniLibs\ + | +- arm64-v8a\ + | | +-libopencv_java3.so + | | +-libScanner.so + | +- armeabi\ + | | +-libopencv_java3.so + | | +-libScanner.so + | +- .... + | + +- AndroidManifest.xml +~~~ + +Currently the native code is the default as the one present in the master branch of the ScanLibrary but when the code will be edited for improvisation, it would be available on the GitHub repo. + +If you need the documentation for the code of this project you can get it **[here](http://docs.nalinangrish.me/IScan)** diff --git a/GPlay/114x114-Icon.png b/GPlay/114x114-Icon.png new file mode 100644 index 0000000..e2fb19d Binary files /dev/null and b/GPlay/114x114-Icon.png differ diff --git a/GPlay/Icon.png b/GPlay/Icon.png new file mode 100644 index 0000000..41da4ff Binary files /dev/null and b/GPlay/Icon.png differ diff --git a/README.md b/README.md index 02138c6..a259c93 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # IScan The Indian Scanner App - Made for the Indians, By the Indians
-Official website: [https://nalinstudios.herokuapp.com/IScan](https://nalinstudios.herokuapp.com/IScan)

+Official website: [http://www.nalinangrish.me/apps/iscan](http://www.nalinangrish.me/apps/iscan)

IScan - The Indian Scanner app, Made for Indians, By an Indian.
@@ -25,7 +25,7 @@ What’s better than knowing what an app does and what things it has access to.

If you ever feel that there is any bug in the Application, you can report that bug and even collaborate with us on this project and provide one of the best experiences to every user of this application.

-Visit https://nalinstudios.herokuapp.com/IScan for more details.


+Visit http://www.nalinangrish.me/apps/iscan for more details.


@@ -65,27 +65,9 @@ Visit https://nalinstudios.herokuapp.com/IScan for more details.




-# Developer Zone: -This project is based upon a customized version of NeutrinosPlatform's scanLibrary at https://github.com/NeutrinosPlatform/scanlibrary . -### Setting up native libraries: - -Uncompress the jniLibs.7z from IScan/app/src/main/ using 7-Zip to IScan/app/src/main/jniLibs. Your directory structure should look something like this: -~~~shell -main\ - +- java - | - +- res - | - +- jniLibs\ - | +- arm64-v8a\ - | | +-libopencv_java3.so - | | +-libScanner.so - | +- armeabi\ - | | +-libopencv_java3.so - | | +-libScanner.so - | +- .... - | - +- AndroidManifest.xml -~~~ - -If you need the documentation for the code of this project you can get it **[here](https://nalin-2005.github.io/IScan)** +# Related Resources: +- Developer Notes: [Visit on GitHub](DEVELOPER.md) +- Privacy Policy: [Visit on GitHub](PrivacyPolicy.md) | [Visit on Website](http://www.nalinangrish.me/apps/iscan/privacy-policy) +- Download: [GitHub Releases](http://github.com/Nalin-2005/IScan/releases/latest) | [Google Play Store](http://play.google.com/store/apps/details?id=com.nalinstudios.iscan) +- Code Documentation: [Visit the Docs](http://docs.nalinangrish.me/IScan/) +- Website: [nalinangrish.me/apps/IScan](http://www.nalinangrish.me/apps/iscan) \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index db1c950..cb0e1a3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "com.nalinstudios.iscan" minSdkVersion 19 targetSdkVersion 29 - versionCode 158 - versionName "1.5.8" + versionCode 159 + versionName "1.5.9" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled = true } @@ -35,10 +35,10 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.2.0' - implementation 'androidx.constraintlayout:constraintlayout:2.0.2' - implementation 'com.google.android.material:material:1.2.1' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + implementation 'com.google.android.material:material:1.3.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation "androidx.exifinterface:exifinterface:1.3.1" + implementation "androidx.exifinterface:exifinterface:1.3.2" testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b690f4a..0ad0859 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,17 +10,21 @@ - - + android:theme="@style/AppTheme.NoActionBar"> + + @@ -28,36 +32,28 @@ - - - - - - - - fragList = new ArrayList<>(); - - + /** A progressbar to inform the user that the PDF is being created */ + ProgressDialogFragment progressDialogFragment = new ProgressDialogFragment("Creating PDF.."); + /** A popup for letting the user enter a name for the PDF.*/ + PopupWindow window; /** * The oncreate function to load the opencv library and initialize the main function. @@ -96,32 +99,53 @@ public void run() { protected void Askname(){ View p = getLayoutInflater().inflate(R.layout.popup_enter_name, null); - final PopupWindow window = new PopupWindow(p, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true); + window = new PopupWindow(); + window.setContentView(p); + window.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); + window.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT); window.setAnimationStyle(android.R.style.Animation_Dialog); window.showAtLocation(p, Gravity.CENTER, 0, 0); + window.setFocusable(true); + window.update(); window.getContentView().findViewById(R.id.end).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v){ - EditText tBox = window.getContentView().findViewById(R.id.pdfName); - window.dismiss(); - try { - if (Statics.isAvailable(tBox.getText().toString())) { - for (ResultFragment frag : fragList) { - if (!frag.deleted){ - frag.finish(); + showProgressDialog("Converting to PDF..."); + new Thread(new Runnable() { + @Override + public void run() { + boolean shouldClose = true; + try { + EditText tBox = window.getContentView().findViewById(R.id.pdfName); + if (Statics.isAvailable(tBox.getText().toString())) { + for (ResultFragment frag : fragList) { + if (!frag.deleted){ + frag.finish(); + } + } + Statics.createPdf(getApplication(), tBox.getText().toString()); + }else { + Toast.makeText(getApplicationContext(), "A PDF with this name already exists. Please try again with a different name.", Toast.LENGTH_LONG).show(); + shouldClose = false; } + }catch (Exception e){ + Toast.makeText(getApplicationContext(), "Couldn't create PDF, Please try again", Toast.LENGTH_LONG).show(); + e.printStackTrace(); + shouldClose = false; + } + dismissDialog(); + if (shouldClose){ + runOnUiThread(new Runnable() { + @Override + public void run() { + Intent i = new Intent(EditViewActivity.this, MainActivity.class); + startActivity(i); + finish(); + } + }); } - Statics.createPdf(getApplication(), tBox.getText().toString()); - Intent intent = new Intent(EditViewActivity.this, MainActivity.class); - startActivity(intent); - finish(); - }else { - Toast.makeText(getApplicationContext(), "A PDF with this name already exists. Please try again with a different name.", Toast.LENGTH_LONG).show(); } - }catch (Exception e){ - Toast.makeText(getApplicationContext(), "Couldn't create PDF, Please try again", Toast.LENGTH_LONG).show(); - e.printStackTrace(); - } + }).start(); } }); window.getContentView().findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { @@ -170,4 +194,31 @@ public void delete(ResultFragment fragment){ this.onBackPressed(); } } + + + /** + * A function to show the progress dialog. + * @param message the message to show. + */ + protected synchronized void showProgressDialog(String message) { + if (progressDialogFragment != null && progressDialogFragment.isVisible()) { + // Before creating another loading dialog, close all opened loading dialogs (if any) + progressDialogFragment.dismissAllowingStateLoss(); + } + progressDialogFragment = null; + progressDialogFragment = new ProgressDialogFragment(message); + FragmentManager fm = getFragmentManager(); + progressDialogFragment.show(fm, ProgressDialogFragment.class.toString()); + } + + + + /** + * A function to dismiss the progress dialog. + */ + protected synchronized void dismissDialog() { + progressDialogFragment.dismissAllowingStateLoss(); + } + + } diff --git a/app/src/main/java/com/nalinstudios/iscan/MainActivity.java b/app/src/main/java/com/nalinstudios/iscan/MainActivity.java index 96d1edd..f33d603 100644 --- a/app/src/main/java/com/nalinstudios/iscan/MainActivity.java +++ b/app/src/main/java/com/nalinstudios/iscan/MainActivity.java @@ -3,6 +3,7 @@ import android.content.Intent; import android.graphics.BitmapFactory; import android.graphics.Color; +import android.net.Uri; import android.os.Bundle; import com.google.android.material.floatingactionbutton.FloatingActionButton; @@ -17,6 +18,8 @@ import androidx.core.content.PermissionChecker; import android.os.Environment; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; @@ -91,11 +94,12 @@ public void onResume() { getApplicationContext().getSharedPreferences("IScan", MODE_PRIVATE).edit().putString("sessionName", Statics.randString()).apply(); File[] folder = new File(new File(Environment.getExternalStorageDirectory(), "IScan"), ".data-internal").listFiles(); - assert folder != null; - Arrays.sort(folder, new Comparator(){ - public int compare(File f1, File f2){ + if (folder==null){folder=new File[]{};} + Arrays.sort(folder, new Comparator() { + public int compare(File f1, File f2) { return Long.valueOf(f1.lastModified()).compareTo(f2.lastModified()); - } }); + } + }); folder = reverseArray(folder); int stdlimit = 10; // this limit is the number of cards that will be shown. Keep this as low so it does not lag the device (low end devices may lag) //But keep it high enough that the user does not get frustrated by asking to open another app (the file explorer) @@ -221,4 +225,32 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis super.onRequestPermissionsResult(requestCode, permissions, grantResults); } + + + /** + * A function to inflate the menu on the main screen for letting the User do some things like viewing the manual or the privacy policy of the app. + * @param menu The menu to be shown to the user. + * @return super's onCreateOptionsMenu + */ + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_main, menu); + menu.findItem(R.id.mainmenu_manual).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + Intent i = new Intent(MainActivity.this, TutorialActivity.class); + startActivity(i); + return true; + } + }); + menu.findItem(R.id.mainmenu_privacypolicy).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.nalinangrish.me/apps/iscan/privacy-policy")); + startActivity(i); + return true; + } + }); + return super.onCreateOptionsMenu(menu); + } } diff --git a/app/src/main/java/com/nalinstudios/iscan/ScannerActivity.java b/app/src/main/java/com/nalinstudios/iscan/ScannerActivity.java index 3836b1e..8b9c9fe 100644 --- a/app/src/main/java/com/nalinstudios/iscan/ScannerActivity.java +++ b/app/src/main/java/com/nalinstudios/iscan/ScannerActivity.java @@ -153,8 +153,8 @@ public void onClick(View view){ */ protected void click(){ - final File[] files = dir.listFiles(); - assert files != null; + File[] temp = dir.listFiles(); + final File[] files = temp==null?new File[]{}:temp; try { countView.setText(String.valueOf(files.length + 1)); diff --git a/app/src/main/java/com/nalinstudios/iscan/SplashActivity.java b/app/src/main/java/com/nalinstudios/iscan/SplashActivity.java index af0bf16..66ff4ac 100644 --- a/app/src/main/java/com/nalinstudios/iscan/SplashActivity.java +++ b/app/src/main/java/com/nalinstudios/iscan/SplashActivity.java @@ -3,6 +3,7 @@ import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; +import android.content.SharedPreferences; import android.graphics.BitmapFactory; import android.os.Bundle; import android.os.Handler; @@ -33,7 +34,12 @@ protected void onCreate(Bundle savedInstanceState) { new Handler().postDelayed(new Runnable() { @Override public void run() { - Intent i=new Intent(SplashActivity.this, MainActivity.class); + Intent i; + if (getApplication().getSharedPreferences("IScan", MODE_PRIVATE).getBoolean("firstTime", true)){ + i = new Intent(SplashActivity.this, TutorialActivity.class); + }else { + i = new Intent(SplashActivity.this, MainActivity.class); + } startActivity(i); finish(); } diff --git a/app/src/main/java/com/nalinstudios/iscan/TutorialActivity.java b/app/src/main/java/com/nalinstudios/iscan/TutorialActivity.java new file mode 100644 index 0000000..0b0ceee --- /dev/null +++ b/app/src/main/java/com/nalinstudios/iscan/TutorialActivity.java @@ -0,0 +1,120 @@ +package com.nalinstudios.iscan; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.os.Bundle; +import android.view.Gravity; +import android.view.View; +import android.widget.Button; +import android.widget.FrameLayout; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.LinearLayout; + +import com.nalinstudios.iscan.internal.LockedHScrollView; + + +/** + * A class to give a simple walkthrough to inform the user about how to use the app. + * @author Nalin Angrish. + */ +public class TutorialActivity extends AppCompatActivity { + /** A ratio defining the relative size of each slide of the tutorial */ + public final float ratio = 0.75f; + + + /** + * The main function of the class to show the slide show. + * @param savedInstanceState The saved instance. not used. + */ + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_tutorial); + + + ImageButton nextB = findViewById(R.id.nextSlide); + ImageButton prevB = findViewById(R.id.previousSlide); + nextB.setOnClickListener(new SlideListener()); + prevB.setOnClickListener(new SlideListener()); + + Button skip_finishB = findViewById(R.id.skip); + skip_finishB.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + getApplication().getSharedPreferences("IScan", MODE_PRIVATE) + .edit().putBoolean("firstTime", false).apply(); + Intent i = new Intent(TutorialActivity.this, MainActivity.class); + startActivity(i); + finish(); + } + }); + + + + + + LinearLayout layout = findViewById(R.id.slideLayout); + Bitmap[] images = new Bitmap[]{ + BitmapFactory.decodeResource(getResources(), R.raw.slide1), + BitmapFactory.decodeResource(getResources(), R.raw.slide2), + BitmapFactory.decodeResource(getResources(), R.raw.slide3), + BitmapFactory.decodeResource(getResources(), R.raw.slide4), + BitmapFactory.decodeResource(getResources(), R.raw.slide5), + BitmapFactory.decodeResource(getResources(), R.raw.slide6) + }; + + for (Bitmap image:images){ + int width = (int)(getResources().getDisplayMetrics().widthPixels * ratio); + + + ImageView imageView = new ImageView(this); + imageView.setImageBitmap(image); + imageView.setMaxWidth(width); + + + FrameLayout imageHolder = new FrameLayout(this); + FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( + width, + getResources().getDisplayMetrics().heightPixels, + Gravity.CENTER); + imageHolder.setLayoutParams(params); + + + FrameLayout imageHolderParent = new FrameLayout(this); + FrameLayout.LayoutParams params2 = new FrameLayout.LayoutParams( + getResources().getDisplayMetrics().widthPixels, + getResources().getDisplayMetrics().heightPixels, + Gravity.CENTER); + imageHolderParent.setLayoutParams(params2); + + + imageHolder.addView(imageView); + imageHolderParent.addView(imageHolder); + layout.addView(imageHolderParent); + } + } + + + /** + * A Click listener to navigate through the slides. + */ + protected class SlideListener implements View.OnClickListener{ + /** + * The main click listener function. + * @param v the view clicked. used to check whether the back key is pressed or the front key. + */ + @Override + public void onClick(View v){ + LockedHScrollView layout = findViewById(R.id.lockedHScrollView); + if (v == findViewById(R.id.nextSlide)){ + layout.scrollRight(); + }else { + layout.scrollLeft(); + } + } + } +} diff --git a/app/src/main/java/com/nalinstudios/iscan/edit/PDFEditActivity.java b/app/src/main/java/com/nalinstudios/iscan/edit/PDFEditActivity.java index 3e3a5fd..d14f1c8 100644 --- a/app/src/main/java/com/nalinstudios/iscan/edit/PDFEditActivity.java +++ b/app/src/main/java/com/nalinstudios/iscan/edit/PDFEditActivity.java @@ -49,9 +49,12 @@ public class PDFEditActivity extends FragmentActivity implements View.OnClickLis List fragList = new ArrayList<>(); /** A fragment to show to the user while the pdf is decoded*/ static ProgressDialogFragment progressDialogFragment; - /** */ + /** A reference to current ScanFragment*/ ScanFragment currentFragment; + /** A reference to the current ResultFragment*/ ResultFragment currentResult; + /** The popup for entering name*/ + PopupWindow window; @@ -164,32 +167,53 @@ public void run() { protected void Askname(){ View p = getLayoutInflater().inflate(R.layout.popup_enter_name, null); - final PopupWindow window = new PopupWindow(p, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true); + window = new PopupWindow(); + window.setContentView(p); + window.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); + window.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT); window.setAnimationStyle(android.R.style.Animation_Dialog); window.showAtLocation(p, Gravity.CENTER, 0, 0); + window.setFocusable(true); + window.update(); window.getContentView().findViewById(R.id.end).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v){ - EditText tBox = window.getContentView().findViewById(R.id.pdfName); - window.dismiss(); - try { - if (Statics.isAvailable(tBox.getText().toString())) { - for (ResultFragment frag : fragList) { - if (!frag.deleted){ - frag.finish(); + showProgressDialog("Converting to PDF..."); + new Thread(new Runnable() { + @Override + public void run() { + boolean shouldClose = true; + try { + EditText tBox = window.getContentView().findViewById(R.id.pdfName); + if (Statics.isAvailable(tBox.getText().toString())) { + for (ResultFragment frag : fragList) { + if (!frag.deleted){ + frag.finish(); + } + } + Statics.createPdf(getApplication(), tBox.getText().toString()); + }else { + Toast.makeText(getApplicationContext(), "A PDF with this name already exists. Please try again with a different name.", Toast.LENGTH_LONG).show(); + shouldClose = false; } + }catch (Exception e){ + Toast.makeText(getApplicationContext(), "Couldn't create PDF, Please try again", Toast.LENGTH_LONG).show(); + e.printStackTrace(); + shouldClose = false; + } + dismissDialog(); + if (shouldClose){ + runOnUiThread(new Runnable() { + @Override + public void run() { + Intent i = new Intent(PDFEditActivity.this, MainActivity.class); + startActivity(i); + finish(); + } + }); } - Statics.createPdf(getApplication(), tBox.getText().toString()); - Intent intent = new Intent(PDFEditActivity.this, MainActivity.class); - startActivity(intent); - finish(); - }else { - Toast.makeText(getApplicationContext(), "A PDF with this name already exists. Please try again with a different name.", Toast.LENGTH_LONG).show(); } - }catch (Exception e){ - Toast.makeText(getApplicationContext(), "Couldn't create PDF, Please try again", Toast.LENGTH_LONG).show(); - e.printStackTrace(); - } + }).start(); } }); window.getContentView().findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { diff --git a/app/src/main/java/com/nalinstudios/iscan/edit/package-info.java b/app/src/main/java/com/nalinstudios/iscan/edit/package-info.java index 16dec28..0c43094 100644 --- a/app/src/main/java/com/nalinstudios/iscan/edit/package-info.java +++ b/app/src/main/java/com/nalinstudios/iscan/edit/package-info.java @@ -1,10 +1,5 @@ /** * A package for storing all Classes required to edit previously made PDFs. - * This package includes the following classes:
    - *
  1. PDFEditActivity : Activity to handle all the editing functionality after the PDF has been created.
  2. - *
  3. ResultFragment : A customized version of ResultFragment specifically enhanced for later-editing purposes.
  4. - *
  5. ScanFragment : A customized version of ScanFragment specifically enhanced for later-editing purposes.
  6. - *
* @author Nalin Angrish, Jhansi. */ package com.nalinstudios.iscan.edit; \ No newline at end of file diff --git a/app/src/main/java/com/nalinstudios/iscan/internal/LockedHScrollView.java b/app/src/main/java/com/nalinstudios/iscan/internal/LockedHScrollView.java index 3483626..9b85fea 100644 --- a/app/src/main/java/com/nalinstudios/iscan/internal/LockedHScrollView.java +++ b/app/src/main/java/com/nalinstudios/iscan/internal/LockedHScrollView.java @@ -19,9 +19,21 @@ public class LockedHScrollView extends HorizontalScrollView { - public LockedHScrollView(Context context){super(context);} - public LockedHScrollView(Context context, AttributeSet attrs){super(context, attrs);} - public LockedHScrollView(Context context, AttributeSet attrs, int defStyleAttr){super(context, attrs, defStyleAttr);} + /** One of the entry points for constructing the ScrollView*/ + public LockedHScrollView(Context context){super(context);init();} + /** One of the entry points for constructing the ScrollView*/ + public LockedHScrollView(Context context, AttributeSet attrs){super(context, attrs);init();} + /** One of the entry points for constructing the ScrollView*/ + public LockedHScrollView(Context context, AttributeSet attrs, int defStyleAttr){super(context, attrs, defStyleAttr);init();} + + + /** + * The main initializer. + */ + public void init(){ + setVerticalScrollBarEnabled(false); + setHorizontalScrollBarEnabled(false); + } /** diff --git a/app/src/main/java/com/nalinstudios/iscan/internal/PdfCard.java b/app/src/main/java/com/nalinstudios/iscan/internal/PdfCard.java index fab4930..42edcb8 100644 --- a/app/src/main/java/com/nalinstudios/iscan/internal/PdfCard.java +++ b/app/src/main/java/com/nalinstudios/iscan/internal/PdfCard.java @@ -39,12 +39,19 @@ * @author Nalin Angrish. */ public class PdfCard{ + /** The main view that contains the content for the PDF Card*/ private View content; + /** The thumbnail icon for the PDF Card*/ private ImageView thumbnail; + /** The TextView representing the Title of the PDF*/ private TextView title; + /** The imagebuttons present on the CardView*/ private ImageButton view, share, options; + /** The context of the application */ private Context context; + /** The activity creating the Card*/ private AppCompatActivity activity; + /** The thumbnail file which can be used to get the original PDF File*/ private File file; /** @@ -54,7 +61,7 @@ public class PdfCard{ * @param inflater The LayoutInflater of the activity. */ public PdfCard(Context ctx, File file, LayoutInflater inflater, AppCompatActivity activity){ - context = ctx; + this.context = ctx; this.activity = activity; content = inflater.inflate(R.layout.pdf_card, null); thumbnail = content.findViewById(R.id.pdfThumbnail); diff --git a/app/src/main/java/com/nalinstudios/iscan/internal/Statics.java b/app/src/main/java/com/nalinstudios/iscan/internal/Statics.java index 6b9727a..cf6690f 100644 --- a/app/src/main/java/com/nalinstudios/iscan/internal/Statics.java +++ b/app/src/main/java/com/nalinstudios/iscan/internal/Statics.java @@ -137,9 +137,11 @@ public static void clearData(Application app){ */ private static File getThumbnail(Application app){ String folder = app.getSharedPreferences("IScan", Context.MODE_PRIVATE).getString("sessionName", "hello"); - File thumb = new File(app.getFilesDir(), folder).listFiles()[0]; - assert thumb != null; - return thumb; + File[] all = new File(app.getFilesDir(), folder).listFiles(); + if (all!=null && all.length>0) { + return all[0]; + } + return null; } /** diff --git a/app/src/main/java/com/nalinstudios/iscan/internal/package-info.java b/app/src/main/java/com/nalinstudios/iscan/internal/package-info.java index e023a13..2b0a854 100644 --- a/app/src/main/java/com/nalinstudios/iscan/internal/package-info.java +++ b/app/src/main/java/com/nalinstudios/iscan/internal/package-info.java @@ -1,10 +1,6 @@ /** - * A package for storing all other helper classes used by our Activities. This package contains classes which are used to perform functions like generating cardViews for each PDF, Handle zoom gestures, create PDFs, etc. - * This package includes the following classes:
    - *
  1. PdfCard : A class to create CardView Layouts for each PDF thumbnail found in the internal data directory.
  2. - *
  3. Statics : A class to store all simple functions used by other files in this application.
  4. - *
  5. ZoomHandler : A class to handle zoom events in the ScannerActivity.
  6. - *
+ * A package for storing all other helper classes used by our Activities. + * This package contains classes which are used to perform functions like generating cardViews for each PDF, Handle zoom gestures, create PDFs, etc. * @author Nalin Angrish. */ package com.nalinstudios.iscan.internal; \ No newline at end of file diff --git a/app/src/main/java/com/nalinstudios/iscan/package-info.java b/app/src/main/java/com/nalinstudios/iscan/package-info.java index f63f4b3..f438a85 100644 --- a/app/src/main/java/com/nalinstudios/iscan/package-info.java +++ b/app/src/main/java/com/nalinstudios/iscan/package-info.java @@ -1,13 +1,6 @@ /** - * The base package for the application. This package contains the Activities that constitute this application. - * The Classes in this package are:
    - *
  1. MainActivity : It will make the main list of all the PDFs created till now and will provide access to the other activities.
  2. - *
  3. ScannerActivity : This activity is the window where the user will scan the documents.
  4. - *
  5. EditViewActivity : Activity to handle all the editing functionality.
  6. - *
  7. ListFileActivity : An activity that will work as a file browser to show all the PDFs scanned.
  8. - *
  9. SplashActivity : A splash screen for the app.
  10. - *
- * + * The base package for the application. + * This package contains the main activities that constitute this application. * @author Nalin Angrish. */ package com.nalinstudios.iscan; \ No newline at end of file diff --git a/app/src/main/java/com/nalinstudios/iscan/scanlibrary/Loader.java b/app/src/main/java/com/nalinstudios/iscan/scanlibrary/Loader.java index 3e89057..742d6d0 100644 --- a/app/src/main/java/com/nalinstudios/iscan/scanlibrary/Loader.java +++ b/app/src/main/java/com/nalinstudios/iscan/scanlibrary/Loader.java @@ -5,8 +5,13 @@ * @author Nalin Angrish, Sekar. */ public class Loader { + /** Whether we have already loaded the native libraries or not */ private static boolean done = false; + + /** + * Load the native libraries. + */ public static synchronized void load() { if (done) return; diff --git a/app/src/main/java/com/nalinstudios/iscan/scanlibrary/package-info.java b/app/src/main/java/com/nalinstudios/iscan/scanlibrary/package-info.java index da8553e..15ec602 100644 --- a/app/src/main/java/com/nalinstudios/iscan/scanlibrary/package-info.java +++ b/app/src/main/java/com/nalinstudios/iscan/scanlibrary/package-info.java @@ -1,15 +1,5 @@ /** * A custom implementation of the ScanLibrary. - * This package includes the following classes:
    - *
  1. Loader : A class to load the required native Libraries.
  2. - *
  3. PolygonView : The View that is used to mark the corners and allow the user to change them.
  4. - *
  5. ProgressDialogFragment : A class to show progress bar.
  6. - *
  7. ResultFragment : Customized version of ResultFragment.
  8. - *
  9. ScanConstants : A class to contain all the constants for the scanLibrary.
  10. - *
  11. ScanFragment : Customized version of ScanFragment.
  12. - *
  13. SingleButtonDialogFragment : A class to generate a dialog with a single button.
  14. - *
  15. Utils : The class containing helper method(s).
  16. - *
* @author Nalin Angrish, Jhansi, Sekar. */ package com.nalinstudios.iscan.scanlibrary; \ No newline at end of file diff --git a/app/src/main/java/com/scanlibrary/package-info.java b/app/src/main/java/com/scanlibrary/package-info.java index d6cfd8c..2b39754 100644 --- a/app/src/main/java/com/scanlibrary/package-info.java +++ b/app/src/main/java/com/scanlibrary/package-info.java @@ -1,8 +1,5 @@ /** * A Pseudo-package to have access to the native methods of the ScanLibrary. - * This package includes the following classes:
    - *
  1. ScanActivity : A simple class to get access to native methods of the scanLibrary's ScanActivity class.
  2. - *
* @author Nalin Angirsh. */ package com.scanlibrary; \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 554317e..80b77da 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -4,6 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="#FFFFFF" tools:context=".MainActivity"> + layout="@layout/content_main" + android:background="#FFFFFF" /> + + + + + + + + + + + +