Merge pull request #956 from tinloaf/refreshfromlist

Add possiblity to refresh the push directory directly from contact list
This commit is contained in:
Moxie Marlinspike 2014-03-03 10:09:32 -08:00
commit 3474950830
13 changed files with 76 additions and 1 deletions

View File

Before

Width:  |  Height:  |  Size: 406 B

After

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 678 B

View File

Before

Width:  |  Height:  |  Size: 293 B

After

Width:  |  Height:  |  Size: 293 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

View File

Before

Width:  |  Height:  |  Size: 481 B

After

Width:  |  Height:  |  Size: 481 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 901 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View 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>

View File

@ -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" />

View File

@ -416,6 +416,9 @@
<!-- single_contact_selection_activity -->
<string name="single_contact_selection_group_activity__filter">Type a name to filter&#8230;</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>

View File

@ -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"

View File

@ -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();
}
}