// Path: app/src/main/java/org/indywidualni/centrumfm/util/Miscellany.java
// public abstract class Miscellany {
// 
//     public static int dpToPx(int dp) {
//         final float scale = MyApplication.getContextOfApplication().getResources()
//                 .getDisplayMetrics().density;
//         return (int) (dp * scale + 0.5f);
//     }
// 
//     public static String readFromAssets(String filename) {
//         String result = "";
//         try {
//             result = convertStreamToString(MyApplication.getContextOfApplication()
//                     .getAssets().open(filename));
//         } catch (IOException e) {
//             e.printStackTrace();
//         }
//         return result;
//     }
// 
//     private static String convertStreamToString(java.io.InputStream is) {
//         java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
//         return s.hasNext() ? s.next() : "";
//     }
//     
//     public static String convertMillisToHuman(long total) {
//         total /= 1000;
//         int minutes = (int) (total % 3600) / 60;
//         int seconds = (int) total % 60;
//         return minutes + ":" + (seconds < 10 ? "0" + seconds : seconds);
//     }
// 
//     public static String constructDateQueryForDay(boolean dayStart) {
//         DateFormat df = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
//         Date today = Calendar.getInstance(TimeZone.getTimeZone("Europe/Warsaw")).getTime();
//         String reportDate = df.format(today);
//         return dayStart ? reportDate + "T00:00:00" : reportDate + "T23:59:59";
//     }
//     
//     public static String constructDateQueryForDay(boolean dayStart,
//                                                   int year, int month, int day) {
//         @SuppressLint("DefaultLocale") String reportDate = year + "-" +
//                 String.format("%02d", month + 1) + "-" + String.format("%02d", day);
//         return dayStart ? reportDate + "T00:00:00" : reportDate + "T23:59:59";
//     }
//     
//     public static void addFavouriteSongFromRds(Context context, List<Rds> rds) {
//         String error = context.getString(R.string.cannot_favourite_song);
//         if (rds == null)
//             Toast.makeText(context, error, Toast.LENGTH_SHORT).show();
//         else {
//             Rds now = rds.get(0);
//             if (!now.getTitle().isEmpty() && !now.getArtist().isEmpty()) {
//                 Song song = new Song();
//                 song.setTitle(now.getTitle());
//                 song.setArtist(now.getArtist());
//                 song.setDuration(now.getTotal());
//                 AsyncWrapper.insertFavouriteSong(song);
//                 String message = "\u2605 " + now.getArtist() + " – " + now.getTitle();
//                 Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
//             } else
//                 Toast.makeText(context, error, Toast.LENGTH_SHORT).show();
//         }
//     }
// 
//     public static String formatSubtitleSave(Context context, String subtitle) {
//         return subtitle == null ? null : context.getString(R.string.songs_given_day,
//                 subtitle.substring(0, 10));
//     }
// 
//     public static String formatSubtitleRead(Context context, String subtitle) {
//         return subtitle == null ? context.getString(R.string.songs_current_day) : subtitle;
//     }
// 
//     // get some information about the device (needed for e-mail signature)
//     public static String getDeviceInfo(Activity activity) {
//         StringBuilder sb = new StringBuilder();
// 
//         try {
//             PackageInfo pInfo = activity.getPackageManager().getPackageInfo(
//                     activity.getPackageName(), PackageManager.GET_META_DATA);
//             sb.append("\nApp Package Name: ").append(activity.getPackageName());
//             sb.append("\nApp Version Name: ").append(pInfo.versionName);
//             sb.append("\nApp Version Code: ").append(pInfo.versionCode);
//         } catch (PackageManager.NameNotFoundException ex) {
//             Log.e("Misc: getDeviceInfo", "" + ex.getMessage());
//         }
// 
//         sb.append("\nOS Version: ").append(System.getProperty("os.version")).append(" (")
//                 .append(android.os.Build.VERSION.RELEASE).append(")");
//         sb.append("\nOS API Level: ").append(android.os.Build.VERSION.SDK_INT);
//         sb.append("\nDevice: ").append(android.os.Build.DEVICE);
//         sb.append("\nModel: ").append(android.os.Build.MODEL);
//         sb.append("\nManufacturer: ").append(android.os.Build.MANUFACTURER);
// 
//         DisplayMetrics metrics = new DisplayMetrics();
//         activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
// 
//         sb.append("\nScreen: ").append(metrics.heightPixels).append(" x ")
//                 .append(metrics.widthPixels);
//         sb.append("\nLocale: ").append(Locale.getDefault().toString());
// 
//         return sb.toString();
//     }
// 
// }


import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import org.indywidualni.centrumfm.R;
import org.indywidualni.centrumfm.util.Miscellany;
import butterknife.BindView;
package org.indywidualni.centrumfm.activity;




public abstract class BaseActivity extends AppCompatActivity {

    @BindView(R.id.toolbar) Toolbar toolbar;

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu_base, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                onBackPressed();
                return true;
            case R.id.email_me:
                Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto",
                        getString(R.string.author_email_address), null));
                emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name) + ": " +
                        getString(R.string.email_author));
// Path: app/src/main/java/org/indywidualni/centrumfm/util/Miscellany.java
// public abstract class Miscellany {
// 
//     public static int dpToPx(int dp) {
//         final float scale = MyApplication.getContextOfApplication().getResources()
//                 .getDisplayMetrics().density;
//         return (int) (dp * scale + 0.5f);
//     }
// 
//     public static String readFromAssets(String filename) {
//         String result = "";
//         try {
//             result = convertStreamToString(MyApplication.getContextOfApplication()
//                     .getAssets().open(filename));
//         } catch (IOException e) {
//             e.printStackTrace();
//         }
//         return result;
//     }
// 
//     private static String convertStreamToString(java.io.InputStream is) {
//         java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
//         return s.hasNext() ? s.next() : "";
//     }
//     
//     public static String convertMillisToHuman(long total) {
//         total /= 1000;
//         int minutes = (int) (total % 3600) / 60;
//         int seconds = (int) total % 60;
//         return minutes + ":" + (seconds < 10 ? "0" + seconds : seconds);
//     }
// 
//     public static String constructDateQueryForDay(boolean dayStart) {
//         DateFormat df = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
//         Date today = Calendar.getInstance(TimeZone.getTimeZone("Europe/Warsaw")).getTime();
//         String reportDate = df.format(today);
//         return dayStart ? reportDate + "T00:00:00" : reportDate + "T23:59:59";
//     }
//     
//     public static String constructDateQueryForDay(boolean dayStart,
//                                                   int year, int month, int day) {
//         @SuppressLint("DefaultLocale") String reportDate = year + "-" +
//                 String.format("%02d", month + 1) + "-" + String.format("%02d", day);
//         return dayStart ? reportDate + "T00:00:00" : reportDate + "T23:59:59";
//     }
//     
//     public static void addFavouriteSongFromRds(Context context, List<Rds> rds) {
//         String error = context.getString(R.string.cannot_favourite_song);
//         if (rds == null)
//             Toast.makeText(context, error, Toast.LENGTH_SHORT).show();
//         else {
//             Rds now = rds.get(0);
//             if (!now.getTitle().isEmpty() && !now.getArtist().isEmpty()) {
//                 Song song = new Song();
//                 song.setTitle(now.getTitle());
//                 song.setArtist(now.getArtist());
//                 song.setDuration(now.getTotal());
//                 AsyncWrapper.insertFavouriteSong(song);
//                 String message = "\u2605 " + now.getArtist() + " – " + now.getTitle();
//                 Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
//             } else
//                 Toast.makeText(context, error, Toast.LENGTH_SHORT).show();
//         }
//     }
// 
//     public static String formatSubtitleSave(Context context, String subtitle) {
//         return subtitle == null ? null : context.getString(R.string.songs_given_day,
//                 subtitle.substring(0, 10));
//     }
// 
//     public static String formatSubtitleRead(Context context, String subtitle) {
//         return subtitle == null ? context.getString(R.string.songs_current_day) : subtitle;
//     }
// 
//     // get some information about the device (needed for e-mail signature)
//     public static String getDeviceInfo(Activity activity) {
//         StringBuilder sb = new StringBuilder();
// 
//         try {
//             PackageInfo pInfo = activity.getPackageManager().getPackageInfo(
//                     activity.getPackageName(), PackageManager.GET_META_DATA);
//             sb.append("\nApp Package Name: ").append(activity.getPackageName());
//             sb.append("\nApp Version Name: ").append(pInfo.versionName);
//             sb.append("\nApp Version Code: ").append(pInfo.versionCode);
//         } catch (PackageManager.NameNotFoundException ex) {
//             Log.e("Misc: getDeviceInfo", "" + ex.getMessage());
//         }
// 
//         sb.append("\nOS Version: ").append(System.getProperty("os.version")).append(" (")
//                 .append(android.os.Build.VERSION.RELEASE).append(")");
//         sb.append("\nOS API Level: ").append(android.os.Build.VERSION.SDK_INT);
//         sb.append("\nDevice: ").append(android.os.Build.DEVICE);
//         sb.append("\nModel: ").append(android.os.Build.MODEL);
//         sb.append("\nManufacturer: ").append(android.os.Build.MANUFACTURER);
// 
//         DisplayMetrics metrics = new DisplayMetrics();
//         activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
// 
//         sb.append("\nScreen: ").append(metrics.heightPixels).append(" x ")
//                 .append(metrics.widthPixels);
//         sb.append("\nLocale: ").append(Locale.getDefault().toString());
// 
//         return sb.toString();
//     }
// 
// }


// Path: app/src/main/java/org/indywidualni/centrumfm/activity/BaseActivity.java
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import org.indywidualni.centrumfm.R;
import org.indywidualni.centrumfm.util.Miscellany;
import butterknife.BindView;

package org.indywidualni.centrumfm.activity;




public abstract class BaseActivity extends AppCompatActivity {

    @BindView(R.id.toolbar) Toolbar toolbar;

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu_base, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                onBackPressed();
                return true;
            case R.id.email_me:
                Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto",
                        getString(R.string.author_email_address), null));
                emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name) + ": " +
                        getString(R.string.email_author));
                emailIntent.putExtra(Intent.EXTRA_TEXT, "\n\n--" + Miscellany.getDeviceInfo(this));