diff --git a/build.gradle b/build.gradle
index ce93597..899cff1 100644
--- a/build.gradle
+++ b/build.gradle
@@ -27,7 +27,6 @@ repositories {
dependencies {
compile project(':owncloudAndroidLibrary')
- compile project(':nrzandroidlib')
compile 'com.android.support:support-v13:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index 7c0637f..15c9a0e 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -4,7 +4,7 @@
android:versionCode="34"
android:versionName="0.20.1">
@@ -95,7 +95,7 @@
android:label="@string/title_activity_select_account">
syncList = ContentResolver.getPeriodicSyncs(acct, GeneralSettingsActivity._accountAuthority);
+ List syncList = ContentResolver.getPeriodicSyncs(acct, _accountAuthority);
boolean foundSameSyncCycle = false;
for (PeriodicSync ps: syncList) {
@@ -112,9 +112,9 @@ public class GeneralSettingsActivity extends NrzSettingsActivity {
Bundle b = new Bundle();
b.putInt("synctype", 1);
- ContentResolver.removePeriodicSync(acct, GeneralSettingsActivity._accountAuthority, b);
+ ContentResolver.removePeriodicSync(acct, _accountAuthority, b);
if (syncFreq > 0) {
- ContentResolver.addPeriodicSync(acct, GeneralSettingsActivity._accountAuthority, b, syncFreq * 60);
+ ContentResolver.addPeriodicSync(acct, _accountAuthority, b, syncFreq * 60);
}
}
diff --git a/src/main/java/fr/unix_experience/owncloud_sms/activities/remote_account/AccountListActivity.java b/src/main/java/fr/unix_experience/owncloud_sms/activities/remote_account/AccountListActivity.java
index bf52e9a..25e7b91 100644
--- a/src/main/java/fr/unix_experience/owncloud_sms/activities/remote_account/AccountListActivity.java
+++ b/src/main/java/fr/unix_experience/owncloud_sms/activities/remote_account/AccountListActivity.java
@@ -7,7 +7,7 @@ import android.os.Bundle;
import java.util.ArrayList;
import java.util.Collections;
-import fr.nrz.androidlib.adapters.AndroidAccountAdapter;
+import fr.unix_experience.owncloud_sms.adapters.AndroidAccountAdapter;
import fr.unix_experience.android_lib.AppCompatListActivity;
import fr.unix_experience.owncloud_sms.R;
diff --git a/src/main/java/fr/unix_experience/owncloud_sms/activities/virtual/VirtualSettingsActivity.java b/src/main/java/fr/unix_experience/owncloud_sms/activities/virtual/VirtualSettingsActivity.java
new file mode 100644
index 0000000..89de2e6
--- /dev/null
+++ b/src/main/java/fr/unix_experience/owncloud_sms/activities/virtual/VirtualSettingsActivity.java
@@ -0,0 +1,212 @@
+package fr.unix_experience.owncloud_sms.activities.virtual;
+
+/**
+ * Copyright (c) 2013-2015, Loic Blot
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those
+ * of the authors and should not be interpreted as representing official policies,
+ * either expressed or implied, of the FreeBSD Project.
+ */
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.content.res.Configuration;
+import android.os.Build;
+import android.os.Bundle;
+import android.preference.CheckBoxPreference;
+import android.preference.ListPreference;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceFragment;
+import android.preference.PreferenceManager;
+import android.util.Log;
+
+import java.util.Vector;
+
+public class VirtualSettingsActivity extends PreferenceActivity {
+ private static String TAG = VirtualSettingsActivity.class.getSimpleName();
+ protected static Context _context;
+ protected static int _prefsRessourceFile;
+ protected static Vector _boolPrefs = new Vector<>();
+ protected static Vector _stringPrefs = new Vector<>();
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ VirtualSettingsActivity._context = getBaseContext();
+ setupSimplePreferencesScreen();
+ }
+
+ /**
+ * Shows the simplified settings UI if the device configuration if the
+ * device configuration dictates that a simplified, single-pane UI should be
+ * shown.
+ */
+ @SuppressWarnings("deprecation")
+ private void setupSimplePreferencesScreen() {
+ if (!VirtualSettingsActivity.isSimplePreferences(this)) {
+ return;
+ }
+
+ // In the simplified UI, fragments are not used at all and we instead
+ // use the older PreferenceActivity APIs.
+ addPreferencesFromResource(VirtualSettingsActivity._prefsRessourceFile);
+ bindPreferences();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean onIsMultiPane() {
+ return VirtualSettingsActivity.isXLargeTablet(this) && !VirtualSettingsActivity.isSimplePreferences(this);
+ }
+
+ /**
+ * Helper method to determine if the device has an extra-large screen. For
+ * example, 10" tablets are extra-large.
+ */
+ private static boolean isXLargeTablet(Context context) {
+ return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
+ }
+
+ /**
+ * Determines whether the simplified settings UI should be shown. This is
+ * true if this is forced via the device
+ * doesn't have newer APIs like {@link PreferenceFragment}, or the device
+ * doesn't have an extra-large screen. In these cases, a single-pane
+ * "simplified" settings UI should be shown.
+ */
+ protected static boolean isSimplePreferences(Context context) {
+ return (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
+ || !VirtualSettingsActivity.isXLargeTablet(context);
+ }
+
+ /**
+ * Binds a preference's summary to its value. More specifically, when the
+ * preference's value is changed, its summary (line of text below the
+ * preference title) is updated to reflect the value. The summary is also
+ * immediately updated upon calling this method. The exact display format is
+ * dependent on the type of preference.
+ *
+ * @see #bindPreferenceBooleanToValue
+ */
+ public void bindPreferenceBooleanToValue(Preference preference, Boolean defValue) {
+ // Set the listener to watch for value changes.
+ preference
+ .setOnPreferenceChangeListener(_bindPreferenceListener);
+
+ // Trigger the listener immediately with the preference's
+ // current value.
+ _bindPreferenceListener.onPreferenceChange(
+ preference,
+ PreferenceManager.getDefaultSharedPreferences(
+ preference.getContext()).getBoolean(
+ preference.getKey(),
+ defValue
+ )
+ );
+ }
+
+ public void bindPreferenceStringToValue(Preference preference, String defValue) {
+ // Set the listener to watch for value changes.
+ preference
+ .setOnPreferenceChangeListener(_bindPreferenceListener);
+
+ // Trigger the listener immediately with the preference's
+ // current value.
+ _bindPreferenceListener.onPreferenceChange(
+ preference,
+ PreferenceManager.getDefaultSharedPreferences(
+ preference.getContext()).getString(
+ preference.getKey(),
+ defValue
+ )
+ );
+ }
+
+ /**
+ * This fragment shows data and sync preferences only. It is used when the
+ * activity is showing a two-pane settings UI.
+ */
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
+ public class DataSyncPreferenceFragment extends PreferenceFragment {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(VirtualSettingsActivity._prefsRessourceFile);
+
+ bindPreferences();
+ }
+ }
+
+ private void bindPreferences() {
+ // Bind the summaries of EditText/List/Dialog/Ringtone preferences to
+ // their values. When their values change, their summaries are updated
+ // to reflect the new value, per the Android Design guidelines.
+ for (BindObjectPref pref: VirtualSettingsActivity._stringPrefs) {
+ bindPreferenceStringToValue(findPreference(pref.name),
+ (String) pref.value);
+ }
+
+ for (BindObjectPref pref: VirtualSettingsActivity._boolPrefs) {
+ bindPreferenceBooleanToValue(findPreference(pref.name),
+ (Boolean) pref.value);
+ }
+ }
+
+ // The preference object, it's only a key value pair
+ protected class BindObjectPref {
+ public String name;
+ public Object value;
+ public BindObjectPref(String prefName, Object prefVal) {
+ name = prefName;
+ value = prefVal;
+ }
+ }
+
+ /**
+ * A preference value change listener that updates the preference's summary
+ * to reflect its new value.
+ */
+ private final Preference.OnPreferenceChangeListener _bindPreferenceListener = new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object value) {
+ if (preference instanceof ListPreference) {
+ Log.d(TAG, "Changed list preference " + preference.toString() + " value " + value.toString());
+ handleListPreference(preference.getKey(), value.toString(), (ListPreference) preference);
+
+ } else if (preference instanceof CheckBoxPreference) {
+ Log.d(TAG, "Changed checkbox preference " + preference.toString() + " value " + value.toString());
+ handleCheckboxPreference(preference.getKey(), (Boolean) value);
+ } else {
+ // For all other preferences, set the summary to the value's
+ // simple string representation.
+ //preference.setSummary(boolValue);
+ }
+ return true;
+ }
+ };
+
+ protected void handleCheckboxPreference(String key, Boolean value) {}
+ protected void handleListPreference(String key, String value,
+ ListPreference preference) {}
+}
diff --git a/src/main/java/fr/unix_experience/owncloud_sms/adapters/AndroidAccountAdapter.java b/src/main/java/fr/unix_experience/owncloud_sms/adapters/AndroidAccountAdapter.java
new file mode 100644
index 0000000..79e9604
--- /dev/null
+++ b/src/main/java/fr/unix_experience/owncloud_sms/adapters/AndroidAccountAdapter.java
@@ -0,0 +1,63 @@
+package fr.unix_experience.owncloud_sms.adapters;
+
+import android.accounts.Account;
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.TextView;
+
+import java.util.ArrayList;
+
+public class AndroidAccountAdapter extends ArrayAdapter {
+
+ private final ArrayList _accounts;
+ private static int _itemLayout;
+ private static int _accountFieldId;
+ private final Activity _activity;
+ Class> _newActivityClass;
+
+ public AndroidAccountAdapter(Activity activity, int resource,
+ ArrayList objects, int itemLayout,
+ int accountFieldId, Class> newActivityClass) {
+ super(activity.getBaseContext(), resource, objects);
+ _accounts = objects;
+ AndroidAccountAdapter._itemLayout = itemLayout;
+ AndroidAccountAdapter._accountFieldId = accountFieldId;
+ _activity = activity;
+ _newActivityClass = newActivityClass;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View v = convertView;
+ if (v == null) {
+ LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ v = inflater.inflate(AndroidAccountAdapter._itemLayout, null);
+ }
+
+ final Account account = _accounts.get(position);
+
+ if (account != null) {
+ TextView label = (TextView) v.findViewById(AndroidAccountAdapter._accountFieldId);
+ if (label != null) {
+ label.setText(account.name + " >");
+ v.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent i = new Intent(_activity, _newActivityClass);
+ i.putExtra("account", account.name);
+ _activity.startActivity(i);
+ }
+ });
+ }
+ }
+
+ return v;
+ }
+
+}
diff --git a/src/main/java/fr/unix_experience/owncloud_sms/prefs/OCSMSSharedPrefs.java b/src/main/java/fr/unix_experience/owncloud_sms/prefs/OCSMSSharedPrefs.java
index 1d65596..aebac20 100644
--- a/src/main/java/fr/unix_experience/owncloud_sms/prefs/OCSMSSharedPrefs.java
+++ b/src/main/java/fr/unix_experience/owncloud_sms/prefs/OCSMSSharedPrefs.java
@@ -19,7 +19,7 @@ package fr.unix_experience.owncloud_sms.prefs;
import android.content.Context;
import android.content.SharedPreferences;
-import fr.nrz.androidlib.common.SharedPrefs;
+
import fr.unix_experience.owncloud_sms.R;
import fr.unix_experience.owncloud_sms.defines.DefaultPrefs;
diff --git a/src/main/java/fr/unix_experience/owncloud_sms/prefs/SharedPrefs.java b/src/main/java/fr/unix_experience/owncloud_sms/prefs/SharedPrefs.java
new file mode 100644
index 0000000..f6a48e2
--- /dev/null
+++ b/src/main/java/fr/unix_experience/owncloud_sms/prefs/SharedPrefs.java
@@ -0,0 +1,63 @@
+package fr.unix_experience.owncloud_sms.prefs;
+
+/**
+ * Copyright (c) 2013-2015, Loic Blot
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those
+ * of the authors and should not be interpreted as representing official policies,
+ * either expressed or implied, of the FreeBSD Project.
+ */
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
+
+public class SharedPrefs {
+
+ protected final SharedPreferences _sPrefs;
+ protected final Context _context;
+
+ public SharedPrefs(Context context, int prefFile) {
+ _context = context;
+
+ _sPrefs = _context.getSharedPreferences(_context.getString(prefFile), Context.MODE_PRIVATE);
+ }
+
+ public void putBoolean(String prefKey, Boolean boolValue) {
+ Editor edit = _sPrefs.edit();
+ edit.putBoolean(prefKey, boolValue);
+ edit.apply();
+ }
+
+ public void putInteger(String prefKey, Integer intValue) {
+ Editor edit = _sPrefs.edit();
+ edit.putInt(prefKey, intValue);
+ edit.apply();
+ }
+
+ public void putLong(String prefKey, long longValue) {
+ Editor edit = _sPrefs.edit();
+ edit.putLong(prefKey, longValue);
+ edit.apply();
+ }
+}
diff --git a/src/main/java/fr/unix_experience/owncloud_sms/providers/SmsDataProvider.java b/src/main/java/fr/unix_experience/owncloud_sms/providers/SmsDataProvider.java
index 9ec9c76..ce24b48 100644
--- a/src/main/java/fr/unix_experience/owncloud_sms/providers/SmsDataProvider.java
+++ b/src/main/java/fr/unix_experience/owncloud_sms/providers/SmsDataProvider.java
@@ -27,9 +27,8 @@ import android.support.annotation.NonNull;
import fr.unix_experience.owncloud_sms.prefs.OCSMSSharedPrefs;
public class SmsDataProvider extends ContentProvider {
- public SmsDataProvider () {}
- public SmsDataProvider (Context ct) {
+ public SmsDataProvider (Context ct) {
super();
_context = ct;
}