mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-25 22:38:49 +00:00
material actionbar and fab
// FREEBIE
This commit is contained in:
@@ -74,7 +74,6 @@ public class ApplicationContext extends Application implements DependencyInjecto
|
||||
|
||||
|
||||
private void initializeRandomNumberFix() {
|
||||
Security.insertProviderAt(new org.spongycastle.jce.provider.BouncyCastleProvider(), 1);
|
||||
PRNGFixes.apply();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.database.ContentObserver;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.provider.ContactsContract;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.util.Log;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.widget.SearchView;
|
||||
@@ -57,6 +58,8 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
dynamicLanguage.onCreate(this);
|
||||
super.onCreate(icicle);
|
||||
|
||||
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
|
||||
|
||||
setContentView(R.layout.conversation_list_activity);
|
||||
|
||||
getSupportActionBar().setTitle(R.string.app_name);
|
||||
@@ -156,7 +159,6 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
super.onOptionsItemSelected(item);
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_new_message: openSingleContactSelection(); return true;
|
||||
case R.id.menu_new_group: createGroup(); return true;
|
||||
case R.id.menu_settings: handleDisplaySettings(); return true;
|
||||
case R.id.menu_clear_passphrase: handleClearPassphrase(); return true;
|
||||
@@ -179,12 +181,6 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private void openSingleContactSelection() {
|
||||
Intent intent = new Intent(this, NewConversationActivity.class);
|
||||
intent.putExtra(NewConversationActivity.MASTER_SECRET_EXTRA, masterSecret);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private void createConversation(long threadId, Recipients recipients, int distributionType) {
|
||||
Intent intent = new Intent(this, ConversationActivity.class);
|
||||
intent.putExtra(ConversationActivity.RECIPIENTS_EXTRA, recipients.getIds());
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
@@ -27,21 +28,21 @@ import android.support.v4.app.ListFragment;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.text.TextUtils;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.view.ActionMode;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.util.Log;
|
||||
import android.support.v4.widget.CursorAdapter;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.melnykov.fab.FloatingActionButton;
|
||||
|
||||
import org.thoughtcrime.securesms.components.DefaultSmsReminder;
|
||||
import org.thoughtcrime.securesms.components.ExpiredBuildReminder;
|
||||
import org.thoughtcrime.securesms.components.PushRegistrationReminder;
|
||||
@@ -65,12 +66,14 @@ public class ConversationListFragment extends ListFragment
|
||||
private MasterSecret masterSecret;
|
||||
private ActionMode actionMode;
|
||||
private ReminderView reminderView;
|
||||
private FloatingActionButton fab;
|
||||
private String queryFilter = "";
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
||||
final View view = inflater.inflate(R.layout.conversation_list_fragment, container, false);
|
||||
reminderView = new ReminderView(getActivity());
|
||||
fab = (FloatingActionButton) view.findViewById(R.id.fab);
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -87,6 +90,14 @@ public class ConversationListFragment extends ListFragment
|
||||
setHasOptionsMenu(true);
|
||||
getListView().setAdapter(null);
|
||||
getListView().addHeaderView(reminderView);
|
||||
fab.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(), NewConversationActivity.class);
|
||||
intent.putExtra(NewConversationActivity.MASTER_SECRET_EXTRA, masterSecret);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
initializeListAdapter();
|
||||
initializeBatchListener();
|
||||
|
||||
@@ -238,12 +249,6 @@ public class ConversationListFragment extends ListFragment
|
||||
((ConversationListAdapter)this.getListAdapter()).getBatchSelections().size()));
|
||||
}
|
||||
|
||||
private void handleUnselectAllThreads() {
|
||||
((ConversationListAdapter)this.getListAdapter()).selectAllThreads();
|
||||
actionMode.setSubtitle(getString(R.string.conversation_fragment_cab__batch_selection_amount,
|
||||
((ConversationListAdapter)this.getListAdapter()).getBatchSelections().size()));
|
||||
}
|
||||
|
||||
private void handleCreateConversation(long threadId, Recipients recipients, int distributionType) {
|
||||
listener.onCreateConversation(threadId, recipients, distributionType);
|
||||
}
|
||||
|
||||
@@ -110,7 +110,10 @@ public class ConversationListItem extends RelativeLayout
|
||||
TextView.BufferType.SPANNABLE);
|
||||
|
||||
if (thread.getDate() > 0)
|
||||
this.dateView.setText(DateUtils.getBetterRelativeTimeSpanString(getContext(), thread.getDate()));
|
||||
this.dateView.setText(DateUtils.getRelativeTimeSpanString(thread.getDate(),
|
||||
System.currentTimeMillis(),
|
||||
DateUtils.MINUTE_IN_MILLIS,
|
||||
DateUtils.FORMAT_ABBREV_RELATIVE));
|
||||
|
||||
setBackground(read, batchMode);
|
||||
setContactPhoto(this.recipients.getPrimaryRecipient());
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
|
||||
import org.thoughtcrime.securesms.util.MemoryCleaner;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.VersionTracker;
|
||||
|
||||
/**
|
||||
@@ -52,7 +51,6 @@ public class PassphraseCreateActivity extends PassphraseActivity {
|
||||
private void initializeResources() {
|
||||
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
getSupportActionBar().setCustomView(R.layout.light_centered_app_title);
|
||||
mitigateAndroidTilingBug();
|
||||
|
||||
TextSecurePreferences.setPasswordDisabled(this, true);
|
||||
new SecretGenerator().execute(MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
|
||||
@@ -86,15 +84,6 @@ public class PassphraseCreateActivity extends PassphraseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private void mitigateAndroidTilingBug() {
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
Drawable actionBarBackground = getResources().getDrawable(R.drawable.background_pattern_repeat);
|
||||
Util.fixBackgroundRepeat(actionBarBackground);
|
||||
getSupportActionBar().setBackgroundDrawable(actionBarBackground);
|
||||
Util.fixBackgroundRepeat(findViewById(R.id.scroll_parent).getBackground());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cleanup() {
|
||||
System.gc();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
@@ -115,15 +116,14 @@ public class PassphrasePromptActivity extends PassphraseActivity {
|
||||
private void initializeResources() {
|
||||
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
getSupportActionBar().setCustomView(R.layout.light_centered_app_title);
|
||||
mitigateAndroidTilingBug();
|
||||
|
||||
ImageButton okButton = (ImageButton) findViewById(R.id.ok_button);
|
||||
passphraseText = (EditText) findViewById(R.id.passphrase_edit);
|
||||
SpannableString hint = new SpannableString(getString(R.string.PassphrasePromptActivity_enter_passphrase));
|
||||
|
||||
hint.setSpan(new RelativeSizeSpan(0.8f), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
SpannableString hint = new SpannableString(" " + getString(R.string.PassphrasePromptActivity_enter_passphrase));
|
||||
hint.setSpan(new RelativeSizeSpan(0.9f), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
hint.setSpan(new TypefaceSpan("sans-serif"), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
hint.setSpan(new ForegroundColorSpan(0x66000000), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
hint.setSpan(new ForegroundColorSpan(0xcc000000), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
|
||||
passphraseText.setHint(hint);
|
||||
okButton.setOnClickListener(new OkButtonClickListener());
|
||||
passphraseText.setOnEditorActionListener(new PassphraseActionListener());
|
||||
@@ -150,15 +150,6 @@ public class PassphrasePromptActivity extends PassphraseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private void mitigateAndroidTilingBug() {
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
Drawable actionBarBackground = getResources().getDrawable(R.drawable.background_pattern_repeat);
|
||||
Util.fixBackgroundRepeat(actionBarBackground);
|
||||
getSupportActionBar().setBackgroundDrawable(actionBarBackground);
|
||||
Util.fixBackgroundRepeat(findViewById(R.id.scroll_parent).getBackground());
|
||||
}
|
||||
}
|
||||
|
||||
private class OkButtonClickListener implements OnClickListener {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.thoughtcrime.securesms.R;
|
||||
public class ReminderView extends LinearLayout {
|
||||
private ViewGroup container;
|
||||
private ImageButton cancel;
|
||||
private Button ok;
|
||||
private TextView title;
|
||||
private TextView text;
|
||||
private ImageView icon;
|
||||
@@ -46,7 +45,6 @@ public class ReminderView extends LinearLayout {
|
||||
LayoutInflater.from(getContext()).inflate(R.layout.reminder_header, this, true);
|
||||
container = (ViewGroup ) findViewById(R.id.container);
|
||||
cancel = (ImageButton) findViewById(R.id.cancel);
|
||||
ok = (Button ) findViewById(R.id.ok);
|
||||
title = (TextView ) findViewById(R.id.reminder_title);
|
||||
text = (TextView ) findViewById(R.id.reminder_text);
|
||||
icon = (ImageView ) findViewById(R.id.icon);
|
||||
@@ -58,7 +56,7 @@ public class ReminderView extends LinearLayout {
|
||||
text.setText(reminder.getTextResId());
|
||||
|
||||
if (reminder.isDismissable()) {
|
||||
ok.setOnClickListener(reminder.getOkListener());
|
||||
this.setOnClickListener(reminder.getOkListener());
|
||||
cancel.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -68,7 +66,6 @@ public class ReminderView extends LinearLayout {
|
||||
});
|
||||
container.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
ok.setVisibility(View.GONE);
|
||||
cancel.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,20 +276,6 @@ public class Util {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* source: http://stackoverflow.com/a/9500334
|
||||
*/
|
||||
public static void fixBackgroundRepeat(Drawable bg) {
|
||||
if (bg != null) {
|
||||
if (bg instanceof BitmapDrawable) {
|
||||
BitmapDrawable bmp = (BitmapDrawable) bg;
|
||||
bmp.mutate();
|
||||
bmp.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isBuildFresh() {
|
||||
return BuildConfig.BUILD_TIMESTAMP + TimeUnit.DAYS.toMillis(180) > System.currentTimeMillis();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user