updated Tagger library
added error checking when accessing activities outside the app added messages
This commit is contained in:
parent
ea9e69693c
commit
3b3e8b00cb
@ -44,5 +44,5 @@ dependencies {
|
||||
implementation 'com.squareup.picasso:picasso:2.71828'
|
||||
implementation 'com.github.QuadFlask:colorpicker:0.0.13'
|
||||
implementation 'com.github.nuclearfog:ZoomView:1.0.2'
|
||||
implementation 'com.github.nuclearfog:Tagger:1'
|
||||
implementation 'com.github.nuclearfog:Tagger:d0ab932'
|
||||
}
|
@ -1,11 +1,9 @@
|
||||
package org.nuclearfog.twidda.activity;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
@ -22,7 +20,6 @@ import android.widget.NumberPicker;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog.Builder;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
@ -58,8 +55,6 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
|
||||
private static final int POPUPCOLOR = 3;
|
||||
private static final int INVERTCOLOR = 0xffffff;
|
||||
|
||||
@Nullable
|
||||
private ConnectivityManager mConnect;
|
||||
private GlobalSettings settings;
|
||||
private LocationLoader locationAsync;
|
||||
private Button colorButton1, colorButton2, colorButton3, colorButton4;
|
||||
@ -98,7 +93,6 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
|
||||
if (getSupportActionBar() != null)
|
||||
getSupportActionBar().setTitle(R.string.settings);
|
||||
|
||||
mConnect = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
settings = GlobalSettings.getInstance(this);
|
||||
if (!settings.getLogin())
|
||||
login_layout.setVisibility(GONE);
|
||||
@ -182,14 +176,12 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.settings_info) {
|
||||
if (mConnect != null && mConnect.getActiveNetworkInfo() != null && mConnect.getActiveNetworkInfo().isConnected()) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
String link = getString(R.string.information_link);
|
||||
intent.setData(Uri.parse(link));
|
||||
String link = getString(R.string.information_link);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
|
||||
if (intent.resolveActivity(getPackageManager()) != null)
|
||||
startActivity(intent);
|
||||
} else {
|
||||
else
|
||||
Toast.makeText(this, R.string.connection_failed, LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.nuclearfog.twidda.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
@ -130,14 +129,11 @@ public class LoginPage extends AppCompatActivity implements OnClickListener {
|
||||
|
||||
|
||||
public void connect(String link) {
|
||||
ConnectivityManager mConnect = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
|
||||
if (mConnect != null && mConnect.getActiveNetworkInfo() != null && mConnect.getActiveNetworkInfo().isConnected()) {
|
||||
Intent browser = new Intent(ACTION_VIEW);
|
||||
browser.setData(Uri.parse(link));
|
||||
startActivity(browser);
|
||||
this.link = link;
|
||||
} else {
|
||||
this.link = link;
|
||||
Intent loginIntent = new Intent(ACTION_VIEW, Uri.parse(link));
|
||||
if (loginIntent.resolveActivity(getPackageManager()) != null)
|
||||
startActivity(loginIntent);
|
||||
else
|
||||
Toast.makeText(this, R.string.connection_failed, LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
@ -71,7 +71,7 @@ public class ProfileSettings extends AppCompatActivity implements OnClickListene
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
if (getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||
getSupportActionBar().setTitle(R.string.page_profile_edior);
|
||||
GlobalSettings settings = GlobalSettings.getInstance(this);
|
||||
FontTool.setViewFont(root, settings.getFontFace());
|
||||
root.setBackgroundColor(settings.getBackgroundColor());
|
||||
|
@ -43,7 +43,6 @@ public class SearchPage extends AppCompatActivity implements OnTabSelectedListen
|
||||
protected void onCreate(Bundle b) {
|
||||
super.onCreate(b);
|
||||
setContentView(R.layout.page_search);
|
||||
|
||||
Toolbar tool = findViewById(R.id.search_toolbar);
|
||||
TabLayout tablayout = findViewById(R.id.search_tab);
|
||||
View root = findViewById(R.id.search_layout);
|
||||
@ -55,25 +54,23 @@ public class SearchPage extends AppCompatActivity implements OnTabSelectedListen
|
||||
|
||||
Bundle param = getIntent().getExtras();
|
||||
Uri link = getIntent().getData();
|
||||
settings = GlobalSettings.getInstance(this);
|
||||
|
||||
if (param != null && param.containsKey(KEY_SEARCH_QUERY)) {
|
||||
search = param.getString(KEY_SEARCH_QUERY);
|
||||
} else if (link != null) {
|
||||
getSearchString(link);
|
||||
}
|
||||
|
||||
settings = GlobalSettings.getInstance(this);
|
||||
root.setBackgroundColor(settings.getBackgroundColor());
|
||||
tablayout.setSelectedTabIndicatorColor(settings.getHighlightColor());
|
||||
|
||||
adapter = new FragmentAdapter(getSupportFragmentManager(), AdapterType.SEARCH_TAB, 0, search);
|
||||
tablayout.setupWithViewPager(pager);
|
||||
tablayout.addOnTabSelectedListener(this);
|
||||
|
||||
adapter = new FragmentAdapter(getSupportFragmentManager(), AdapterType.SEARCH_TAB, 0, search);
|
||||
pager.setAdapter(adapter);
|
||||
|
||||
Tab twtSearch = tablayout.getTabAt(0);
|
||||
Tab usrSearch = tablayout.getTabAt(1);
|
||||
|
||||
if (twtSearch != null && usrSearch != null) {
|
||||
twtSearch.setIcon(R.drawable.search);
|
||||
usrSearch.setIcon(R.drawable.user);
|
||||
|
@ -2,10 +2,8 @@ package org.nuclearfog.twidda.activity;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
@ -84,8 +82,6 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
private Button rtwButton, favButton, replyName;
|
||||
private ImageView profile_img;
|
||||
|
||||
@Nullable
|
||||
private ConnectivityManager mConnect;
|
||||
private GlobalSettings settings;
|
||||
private NumberFormat format;
|
||||
private StatusLoader statusAsync;
|
||||
@ -135,7 +131,6 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||
|
||||
FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager(), AdapterType.TWEET_PAGE, tweetID, username);
|
||||
mConnect = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
|
||||
FontTool.setViewFont(root, settings.getFontFace());
|
||||
tweetLoc.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
@ -210,18 +205,16 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
break;
|
||||
|
||||
case R.id.tweet_link:
|
||||
if (mConnect != null && mConnect.getActiveNetworkInfo() != null && mConnect.getActiveNetworkInfo().isConnected()) {
|
||||
String tweetLink = "https://twitter.com/" + username.substring(1) + "/status/" + tweetID;
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(tweetLink));
|
||||
String tweetLink = "https://twitter.com/" + username.substring(1) + "/status/" + tweetID;
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(tweetLink));
|
||||
if (intent.resolveActivity(getPackageManager()) != null)
|
||||
startActivity(intent);
|
||||
} else {
|
||||
else
|
||||
Toast.makeText(this, R.string.connection_failed, LENGTH_SHORT).show();
|
||||
}
|
||||
break;
|
||||
|
||||
case R.id.link_copy:
|
||||
String tweetLink = "https://twitter.com/" + username.substring(1) + "/status/" + tweetID;
|
||||
tweetLink = "https://twitter.com/" + username.substring(1) + "/status/" + tweetID;
|
||||
ClipboardManager clip = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
if (clip != null) {
|
||||
ClipData linkClip = ClipData.newPlainText("tweet link", tweetLink);
|
||||
@ -305,13 +298,27 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(String text) {
|
||||
public void onTagClick(String tag) {
|
||||
Intent intent = new Intent(this, SearchPage.class);
|
||||
intent.putExtra(KEY_SEARCH_QUERY, text);
|
||||
intent.putExtra(KEY_SEARCH_QUERY, tag);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onLinkClick(String link) {
|
||||
if (link.startsWith("https://twitter.com/") && link.contains("/status/")) {
|
||||
Intent intent = new Intent(this, TweetDetail.class);
|
||||
intent.setData(Uri.parse(link));
|
||||
startActivity(intent);
|
||||
} else {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
|
||||
if (intent.resolveActivity(getPackageManager()) != null)
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
switch (event.getAction()) {
|
||||
@ -355,7 +362,7 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
footer.setVisibility(VISIBLE);
|
||||
|
||||
if (!tweet.getTweet().trim().isEmpty()) {
|
||||
Spannable sTweet = Tagger.makeText(tweet.getTweet(), settings.getHighlightColor(), this);
|
||||
Spannable sTweet = Tagger.makeTextWithLinks(tweet.getTweet(), settings.getHighlightColor(), this);
|
||||
tweetText.setVisibility(VISIBLE);
|
||||
tweetText.setText(sTweet);
|
||||
}
|
||||
@ -429,7 +436,10 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
public void onClick(@NonNull View widget) {
|
||||
Intent locationIntent = new Intent(Intent.ACTION_VIEW);
|
||||
locationIntent.setData(Uri.parse("geo:" + location));
|
||||
startActivity(locationIntent);
|
||||
if (locationIntent.resolveActivity(getPackageManager()) != null)
|
||||
startActivity(locationIntent);
|
||||
else
|
||||
Toast.makeText(getApplicationContext(), R.string.error_no_card_app, LENGTH_SHORT).show();
|
||||
}
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
|
@ -46,7 +46,6 @@ public class UserDetail extends AppCompatActivity {
|
||||
Toolbar toolbar = findViewById(R.id.user_toolbar);
|
||||
|
||||
GlobalSettings settings = GlobalSettings.getInstance(this);
|
||||
FontTool.setViewFont(root, settings.getFontFace());
|
||||
root.setBackgroundColor(settings.getBackgroundColor());
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
@ -81,5 +80,6 @@ public class UserDetail extends AppCompatActivity {
|
||||
adapter = new FragmentAdapter(getSupportFragmentManager(), AdapterType.SUBSCRIBER_PAGE, id, "");
|
||||
pager.setAdapter(adapter);
|
||||
}
|
||||
FontTool.setViewFont(root, settings.getFontFace());
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ package org.nuclearfog.twidda.activity;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spanned;
|
||||
@ -361,13 +360,21 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(String text) {
|
||||
public void onTagClick(String text) {
|
||||
Intent intent = new Intent(this, SearchPage.class);
|
||||
intent.putExtra(KEY_SEARCH_QUERY, text);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onLinkClick(String link) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
|
||||
if (intent.resolveActivity(getPackageManager()) != null)
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
@ -395,15 +402,12 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
|
||||
|
||||
case R.id.links:
|
||||
if (user != null && !user.getLink().isEmpty()) {
|
||||
ConnectivityManager mConnect = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
|
||||
if (mConnect != null && mConnect.getActiveNetworkInfo() != null && mConnect.getActiveNetworkInfo().isConnected()) {
|
||||
Intent browserIntent = new Intent(ACTION_VIEW);
|
||||
String link = user.getLink();
|
||||
browserIntent.setData(Uri.parse(link));
|
||||
String link = user.getLink();
|
||||
Intent browserIntent = new Intent(ACTION_VIEW, Uri.parse(link));
|
||||
if (browserIntent.resolveActivity(getPackageManager()) != null)
|
||||
startActivity(browserIntent);
|
||||
} else {
|
||||
else
|
||||
Toast.makeText(this, R.string.connection_failed, LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -458,7 +462,7 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
|
||||
public void setUser(final TwitterUser user) {
|
||||
this.user = user;
|
||||
NumberFormat formatter = NumberFormat.getIntegerInstance();
|
||||
Spanned bio = Tagger.makeText(user.getBio(), settings.getHighlightColor(), this);
|
||||
Spanned bio = Tagger.makeTextWithLinks(user.getBio(), settings.getHighlightColor(), this);
|
||||
int verify = user.isVerified() ? R.drawable.verify : 0;
|
||||
int locked = user.isLocked() ? R.drawable.lock : 0;
|
||||
|
||||
|
@ -124,9 +124,9 @@ public class MessageAdapter extends Adapter<MessageAdapter.MessageHolder> {
|
||||
Message message = messages.get(index);
|
||||
TwitterUser sender = message.getSender();
|
||||
if (itemClickListener.get() != null)
|
||||
text = Tagger.makeText(message.getText(), settings.getHighlightColor(), itemClickListener.get());
|
||||
text = Tagger.makeTextWithLinks(message.getText(), settings.getHighlightColor(), itemClickListener.get());
|
||||
else
|
||||
text = Tagger.makeText(message.getText(), settings.getHighlightColor());
|
||||
text = Tagger.makeTextWithLinks(message.getText(), settings.getHighlightColor());
|
||||
vh.message.setText(text);
|
||||
vh.username.setText(sender.getUsername());
|
||||
vh.screenname.setText(sender.getScreenname());
|
||||
|
@ -129,7 +129,7 @@ public class TweetAdapter extends Adapter<TweetAdapter.ItemHolder> {
|
||||
vh.screenname.setTextColor(color);
|
||||
vh.tweet.setTextColor(color);
|
||||
vh.time.setTextColor(color);
|
||||
Spanned text = Tagger.makeText(tweet.getTweet(), settings.getHighlightColor());
|
||||
Spanned text = Tagger.makeTextWithLinks(tweet.getTweet(), settings.getHighlightColor());
|
||||
vh.tweet.setText(text);
|
||||
vh.username.setText(user.getUsername());
|
||||
vh.screenname.setText(user.getScreenname());
|
||||
|
@ -2,6 +2,7 @@ package org.nuclearfog.twidda.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -81,7 +82,7 @@ public class MessageFragment extends Fragment implements OnRefreshListener, OnIt
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(String tag) {
|
||||
public void onTagClick(String tag) {
|
||||
if (reload != null && !reload.isRefreshing()) {
|
||||
Intent intent = new Intent(getContext(), SearchPage.class);
|
||||
intent.putExtra(KEY_SEARCH_QUERY, tag);
|
||||
@ -90,6 +91,16 @@ public class MessageFragment extends Fragment implements OnRefreshListener, OnIt
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onLinkClick(String link) {
|
||||
if (reload != null && !reload.isRefreshing() && getContext() != null) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
|
||||
if (intent.resolveActivity(getContext().getPackageManager()) != null)
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(Message message, Action action) {
|
||||
if (reload != null && !reload.isRefreshing()) {
|
||||
|
@ -100,7 +100,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/margin_layout"
|
||||
android:layout_marginBottom="@dimen/margin_layout"
|
||||
android:autoLink="web"
|
||||
android:linksClickable="true" />
|
||||
|
||||
<LinearLayout
|
||||
|
@ -143,7 +143,6 @@
|
||||
android:id="@+id/bio"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:autoLink="web"
|
||||
android:fadeScrollbars="false"
|
||||
android:linksClickable="true"
|
||||
android:maxLines="@integer/text_bio_lines"
|
||||
|
@ -104,7 +104,6 @@
|
||||
android:id="@+id/tweet_detailed"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:autoLink="web"
|
||||
android:fadeScrollbars="false"
|
||||
android:linksClickable="true"
|
||||
android:maxLines="@integer/text_tweet_lines"
|
||||
|
@ -138,4 +138,5 @@
|
||||
<string name="edit_hint_link">Link eingeben</string>
|
||||
<string name="edit_location_hint">Standortnamen eingeben</string>
|
||||
<string name="settins_font">Schriftart</string>
|
||||
<string name="page_profile_edior">Profil bearbeiten</string>
|
||||
</resources>
|
@ -139,4 +139,6 @@
|
||||
<string name="edit_hint_link">enter internetlink</string>
|
||||
<string name="edit_hint_enter_descr">enter profile description</string>
|
||||
<string name="settins_font">Font style</string>
|
||||
<string name="page_profile_edior">Edit profile</string>
|
||||
<string name="error_no_card_app">No card app installed!</string>
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user