Is there a way in Android Studio to see all local changes in a single diff window? - android-studio

With other editors I used it was possible to see all local changes in a single diff window showing the unified diffs off all files one after the other, so if I changed 3 files for example then I could simply scroll through the changes in a single window without having to select the files separately for diffs.
Here's an example of what I mean from magit which shows all changes in a single window:
Is there a way to do this is Android studio?

Right-click on your project in project structure on the left.
then Local History -> Show History. If you want to show history only for src folder, click on it.. the same for layout folder etc..
It will open in one separate window and shows diff between changed and file before changes.

Try Version Control on the bottom left of Android Studio:
It lets you choose between the unified viewer and a side-by-side view:

Related

Recovering files deleted by Android studio?

I'm working on an app at the moment, and one of the final steps was to get it built and signed in Android studio.
Unfortunately I was having some problems, and one of the recommended solutions was to remove the project and start again, however when I did this it took all of my files with it, and they're not in the trash (OSX) either.
Is there anyway to recover these files, or are they lost forever? :(
In my case I was looking for the file named 'landing_page222.java' which I deleted one day back.
Following Steps can help you to find your previously deleted files in Android Studio.
Step 1: Right Click on the folder where you deleted the file
Step 2: Find option for Local History and Click Show History.
Step 3: Find your File from Given List.
Hopefully it will be available in Instance
Step 4: Copy the code back as per need.
You can try:
looking for those files in the file system (perhaps they are still in your Android Studio projects folder)
looking in your OS's temp folder
using Android Studio's history feature (right-click on the Project tab > Local History > Show history)
Click whereever you want in the left frame (for example "drawable" file is ok) and then press CTRL+z. You are going to see "Undo delete popup" window.
And as you understand, when you press CTRL+z in Android Studio, which (XML or Java) file is active, you will undo the action on that tab. So, if you click any file on the left side and press the CTRL+z combination, you will undo the action at the file structure.
Go to View > Recent Changes > Click on the file you want to recover > Click "Revert"
Im late but this works. Go to the folder where u want to recover. right-click, local history. select ones you deleted and click revert. :)

Stop android studio grouping single-item directories with a dot

If I have a directory which only (at present!) contains another directory Android Studio decides, for some strange reason, to not expand the directories in the usual manor - ie click folder1 to reveal folder2, then click folder2 to show its contents - but instead put them together in a single entry (folder1.folder2). This makes the directory structure incredibly difficult and inconsistent to deal with when trying to manipulate the contents. Right now I'm having to revert to doing so in windows explorer!
Is the any way to change this peculiar behavior.
Click the settings icon in the Project view and uncheck Compact Empty Middle Packages.
Note: this screenshot is from IntelliJ Ultimate, but it should look the same (or similar) in Android Studio.
I got it to work similarly by going to the Project View settings and then unchecking the Flatten Packages option. This then got my folder configuration to the desired subfolder configuration format as described above. This may be new compared to the answer of 5 years ago. In my case, only unchecking the Compact Empty Middle option was not enough.
Use combination of Ctrl+Shift+A inside Android studio, it's a shortcut for "Find Action..." and type in "package", there is "Compact Middle Packages", turn that off.

I want to compare two projects in Android studio

I have a couple Android Studio projects that are similar, and I want to know exactly where their source files differ. What is an easy way to do that?
Right click file/directory/project/module > click compare with > give the path to compare
EASY WAY TO FIND PATH : ( considering both projects are open in Android Studio)
Switch to project you want to compare > right click file/directory/project/module > copy path > paste it back in select path dialog.
BETTER to copy path first.
Verified : Android Studio 1.5.1
In Android studio 3.4.2 you can do by right click on
Select Android : app → Compare Directories select proper path for your files and done.
In Android Studio Bumblebee : app → Compare With or Ctrl+D :)
I'm highly recommend Compare Directories Plugin for Android Studio 2+.
Allows the fast comparison of two directories or archive files (jar,
zip, war... and also tar/gz) based on file contents. Compared
directories/archives are shown in a tree view to give a better and
easier-to-read overall view of the differences.
Installation:
Open: File > Settings > Plugins
Click on the button “Browse repositories”, find the “Compare Directories” plugin in the available plugins list, right click on it and choose install.
General usage instructions:
Execute the Compare Directories... menu command, select two directories or zip/jar/tar files containing files with the same file names and see the comparison results on the opened Compare Directories panel:
Files and directories are shown depending on the differences in their
contents: identical, different by blanks only, non-significantly
different, different, left-only, right-only.
Compared text file can be then edited within IDEA.
Compared text file differences can be then viewed with the usual IDEA diff window.
Compared class bytecode differences can be also viewed with the usual IDEA diff window.
Files and directories can be copied from one side to the other.
You will find many more details in the plugin page:
https://plugins.jetbrains.com/plugin/113-compare-directories

Count lines of code in all java classes in Android Studio

Is there any way I can view the total lines of code in each java class in my project?
Looking for something like this for Android Studio.
Go to
https://plugins.jetbrains.com/idea/plugin/4509-statistic
and install the latest version
To install
Run Android Studio
From the menu bar, select File-->Settings
Under IDE Settings, click Plugins, and then click Install plugin from disk
Navigate to the folder where you downloaded the plugin and double-click it
Restart Android Studio
To count the lines
Check the statistics option that is visible after installing the
plugin
This option is near the run, debug, gradle console, bottom left corner of Android studio
21/05/2015
If you cannot see the Statistics options, do the following:
Select VIEW from the toolbar.
Select TOOLS Windows.
Choose STATISTICS.
You will see the statistics of your project and at the bottom, there is TOTAL section which displays the total lines under the Column of LINES.
You could try this plugin (It is for IntelliJ but should work with AS): http://plugins.jetbrains.com/plugin/?idea&id=4509
Goto the link https://plugins.jetbrains.com/plugin/4509-statistic and install it.
General Usage Instructions
Install plugin from official Jetbrains plugin site,
After installing, just click on the TAB "Statistic" at the bottom of the screen (left side),
Click "Refresh" button to run statistic for whole project,
Click "Refresh on selection" button to run statistic for selected directory,
Click "Settings" button to customize plugin behavior,
Adjust "Excluded file types" with all extensions which you want to remove from the statistic (e.g. class;jar;...),
Adjust "Seperate TABs file types" with all extensions which you want to have in separate tab (e.g. php;java;...),
Note:
Size - total size of the file,
Size Min - size of the smallest file of the given type,
Size Max - size of the biggest file of the given type,
Size Avg - average size of the file of the given type.
Jetbrain's statistics plugin is counting only .java files. It is not accurate for getting android app source line of code.
We can use locmatrics for this.
http://www.locmetrics.com/
This will return loc for all the entered extensions.
Please set a valid output directory while checking this. Otherwise garbage files will be generated inside source directory

How do I create a patch from diff between revisions using TortoiseSVN?

I'm working on a project where Subversion is used to maintain version control. I use TortoiseSVN to access the project repository.
Some changes were made between two revisions on a project (let's call them rev1 and rev2), and I want to be able to apply these changes to a working copy somewhere that temporarily does not have access to the repository.
I right-clicked on a project folder, clicked 'SVN show log', selected the two revisions and selected 'Show changes as unified diff'.
This causes a window to be shown, displaying output that very much looks like a patch file that I could save. Unfortunately, I find that there is no option in the window that lets me save this as a patch file.
How can I create the patch file?
The next version of TortoiseSVN (1.7.x) will have that save option. In the meantime, you can configure a plain text editor as your unified diff viewer:
Settings dialog->External Programs->Unified Diff Viewer
There you could, for example, specify notepad.exe as your diff viewer.
One way to achieve you goal is to right click on the revision in the TortoiseSVN log and choose "Merge revision to...". Then you select you local working project and click OK.

Resources