mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 13:48:26 +00:00
Add advanced preference for refreshing push directory.
This commit is contained in:
parent
e188f62d70
commit
ca2eecaedf
@ -142,6 +142,8 @@ public class PushServiceSocket {
|
||||
return response.getKeys();
|
||||
} catch (JsonParseException e) {
|
||||
throw new IOException(e);
|
||||
} catch (NotFoundException nfe) {
|
||||
throw new UnregisteredUserException(destination.getNumber(), nfe);
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,6 +165,8 @@ public class PushServiceSocket {
|
||||
return response.getKeys().get(0);
|
||||
} catch (JsonParseException e) {
|
||||
throw new IOException(e);
|
||||
} catch (NotFoundException nfe) {
|
||||
throw new UnregisteredUserException(destination.getNumber(), nfe);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,9 @@
|
||||
<string name="ApplicationPreferencesActivity_unregistering">Unregistering...</string>
|
||||
<string name="ApplicationPreferencesActivity_unregistering_for_data_based_communication">Unregistering for data based communication</string>
|
||||
<string name="ApplicationPreferencesActivity_error_connecting_to_server">Error connecting to server!</string>
|
||||
<string name="ApplicationPreferencesActivity_you_are_not_registered_with_the_push_service">You are not registered with the push service...</string>
|
||||
<string name="ApplicationPreferencesActivity_updating_directory">Updating directory</string>
|
||||
<string name="ApplicationPreferencesActivity_updating_push_directory">Updating push directory...</string>
|
||||
|
||||
<!-- AttachmentTypeSelectorAdapter -->
|
||||
|
||||
@ -689,7 +692,8 @@
|
||||
</string>
|
||||
<string name="preferences__allow_sms_fallback">Allow SMS Fallback</string>
|
||||
<string name="preferences__send_and_receive_sms_messages_when_push_is_not_available">Send and receive SMS messages when push is not available</string>
|
||||
|
||||
<string name="preferences__refresh_push_directory">Refresh Push Directory</string>
|
||||
|
||||
<!-- **************************************** -->
|
||||
<!-- menus -->
|
||||
<!-- **************************************** -->
|
||||
|
@ -173,5 +173,9 @@
|
||||
|
||||
<Preference android:key="pref_mms_preferences"
|
||||
android:title="@string/preferences__advanced_mms_access_point_names"/>
|
||||
|
||||
<Preference android:key="pref_update_directory"
|
||||
android:title="@string/preferences__refresh_push_directory"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
@ -52,6 +52,7 @@ import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
|
||||
import org.thoughtcrime.securesms.push.PushServiceSocketFactory;
|
||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||
import org.thoughtcrime.securesms.util.ActionBarUtil;
|
||||
import org.thoughtcrime.securesms.util.DirectoryHelper;
|
||||
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||
import org.thoughtcrime.securesms.util.MemoryCleaner;
|
||||
@ -82,7 +83,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr
|
||||
private static final String PUSH_MESSAGING_PREF = "pref_toggle_push_messaging";
|
||||
private static final String MMS_PREF = "pref_mms_preferences";
|
||||
private static final String KITKAT_DEFAULT_PREF = "pref_set_default";
|
||||
|
||||
private static final String UPDATE_DIRECTORY_PREF = "pref_update_directory";
|
||||
|
||||
private final DynamicTheme dynamicTheme = new DynamicTheme();
|
||||
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
||||
@ -119,6 +120,8 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr
|
||||
.setOnPreferenceChangeListener(new ListSummaryListener());
|
||||
this.findPreference(TextSecurePreferences.RINGTONE_PREF)
|
||||
.setOnPreferenceChangeListener(new RingtoneSummaryListener());
|
||||
this.findPreference(UPDATE_DIRECTORY_PREF)
|
||||
.setOnPreferenceClickListener(new DirectoryUpdateListener());
|
||||
|
||||
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_COLOR_PREF));
|
||||
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_BLINK_PREF));
|
||||
@ -529,6 +532,46 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr
|
||||
}
|
||||
}
|
||||
|
||||
private class DirectoryUpdateListener implements Preference.OnPreferenceClickListener {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
final Context context = ApplicationPreferencesActivity.this;
|
||||
|
||||
if (!TextSecurePreferences.isPushRegistered(context)) {
|
||||
Toast.makeText(context,
|
||||
getString(R.string.ApplicationPreferencesActivity_you_are_not_registered_with_the_push_service),
|
||||
Toast.LENGTH_LONG).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
private ProgressDialog progress;
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
progress = ProgressDialog.show(context,
|
||||
getString(R.string.ApplicationPreferencesActivity_updating_directory),
|
||||
getString(R.string.ApplicationPreferencesActivity_updating_push_directory),
|
||||
true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
DirectoryHelper.refreshDirectory(context);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
if (progress != null)
|
||||
progress.dismiss();
|
||||
}
|
||||
}.execute();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* http://code.google.com/p/android/issues/detail?id=4611#c35 */
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user