|
@ -2,7 +2,10 @@ package gr.thmmy.mthmmy.activities.topic; |
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint; |
|
|
import android.annotation.SuppressLint; |
|
|
import android.app.NotificationManager; |
|
|
import android.app.NotificationManager; |
|
|
|
|
|
import android.content.ClipData; |
|
|
|
|
|
import android.content.ClipboardManager; |
|
|
import android.content.Context; |
|
|
import android.content.Context; |
|
|
|
|
|
import android.content.DialogInterface; |
|
|
import android.content.Intent; |
|
|
import android.content.Intent; |
|
|
import android.content.SharedPreferences; |
|
|
import android.content.SharedPreferences; |
|
|
import android.graphics.Rect; |
|
|
import android.graphics.Rect; |
|
@ -162,6 +165,7 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo |
|
|
toolbarTitle.setMarqueeRepeatLimit(-1); |
|
|
toolbarTitle.setMarqueeRepeatLimit(-1); |
|
|
toolbarTitle.setText(topicTitle); |
|
|
toolbarTitle.setText(topicTitle); |
|
|
toolbarTitle.setSelected(true); |
|
|
toolbarTitle.setSelected(true); |
|
|
|
|
|
this.setToolbarOnLongClickListener(topicPageUrl); |
|
|
setSupportActionBar(toolbar); |
|
|
setSupportActionBar(toolbar); |
|
|
if (getSupportActionBar() != null) { |
|
|
if (getSupportActionBar() != null) { |
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
|
@ -793,4 +797,31 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**This method sets a long click listener on the title of the topic. Once the |
|
|
|
|
|
* listener gets triggered, it copies the link url of the topic in the clipboard. |
|
|
|
|
|
* This method is getting called on the onCreate() of the TopicActivity*/ |
|
|
|
|
|
void setToolbarOnLongClickListener(String url) { |
|
|
|
|
|
toolbar.setOnLongClickListener(view -> { |
|
|
|
|
|
//Try to set the clipboard text
|
|
|
|
|
|
try { |
|
|
|
|
|
//Create a ClipboardManager
|
|
|
|
|
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); |
|
|
|
|
|
|
|
|
|
|
|
clipboard.setPrimaryClip(ClipData.newPlainText(BUNDLE_TOPIC_URL, url)); |
|
|
|
|
|
|
|
|
|
|
|
//Make a toast to inform the user that the url was copied
|
|
|
|
|
|
Toast.makeText( |
|
|
|
|
|
TopicActivity.this, |
|
|
|
|
|
TopicActivity.this.getString(R.string.url_copied_msg), |
|
|
|
|
|
Toast.LENGTH_SHORT).show(); |
|
|
|
|
|
} |
|
|
|
|
|
//Something happened. Probably the device does not support this (report to Firebase)
|
|
|
|
|
|
catch (NullPointerException e) { |
|
|
|
|
|
Timber.e(e, "Error while trying to copy topic's url."); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
} |