Skip to content

Commit

Permalink
Library updates (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlewis13 authored Oct 11, 2019
1 parent 2e72c29 commit 738c3d4
Show file tree
Hide file tree
Showing 19 changed files with 28 additions and 332 deletions.
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
<string name="app_name">ForstaLabs</string>
<string name="relay_main_button">Open Relay</string>
<string name="relay_dashbboard_button">Open Relay</string>

<string name="forsta_login_title">Login to Relay</string>
<string name="forsta_login_title_join">Join Relay</string>
</resources>
Binary file removed librelay/res/drawable-hdpi-v11/icon_notification.png
Binary file not shown.
Binary file removed librelay/res/drawable-hdpi-v9/icon_notification.png
Binary file not shown.
Binary file removed librelay/res/drawable-mdpi-v11/icon_notification.png
Binary file not shown.
Binary file removed librelay/res/drawable-mdpi-v9/icon_notification.png
Binary file not shown.
Binary file removed librelay/res/drawable-xhdpi-v11/icon_notification.png
Binary file not shown.
Binary file removed librelay/res/drawable-xhdpi-v9/icon_notification.png
Binary file not shown.
Binary file removed librelay/res/drawable-xxhdpi-v11/icon_notification.png
Binary file not shown.
Binary file removed librelay/res/drawable-xxhdpi-v9/icon_notification.png
Binary file not shown.
90 changes: 7 additions & 83 deletions librelay/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
<string name="NotificationChannel_other">Other</string>
<string name="NotificationChannel_missing_display_name">Unknown</string>

<string name="MessageRetrievalService_forsta">Relay Message Retrieval Service</string>
<string name="MessageRetrievalService_forsta">Message Retrieval Service</string>
<string name="MessageRetrievalService_background_connection_enabled">Background connection enabled</string>

<!-- Relay Strings -->
<string name="forsta_login_title">Login to Relay</string>
<string name="forsta_login_title_join">Join Relay</string>
<string name="forsta_login_title">Login</string>
<string name="forsta_login_title_join">Join</string>
<string name="forsta_login_account_firstname_label">First Name</string>
<string name="forsta_login_account_fullname_label">Full Name</string>
<string name="forsta_login_account_username_label">Username</string>
Expand Down Expand Up @@ -79,9 +79,9 @@
<string name="ApplicationPreferencesActivity_this_will_permanently_unlock_signal_and_message_notifications">This will permanently unlock Relay and message notifications.</string>
<string name="ApplicationPreferencesActivity_disable">Disable</string>
<string name="ApplicationPreferencesActivity_unregistering">Unregistering</string>
<string name="ApplicationPreferencesActivity_unregistering_from_signal_messages_and_calls">Unregistering from Relay messages...</string>
<string name="ApplicationPreferencesActivity_unregistering_from_signal_messages_and_calls">Unregistering...</string>
<string name="ApplicationPreferencesActivity_disable_signal_messages_and_calls">Disable Relay messages?</string>
<string name="ApplicationPreferencesActivity_disable_signal_messages_and_calls_by_unregistering">Disable Relay messages by unregistering from the server. You will need to re-register your phone number to use them again in the future.</string>
<string name="ApplicationPreferencesActivity_disable_signal_messages_and_calls_by_unregistering">Disable messages by unregistering from the server. You will need to re-register your phone number to use them again in the future.</string>
<string name="ApplicationPreferencesActivity_error_connecting_to_server">Error connecting to server!</string>
<string name="ApplicationPreferencesActivity_sms_enabled">SMS Enabled</string>
<string name="ApplicationPreferencesActivity_touch_to_change_your_default_sms_app">Touch to change your default SMS app</string>
Expand Down Expand Up @@ -148,7 +148,7 @@

<!-- ContactsDatabase -->
<string name="ContactsDatabase_message_s">Message %s</string>
<string name="ContactsDatabase_signal_call_s">Relay Call %s</string>
<string name="ContactsDatabase_signal_call_s">Call %s</string>

<!-- ConversationItem -->
<string name="ConversationItem_message_size_d_kb">Message size: %d KB</string>
Expand Down Expand Up @@ -316,23 +316,6 @@
<!-- ShareActivity -->
<string name="ShareActivity_share_with">Share with</string>

<!-- ExperienceUpgradeActivity -->
<string name="ExperienceUpgradeActivity_welcome_to_signal_dgaf">Welcome to Relay.</string>
<string name="ExperienceUpgradeActivity_textsecure_is_now_called_signal">Thanks for upgrading to the latest Relay.</string>
<string name="ExperienceUpgradeActivity_welcome_to_signal_excited">Welcome to Relay!</string>
<string name="ExperienceUpgradeActivity_textsecure_is_now_signal">Thanks for upgrading to the latest Relay.</string>
<string name="ExperienceUpgradeActivity_textsecure_is_now_signal_long">Thanks for upgrading to the latest Relay.</string>
<!-- ExportFragment -->
<string name="ExportFragment_export">Export</string>
<string name="ExportFragment_export_plaintext_to_storage">Export plaintext to storage?</string>
<string name="ExportFragment_warning_this_will_export_the_plaintext_contents">Warning, this will export the plaintext contents of your Relay messages to storage.</string>
<string name="ExportFragment_cancel">Cancel</string>
<string name="ExportFragment_exporting">Exporting</string>
<string name="ExportFragment_exporting_plaintext_to_storage">Exporting plaintext to storage...</string>
<string name="ExportFragment_error_unable_to_write_to_storage">Error, unable to write to storage.</string>
<string name="ExportFragment_error_while_writing_to_storage">Error while writing to storage.</string>
<string name="ExportFragment_export_successful">Export successful.</string>

<!-- FcmRefreshJob -->
<string name="GcmRefreshJob_Permanent_Signal_communication_failure">Permanent Relay communication failure!</string>
<string name="GcmRefreshJob_Signal_was_unable_to_register_with_Google_Play_Services">Relay was unable to register with Google Play Services. Relay messages have been disabled, please try re-registering in Settings &gt; Advanced.</string>
Expand All @@ -358,40 +341,6 @@
<!-- GroupMembersDialog -->
<string name="GroupMembersDialog_me">Me</string>

<!-- ImportExportActivity -->
<string name="ImportExportActivity_import">Import</string>
<string name="ImportExportActivity_export">Export</string>

<!-- ImportFragment -->
<string name="ImportFragment_import_system_sms_database">Import system SMS database?</string>
<string name="ImportFragment_this_will_import_messages_from_the_system">This will import
messages from the system\'s default SMS database to Relay. If you\'ve previously
imported the system\'s SMS database, importing again will result in duplicated messages.
</string>
<string name="ImportFragment_import">Import</string>
<string name="ImportFragment_cancel">Cancel</string>
<string name="ImportFragment_restore_encrypted_backup">Restore encrypted backup?</string>
<string name="ImportFragment_restoring_an_encrypted_backup_will_completely_replace_your_existing_keys">
Restoring an encrypted backup will completely replace your existing keys, preferences, and
messages. You will lose any information that\'s in your current Relay install but not
in the backup.
</string>
<string name="ImportFragment_restore">Restore</string>
<string name="ImportFragment_import_plaintext_backup">Import plaintext backup?</string>
<string name="ImportFragment_this_will_import_messages_from_a_plaintext_backup">This will import
messages from a plaintext backup. If you\'ve previously imported this backup,
importing again will result in duplicated messages.
</string>
<string name="ImportFragment_importing">Importing</string>
<string name="ImportFragment_import_plaintext_backup_elipse">Importing plaintext backup...</string>
<string name="ImportFragment_no_plaintext_backup_found">No plaintext backup found!</string>
<string name="ImportFragment_error_importing_backup">Error importing backup!</string>
<string name="ImportFragment_import_complete">Import complete!</string>
<string name="ImportFragment_restoring">Restoring</string>
<string name="ImportFragment_restoring_encrypted_backup">Restoring encrypted backup...</string>
<string name="ImportFragment_no_encrypted_backup_found">No encrypted backup found!</string>
<string name="ImportFragment_restore_complete">Restore complete!</string>

<!-- InputPanel -->
<string name="InputPanel_tap_and_hold_to_record_a_voice_message_release_to_send">Tap and hold to record a voice message, release to send</string>

Expand All @@ -402,31 +351,6 @@
<string name="QuoteView_document">Document</string>
<string name="QuoteView_you">You</string>

<!-- InviteActivity -->
<string name="InviteActivity_share">Share</string>
<string name="InviteActivity_choose_contacts">Choose contacts</string>
<string name="InviteActivity_cancel">Cancel</string>
<string name="InviteActivity_sending">Sending...</string>
<string name="InviteActivity_heart_content_description">Heart</string>
<string name="InviteActivity_invitations_sent">Invitations sent!</string>
<string name="InviteActivity_invite_to_signal">Invite to Relay</string>
<plurals name="InviteActivity_send_sms_to_friends">
<item quantity="one">SEND SMS TO 1 FRIEND</item>
<item quantity="other">SEND SMS TO %d FRIENDS</item>
</plurals>
<plurals name="InviteActivity_send_sms_invites">
<item quantity="one">Send 1 SMS invite?</item>
<item quantity="other">Send %d SMS invites?</item>
</plurals>
<string name="InviteActivity_lets_switch_to_signal">Please download the Relay secure messaging app for encrypted messaging. %1$s</string>
<string name="InviteActivity_no_app_to_share_to">It looks like you don\'t have any apps to share to.</string>
<string name="InviteActivity_invite_a_friend">Invite a friend to use Relay Relay.</string>

<!-- KeyScanningActivity -->
<string name="KeyScanningActivity_no_scanned_key_found_exclamation">No scanned key found!</string>
<string name="KeyScanningActivity_install_barcode_Scanner">Install Barcode Scanner?</string>
<string name="KeyScanningActivity_this_application_requires_barcode_scanner_would_you_like_to_install_it">Relay needs Barcode Scanner for QR codes.</string>

<!-- MessageDetailsRecipient -->
<string name="MessageDetailsRecipient_failed_to_send">Failed to send</string>
<string name="MessageDetailsRecipient_new_safety_numbers">New safety numbers</string>
Expand Down Expand Up @@ -527,7 +451,7 @@
<string name="RecipientPreferenceActivity_enabled">Enabled</string>
<string name="RecipientPreferenceActivity_disabled">Disabled</string>

<!-- RedPhone -->
<!-- Calling -->
<string name="RedPhone_answering">Answering</string>
<string name="RedPhone_ending_call">Ending call</string>
<string name="RedPhone_dialing">Dialing</string>
Expand Down
2 changes: 0 additions & 2 deletions librelay/src/io/forsta/librelay/jobs/FcmRefreshJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ protected void initialize(@NonNull SafeData data) {

@Override
public void onRun() throws Exception {
if (TextSecurePreferences.isFcmDisabled(context)) return;

Log.w(TAG, "FCM Reregistering...");

int result = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public AbstractNotificationBuilder(Context context, NotificationPrivacyPreferenc
this.privacy = privacy;

setColor(context.getResources().getColor(R.color.textsecure_primary));
setSmallIcon(R.drawable.icon_notification);
setSmallIcon(R.drawable.ic_message_white);
setChannelId(NotificationChannels.getMessagesChannel(context));
setLed();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package io.forsta.librelay.notifications;

import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;

import io.forsta.librelay.R;
Expand All @@ -14,7 +12,7 @@ public class FailedNotificationBuilder extends AbstractNotificationBuilder {
public FailedNotificationBuilder(Context context, NotificationPrivacyPreference privacy) {
super(context, privacy);

setSmallIcon(R.drawable.icon_notification);
setSmallIcon(R.drawable.ic_message_white);
setLargeIcon(BitmapFactory.decodeResource(context.getResources(),
R.drawable.ic_action_warning_red));
setContentTitle(context.getString(R.string.MessageNotifier_message_delivery_failed));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.preference.PreferenceFragment;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import io.forsta.librelay.R;
Expand Down Expand Up @@ -40,6 +41,7 @@ public void onCreate(Bundle paramBundle) {
@Override
public void onResume() {
super.onResume();
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(R.string.preferences__advanced);
}

public void setOnClickCallbacks(OnClickCallbacks callbacks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.os.Bundle;
import android.preference.ListPreference;
import android.support.v7.app.AppCompatActivity;

import io.forsta.librelay.R;
import io.forsta.librelay.util.TextSecurePreferences;
Expand All @@ -25,19 +26,17 @@ public void onCreate(Bundle paramBundle) {
@Override
public void onStart() {
super.onStart();
// getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener((ApplicationPreferencesActivity)getActivity());
}

@Override
public void onResume() {
super.onResume();
// ((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.preferences__appearance);
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(R.string.preferences__appearance);
}

@Override
public void onStop() {
super.onStop();
// getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener((ApplicationPreferencesActivity) getActivity());
}

public static CharSequence getSummary(Context context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.preference.Preference.OnPreferenceChangeListener;
import android.support.v4.preference.PreferenceFragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;

Expand Down Expand Up @@ -42,7 +43,7 @@ public void onCreate(Bundle paramBundle) {
@Override
public void onResume() {
super.onResume();
// ((ApplicationPreferencesActivity)getActivity()).getSupportActionBar().setTitle(R.string.preferences__chats);
((AppCompatActivity)getActivity()).getSupportActionBar().setTitle(R.string.preferences__chats);
setMediaDownloadSummaries();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.preference.Preference;
import android.preference.PreferenceManager;
import android.preference.RingtonePreference;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;

import java.util.ArrayList;
Expand Down Expand Up @@ -63,7 +64,7 @@ public boolean onPreferenceChange(Preference preference, Object o) {
@Override
public void onResume() {
super.onResume();
// ((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.preferences__notifications);
((AppCompatActivity)getActivity()).getSupportActionBar().setTitle(R.string.preferences__notifications);
}

private class RingtoneSummaryListener implements Preference.OnPreferenceChangeListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,16 @@ public class IncomingMessageObserver implements ConstraintObserver.Notifier {

private static final String TAG = IncomingMessageObserver.class.getSimpleName();

public static final int FOREGROUND_ID = 313399;
private static final long REQUEST_TIMEOUT_MINUTES = 1;
private static final long REQUEST_TIMEOUT_MINUTES = 1;

private static SignalServiceMessagePipe pipe = null;
private static SignalServiceMessagePipe pipe = null;

private final Context context;
private final NetworkConstraint networkConstraint;
private final SignalServiceMessageReceiver receiver;

private boolean appVisible;


public IncomingMessageObserver(@NonNull Context context) {
this.context = context;
this.networkConstraint = new NetworkConstraint.Factory(ApplicationContext.getInstance(context)).create();
Expand All @@ -54,10 +52,6 @@ public IncomingMessageObserver(@NonNull Context context) {
new NetworkConstraintObserver(ApplicationContext.getInstance(context)).register(this);
new MessageRetrievalThread().start();

if (TextSecurePreferences.isFcmDisabled(context)) {
ContextCompat.startForegroundService(context, new Intent(context, ForegroundService.class));
}

ProcessLifecycleOwner.get().getLifecycle().addObserver(new DefaultLifecycleObserver() {
@Override
public void onStart(@NonNull LifecycleOwner owner) {
Expand Down Expand Up @@ -89,14 +83,12 @@ private synchronized void onAppBackgrounded() {
}

private synchronized boolean isConnectionNecessary() {
boolean isGcmDisabled = TextSecurePreferences.isFcmDisabled(context);

Log.d(TAG, String.format("Network requirement: %s, app visible: %s, gcm disabled: %b",
networkConstraint.isMet(), appVisible, isGcmDisabled));
networkConstraint.isMet(), appVisible, false));

return TextSecurePreferences.isPushRegistered(context) &&
return TextSecurePreferences.isPushRegistered(context) &&
TextSecurePreferences.isWebsocketRegistered(context) &&
(appVisible || isGcmDisabled) &&
appVisible &&
networkConstraint.isMet();
}

Expand Down Expand Up @@ -167,28 +159,4 @@ public void uncaughtException(Thread t, Throwable e) {
Log.w(TAG, e);
}
}

public static class ForegroundService extends Service {

@Override
public @Nullable
IBinder onBind(Intent intent) {
return null;
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);

NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext(), NotificationChannels.OTHER);
builder.setContentTitle(getApplicationContext().getString(R.string.MessageRetrievalService_forsta));
builder.setContentText(getApplicationContext().getString(R.string.MessageRetrievalService_background_connection_enabled));
builder.setPriority(NotificationCompat.PRIORITY_MIN);
builder.setWhen(0);
builder.setSmallIcon(R.drawable.ic_forsta_notification);
startForeground(FOREGROUND_ID, builder.build());

return Service.START_STICKY;
}
}
}
Loading

0 comments on commit 738c3d4

Please sign in to comment.