diff --git a/src/fr/unix_experience/owncloud_sms/activities/GeneralSettingsActivity.java b/src/fr/unix_experience/owncloud_sms/activities/GeneralSettingsActivity.java index 64acb53..38e7eb2 100644 --- a/src/fr/unix_experience/owncloud_sms/activities/GeneralSettingsActivity.java +++ b/src/fr/unix_experience/owncloud_sms/activities/GeneralSettingsActivity.java @@ -12,19 +12,19 @@ package fr.unix_experience.owncloud_sms.activities; * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ +import java.util.List; + import android.accounts.Account; import android.accounts.AccountManager; import android.annotation.TargetApi; import android.content.ContentResolver; import android.content.Context; import android.content.PeriodicSync; -import android.content.SharedPreferences; -import android.content.SharedPreferences.Editor; import android.content.res.Configuration; import android.os.Build; import android.os.Bundle; @@ -34,10 +34,6 @@ import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.PreferenceFragment; import android.preference.PreferenceManager; -import android.util.Log; - -import java.util.List; - import fr.unix_experience.owncloud_sms.R; import fr.unix_experience.owncloud_sms.defines.DefaultPrefs; import fr.unix_experience.owncloud_sms.prefs.OCSMSSharedPrefs; @@ -51,7 +47,7 @@ public class GeneralSettingsActivity extends PreferenceActivity { static String mAccountType; @Override - protected void onPostCreate(Bundle savedInstanceState) { + protected void onPostCreate(final Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); mAccountMgr = AccountManager.get(getBaseContext()); @@ -74,7 +70,7 @@ public class GeneralSettingsActivity extends PreferenceActivity { // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. addPreferencesFromResource(R.xml.pref_data_sync); - + mContext = getBaseContext(); bindPreferences(); @@ -90,7 +86,7 @@ public class GeneralSettingsActivity extends PreferenceActivity { * 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) { + private static boolean isXLargeTablet(final Context context) { return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE; } @@ -101,7 +97,7 @@ public class GeneralSettingsActivity extends PreferenceActivity { * doesn't have an extra-large screen. In these cases, a single-pane * "simplified" settings UI should be shown. */ - private static boolean isSimplePreferences(Context context) { + private static boolean isSimplePreferences(final Context context) { return ALWAYS_SIMPLE_PREFS || Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB || !isXLargeTablet(context); @@ -113,52 +109,52 @@ public class GeneralSettingsActivity extends PreferenceActivity { */ private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() { @Override - public boolean onPreferenceChange(Preference preference, Object value) { + public boolean onPreferenceChange(final Preference preference, final Object value) { if (preference instanceof ListPreference) { - String prefKey = preference.getKey(); - String stringValue = value.toString(); + final String prefKey = preference.getKey(); + final String stringValue = value.toString(); // For list preferences, look up the correct display value in // the preference's 'entries' list. - ListPreference listPreference = (ListPreference) preference; - int index = listPreference.findIndexOfValue(stringValue); + final ListPreference listPreference = (ListPreference) preference; + final int index = listPreference.findIndexOfValue(stringValue); // Set the summary to reflect the new value. preference - .setSummary(index >= 0 ? listPreference.getEntries()[index] - : null); - - Account[] myAccountList = mAccountMgr.getAccountsByType(mAccountType); - + .setSummary(index >= 0 ? listPreference.getEntries()[index] + : null); + + final Account[] myAccountList = mAccountMgr.getAccountsByType(mAccountType); + // Handle sync frequency change if (prefKey.equals("sync_frequency")) { - long syncFreq = Long.parseLong(stringValue); + final long syncFreq = Long.parseLong(stringValue); // Get ownCloud SMS account list for (int i = 0; i < myAccountList.length; i++) { // And get all authorities for this account - List syncList = ContentResolver.getPeriodicSyncs(myAccountList[i], mAccountAuthority); - + final List syncList = ContentResolver.getPeriodicSyncs(myAccountList[i], mAccountAuthority); + boolean foundSameSyncCycle = false; for (int j = 0; j < syncList.size(); j++) { - PeriodicSync ps = syncList.get(i); - + final PeriodicSync ps = syncList.get(i); + if (ps.period == syncFreq && ps.extras.getInt("synctype") == 1) { foundSameSyncCycle = true; } } - + if (foundSameSyncCycle == false) { - Bundle b = new Bundle(); + final Bundle b = new Bundle(); b.putInt("synctype", 1); - ContentResolver.removePeriodicSync(myAccountList[i], + ContentResolver.removePeriodicSync(myAccountList[i], mAccountAuthority, b); ContentResolver.addPeriodicSync(myAccountList[i], - mAccountAuthority, b, syncFreq * 60); + mAccountAuthority, b, syncFreq * 60); } } } - // Slow Sync frequency + // Slow Sync frequency /*else if (prefKey.equals(new String("slow_sync_frequency"))) { long syncFreq = Long.parseLong((String)value); @@ -167,21 +163,21 @@ public class GeneralSettingsActivity extends PreferenceActivity { for (int i = 0; i < myAccountList.length; i++) { // And get all authorities for this account List syncList = ContentResolver.getPeriodicSyncs(myAccountList[i], mSlowSyncAccountAuthority); - + boolean foundSameSyncCycle = false; for (int j = 0; j < syncList.size(); j++) { PeriodicSync ps = syncList.get(i); - + if (ps.period == syncFreq && ps.extras.getInt("synctype") == 2) { foundSameSyncCycle = true; } } - + if (foundSameSyncCycle == false) { Bundle b = new Bundle(); b.putInt("synctype", 2); - ContentResolver.removePeriodicSync(myAccountList[i], + ContentResolver.removePeriodicSync(myAccountList[i], mSlowSyncAccountAuthority, b); ContentResolver.addPeriodicSync(myAccountList[i], mSlowSyncAccountAuthority, b, syncFreq * 60); @@ -189,15 +185,14 @@ public class GeneralSettingsActivity extends PreferenceActivity { } }*/ } else if (preference instanceof CheckBoxPreference) { - String prefKey = preference.getKey(); - Boolean boolValue = (Boolean)value; + final String prefKey = preference.getKey(); + final Boolean boolValue = (Boolean)value; // Network types allowed for sync if(prefKey.equals(new String("sync_wifi")) || prefKey.equals("sync_2g") || - prefKey.equals(new String("sync_3g")) || prefKey.equals("sync_gprs") || - prefKey.equals("sync_4g") || prefKey.equals("sync_others")) { - Log.d("FUCK",prefKey + " " + boolValue.toString()); - - OCSMSSharedPrefs prefs = new OCSMSSharedPrefs(mContext); + prefKey.equals(new String("sync_3g")) || prefKey.equals("sync_gprs") || + prefKey.equals("sync_4g") || prefKey.equals("sync_others")) { + + final OCSMSSharedPrefs prefs = new OCSMSSharedPrefs(mContext); prefs.putBoolean(prefKey, boolValue); } } else { @@ -218,38 +213,38 @@ public class GeneralSettingsActivity extends PreferenceActivity { * * @see #sBindPreferenceSummaryToValueListener */ - private static void bindPreferenceBooleanToValue(Preference preference, Boolean defValue) { + private static void bindPreferenceBooleanToValue(final Preference preference, final Boolean defValue) { // Set the listener to watch for value changes. preference - .setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); + .setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); // Trigger the listener immediately with the preference's // current value. sBindPreferenceSummaryToValueListener.onPreferenceChange( - preference, - PreferenceManager.getDefaultSharedPreferences( - preference.getContext()).getBoolean( - preference.getKey(), - defValue - ) - ); + preference, + PreferenceManager.getDefaultSharedPreferences( + preference.getContext()).getBoolean( + preference.getKey(), + defValue + ) + ); } - - private static void bindPreferenceStringToValue(Preference preference) { + + private static void bindPreferenceStringToValue(final Preference preference) { // Set the listener to watch for value changes. preference - .setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); + .setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); // Trigger the listener immediately with the preference's // current value. sBindPreferenceSummaryToValueListener.onPreferenceChange( - preference, - PreferenceManager.getDefaultSharedPreferences( - preference.getContext()).getString( - preference.getKey(), - "" - ) - ); + preference, + PreferenceManager.getDefaultSharedPreferences( + preference.getContext()).getString( + preference.getKey(), + "" + ) + ); } /** @@ -259,7 +254,7 @@ public class GeneralSettingsActivity extends PreferenceActivity { @TargetApi(Build.VERSION_CODES.HONEYCOMB) public static class DataSyncPreferenceFragment extends PreferenceFragment { @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.pref_data_sync); @@ -277,7 +272,7 @@ public class GeneralSettingsActivity extends PreferenceActivity { //bindPreferenceSummaryToValue(findPreference("slow_sync_frequency")); } } - + private void bindPreferences() { mContext = getBaseContext(); diff --git a/src/fr/unix_experience/owncloud_sms/activities/MainActivity.java b/src/fr/unix_experience/owncloud_sms/activities/MainActivity.java index 09c17de..e1c727f 100644 --- a/src/fr/unix_experience/owncloud_sms/activities/MainActivity.java +++ b/src/fr/unix_experience/owncloud_sms/activities/MainActivity.java @@ -30,11 +30,6 @@ import java.util.Vector; import org.json.JSONArray; -import fr.unix_experience.owncloud_sms.R; -import fr.unix_experience.owncloud_sms.engine.ConnectivityMonitor; -import fr.unix_experience.owncloud_sms.engine.SmsFetcher; -import fr.unix_experience.owncloud_sms.engine.ASyncTask.SyncTask; -import fr.unix_experience.owncloud_sms.prefs.OCSMSSharedPrefs; import android.app.Activity; import android.app.Fragment; import android.app.FragmentManager; @@ -45,10 +40,14 @@ import android.provider.Settings; import android.support.v13.app.FragmentPagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import fr.unix_experience.owncloud_sms.R; +import fr.unix_experience.owncloud_sms.engine.ASyncTask.SyncTask; +import fr.unix_experience.owncloud_sms.engine.ConnectivityMonitor; +import fr.unix_experience.owncloud_sms.engine.SmsFetcher; +import fr.unix_experience.owncloud_sms.notifications.OCSMSNotificationManager; public class MainActivity extends Activity { @@ -67,23 +66,23 @@ public class MainActivity extends Activity { ViewPager mViewPager; @Override - protected void onCreate(Bundle savedInstanceState) { + protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. - - List fragments = new Vector(); - + + final List fragments = new Vector(); + /* * Add the Main tabs here */ - + fragments.add(Fragment.instantiate(this,StarterFragment.class.getName())); fragments.add(Fragment.instantiate(this,SecondTestFragment.class.getName())); fragments.add(Fragment.instantiate(this,ThanksAndRateFragment.class.getName())); - + mPagerAdapter = new MainPagerAdapter(getFragmentManager(), fragments); // Set up the ViewPager with the sections adapter. @@ -98,13 +97,14 @@ public class MainActivity extends Activity { public class MainPagerAdapter extends FragmentPagerAdapter { private final List mFragments; - - public MainPagerAdapter(FragmentManager fragmentManager, List fragments) { + + public MainPagerAdapter(final FragmentManager fragmentManager, final List fragments) { super(fragmentManager); mFragments = fragments; } - public Fragment getItem(int position) { + @Override + public Fragment getItem(final int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class // below). @@ -123,65 +123,67 @@ public class MainActivity extends Activity { */ public static class StarterFragment extends Fragment { @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_mainactivity_main, container, + public View onCreateView(final LayoutInflater inflater, final ViewGroup container, + final Bundle savedInstanceState) { + final View rootView = inflater.inflate(R.layout.fragment_mainactivity_main, container, false); return rootView; } } - + public static class SecondTestFragment extends Fragment { @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_mainactivity_gotosettings, container, + public View onCreateView(final LayoutInflater inflater, final ViewGroup container, + final Bundle savedInstanceState) { + final View rootView = inflater.inflate(R.layout.fragment_mainactivity_gotosettings, container, false); return rootView; } } - + public static class ThanksAndRateFragment extends Fragment { @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_mainactivity_thanks_note, container, + public View onCreateView(final LayoutInflater inflater, final ViewGroup container, + final Bundle savedInstanceState) { + final View rootView = inflater.inflate(R.layout.fragment_mainactivity_thanks_note, container, false); return rootView; } } - - public void openAppSettings(View view) { + + public void openAppSettings(final View view) { startActivity(new Intent(this, GeneralSettingsActivity.class)); } - - public void openAddAccount(View view) { + + public void openAddAccount(final View view) { startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT)); } - - public void syncAllMessages(View view) { - ConnectivityMonitor cMon = new ConnectivityMonitor(getApplicationContext()); - + + public void syncAllMessages(final View view) { + final ConnectivityMonitor cMon = new ConnectivityMonitor(getApplicationContext()); + if (cMon.isValid()) { // Now fetch messages since last stored date - JSONArray smsList = new SmsFetcher(getApplicationContext()) - .bufferizeMessagesSinceDate((long) 0); - + final JSONArray smsList = new SmsFetcher(getApplicationContext()) + .bufferizeMessagesSinceDate((long) 0); + if (smsList != null) { + final OCSMSNotificationManager nMgr = new OCSMSNotificationManager(getApplicationContext()); + nMgr.setSyncProcessMsg(); new SyncTask(getApplicationContext(), smsList).execute(); } } } - public void openGooglePlayStore(View view) { + public void openGooglePlayStore(final View view) { Intent intent; try { intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName())); - - } catch (android.content.ActivityNotFoundException anfe) { - intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + getPackageName())); + + } catch (final android.content.ActivityNotFoundException anfe) { + intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + getPackageName())); } - + startActivity(intent); } } diff --git a/src/fr/unix_experience/owncloud_sms/engine/ASyncTask.java b/src/fr/unix_experience/owncloud_sms/engine/ASyncTask.java index 7cf277b..bd72081 100644 --- a/src/fr/unix_experience/owncloud_sms/engine/ASyncTask.java +++ b/src/fr/unix_experience/owncloud_sms/engine/ASyncTask.java @@ -12,7 +12,7 @@ package fr.unix_experience.owncloud_sms.engine; * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ @@ -27,39 +27,43 @@ import android.os.AsyncTask; import android.util.Log; import fr.unix_experience.owncloud_sms.R; import fr.unix_experience.owncloud_sms.exceptions.OCSyncException; +import fr.unix_experience.owncloud_sms.notifications.OCSMSNotificationManager; public interface ASyncTask { class SyncTask extends AsyncTask{ - public SyncTask(Context context, JSONArray smsList) { + public SyncTask(final Context context, final JSONArray smsList) { _context = context; _smsList = smsList; } - + @Override - protected Void doInBackground(Void... params) { + protected Void doInBackground(final Void... params) { + final OCSMSNotificationManager nMgr = new OCSMSNotificationManager(_context); + // Get ownCloud SMS account list - AccountManager _accountMgr = AccountManager.get(_context); - - Account[] myAccountList = _accountMgr.getAccountsByType(_context.getString(R.string.account_type)); - for (int i = 0; i < myAccountList.length; i++) { - Uri serverURI = Uri.parse(_accountMgr.getUserData(myAccountList[i], "ocURI")); - - OCSMSOwnCloudClient _client = new OCSMSOwnCloudClient(_context, - serverURI, _accountMgr.getUserData(myAccountList[i], "ocLogin"), - _accountMgr.getPassword(myAccountList[i])); - + final AccountManager _accountMgr = AccountManager.get(_context); + + final Account[] myAccountList = _accountMgr.getAccountsByType(_context.getString(R.string.account_type)); + for (final Account element : myAccountList) { + final Uri serverURI = Uri.parse(_accountMgr.getUserData(element, "ocURI")); + + final OCSMSOwnCloudClient _client = new OCSMSOwnCloudClient(_context, + serverURI, _accountMgr.getUserData(element, "ocLogin"), + _accountMgr.getPassword(element)); + try { _client.doPushRequest(_smsList); - } catch (OCSyncException e) { + } catch (final OCSyncException e) { Log.e(TAG, _context.getString(e.getErrorId())); } } + nMgr.dropSyncProcessMsg(); return null; } - - private Context _context; - private JSONArray _smsList; + + private final Context _context; + private final JSONArray _smsList; } - + static final String TAG = ASyncTask.class.getSimpleName(); } diff --git a/src/fr/unix_experience/owncloud_sms/prefs/OCSMSSharedPrefs.java b/src/fr/unix_experience/owncloud_sms/prefs/OCSMSSharedPrefs.java index b118bbf..4a16658 100644 --- a/src/fr/unix_experience/owncloud_sms/prefs/OCSMSSharedPrefs.java +++ b/src/fr/unix_experience/owncloud_sms/prefs/OCSMSSharedPrefs.java @@ -12,65 +12,65 @@ package fr.unix_experience.owncloud_sms.prefs; * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import fr.unix_experience.owncloud_sms.R; -import fr.unix_experience.owncloud_sms.defines.DefaultPrefs; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; +import fr.unix_experience.owncloud_sms.R; +import fr.unix_experience.owncloud_sms.defines.DefaultPrefs; public class OCSMSSharedPrefs { - public OCSMSSharedPrefs(Context context) { + public OCSMSSharedPrefs(final Context context) { _context = context; - + _sPrefs = _context.getSharedPreferences(_context.getString(R.string.shared_preference_file), Context.MODE_PRIVATE); } - - public void putBoolean(String prefKey, Boolean boolValue) { - Editor edit = _sPrefs.edit(); + + public void putBoolean(final String prefKey, final Boolean boolValue) { + final Editor edit = _sPrefs.edit(); edit.putBoolean(prefKey, boolValue); edit.commit(); } - - public void setLastMessageDate(Long msgDate) { - SharedPreferences.Editor editor = _sPrefs.edit(); + + public void setLastMessageDate(final Long msgDate) { + final SharedPreferences.Editor editor = _sPrefs.edit(); editor.putLong(_context.getString(R.string.pref_lastmsgdate), msgDate); editor.commit(); } - + public Long getLastMessageDate() { return _sPrefs.getLong(_context.getString(R.string.pref_lastmsgdate), 0); } - + public Boolean syncInWifi() { return _sPrefs.getBoolean("sync_wifi", DefaultPrefs.syncWifi); } - + public Boolean syncIn2G() { return _sPrefs.getBoolean("sync_2g", DefaultPrefs.sync2G); } - + public Boolean syncInGPRS() { return _sPrefs.getBoolean("sync_gprs", DefaultPrefs.syncGPRS); } - + public Boolean syncIn3G() { return _sPrefs.getBoolean("sync_3g", DefaultPrefs.sync3G); } - + public Boolean syncIn4G() { return _sPrefs.getBoolean("sync_4g", DefaultPrefs.sync4G); } - + public Boolean syncInOtherModes() { return _sPrefs.getBoolean("sync_others", DefaultPrefs.syncOthers); } - - private SharedPreferences _sPrefs; - private Context _context; + + private final SharedPreferences _sPrefs; + private final Context _context; } diff --git a/src/fr/unix_experience/owncloud_sms/sync_adapters/SmsSyncAdapter.java b/src/fr/unix_experience/owncloud_sms/sync_adapters/SmsSyncAdapter.java index 9972ed3..fb85aa7 100644 --- a/src/fr/unix_experience/owncloud_sms/sync_adapters/SmsSyncAdapter.java +++ b/src/fr/unix_experience/owncloud_sms/sync_adapters/SmsSyncAdapter.java @@ -12,16 +12,11 @@ package fr.unix_experience.owncloud_sms.sync_adapters; * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import fr.unix_experience.owncloud_sms.R; -import fr.unix_experience.owncloud_sms.engine.OCSMSOwnCloudClient; -import fr.unix_experience.owncloud_sms.enums.OCSyncErrorType; -import fr.unix_experience.owncloud_sms.exceptions.OCSyncException; -import fr.unix_experience.owncloud_sms.notifications.OCSMSNotificationManager; import android.accounts.Account; import android.accounts.AccountManager; import android.content.AbstractThreadedSyncAdapter; @@ -31,43 +26,48 @@ import android.content.SyncResult; import android.net.Uri; import android.os.Bundle; import android.util.Log; +import fr.unix_experience.owncloud_sms.R; +import fr.unix_experience.owncloud_sms.engine.OCSMSOwnCloudClient; +import fr.unix_experience.owncloud_sms.enums.OCSyncErrorType; +import fr.unix_experience.owncloud_sms.exceptions.OCSyncException; +import fr.unix_experience.owncloud_sms.notifications.OCSMSNotificationManager; public class SmsSyncAdapter extends AbstractThreadedSyncAdapter { - public SmsSyncAdapter(Context context, boolean autoInitialize) { + public SmsSyncAdapter(final Context context, final boolean autoInitialize) { super(context, autoInitialize); _accountMgr = AccountManager.get(context); } @Override - public void onPerformSync(Account account, Bundle extras, String authority, - ContentProviderClient provider, SyncResult syncResult) { - - OCSMSNotificationManager nMgr = new OCSMSNotificationManager(getContext()); - + public void onPerformSync(final Account account, final Bundle extras, final String authority, + final ContentProviderClient provider, final SyncResult syncResult) { + + final OCSMSNotificationManager nMgr = new OCSMSNotificationManager(getContext()); + // Create client - String ocURI = _accountMgr.getUserData(account, "ocURI"); + final String ocURI = _accountMgr.getUserData(account, "ocURI"); if (ocURI == null) { nMgr.setSyncErrorMsg(getContext().getString(R.string.err_sync_account_unparsable)); return; } - - Uri serverURI = Uri.parse(ocURI); - nMgr.setSyncProcessMsg(); - - OCSMSOwnCloudClient _client = new OCSMSOwnCloudClient(getContext(), + + final Uri serverURI = Uri.parse(ocURI); + nMgr.setSyncProcessMsg(); + + final OCSMSOwnCloudClient _client = new OCSMSOwnCloudClient(getContext(), serverURI, _accountMgr.getUserData(account, "ocLogin"), _accountMgr.getPassword(account)); - + try { // getServerAPI version Log.d(TAG,"Server API version: " + _client.getServerAPIVersion()); - + // and push datas _client.doPushRequest(null); - + nMgr.dropSyncErrorMsg(); - } catch (OCSyncException e) { + } catch (final OCSyncException e) { nMgr.setSyncErrorMsg(getContext().getString(e.getErrorId())); if (e.getErrorType() == OCSyncErrorType.IO) { syncResult.stats.numIoExceptions++; @@ -82,12 +82,12 @@ public class SmsSyncAdapter extends AbstractThreadedSyncAdapter { // UNHANDLED } } - + nMgr.dropSyncProcessMsg(); - + } - private AccountManager _accountMgr; - + private final AccountManager _accountMgr; + private static final String TAG = SmsSyncAdapter.class.getSimpleName(); }