1
0
mirror of https://github.com/nerzhul/ownCloud-SMS-App.git synced 2025-06-21 14:56:27 +00:00

Use disable push_on_receive mechanism and comment new feature to prepare next release

This commit is contained in:
Loic Blot 2015-06-23 18:59:48 +02:00
parent af171ce788
commit 9ba7054d14
7 changed files with 44 additions and 24 deletions

View File

@ -103,7 +103,7 @@
style="@style/StandardButton" style="@style/StandardButton"
android:text="@string/ma_button_sync_accounts_now" /> android:text="@string/ma_button_sync_accounts_now" />
<TextView <!-- <TextView
android:id="@+id/tv_remoteaccount" android:id="@+id/tv_remoteaccount"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -125,15 +125,16 @@
android:background="@drawable/standard_button" android:background="@drawable/standard_button"
style="@style/StandardButton" style="@style/StandardButton"
android:text="@string/choose_account" /> android:text="@string/choose_account" />
-->
<ImageView <ImageView
android:id="@+id/imageView1" android:id="@+id/imageView1"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1" android:layout_alignLeft="@+id/textView1"
android:layout_alignStart="@+id/textView1" android:layout_alignStart="@+id/textView1"
android:layout_below="@+id/main_button_choose_account" android:layout_below="@+id/main_button_sync"
android:layout_marginTop="33dp" android:layout_marginTop="33dp"
android:src="@drawable/next_arrow" /> android:src="@drawable/next_arrow" />
<!-- android:layout_below="@+id/main_button_choose_account" -->
</RelativeLayout> </RelativeLayout>

View File

@ -27,7 +27,7 @@
--> -->
<resources> <resources>
<!-- Translation version, reference for translators --> <!-- Translation version, reference for translators -->
<string name="translation_version">6</string> <string name="translation_version">7</string>
<!-- Translations must begin there --> <!-- Translations must begin there -->
<!-- Preferences --> <!-- Preferences -->
@ -91,6 +91,7 @@
<item>-1</item> <item>-1</item>
</string-array> </string-array>
<string name="pref_push_on_receive">Push SMS on reception</string>
<string name="pref_sync_wifi">Synchronize in Wi-Fi</string> <string name="pref_sync_wifi">Synchronize in Wi-Fi</string>
<string name="pref_sync_4g">Synchronize in 4G</string> <string name="pref_sync_4g">Synchronize in 4G</string>
<string name="pref_sync_3g">Synchronize in 3G</string> <string name="pref_sync_3g">Synchronize in 3G</string>

View File

@ -27,7 +27,7 @@
--> -->
<resources> <resources>
<!-- Translation version, reference for translators --> <!-- Translation version, reference for translators -->
<string name="translation_version">6</string> <string name="translation_version">7</string>
<!-- Translations must begin there --> <!-- Translations must begin there -->
@ -71,6 +71,7 @@
<item>-1</item> <item>-1</item>
</string-array> </string-array>
<string name="pref_push_on_receive">Pousser le SMS à la réception</string>
<string name="pref_sync_wifi">Synchroniser en Wi-Fi</string> <string name="pref_sync_wifi">Synchroniser en Wi-Fi</string>
<string name="pref_sync_4g">Synchroniser en 4G</string> <string name="pref_sync_4g">Synchroniser en 4G</string>
<string name="pref_sync_3g">Synchroniser en 3G</string> <string name="pref_sync_3g">Synchroniser en 3G</string>

View File

@ -28,7 +28,7 @@
<resources> <resources>
<!-- Translation version, reference for translators --> <!-- Translation version, reference for translators -->
<string name="translation_version">6</string> <string name="translation_version">7</string>
<!-- System strings, do not translate --> <!-- System strings, do not translate -->
<string name="app_name">ownCloud-SMS</string> <string name="app_name">ownCloud-SMS</string>
@ -96,6 +96,7 @@
<item>-1</item> <item>-1</item>
</string-array> </string-array>
<string name="pref_push_on_receive">Push SMS on reception</string>
<string name="pref_sync_wifi">Synchronize in Wi-Fi</string> <string name="pref_sync_wifi">Synchronize in Wi-Fi</string>
<string name="pref_sync_4g">Synchronize in 4G</string> <string name="pref_sync_4g">Synchronize in 4G</string>
<string name="pref_sync_3g">Synchronize in 3G</string> <string name="pref_sync_3g">Synchronize in 3G</string>

View File

@ -25,12 +25,15 @@ import android.content.ContentResolver;
import android.content.PeriodicSync; import android.content.PeriodicSync;
import android.os.Bundle; import android.os.Bundle;
import android.preference.ListPreference; import android.preference.ListPreference;
import android.util.Log;
import fr.nrz.androidlib.activities.NrzSettingsActivity; import fr.nrz.androidlib.activities.NrzSettingsActivity;
import fr.unix_experience.owncloud_sms.R; import fr.unix_experience.owncloud_sms.R;
import fr.unix_experience.owncloud_sms.defines.DefaultPrefs; import fr.unix_experience.owncloud_sms.defines.DefaultPrefs;
import fr.unix_experience.owncloud_sms.prefs.OCSMSSharedPrefs; import fr.unix_experience.owncloud_sms.prefs.OCSMSSharedPrefs;
public class GeneralSettingsActivity extends NrzSettingsActivity { public class GeneralSettingsActivity extends NrzSettingsActivity {
private static final String TAG = GeneralSettingsActivity.class.getSimpleName();
private static AccountManager _accountMgr; private static AccountManager _accountMgr;
private static String _accountAuthority; private static String _accountAuthority;
private static String _accountType; private static String _accountType;
@ -65,6 +68,8 @@ public class GeneralSettingsActivity extends NrzSettingsActivity {
key.equals(new String("sync_3g")) || key.equals("sync_gprs") || key.equals(new String("sync_3g")) || key.equals("sync_gprs") ||
key.equals("sync_4g") || key.equals("sync_others")) { key.equals("sync_4g") || key.equals("sync_others")) {
final OCSMSSharedPrefs prefs = new OCSMSSharedPrefs(_context); final OCSMSSharedPrefs prefs = new OCSMSSharedPrefs(_context);
Log.d(TAG,"GeneralSettingsActivity.handleCheckboxPreference: set " + key + " to "
+ value.toString());
prefs.putBoolean(key, value); prefs.putBoolean(key, value);
} }
else { else {

View File

@ -12,28 +12,35 @@ package fr.unix_experience.owncloud_sms.broadcast_receivers;
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
import org.json.JSONArray; import org.json.JSONArray;
import fr.unix_experience.owncloud_sms.engine.ASyncSMSSync;
import fr.unix_experience.owncloud_sms.engine.ConnectivityMonitor;
import fr.unix_experience.owncloud_sms.engine.SmsFetcher;
import fr.unix_experience.owncloud_sms.prefs.OCSMSSharedPrefs;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.util.Log; import android.util.Log;
import fr.unix_experience.owncloud_sms.engine.ASyncSMSSync;
import fr.unix_experience.owncloud_sms.engine.ConnectivityMonitor;
import fr.unix_experience.owncloud_sms.engine.SmsFetcher;
import fr.unix_experience.owncloud_sms.prefs.OCSMSSharedPrefs;
public class ConnectivityChanged extends BroadcastReceiver implements ASyncSMSSync { public class ConnectivityChanged extends BroadcastReceiver implements ASyncSMSSync {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(final Context context, final Intent intent) {
ConnectivityMonitor cMon = new ConnectivityMonitor(context); final ConnectivityMonitor cMon = new ConnectivityMonitor(context);
final OCSMSSharedPrefs prefs = new OCSMSSharedPrefs(context);
if (!prefs.pushOnReceive()) {
Log.d(TAG,"ConnectivityChanges.onReceive: pushOnReceive is disabled");
return;
}
// If data is available and previous dataConnectionState was false, then we need to sync // If data is available and previous dataConnectionState was false, then we need to sync
if (cMon.isValid() && dataConnectionAvailable == false) { if (cMon.isValid() && dataConnectionAvailable == false) {
dataConnectionAvailable = true; dataConnectionAvailable = true;
@ -46,24 +53,24 @@ public class ConnectivityChanged extends BroadcastReceiver implements ASyncSMSSy
Log.d(TAG,"ConnectivityChanges.onReceive: data conn is off"); Log.d(TAG,"ConnectivityChanges.onReceive: data conn is off");
} }
} }
private void checkMessagesAndSend(Context context) { private void checkMessagesAndSend(final Context context) {
// Get last message synced from preferences // Get last message synced from preferences
Long lastMessageSynced = (new OCSMSSharedPrefs(context)).getLastMessageDate(); final Long lastMessageSynced = (new OCSMSSharedPrefs(context)).getLastMessageDate();
Log.d(TAG,"Synced Last:" + lastMessageSynced); Log.d(TAG,"Synced Last:" + lastMessageSynced);
// Now fetch messages since last stored date // Now fetch messages since last stored date
JSONArray smsList = new SmsFetcher(context).bufferizeMessagesSinceDate(lastMessageSynced); final JSONArray smsList = new SmsFetcher(context).bufferizeMessagesSinceDate(lastMessageSynced);
ConnectivityMonitor cMon = new ConnectivityMonitor(context); final ConnectivityMonitor cMon = new ConnectivityMonitor(context);
// Synchronize if network is valid and there are SMS // Synchronize if network is valid and there are SMS
if (cMon.isValid() && smsList != null) { if (cMon.isValid() && smsList != null) {
new SyncTask(context, smsList).execute(); new SyncTask(context, smsList).execute();
} }
} }
private static boolean dataConnectionAvailable = false; private static boolean dataConnectionAvailable = false;
private static final String TAG = ConnectivityChanged.class.getSimpleName(); private static final String TAG = ConnectivityChanged.class.getSimpleName();
} }

View File

@ -39,6 +39,10 @@ public class OCSMSSharedPrefs extends SharedPrefs {
return _sPrefs.getLong(_context.getString(R.string.pref_lastmsgdate), 0); return _sPrefs.getLong(_context.getString(R.string.pref_lastmsgdate), 0);
} }
public Boolean pushOnReceive() {
return _sPrefs.getBoolean("push_on_receive", DefaultPrefs.pushOnReceive);
}
public Boolean syncInWifi() { public Boolean syncInWifi() {
return _sPrefs.getBoolean("sync_wifi", DefaultPrefs.syncWifi); return _sPrefs.getBoolean("sync_wifi", DefaultPrefs.syncWifi);
} }