From 53729043ee41f55d530a50e32e5087a18697f1d4 Mon Sep 17 00:00:00 2001
From: SeeLook <945374+SeeLook@users.noreply.github.com>
Date: Sat, 27 Aug 2016 11:22:53 +0200
Subject: [PATCH] Updated changes, added missed java files

---
 changes                                       |  7 +-
 .../src/net/sf/nootka/TexternalStorage.java   | 43 +++++++++++
 src/android/src/net/sf/nootka/Tusers.java     | 72 +++++++++++++++++++
 3 files changed, 118 insertions(+), 4 deletions(-)
 create mode 100644 src/android/src/net/sf/nootka/TexternalStorage.java
 create mode 100644 src/android/src/net/sf/nootka/Tusers.java

diff --git a/changes b/changes
index 957ca93fb..6e189f7b0 100644
--- a/changes
+++ b/changes
@@ -2,7 +2,6 @@
     ANDROID
      - handle pinch gesture to zoom score in/out
      - touching screen suspends pitch detection
-     - application can restart itself to restore initial settings
      - updated Qt version to 5.6.1
     BUGS FIXES
      - prevent stopping input sound randomly
@@ -11,14 +10,14 @@
 1.2.7
   Nootka says: I speak Spanish
      - translated to Spanish language
-     - better handling input audio data, increased buffer size
-     - less fragmented pitch detection, if any
+     - better method of handling input audio data, increased buffer size
      - forwarding input to output works with every sound system now
     BUGS FIXES
      - fixed reason of random crashes when audio input started
      - repaired starting exam with melodies from single note mode view
+     - file descriptions are translated under Mac Os Finder
      - fixed deb package compatibility with Ubuntu 16.04
-     - minor fixes
+     - other minor fixes
 
 1.2A.6 rc2
   Google Play(s) with Nootka
diff --git a/src/android/src/net/sf/nootka/TexternalStorage.java b/src/android/src/net/sf/nootka/TexternalStorage.java
new file mode 100644
index 000000000..d9eb375d4
--- /dev/null
+++ b/src/android/src/net/sf/nootka/TexternalStorage.java
@@ -0,0 +1,43 @@
+/***************************************************************************
+ *   Copyright (C) 2016 by Tomasz Bojczuk                  				         *
+ *   seelook@gmail.com        						                                 *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 3 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License	     *
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
+ ***************************************************************************/
+
+package net.sf.nootka;
+
+import java.lang.Object;
+import java.io.File;
+import android.os.Environment;
+
+
+public class TexternalStorage
+{
+
+  public static boolean isWritable() {
+    String state = Environment.getExternalStorageState();
+    if (Environment.MEDIA_MOUNTED.equals(state)) {
+        return true;
+    }
+    return false;
+  }
+
+  public static String get() {
+    File docDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS);
+    docDir.mkdirs();
+    return docDir.getPath();
+  }
+
+}
diff --git a/src/android/src/net/sf/nootka/Tusers.java b/src/android/src/net/sf/nootka/Tusers.java
new file mode 100644
index 000000000..b34a3b4ad
--- /dev/null
+++ b/src/android/src/net/sf/nootka/Tusers.java
@@ -0,0 +1,72 @@
+/***************************************************************************
+ *   Copyright (C) 2016 by Tomasz Bojczuk                                  *
+ *   seelook@gmail.com                                                     *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 3 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
+ ***************************************************************************/
+
+package net.sf.nootka;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.content.Context;
+
+
+public class Tusers {
+
+  public static String getEmail(Context context) {
+    AccountManager accountManager = AccountManager.get(context);
+    Account account = getAccount(accountManager);
+
+    if (account == null) {
+      return null;
+    } else {
+      return account.name;
+    }
+  }
+
+
+  public static String getUserName(Context context) {
+    AccountManager manager = AccountManager.get(context);
+    Account account = getAccount(manager);
+    if (account == null) {
+      return "";
+    } else {
+      String email = account.name;
+      String[] parts = email.split("@");
+      if (parts.length > 0 && parts[0] != null)
+        return parts[0];
+      else
+        return "";
+    }
+  }
+
+//#################################################################################################
+//###################              PRIVATE             ############################################
+//#################################################################################################
+
+  private static Account getAccount(AccountManager accountManager) {
+    Account[] accounts = accountManager.getAccountsByType("com.google");
+    Account account;
+    if (accounts.length > 0) {
+      account = accounts[0];
+    } else {
+      account = null;
+    }
+    return account;
+  }
+
+}
+
+
-- 
GitLab