scribe-org / Scribe-Android

Android app with keyboards for language learners
GNU General Public License v3.0
27 stars 14 forks source link

Remove unneeded files from Scribe-Android #22

Closed andrewtavis closed 1 year ago

andrewtavis commented 2 years ago

Terms

Issue

In combining Simple-Keyboard and Simple-Commons in #17 - to remove a single line that alerted the user that the app was "fake" and they should for their safety download something from Simple Mobile Tools - there were a lot of unneeded files added to the project. Many of these are used to power parts of other apps or provide features that will not be included in Scribe-Android. Those that are not necessary for the keyboard functionality should be removed.

The following list is functions and classes that are imported by base keyboard files:

Most of what's not necessary for the above functions should be removed, and everything that's left in the commons folder should be moved to appropriate locations within the app.

mrnninster commented 2 years ago

Hi Andrew,

So basically we want to write a python script "cleaner" that goes through the list of files and removes all unused files.

andrewtavis commented 2 years ago

Hi @mrnninster, I'm realizing that this is a bit more complex, as there are going to be some files in org.scribe.commons that are being imported by the ones we want to keep, but aren't imported by the keyboard files... Thinking about this, I'd say we might need to go through line by line, but then it shouldn't be that difficult.

What we want to keep is:

  1. The keyboard app files
  2. The files they import
  3. The files imported by those files above
  4. Etc (as there could be further imports)

Seems that the original coder also doesn't do explicit imports very much, and also uses import * for whole directories. For this, let's focus on the files that aren't imported, and then we can go file by file for classes and functions in another issue (should be simple to check with a full file search where the class or function wouldn't be found).

What we need is:

  1. A list of all file paths in the project's src.main.kotlin directory like org.scribe.commons.activities.AboutActivity
  2. All the strings that aren't in org.scribe.commons can be saved to a list like files_to_keep (copy it to new_files_to_keep as well - see below)
  3. We then read through the files in new_files_to_keep line by line
    • Find import statements
    • Find those that start with org.scribe.commons
    • For those that aren't in files_to_keep:
      • Append them files_to_keep
      • Overwrite new_files_to_keep with these new files
  4. Do the same process over the files in new_files_to_keep, with the process stopping when new_files_to_keep is empty :)

How does this sound?

andrewtavis commented 2 years ago

Most of the file searching is done using os in Python. As far as line by line reading in code, this SO question should be a good starting spot :)

Let me know on all this, and looking forward to the work!

andrewtavis commented 2 years ago
  1. A list of all file paths in the project's src.main.kotlin

For this, say that we make a list kotlin_files. We then compare files_to_keep and kotlin_files at the end to figure out what to get rid of, and also make sure that we keep what's in repos that he's used import * from.

mrnninster commented 2 years ago

Hi @mrnninster, I'm realizing that this is a bit more complex, as there are going to be some files in org.scribe.commons that are being imported by the ones we want to keep, but aren't imported by the keyboard files... Thinking about this, I'd say we might need to go through line by line, but then it shouldn't be that difficult.

What we want to keep is:

  1. The keyboard app files
  2. The files they import
  3. The files imported by those files above
  4. Etc (as there could be further imports)

Seems that the original coder also doesn't do explicit imports very much, and also uses import * for whole directories. For this, let's focus on the files that aren't imported, and then we can go file by file for classes and functions in another issue (should be simple to check with a full file search where the class or function wouldn't be found).

What we need is:

  1. A list of all file paths in the project's src.main.kotlin directory like org.scribe.commons.activities.AboutActivity
  2. All the strings that aren't in org.scribe.commons can be saved to a list like files_to_keep (copy it to new_files_to_keep as well - see below)
  3. We then read through the files in new_files_to_keep line by line
    • Find import statements
    • Find those that start with org.scribe.commons
    • For those that aren't in files_to_keep:
      • Append them files_to_keep
      • Overwrite new_files_to_keep with these new files
  4. Do the same process over the files in new_files_to_keep, with the process stopping when new_files_to_keep is empty :)

How does this sound?

So I actually saw this when I wanted to start writing the script last night.

So just to reiterate your idea here and to make sure I am clear on it Say the list of items in the dir are a,b,c with "c" being Commons The list of dir_to_keep would be [a,b]. We then go through the files in dir_to_keep and identify import statement that have "commons" adding them to files to keep. The problem I see with this is that there's no actual difference between import statements syntax for classes, function or packages

mrnninster commented 2 years ago

If we ignore that and search through the commons directory and temporarily store the item we couldn't find in the commons directory on the basis that the could be functions or classes, then we will need to collect the import statements of those files as well check for imports that the function or class is potentially using and and check to see if they are in the commons directory

mrnninster commented 2 years ago

Alternatively we could just find a day when we are less busy and go through the files together preferably a weekend

andrewtavis commented 2 years ago

Thanks for your thoughts, @mrnninster :)

The problem I see with this is that there's no actual difference between import statements syntax for classes, function or packages

For this issue, maybe let's keep it easy and find the files in commons that we don't need? Let's ignore functions and classes for now, and just look for the files in org.scribe.commons that aren't imported. Might make deleting functions and classes easier going forward?

Aside from that, also happy to get on a call and talk it over. It'd be good to just check things, and we can run the emulator after deleting certain things to make sure it's all still working. Most of the files are just single classes, so we just check if they're imported in the main files, and if not then both of us can check if it's in other files we want to keep. Will be annoying, but then we're potentially in a situation like one of my favorite XKCD comics if we try to automate this :D

andrewtavis commented 1 year ago

Hi @mrnninster :) 505e004 just finished the first part of this issue. Took a couple hours, but it's basically just doing safe delete within Android studio and removing unneeded references along the way. I think that's most of the Kotlin/layout files that aren't needed, and I'll start going through the icons soon :)

Let me know if you still have interest in all this! I've been hammering Scribe-iOS with the other contributor recently as we're trying to get v2.0.0 out :) That's adding autocomplete, autosuggest, and a bunch of other great features 😊

Hope you're well!

andrewtavis commented 1 year ago

Hi again, @mrnninster :) :) So I'm going to close this as the files have generally been removed at this point. There's still lots to do, but I'd say it should happen within #18 where we'll read through the code and add in all the definitions that are needed and learn the code base 😊

Let me know if you have interest, and again, hope you're well!