Merge pull request #956 from tinloaf/refreshfromlist
Add possiblity to refresh the push directory directly from contact list
Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 406 B |
BIN
res/drawable-hdpi/ic_menu_refresh_holo_light.png
Normal file
After Width: | Height: | Size: 678 B |
Before Width: | Height: | Size: 293 B After Width: | Height: | Size: 293 B |
BIN
res/drawable-mdpi/ic_menu_refresh_holo_light.png
Normal file
After Width: | Height: | Size: 507 B |
Before Width: | Height: | Size: 481 B After Width: | Height: | Size: 481 B |
BIN
res/drawable-xhdpi/ic_menu_refresh_holo_light.png
Normal file
After Width: | Height: | Size: 901 B |
BIN
res/drawable-xxhdpi/ic_menu_refresh_holo_dark.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
res/drawable-xxhdpi/ic_menu_refresh_holo_light.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
9
res/menu/push_directory.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:title="@string/push_directory__menu_refresh"
|
||||
android:id="@+id/menu_refresh_directory"
|
||||
android:icon="?menu_refresh_directory"
|
||||
android:showAsAction="ifRoom"
|
||||
/>
|
||||
</menu>
|
@ -60,6 +60,7 @@
|
||||
<attr name="menu_group_icon" format="reference" />
|
||||
<attr name="menu_split_icon" format="reference" />
|
||||
<attr name="menu_accept_icon" format="reference" />
|
||||
<attr name="menu_refresh_directory" format="reference" />
|
||||
|
||||
<declare-styleable name="ForegroundImageView">
|
||||
<attr name="android:foreground" />
|
||||
|
@ -416,6 +416,9 @@
|
||||
|
||||
<!-- single_contact_selection_activity -->
|
||||
<string name="single_contact_selection_group_activity__filter">Type a name to filter…</string>
|
||||
<string name="SingleContactSelectionActivity_you_are_not_registered_with_the_push_service">You are not registered with the push service...</string>
|
||||
<string name="SingleContactSelectionActivity_updating_directory">Updating directory</string>
|
||||
<string name="SingleContactSelectionActivity_updating_push_directory">Updating push directory...</string>
|
||||
|
||||
<!-- ContactSelectionListFragment-->
|
||||
<string name="ContactSelectionlistFragment_select_for">Select for</string>
|
||||
@ -740,6 +743,9 @@
|
||||
<!-- contact_selection -->
|
||||
<string name="contact_selection__menu_finished">Finished</string>
|
||||
|
||||
<!-- refreshing push directory from menu -->
|
||||
<string name="push_directory__menu_refresh">Refresh Contact List</string>
|
||||
|
||||
<!-- conversation_button_context -->
|
||||
<string name="conversation_button_context__menu_send_unencrypted">Send unencrypted</string>
|
||||
|
||||
|
@ -54,6 +54,7 @@
|
||||
<item name="menu_selectall_icon">@drawable/ic_menu_selectall_holo_light</item>
|
||||
<item name="menu_split_icon">@drawable/ic_menu_split_holo_light</item>
|
||||
<item name="menu_accept_icon">@drawable/ic_menu_accept_holo_light</item>
|
||||
<item name="menu_refresh_directory">@drawable/ic_menu_refresh_holo_light</item>
|
||||
|
||||
</style>
|
||||
|
||||
@ -122,6 +123,7 @@
|
||||
<item name="menu_selectall_icon">@drawable/ic_menu_selectall_holo_dark</item>
|
||||
<item name="menu_split_icon">@drawable/ic_menu_split_holo_dark</item>
|
||||
<item name="menu_accept_icon">@drawable/ic_menu_accept_holo_dark</item>
|
||||
<item name="menu_refresh_directory">@drawable/ic_menu_refresh_holo_dark</item>
|
||||
</style>
|
||||
|
||||
<style name="TextSecure.DarkTheme.NavigationDrawer"
|
||||
|
@ -16,12 +16,19 @@
|
||||
*/
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuInflater;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
import org.thoughtcrime.securesms.components.SingleRecipientPanel;
|
||||
@ -33,8 +40,10 @@ import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
|
||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||
import org.thoughtcrime.securesms.util.ActionBarUtil;
|
||||
import org.thoughtcrime.securesms.util.DirectoryHelper;
|
||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||
import org.thoughtcrime.securesms.util.NumberUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.textsecure.crypto.MasterSecret;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -123,6 +132,18 @@ public class SingleContactSelectionActivity extends PassphraseRequiredSherlockFr
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = this.getSupportMenuInflater();
|
||||
menu.clear();
|
||||
|
||||
if (TextSecurePreferences.isPushRegistered(this)) {
|
||||
inflater.inflate(R.menu.push_directory, menu);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
@ -132,13 +153,49 @@ public class SingleContactSelectionActivity extends PassphraseRequiredSherlockFr
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_refresh_directory:
|
||||
handleDirectoryRefresh();
|
||||
return true;
|
||||
case android.R.id.home:
|
||||
setResult(RESULT_CANCELED);
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void handleDirectoryRefresh() {
|
||||
if (!TextSecurePreferences.isPushRegistered(SingleContactSelectionActivity.this)) {
|
||||
Toast.makeText(getApplicationContext(),
|
||||
getString(R.string.SingleContactSelectionActivity_you_are_not_registered_with_the_push_service),
|
||||
Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
private ProgressDialog progress;
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
progress = ProgressDialog.show(SingleContactSelectionActivity.this,
|
||||
getString(R.string.SingleContactSelectionActivity_updating_directory),
|
||||
getString(R.string.SingleContactSelectionActivity_updating_push_directory),
|
||||
true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
DirectoryHelper.refreshDirectory(getApplicationContext());
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
if (progress != null)
|
||||
progress.dismiss();
|
||||
}
|
||||
}.execute();
|
||||
|
||||
}
|
||||
}
|
||||
|