I tried recommended Red Filename resolutions but still have red filenames?
What I was trying to do: I had existing and working functionality in another project, as in one class
and one activity
, that I copied to this project rather than recreating them.
What I have tried: I included the new activity in the androidmanifest.xml
, corrected import
and package
statements, etc.; I have fixed issues and warnings that were identified or apparent and they have the "green check" with no problems. I tried suggestions such as, invalidating caches and restarting, running an analysis on each file for errors or issues, made updates to the AndroidManifest and if necessary gradle build files, and simply committed to git (VCS) as recommended here at JetBrains and reviewed the recommended link on File Status'.
I'm still fairly new to the inner workings for the IDE and some Android, so I certainly could miss something but it doesn't seem apparent. I was hoping for further thoughts. I posted the two files in question, but I wasn't sure it was all that beneficial if I have the "green check", but maybe someone will see what I don't. This code works in the other project without issue.
Screenshot (requested)
Activity Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivityMaster">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/master_enter_db" />
<EditText
android:id="@+id/database_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="@string/master_enter_db"
android:hint="@string/master_enter_db"
android:inputType="text"
android:text="">
</EditText>
<Button
android:id="@+id/addDatabase"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/master_add_db">
</Button>
<ListView
android:id="@+id/database_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ListView>
<Button
android:id="@+id/useSelectedDatabase"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/master_no_db_selected"
android:clickable="false"
>
</Button>
</LinearLayout>
Activity Class:
package com.mistywillow.researchdb;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.database.Cursor;
import android.view.View;
import android.widget.*;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import androidx.cursoradapter.widget.SimpleCursorAdapter;
import com.mistywillow.researchdb.databases.MasterDatabase;
import com.mistywillow.researchdb.masterdb.dao.MasterDao;
import com.mistywillow.researchdb.masterdb.entity.MasterDatabaseList;
public class MainActivityMaster extends AppCompatActivity {
MasterDatabase mMasterDB;
MasterDao mMasterDBDao;
EditText mDBToAdd;
Button mAddDB,mUseSelectedDatabase;
ListView mDatabaseList;
SimpleCursorAdapter mSCA;
Cursor mCsr;
long mSelectedDatabaseId = 0;
String mSelectedDatabaseName = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_master);
mDBToAdd = this.findViewById(R.id.database_name);
mAddDB = this.findViewById(R.id.addDatabase);
mUseSelectedDatabase = this.findViewById(R.id.useSelectedDatabase);
mDatabaseList = this.findViewById(R.id.database_list);
mMasterDB = MasterDatabase.getInstance(this);
mMasterDBDao = mMasterDB.getMasterDao();
setUpAddDBButton();
setUpUseSelectedDatabaseButton();
setOrRefreshDatabaseList();
}
private void setUpAddDBButton() {
mAddDB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mDBToAdd.getText().toString().length() > 0) {
if (mMasterDBDao.insert(new MasterDatabaseList(mDBToAdd.getText().toString())) > 0) {
mDBToAdd.setText("");
setOrRefreshDatabaseList();
}
}
}
});
}
private void setUpUseSelectedDatabaseButton() {
mUseSelectedDatabase.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mSelectedDatabaseId > 0) {
Intent intent = new Intent(view.getContext(),MainActivity.class);
intent.putExtra(MainActivity.INTENT_EXTRA_DATABASEID, mSelectedDatabaseId);
intent.putExtra(MainActivity.INTENT_EXTRA_DATABASENAME,mSelectedDatabaseName);
startActivity(intent);
}
}
});
}
private void setOrRefreshDatabaseList() {
mCsr = mMasterDBDao.getAllDatabasesAsCursor();
if (mSCA == null) {
mSCA = new SimpleCursorAdapter(
this.getApplicationContext(),
android.R.layout.simple_list_item_1,
mCsr,
new String[]{MasterDatabaseList.COL_DATABASE_NAME},
new int[]{android.R.id.text1},
0
);
mDatabaseList.setAdapter(mSCA);
mDatabaseList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
/* Handle Clicking on an Item (i.e. prepare UseSelected Button) */
@SuppressLint("Range")
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
mSelectedDatabaseId = l;
if (l > 0) {
mSelectedDatabaseName = mCsr.getString(mCsr.getColumnIndex(MasterDatabaseList.COL_DATABASE_NAME));
mUseSelectedDatabase.setText(mSelectedDatabaseName);
mUseSelectedDatabase.setClickable(true);
} else {
mUseSelectedDatabase.setText(R.string.master_no_db_selected);
mUseSelectedDatabase.setClickable(false);
}
}
});
} else {
mSCA.swapCursor(mCsr);
}
}
@Override
protected void onResume() {
super.onResume();
setOrRefreshDatabaseList();
}
@Override
protected void onDestroy() {
super.onDestroy();
mCsr.close();
}
}
Please sign in to leave a comment.
Hi there,
Could you post a screenshot demonstrating these?
Is it a Gradle project?
Arina,
Thanks for the reply. I posted a screen shot as requested. I've continued to work on the project and performed another "committ" and these files do not show up as needing committed or when I write their names in the notes for the commit.
Ohiovallery
As I can see from a screenshot you have red filenames, it means that these files haven't been added to Git.
And in your last message you have mentioned:
>performed another "committ" and these files do not show up as needing committed or when I write their names in the notes for the commit.
So this is expected. Once a file has been added to git - it will change color from red to green, and once committed - from it will have neutral/white filename color. Once you modify it - it will be blue.
Could you please clarify what exactly seems to be an issue with a filename color? Do you consider it as a marker that file has some issues?
Hi Ruslan,
Thanks for the timely responses. I did finally get them to commit but I had to do something I never had done before; I had to select the files. Whereas, any added or modified files in the past were always checked. So, I guess I solved my problem with everyone's help, just having to think take it a step further than usual.
Yes, I do interpret red to mean there are issues or something negative with the file. According to the "File Status" link red appears to mean something is wrong. Red in general always means there is an issue.
Hi Ohiovallery
Thank you for your reply and clarification.
Would it be possible to share a screenshot of Local changes/Commit toolwindow when you experience such issue?
Filename in red can mean that there is a merge conflict OR file hasn't been commited to git (it's unversioned).
When there are some errors/issues in a file then its filename is underlined.
Hi Ruslan,
Sure, I can share a screen shot but I don't have the Red Filename issue at the moment. Here is an example, which once I checked it, it was committed:
Hi Ohiovallery
I am sorry, I believe that there could be a compression issue (with screenshots). But do I understand correctly, that you've done "Git | Add" then you've commited a file and its name became red?
Do you have mutliple repositories in your project?
Hi Ruslan,
I do not have multiple repositories for this project, and when I commit to Git, I use the green arrow in the upper right corner of Intellij. I will take a moment and try to clarify.
The situation was this...
I copied from another separate project two files (i.e., an activity class and activity layout) to avoid having to recreate them in the project I was working. When I did so, they turned red; I suppose because I did not create them locally otherwise they probably would have been green. When I made other modification to use these two new RED files within the project and tried to commit, all the changes committed EXCEPT these two files. I did all the recommended helps and checks but they would not commit.
The solution...
It turned out the only reason the files would not commit is that they were "unchecked" in the Commit Changes window. I found them (I think it was) within a collapsed folder called "Unversioned files." When I opened that folder, I "checked" them, and when I selected commit, they committed and turned white.
The reason I was failing...
Until that time, all my file changes were automatically "checked" and I just simply entered a "commit message" and submitted. Everything is always checked so I was unaware and never thought of anything being unchecked. So I couldn't figure out why they would not commit with the others.
Hi Ohiovallery
Thank you for such broad explanation.
Now it's clear to me what was going on.
>I copied from another separate project two files (i.e., an activity class and activity layout) to avoid having to recreate them in the project I was working. When I did so, they turned red;
They turned red because they were not added to Git. This behavior, by the way, can be controlled by "When files are created" drop down menu in Preferences | Version Control | Confirmation. So you may have "Don't ask" there and this is why your files were red. If you set it to "Add silently" then file would become green once you copy it over in your project.
>I found them (I think it was) within a collapsed folder called "Unversioned files." When I opened that folder, I "checked" them, and when I selected commit, they committed and turned white.
That's right. Files that haven't been added to Git can be found under "Unversioned files" node in Local changes