Thursday, 11 December 2014

Blog is moving to another place, better place

Hi, I am going to write further posts in different url: http://blog.mokrzycki.io/
I decided to move out from blogger to wordpress because I couldn't store any pics or videos. Everytime I had to upload stuff somewhere out of blogger where I wasn't able control it in 100%.
See you there, feel free post there! 
 _      _                                     _                             _     _     _        
| |__  | |  ___    __ _     _ __ ___    ___  | | __ _ __  ____ _   _   ___ | | __(_)   (_)  ___  
| '_ \ | | / _ \  / _` |   | '_ ` _ \  / _ \ | |/ /| '__||_  /| | | | / __|| |/ /| |   | | / _ \ 
| |_) || || (_) || (_| | _ | | | | | || (_) ||   < | |    / / | |_| || (__ |   < | | _ | || (_) |
|_.__/ |_| \___/  \__, |(_)|_| |_| |_| \___/ |_|\_\|_|   /___| \__, | \___||_|\_\|_|(_)|_| \___/ 
                  |___/                                        |___/                             

Tuesday, 18 November 2014

Coca Cola Club/House 2003 collection - names of tracks

Many years ago Coca Cola was giving away for free collection with cool club/house music.I am not sure if is it possible to get that CD from the web but here is that list (hope it will help someone who was lurking around for that great tracks!).

1. Moguai - U know y
2. Spiller - Cry baby
3. Big world meets Gerald - Love is like music
4. Phil Fuldner - Miami pop
5. The goodfallas - Soul heaven
6. David Chong - I love
7. Tomy Novy - I rock
8. Millan & D`Attis - Lift me up
9. Nalin inc. - Planet violet
10. Frank Moiraghi - The sound

Monday, 10 November 2014

com.android.support:appcompat-v7:21.+ and aapt.exe has stopped - solution

If you are occurring still error dialogs after you implemented
compile 'com.android.support:appcompat-v7:21.+' 
in your project, it might means you forget set build tools to the latest version. To fix that, you should go to your gradle.build file and change version in buildToolsVersion param i.e. to 21.1.1 (remember to update your sdk!).

Example:

 android {  
   compileSdkVersion 21  
   buildToolsVersion "21.1.1"//<--------------------!!!  
   defaultConfig {  
     applicationId "com.example.project"  
     minSdkVersion 14  
     targetSdkVersion 21  
     versionCode 1  
     versionName "1.0"  
   }  
   buildTypes {  
     release {  
       runProguard false  
       proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'  
     }  
   }  
 }  
 dependencies {  
   compile fileTree(dir: 'libs', include: ['*.jar'])  
   compile 'org.jsoup:jsoup:1.7.2'  
   compile 'com.android.support:appcompat-v7:21.+'  
 }  

Sunday, 9 November 2014

Problem with update android studio due modified file device-art.xml studio64.exe.vmoptions - rescue text !

Here is a default source of device-art.xml in case of problem with updating android studio to new version
http://pastebin.com/PyZWYv0E

Here is a default source of studio64.exe.vmoptions in case of problem with updating android studio to new version
http://pastebin.com/HrWmusZZ

Friday, 17 October 2014

Intent chooser - custom action button - example

Without saying empty words...
First we need make own Activity which will handle our action - in my example it will be a plain text which will be stored into android clipboard.

First our clipboard activity:

 public class ClipActivity extends Activity {  
   
   public static final String TAG = ClipActivity.class.getSimpleName();  
   
   @Override  
   protected void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
   
     if (getIntent().getExtras() != null) {  
       //just listing keys and values  
       for (String s : getIntent().getExtras().keySet()) {  
         Log.d(TAG, s + " " + getIntent().getExtras().getString(s));  
       }  
   
       //copying our text to android clipboard  
       if (getIntent().hasExtra("android.intent.extra.TEXT")) {  
         ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);  
         ClipData cd = ClipData.newPlainText("clipboard", getIntent().getExtras().getString("android.intent.extra.TEXT"));  
         cm.setPrimaryClip(cd);  
       }  
     }  
     Toast.makeText(this, "Copied by our app :)", Toast.LENGTH_SHORT).show();  
     finish();  
   }  
   
 }  

The second step is to declare our action intent in our manifest file.

 <activity android:name=".ClipActivity" android:noHistory="true" >  
      <intent-filter android:icon="@android:drawable/ic_dialog_alert" android:label="My label">  
           <action android:name="android.intent.action.SEND"/>  
           <category android:name="android.intent.category.DEFAULT"/>  
           <data android:mimeType="text/plain"/>  
      </intent-filter>  
 </activity>  

However it is possible your action will blink while action -> open activity-copy to clipboard-kill activity.

So you should use transculent theme like that:

     <activity android:name=".ClipActivity" android:noHistory="true" android:theme="@android:style/Theme.Translucent">  
       <intent-filter android:icon="@android:drawable/ic_dialog_alert" android:label="My label">  
         <action android:name="android.intent.action.SEND"/>  
         <category android:name="android.intent.category.DEFAULT"/>  
         <data android:mimeType="text/plain"/>  
       </intent-filter>  
     </activity>  

Now it's the matter of call our intent chooser :)

 Intent intent = new Intent();  
 intent.setAction(Intent.ACTION_SEND);  
 intent.putExtra(Intent.EXTRA_TEXT, "This is my text to copy.");  
 intent.setType("text/plain");  
   
 Intent chooser = Intent.createChooser(intent, "My Intent Chooser");  
   
 if(intent.resolveActivity(getActivity().getPackageManager()) !=null)  
      getActivity().startActivity(chooser);  

So as you see, it's nothing hard as it could be.

Saturday, 4 October 2014

OnLoadFinished() called twice - solution

Recently I was learning cursor adapters and I've noticed strange thing with them. My last project was about parsing colors from colourlovers page and generate  custom views with colors values.

What I noticed was that, the cursorloaders existing in my fragment were called twice instead once.
I checked some posts about it and I found solution. IMHO you must always destroy loadmanagers when you don't want make them run twice. So here is just short snippet how to.

First you call your cursor loader somewhere in onActivityCreated in fragment:

 getLoaderManager().initLoader(0, null, this);   


And then somewhere in onStop in fragment you call:

 getLoaderManager().destroyLoader(0);  

Sunday, 28 September 2014

Git ignores my folder - here is a solution (for me it was : git ignored my drawable-xxxx folder with files)

I am not good in writing long posts so.. here is a short example and solution for that problem.
Be sure you have already checked .gitignore files, and you are sure it is not .gitignore files problem.

First, please write this code in console - to get list of ignored files:

 git status --ignored  

 # On branch master  
 # Ignored files:  
 #  (use "git add -f <file>..." to include in what will be committed)  
 #  
 #    ../../../.gradle/  
 #    ../../../.idea/  
 #    ../../app.iml  
 #    ../../build/  
 #    res/drawable-hdpi/  
 #    res/drawable-ldpi/  
 #    res/drawable-mdpi/  
 #    res/drawable-xhdpi/  
 #    res/drawable-xxhdpi/  
 #    res/drawable-xxxhdpi/  
 #    ../../../build/  
 #    ../../../java_pid5188.hprof  
 #    ../../../java_pid5940.hprof  
 #    ../../../local.properties  
 #    ../../../prawo-g.iml  

As you see, somehow res/drawable-xxxx is ignored..
So let's add it again by this command:

 git add --force .\res  

And let's see again our ignore list...

 git status --ignored  


 # On branch master  
 # Ignored files:  
 #  (use "git add -f <file>..." to inclu  
 #  
 #    ../../../.gradle/  
 #    ../../../.idea/  
 #    ../../app.iml  
 #    ../../build/  
 #    ../../../build/  
 #    ../../../java_pid5188.hprof  
 #    ../../../java_pid5940.hprof  
 #    ../../../local.properties  
 #    ../../../prawo-g.iml  

Voila! Our missing files were added back to revision.
Dont forget to use later commands:

 git add -A   
 git commit -am "added missing files in revision"  

Thursday, 28 August 2014

Pretty snippet example for formatting millis to own date format

Here is that pretty snippet

 public static String getDate(long milliSeconds, String dateFormat)  
 {  
   // Create a DateFormatter object for displaying date in specified format.  
   SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);  
   // Create a calendar object that will convert the date and time value in milliseconds to date.   
    Calendar calendar = Calendar.getInstance();  
    calendar.setTimeInMillis(milliSeconds);  
    return formatter.format(calendar.getTime());  
 }  

Took source from: http://stackoverflow.com/a/7954038/619673

And here is pattern structure for formatting:

SymbolMeaningKindExample
Dday in year(Number)189
Eday of week(Text)E/EE/EEE:Tue, EEEE:Tuesday, EEEEE:T
Fday of week in month(Number)2 (2nd Wed in July)
Gera designator(Text)AD
Hhour in day (0-23)(Number)0
Khour in am/pm (0-11)(Number)0
Lstand-alone month(Text)L:1 LL:01 LLL:Jan LLLL:January LLLLL:J
Mmonth in year(Text)M:1 MM:01 MMM:Jan MMMM:January MMMMM:J
Sfractional seconds(Number)978
Wweek in month(Number)2
Ztime zone (RFC 822)(Time Zone)Z/ZZ/ZZZ:-0800 ZZZZ:GMT-08:00 ZZZZZ:-08:00
aam/pm marker(Text)PM
cstand-alone day of week(Text)c/cc/ccc:Tue, cccc:Tuesday, ccccc:T
dday in month(Number)10
hhour in am/pm (1-12)(Number)12
khour in day (1-24)(Number)24
mminute in hour(Number)30
ssecond in minute(Number)55
wweek in year(Number)27
yyear(Number)yy:10 y/yyy/yyyy:2010
ztime zone(Time Zone)z/zz/zzz:PST zzzz:Pacific Standard Time
'escape for text(Delimiter)'Date=':Date=
''single quote(Literal)'o''clock':o'clock

Took source from: http://developer.android.com/reference/java/text/SimpleDateFormat.html


When we format hour, there are few options:

kk = Hours in 1-24 format
hh= hours in 1-12 format
KK= hours in 0-11 format
HH= hours in 0-23 format

Monday, 4 August 2014

Caused by: java.lang.NoClassDefFoundError: java/util/HashMap$Entry in gradle using ConfigSlurper

If suddently  you gets this error:

 Caused by: java.lang.NoClassDefFoundError: java/util/HashMap$Entry  
it might means you are not using Java 7 anymore. So please be nice to check in console using command:

 java -version  
you have java version lower than 8...

The best way is to go Start>Control Panel>Add/Remove apps> and uninstall java jdk/jre version 8, leaving version 7.

Sunday, 6 July 2014

Problem with cannot.find.zip.align - solution

For problem occured like this:

 cannot.find.zip.align=The zipalign tool was not found in the SDK.  
   
 Please update to the latest SDK and re-export your application  
 or run zipalign manually.  
   
 Aligning applications allows Android to use application resources  
 more efficiently.  

The thing what you should do is to: copy file "zipalign.exe" from latest folder in "sdk\build-tools\" (example: sdk\build-tools\20.0.0) and copy to "sdk\tools".

Thursday, 19 June 2014

Collection.sort Comparator and Collator - compare special chars or just polish words

Here is the short example code.

 Collections.sort(parse, new Comparator<HashMap<String, String>>() {  
           @Override  
           public int compare(HashMap<String, String> lhs, HashMap<String, String> rhs) {  
             String station1 = null;  
             String station2 = null;  
   
             try {  
               station1 = new String(lhs.get("station").getBytes(), "utf-8");  
               station2 = new String(rhs.get("station").getBytes(), "utf-8");  
             } catch (UnsupportedEncodingException e) {  
               e.printStackTrace();  
             }  
   
             Locale locale = new Locale("pl_PL");  
             Collator collator = Collator.getInstance(locale);  
             return collator.compare(station1, station2);  
           }  
         });  

Tuesday, 3 June 2014

Example creating DialogFragment with onClickListener

Okay, another post with example DialogFragment with onClickListener.
This a my CustomDialogFragment class:

 public class CustomDialogFragment extends DialogFragment {  
   
   public static final String TAG = CustomDialogFragment.class.getSimpleName();  
   private DialogInterface.OnClickListener onItemClickListener;  
   private ImageView icon;  
   private TextView msg;  
   private Button btn;  
   private int iconRes;  
   private String msgRes;  
   private String btnRes;  
   private Context context;  
   
   public static CustomDialogFragment getInstance() {  
     CustomDialogFragment f = new CustomDialogFragment();  
     return f;  
   }  
   
   public void setOnClickListener(DialogInterface.OnClickListener onItemClickListener) {  
     this.onItemClickListener = onItemClickListener;  
   }  
   
   @Override  
   public Dialog onCreateDialog(Bundle savedInstanceState) {  
   
     final Dialog dialog = new Dialog(getActivity());  
     dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);  
   
     View view = LayoutInflater.from(getActivity()).inflate(R.layout.custom_dialog_fragment, null);  
   
     icon = (ImageView) view.findViewById(R.id.image1);  
     msg = (TextView) view.findViewById(R.id.text1);  
     btn = (Button) view.findViewById(R.id.button1);  
   
     if (iconRes != 0)  
       icon.setImageResource(iconRes);  
   
     if (msgRes != null)  
       msg.setText(msgRes);  
   
     if (btnRes != null)  
       btn.setText(btnRes);  
   
     if (onItemClickListener != null) {  
       btn.setOnClickListener(new View.OnClickListener() {  
         @Override  
         public void onClick(View v) {  
           onItemClickListener.onClick(dialog, 0);  
         }  
       });  
     }  
   
     dialog.setContentView(view);  
   
     return dialog;  
   }  
   
   public void setIconImageResource(int res) {  
     iconRes = res;  
   }  
   
   public void setMessageTextResource(int res) {  
     msgRes = context.getString(res);  
   }  
   
   public void setMessageText(String res) {  
     msgRes = res;  
   }  
   
   public void setButtonTextResource(int res) {  
     btnRes = context.getString(res);  
   }  
   
   public void setButtonTextResource(String res) {  
     btnRes = res;  
   }  
   
   public void setContext(Context context) {  
     this.context = context;  
   }  
   
 }  

And here is dialog layout:

 <?xml version="1.0" encoding="utf-8"?>  
   
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
   android:layout_width="wrap_content"  
   android:layout_height="wrap_content"  
   android:padding="50dp"  
   android:background="#ff0000"  
   >  
   
   <ImageView  
     android:id="@+id/image1"  
     android:layout_width="wrap_content"  
     android:layout_height="wrap_content"  
     android:layout_centerHorizontal="true"  
     android:src="@drawable/ic_launcher" />  
   
   <TextView  
     android:layout_below="@+id/image1"  
     android:id="@+id/text1"  
     android:layout_width="wrap_content"  
     android:layout_height="wrap_content"  
     android:layout_centerHorizontal="true"  
     android:text="This is message" />  
   
   <View  
     android:layout_below="@+id/text1"  
     android:id="@+id/separator"  
     android:layout_width="wrap_content"  
     android:layout_centerHorizontal="true"  
     android:layout_height="10dp" />  
   
   <Button  
     android:layout_below="@id/separator"  
     android:id="@+id/button1"  
     android:layout_width="wrap_content"  
     android:layout_height="wrap_content"  
     android:layout_centerHorizontal="true"  
     android:text="OK" />  
 </RelativeLayout>  

And here is initalization in any FragmentActivity class:

 public class MainActivity extends ActionBarActivity {  
   
   @Override  
   protected void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
     setContentView(R.layout.activity_main);  
   
     initDialog();  
   }  
   
   private void initDialog() {  
     CustomDialogFragment cdf = CustomDialogFragment.getInstance();  
     cdf.setContext(this);  
     cdf.setIconImageResource(android.R.drawable.btn_star);  
     cdf.setMessageText("Hello world!");  
     cdf.setButtonTextResource(android.R.string.ok);  
     cdf.setOnClickListener(new DialogInterface.OnClickListener() {  
       @Override  
       public void onClick(DialogInterface dialog, int which) {  
         dialog.dismiss();  
       }  
     });  
   
     Fragment fragmentByTag = getSupportFragmentManager().findFragmentByTag(CustomDialogFragment.TAG);//avoid opening twice dialog  
     if (fragmentByTag == null)  
       cdf.show(getSupportFragmentManager(), CustomDialogFragment.TAG);  
   }  
   
 }  

Sample pic:

Uri from local drawables for universal image loader

Here is short example how display local drawables by universal image loader.

We have somewhere xml, array with images:

 <array name="avatars_male">  
      <item>@drawable/pic0</item>  
      <item>@drawable/pic1</item>  
      <item>@drawable/pic2</item>  
      <item>@drawable/pic3</item>  
      <item>@drawable/pic4</item>  
      <item>@drawable/pic5</item>  
      <item>@drawable/pic6</item>  
      <item>@drawable/pic7</item>  
      <item>@drawable/pic8</item>  
      <item>@drawable/pic9</item>  
      <item>@drawable/pic10</item>  
      <item>@drawable/pic11</item>  
      <item>@drawable/pic12</item>  
      <item>@drawable/pic13</item>  
 </array>  

We can load them to list:

 ArrayList<Integer> array = new ArrayList<Integer>();  
 TypedArray typedArray = getResources().obtainTypedArray(R.id.avatars_male);  
 for (int i = 0; i < 15; i++) {  
      array.add(typedArray.getResourceId(i, 0));  
 }  

And now we can take any pic by uri:

 int num = 10;//<according to value from dice :)  
   
 Uri uri = Uri.parse("drawable://" + array.get(num));  

Few configs how to prepare universal image loader:

 ImageLoaderConfiguration configBuilder = new ImageLoaderConfiguration.Builder(context)  
           .threadPriority(Thread.NORM_PRIORITY - 2)  
           .discCacheExtraOptions(250, 250, Bitmap.CompressFormat.JPEG, 75, null).build();  
   
 ImageLoader imageLoader = ImageLoader.getInstance();  
 imageLoader.init(configBuilder);  
   
 DisplayImageOptions imageLoaderOptions = new DisplayImageOptions.Builder()  
           .cacheInMemory(true) // default  
           .cacheOnDisc(true) // default  
           .imageScaleType(ImageScaleType.EXACTLY) // default  
           .bitmapConfig(Bitmap.Config.ARGB_8888) // default  
           .handler(new Handler()) // default  
           .build();  

And displaying:

 imageLoader.displayImage(String.valueOf(uri), holder.iv, imageLoaderOptions);  

Thursday, 29 May 2014

Avoid blinking imageViews in android - example nostra confuguration

Here is short code describing configuration for imageLoader to avoid blinking images when scrolling.

 imageLoader = ImageLoader.getInstance();  
 imageLoader.init(configBuilder);  
   
 imageLoaderOptions = new DisplayImageOptions.Builder()  
           .cacheInMemory(true)   
           .cacheOnDisc(true)   
           .imageScaleType(ImageScaleType.EXACTLY)   
           .bitmapConfig(Bitmap.Config.ARGB_8888)   
           .handler(new Handler())   
           .build();  
             
 imageLoader.displayImage("https://i.imgur.com/1od0gIFl.jpg", myImageView, imageLoaderOptions);  

Sunday, 25 May 2014

How to hide keyboard softinputmode in android? By view or without - example

Okay, here is another short code describing how to hide soft keyboard in android. I usually use this second code because I don't have to bother with specifying view. It is very important to call hide keyboard when all elements were initialized.

//1 method - you specify view with focus
public void hideKeyboard(View view) {  
      getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);  
      InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);  
   
      if (view != null) {  
           inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);  
      }  
 }  
 
//  2 method - gets any view which has focus
public void hideKeyboard(Activity activity) {  
      activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);  
      InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);  
            View cur_focus = activity.getCurrentFocus();  
      if (cur_focus != null) {  
           inputMethodManager.hideSoftInputFromWindow(cur_focus.getWindowToken(), 0);  
      }  
}  
   

Thursday, 15 May 2014

Regex - Intellij - examples

 search android:text= without @string refference  
   
 expression:  
 android\:text\=\"[^@].+  
   
 Text  
 android:text="balloon_item_title"<--  
 android:text="@balloon_item_title"  
 android:text="1234"<--  

 select <TextView...> or </TextView...>  
   
 expression:  
 \<(\/|)TextView   

 select just TextView word in <TextView...> or </TextView...>  
   
 Expression  
 (?!=\<(\/|))TextView   

Wednesday, 14 May 2014

Example of dialog fragment with listview (coded)

Here is short example how create dialog fragment with list in code.

 public class DialogMyListFragment extends DialogFragment {  
   
   private android.widget.AdapterView.OnItemClickListener onItemClickListener;  
   private Core application;  
   public static String TAG = "DialogMyListFragment";  
   
   public static DialogMyListFragment getInstance() {  
     DialogMyListFragment df = new DialogMyListFragment();  
     return df;  
   }  
   
   public void setOnItemClickListener(AdapterView.OnItemClickListener onItemClickListener) {  
     this.onItemClickListener = onItemClickListener;  
   }  
   
   @Override  
   public Dialog onCreateDialog(Bundle savedInstanceState) {  
   
     AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());  
     ListView list = new ListView(getActivity());  
   
     application = (Core) getActivity().getApplication();  
   
     List<String> elements = new ArrayList<String>();  
           for(int i=0;i<10;i++)  
                elements.add("item " + i);  
             
     ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, android.R.id.text1, elements);  
       
           list.setAdapter(adapter);  
     list.setOnItemClickListener(onItemClickListener);  
   
     builder.setView(list);  
   
     return builder.create();  
   
   }  
   
 }  

And then you call

 DialogMyListFragment df = new DialogMyListFragment().getInstance();  
 df.setOnItemClickListener(listener); 
 Fragment fr = getSupportFragmentManager().findFragmentByTag(DialogMyListFragment.TAG);  
 if (fr == null) {  
      df.show(getSupportFragmentManager(), DialogMyListFragment.TAG);  
 }   

Friday, 9 May 2014

Playing system notification sound with soundpool, converting uri to path

Here is short example, I think there is no need to explain. This works from 2.3+

 //take an uri and convert to path  
 Uri uriSound = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_NOTIFICATION;  
 String soundPath = getRealPathFromURI(uriSound);  
   
 //get natification system volume  
 AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);  
 final int currentVolume = audio.getStreamVolume(AudioManager.STREAM_NOTIFICATION);  
   
 //create pool, load system notification sound, when load - set volume and play  
 SoundPool soundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0);  
 final int loadedNotification = soundPool.load(soundPath, 1);  
 soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {  
      @Override  
      public void onLoadComplete(SoundPool soundPool, int i, int i2) {  
           soundPool.setVolume(loadedNotification, currentVolume, currentVolume);  
           soundPool.play(loadedNotification, 1, 1, 1, 0, 1);  
      }  
 });  
   
 //somewhere created method...  
   
 private String getRealPathFromURI(Uri contentUri) {  
      String[] proj = { MediaStore.Images.Media.DATA };  
      CursorLoader loader = new CursorLoader(this, contentUri, proj, null, null, null);  
      Cursor cursor = loader.loadInBackground();  
      int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);  
      cursor.moveToFirst();  
      return cursor.getString(column_index);  
 }  

Monday, 5 May 2014

Avoiding double executing fragment element - i.e DialogFragment

In short example:

 //somewhere I create instance of my fragment  
 df = new DialogAllSectionsFragment().getInstance();  
   
 //when calling the fragment  
 Fragment fr = getSupportFragmentManager().findFragmentByTag(DialogAllSectionsFragment.TAG);  
 if (fr == null) {  
      df.show(getSupportFragmentManager(), DialogAllSectionsFragment.TAG);  
 }  

Every fragment element has own TAG with own name, so when fragmentManager finds the current tag exists it just doesn't call it again. It helps when user doubleclik one of our buttons.

Friday, 2 May 2014

Libgdx - custom label text style declared in fonts.json

Here is short tutorial how set custom layout with custom font from json file.

What we need:
  1. create json file describing font style
  2. load json file to skin
  3. create own label with custom style
So let's start:

First I create font.json file to describe font style.

 {   
   com.badlogic.gdx.graphics.g2d.BitmapFont:  
   {  
     normaltext: { file: fonts64.fnt },  
     smalltext: { file: fonts32.fnt },  
   },  
   com.badlogic.gdx.graphics.Color:  
   {  
     white: { hex: "FFFFFF" },  
     green: { hex: "99CC00" },  
   },  
   com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle:  
   {  
     default: { font: normaltext, fontColor: green},  
     smalltext: { font: smalltext, fontColor: white },  
   }  
 }  

In

 com.badlogic.gdx.graphics.g2d.BitmapFont:   
 {   
        ...  
 },   

I declare font files, as you see I use two types of fonts. You can use just one. I assume you created own fonts by program i.e bmfont and stored in "your-project/assets/data/" folder.

In

 com.badlogic.gdx.graphics.Color:   
 {   
  white: { hex: "FFFFFF" },   
  green: { hex: "99CC00" },   
 },   

I declare color which will be used.

In

 com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle:   
 {   
  default: { font: normaltext, fontColor: green},   
  smalltext: { font: smalltext, fontColor: white },   
 }  

I declare here syles. That names will be used in java code to describe which style to use for label. I didn't add here "normaltext" because I won't use it in this example, so don't worry. When you finish your file, place it in "your-project/assets/data/" - the same place where the your .fnt file is stored.

OK, so we created file and stored in specific path. Now I need to go back to Java code. I must create skin object to load this json file.

 Skin skin = new Skin(Gdx.files.internal("data/fonts.json"));

Next step is to create label in code and use own style.

 Label instructionLabel = new Label("My instruction", skin, "smalltext");  

The third argument is the my custom style of font. If I didn't add this third element, label would load "default" style. But I want own style so I added "smalltext".

So, that's it! Don't forget add this label as "addActor(instructionLabel)" to your stage.

Wednesday, 30 April 2014

Timeouting onPause for activity for more operations

Here is some code how to timeout some time for onPause to i.e
  • show dialog (activity behaving like dialog) 
    • when we click on notification 
      • only when any of our activity is displaying  
This example is quite hard to describe in short but there is explanation how to make custom OnClickListener for notification in my one of the latest posts. And by using that code with this post you can achieve this magic trick..

Here will be some help how to open second activity with custom dialog. It makes no sense for normal displaying some data, but for notifications it is very helpful. This is just silly example, how to make it and make it clear.
 So what I did was:

In Application class

 public class MyApplication extends Application {  
      
      //... application methods  

      //declaring flag to know if activity is running  
      public boolean isRunning;  
      public long timeout;  
 }  

For every activity I added to onResume and onPause methods, flag - it will describing if activity is running.

 @Override  
 protected void onResume() {  
   super.onResume();  
   application.isRunning = true;  
 }  

 @Override  
 protected void onPause() {  
   super.onPause();  
   application.isRunning = false;//setting field in Application  
   application.timeout=System.currentTimeMillis();  
 }  

Also there was declared second field describing what is the current time - timeout - in Application class

Let's say we want show this "dialog" when I click the second activity, so in onCreate this second activity you need add something like th

 if (application.isRunning || timeoutLessThan(application, 300)) {  
   //showing dialog  
 } else {  
   //nothing to do  
 }  

 private boolean timeoutLessThan(NHApplication application, int value) {  
      long abs = Math.abs(application.timeout - System.currentTimeMillis());  
      Log.d(TAG, "diff timeout " + abs);  
      return abs < value;  
 }  


This timeout will help when you want do some fast action in 300ms before pausing the first activity.

Monday, 28 April 2014

Android - Make layout clickable with its children

To make your layout clickable with its children you need add this option for every child

 android:clickable="false"   

Of course I am talking about only clickable state, not drawable state which is the another story.

 <LinearLayout  
      android:id="@+id/parent"  
      android:layout_width="match_parent"  
      android:layout_height="wrap_content"  
      android:orientation="horizontal">  
      <ImageButton  
           android:clickable="false"  
           android:layout_width="40dp"  
           android:layout_height="40dp"  
           android:text="Cinema"  
           android:textSize="13sp"  
           android:layout_marginRight="10dp" />  
      <Button  
           android:clickable="false"  
           android:layout_width="match_parent"  
           android:layout_height="40dp"  
           android:text="Check in"  
           android:textSize="13sp" />  
 </LinearLayout>  

Sunday, 27 April 2014

Libgdx - parse Color from String hex to 3x float -> new Color( float, float, float, float)

Here is short code. Very lazy but it works anyway. I ommited transparency.
This code converts String hext to three floats with alpha level 1

 public static Color parseColor(String hex) {  
      String s1 = hex.substring(0, 2);  
      int v1 = Integer.parseInt(s1, 16);  
      float f1 = (float) v1 / 255f;  
      String s2 = hex.substring(2, 4);  
      int v2 = Integer.parseInt(s2, 16);  
      float f2 = (float) v2 / 255f;  
      String s3 = hex.substring(4, 6);  
      int v3 = Integer.parseInt(s3, 16);  
      float f3 = (float) v3 / 255f;  
      return new Color(f1, f2, f3, 1);  
 }  

Example:

 interface Pallete {  
      public static Color blue = parseColor("33B5E5");  
      public static Color violet = parseColor("AA66CC");  
      public static Color green = parseColor("99CC00");  
      public static Color orange = parseColor("FFBB33");  
      public static Color red = parseColor("FF4444");  
      public static Color yellow = parseColor("FFDE00");  
      public static Color brown = parseColor("593E1A");  
      public static Color gray = parseColor("BDD8DA");  
      //  
      public static Color white = parseColor("FFFFFF");  
      public static Color black = parseColor("000000");  
 }  

Wednesday, 23 April 2014

Setting onClick listener for GCM notification

Firstly, there is no such thing like setOnClickListerner for GCM notification but you can combine your own intent with custom multiple actions.

Normally, you creates intent which is goint to pendingIntent which creates notification - and.. this intent is like nothing else simple activity.

This looks something like that:
  1. You set own action for intent, i.e create sms with custom text or call for custom number
  2. Then you create PendingIntent which is taking as one of few arguments our intent
  3. Next step is use Notification.Builder and set its behaviour for notification. You also add to it your pendingIntent(point 2) which will call action from intent (point 1)
  4. As a last step you build it and add to notify
So as you see, there is not place for such thing like onClick, but hey you can create own activity which will call in onCreate your action and then do own action like create sms or call to someone.

Here is my code:

 //gcm part, found on google start guid with gcm, modified some
 //my method takes some data stored in contentValues, this just an example  
 private void sendNotification(ContentValues cv) {  
      mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);  
   
      Intent intent = new Intent(this, StatPendingActivity.class);//CUSTOM ACTIVITY HERE  
   
      Bundle parcerable = new Bundle();  
      parcerable.putParcelable("data", cv);  
   
      intent.putExtra("parcelable", parcerable);  
   
      //intent drops into pendingIntent, REMEMBER USE FLAG_UPDATE_CURRENT to be able pass data!  
      PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);  
   
      NotificationCompat.Builder mBuilder =  
                new NotificationCompat.Builder(this)  
                          .setSmallIcon(android.R.drawable.presence_video_busy)  
                          .setLargeIcon(((BitmapDrawable) getResources().getDrawable(android.R.drawable.presence_video_busy)).getBitmap())  
                          .setContentTitle(cv.getAsString(key_title))  
                          .setStyle(new NotificationCompat.BigTextStyle()  
                                    .bigText(cv.getAsString(key_message)))  
                          .setContentText(cv.getAsString(key_message));  
   
      mBuilder.setContentIntent(contentIntent);  
   
      //FLAG TO SHOW ONLY ONE NOTIFICATION  
      Notification build = mBuilder.build();  
      build.flags |= Notification.FLAG_AUTO_CANCEL;  
      mNotificationManager.notify(NOTIFICATION_ID, build);  
 }  

And here is my custom Activity :

 public class StatPendingActivity extends Activity {  
   
   private String url = "http://localhost";  
   
   @Override  
   protected void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
   
           //this just an example, I takes some data from GCM which was in previous method  
     Bundle parcelable = getIntent().getBundleExtra("parcelable");  
     if (parcelable != null) {  
   
       ContentValues cv = parcelable.getParcelable("data");  
       Intent intent = new Intent();  
   
                //here I do some stuff with data from GCM  
       if (cv.getAsString(key_action).equals("CLICK_TO_SMS")) {  
         String smsNumber = cv.getAsString(key_sms_number);  
         String smsMessage = cv.getAsString(key_sms_message);  
   
         Uri uriNumber = Uri.parse("smsto:" + smsNumber);  
         intent = new Intent(Intent.ACTION_SENDTO, uriNumber);  
         intent.putExtra("sms_body", smsMessage);  
   
       }  
                //calling like notification some action, here is sending the sms  
                //we do not want remember this activity because it should behave like normal notification  
       intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);  
       startActivity(intent);  
   
                //my custom action, something like onClickListener  
                //this method call asynctask, so it wont be killed if activity is destroyed  
       sendClickStat(cv);//my action to do when I click notification  
   
       finish();//destroying this activity  
     }  
   }  
   
 }  

Monday, 3 March 2014

Java snippet - upload images to DCIM Android Folder in one click (intellij)

Here is simple snippert for uploading images to Android DCIM folder.
First we need create folder for images, I have something like this:

 i (1).jpg  
 i (2).jpg  
 i (3).jpg  
 i (4).jpg  
 i (5).jpg  
 i (6).jpg  
 i (7).jpg  
 i (8).jpg  
 i (9).jpg  

Now, we copy path to this folder, lets say it is:
 "C:\\Users\\Me\\Pictures\\images_face\\";  

If everything is prepared, you can use this code to upload images to DCIM

 public class Main {  
   public static final int SECOND_DELAY = 3;  
   public static final String path = "C:\\Users\\Me\\Pictures\\images_face\\";  
   public static void main(String[] args) throws IOException, InterruptedException {  
     new Main().doStuff();  
   }  
   private void doStuff() throws IOException, InterruptedException {  
     File file = new File(path);  
     Runtime rt = Runtime.getRuntime();  
     for(File f: file.listFiles())  
     {  
       String command = "adb push " + "\"" +path + f.getName() + "\"" + " /sdcard/DCIM";  
       System.out.println(command);  
       Process pr = rt.exec(command);  
       long timeDelay= SECOND_DELAY * 1000;  
       Thread.sleep(timeDelay);  
     }  
   }  
 }  

P.S Make sure your device is connected and adb shell works ok of course! :)

Tuesday, 25 February 2014

Java snippet - remove folders out, gen, .idea and files .iml from many Android projects in one click (intellij)

Here is simple java snippet to remove all not interesting files from Android projects.
This snippet removes, gen, out, .idea folders with files inside and also .iml file
 public class main {  
   private static final String[] FOLDERS = new String[]{"gen", "out", "bin", /*".idea"*/};  
   private static final String[] FILES_EXTENSION_TO_DEL = new String[]{/*".iml"*/};  
   private static final String PATH = "C:\\FolderX\\androidprojects";  
   private static final String[] IGNORE_EXTENSIONS = new String[]{".svn"};  
   private static ArrayList<File> dirToRemowe = new ArrayList<File>();  
   private static ArrayList<File> filesToRemowe = new ArrayList<File>();  
   public static void main(String[] args) {  
     new main().doStuff(PATH);  
   }  
   private void doStuff(String path) {  
       String currentPath = PATH;  
       System.out.println("[PATH] " + currentPath);  
       File file = new File(currentPath);  
       iterateFolders(file, false);  
       deleteElements(filesToRemowe);  
       deleteElements(dirToRemowe);  
   }  
   private void deleteElements(ArrayList<File> filesToRemowe) {  
     Collections.reverse(filesToRemowe);  
     for (File f : filesToRemowe) {  
       System.out.println("f[] To remove: " + f.getAbsolutePath());  
       try {  
         FileInputStream in = new FileInputStream(f);  
         in.close();  
       } catch (FileNotFoundException e) {  
       } catch (IOException e) {  
         e.printStackTrace();  
       }  
       System.out.println(f.delete() + "");  
       try {  
         Thread.sleep(5);  
       } catch (InterruptedException e) {  
         e.printStackTrace();  
       }  
     }  
   }  
   public static void iterateFolders(File file, boolean interesting) {  
     File[] files = file.listFiles();  
     for (File f : files) {  
       String absolutePath = f.getAbsolutePath();  
       //if interesting folder true so add all to remove list  
       if (interesting) {  
         if (f.isFile()) {  
           if (!filesToRemowe.contains(f))  
             filesToRemowe.add(f);  
         } else if (f.isDirectory()) {  
           if (!dirToRemowe.contains(f))  
             dirToRemowe.add(f);  
           iterateFolders(f, true);  
         }  
       } else {  
         //default searching folders  
         //add file only with specific name, adding any file will be called when interesting == true  
         if (f.isFile()) {  
           for (String file_extension : FILES_EXTENSION_TO_DEL) {  
             if (f.getName().endsWith(file_extension)) {  
               if (!filesToRemowe.contains(f))  
                 filesToRemowe.add(f);  
             }  
           }  
         } else if (f.isDirectory()) {  
           interesting = false;  
           for (String s : FOLDERS) {  
             if (f.getName().equals(s))  
               if (!dirToRemowe.contains(f)) {  
                 dirToRemowe.add(f);  
                 interesting = true;  
               }  
           }  
           for (String s : IGNORE_EXTENSIONS)  
             if (f.getName().equals(".svn"))  
               continue;//and dont go inside svn, iterate again next  
           iterateFolders(f, interesting);  
           //resert interesting flag on exit from this folder  
           interesting = false;  
         }  
       }  
     }  
   }  
 }  

Monday, 24 February 2014

Unable to open 'xxx-unaligned.apk' as zip archive

If you found in your logs something like this`Unable to open 'xxx-unaligned.apk' as zip archive` it means that somehow compiler cannot reach to all resources so make sure that none of your project items doesn't have spaces in names.
In my situation I couldn't compile project because folder which I was storing project was named "project_android _version_x". As you see the title had space which shouldn't exist. If not, try select it by mouse and you will discover little space between "android" and "_version". Second important thing is to make sure your path to project isn't too long, sometimes it also makes problems..

Few steps:
  1. close project
  2. delete .idea, .iml, gen and out folders in project, main root
  3. correct names of folders which have android projects
  4. import again project
  5. and try now rebuild

Sunday, 23 February 2014

Windows 8 for developers? Not yet!

My opinion about Windows 8 is not quite positive. Few days ago, maybe 5 days I've installed original Windows 8 and then upgraded to 8.1 The only one thing what I connect with this system is "wtf!". Yes, beware from installing to new system. You will have to prepare for many new shiny BSOD's. Most of drivers doesn't work well and you will only lose so much time for searching solution that so far it is no worth for using Windows 8. But as I said, it's my opinion. The most annoying problem was about using android emulator with HAXM Intel tweaker to speed up booting device. It used to drop BSOD after few minutes when anroid emulator booted. I found on stack solution fix for this problem, but after I downloaded fix I couldn't install it, I don't know why, I even didn't wanted to know. (Ok I knew, it was about that the current version is newer than the fix so there was not way to install fix from Intel). So last thing what I did was to back to Windows 7 what is difference like heaven and hell. Please make sure you really want to join to Windows 8 and it's community or maybe give yourself some time to think about and then prepare for new system, new problems which shouldn't be popped up after few days... Remember, you are developer, you don't waste time being tech guy.

Thursday, 20 February 2014

Reading text from files in android - example

Here is working sample how to read text per line from file/files

 //find all files from folder /assets/txt/  
 String[] elements;
  
 try {  
   elements = getAssets().list("txt");  
 } catch (IOException e) {  
   e.printStackTrace();  
 }  

 //for every files read text per line  
 for (String fileName : elements) {  
   Log.d("xxx", "File: " + fileName);  
   try {  
     InputStream open = getAssets().open("txt/" + fileName);  
     InputStreamReader inputStreamReader = new InputStreamReader(open);  
     BufferedReader bufferedReader = new BufferedReader(inputStreamReader);  
     String line = "";  
     while ((line = bufferedReader.readLine()) != null) {  
       Log.d("xxx", line);     
     }  
   } catch (IOException e) {  
     e.printStackTrace();  
   }  
 }  

Saturday, 15 February 2014

Automatic adb install apks files to your phone if you are tired by do it manually - java snippet

This short snippet will help you a lot (I hope so). If you have apps on hardrive  you can speed up installing your apps and save some time.


 public class Main {  
   public static final int SECOND_DELAY = 10;  
   public static final String path = "C:\\Users\\michal\\Dropbox\\android\\back\\";  
   public static void main(String[] args) throws IOException, InterruptedException {  
     new Main().doStuff();  
   }  
   private void doStuff() throws IOException, InterruptedException {  
     File file = new File(path);  
     Runtime rt = Runtime.getRuntime();  
     for(File f: file.listFiles())  
     {  
       String command = "adb install -r " + "\"" + path + f.getName() + "\"";  
       System.out.println(command);  
       Process pr = rt.exec(command);  
       long timeDelay= SECOND_DELAY * 1000;  
       Thread.sleep(timeDelay);  
     }  
   }  
 }  

As you see this snippet automatic installs your apks from specific path with specific second_delay. Thanks for attention :)

Wednesday, 12 February 2014

Fragment dialog with scroll view doesn't scroll - solution

There is possibility, you will have scrollview inside dialog fragment plus with many buttons and the view won't move.

To fix it you should do the same thing like with activities by adjusting windowSoftInputMode in dialog theme.

You should set custom theme for your fragment dialog by inheriting current android dialog and adding windowSoftInputMode option:

 <style name="DialogFragmentStyle" parent="@android:style/Theme.Dialog">  
     <item name="android:windowSoftInputMode">stateHidden|adjustResize</item>  
 </style>  

Use your theme in your fragment dialog while creating constructor

 Dialog dialog = new Dialog(getActivity(), R.style.DialogFragmentStyle);  

 public class MyFragmentDialog extends DialogFragment{  
   @Override  
   public Dialog onCreateDialog(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
     Dialog dialog = new Dialog(getActivity(), R.style.DialogFragmentStyle);  
     //stuff  
     return dialog;  
   }  
   //... other methods  
 }  

Thursday, 6 February 2014

Getting resource name by it's ID

Short code in example:

 getResources().getResourceEntryName(view.getId())  

Will returns something like this:

 myEditText  

EditText hidden / covers by keyboard? Fast solution

My problem was about hidding EditText by keyboard. What is more EditText was in activity with theme for Dialog.

What I did to fix was adding this text before setContentView(...);

 getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);  

How ever even in scrollview you are not able to scroll...

---

You can also move big layout to scrollview and set it to scroll to EditText position. In this example my layout has few EditTexts and my last one at the bottom has problem with keyboard, so I did something like this:

 myEditText.setOnTouchListener(new View.OnTouchListener() {  
       @Override  
       public boolean onTouch(View view, MotionEvent motionEvent) {  
         if(view.getId() == R.id.myEditText)  
         {  
           Handler handler = new Handler();  
           handler.postDelayed(new Runnable() {  
             @Override  
             public void run() {  
               scrollview.scrollTo(0, myEditText.getBottom()+300);  
             }  
           }, 300);  
         }  
         return false;  
       }  
     });  

Wednesday, 5 February 2014

How use custom ActionBar layout - short guide

You need create custom layout first.

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
         android:layout_width="match_parent"  
         android:layout_height="match_parent"  
         android:background="@color/aqua"  
         android:orientation="vertical">  
   <TextView  
       android:layout_width="wrap_content"  
       android:layout_height="wrap_content"  
       android:layout_centerInParent="true"  
       android:textColor="#ffffff"  
       android:id="@+id/barTitle"  
       android:textSize="25dp"/>  

 </RelativeLayout>  

After this in our SherlockActivity need add some code in onCreate method.

 @Override  
 protected void onCreate(Bundle savedInstanceState) {  
      super.onCreate(savedInstanceState);  

      getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);  
      getSupportActionBar().setCustomView(R.layout.customBar);  

      //element from our custom layout, textview is my component which acts like title  
      ((TextView) findViewById(R.id.barTitle)).setText("This is title"));  
      setContentView(R.layout.l1a2a_has_account);  
      
      //further stuff  

 }  

Monday, 27 January 2014

Enable paste Ctrl+V in Dos Console Windows

  1. Create file and set extension to .ahk
  2. Open file by notepad
  3. Insert this code to file and save
  4.  #IfWinActive ahk_class ConsoleWindowClass  
     ^V::  
     SendInput {Raw}%clipboard%  
     return  
     #IfWinActive  
    
  5. Download, install AutoHotkey and run it
  6. Double click on your script (your file should be recognized by AutoHotkey by displaying AutoHotkey icon)
Information from howtogeek.com

What you should do, and what don't (future example here)

Save time by using
String.format (Object object, StringBuffer buffer, FieldPosition field)(

You shouldn't do:
      public String generateDateString(long timeMilises) {  
           String dateString = "";  
           Calendar c = Calendar.getInstance();  
           c.setTimeInMillis(timeMilises);  

           dateString = ((c.get(Calendar.DAY_OF_MONTH) < 10) ? ("0" + c.get(Calendar.DAY_OF_MONTH))  
                     : (c.get(Calendar.DAY_OF_MONTH)))  
                     + "."  
                     + (((c.get(Calendar.MONTH) + 1) < 10) ? ("0" + (c.get(Calendar.MONTH) + 1))  
                               : (c.get(Calendar.MONTH) + 1)) + "." + c.get(Calendar.YEAR);  
           return dateString;  
      }  
You should do:
      public String generateDateString(long timeMilises) {  
           String dateString = "";  
           Calendar c = Calendar.getInstance();  
           c.setTimeInMillis(timeMilises);  
           
           dateString = String.format("%02d.%02d.%d", c.get(Calendar.DAY_OF_MONTH), c.get(Calendar.MONTH)+1, c.get(Calendar.YEAR));

           return dateString;  
      }  

Tuesday, 7 January 2014

Easy way to hide softinputmode softinputkeyboard example

Here is the code:
 public void hideKeyboard(Activity activity) {  
   activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);  
   InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);  
   View cur_focus = activity.getCurrentFocus();  
   if (cur_focus != null) {  
     inputMethodManager.hideSoftInputFromWindow(cur_focus.getWindowToken(), 0);  
   }  
 }  

Thursday, 2 January 2014

Run project as default by USB DEVICE instead EMULATOR - Intellij Android Studio


To make run your projects as default and don't waste time (I am talking about imported 50+ project at once) here is the solution.

Every imported project has own hidden .idea folder placed in root folder. There is something like workspace.xml file. Open it in example by notepad++ and click now CTRL+H(shortcut to replace).
Try replace:

from (whole text with quotes):
"TARGET_SELECTION_MODE" value=".+"
to:
"TARGET_SELECTION_MODE" value="USB_DEVICE"

".+" (quote dot plus quote)  in regex means select starting with quote, take anything till you get next quote

make sure you selected regular expression option in notepad search dialog

Now save file and try run your IDE with projects.

If you don't see your hidden .idea folder try search somewhere to turn it on, it's easy- link

PS. if you have problems with project, make sure you deleted all R files and rebuilded projects.