move copyToClipboard() to CommonActivity
This commit is contained in:
parent
3d39b03a60
commit
7b10e95213
@ -7,6 +7,7 @@ import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class CommonActivity extends FragmentActivity {
|
||||
private final String TAG = this.getClass().getSimpleName();
|
||||
@ -72,5 +73,19 @@ public class CommonActivity extends FragmentActivity {
|
||||
public int getOrientation() {
|
||||
return getWindowManager().getDefaultDisplay().getOrientation();
|
||||
}
|
||||
|
||||
|
||||
public void copyToClipboard(String str) {
|
||||
if (android.os.Build.VERSION.SDK_INT < 11) {
|
||||
@SuppressWarnings("deprecation")
|
||||
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
clipboard.setText(str);
|
||||
} else {
|
||||
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
clipboard.setText(str);
|
||||
}
|
||||
|
||||
Toast toast = Toast.makeText(this, R.string.text_copied_to_clipboard, Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2245,21 +2245,6 @@ public class MainActivity extends CommonActivity implements OnlineServices {
|
||||
initMainMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyToClipboard(String str) {
|
||||
if (android.os.Build.VERSION.SDK_INT < 11) {
|
||||
@SuppressWarnings("deprecation")
|
||||
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
clipboard.setText(str);
|
||||
} else {
|
||||
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
clipboard.setText(str);
|
||||
}
|
||||
|
||||
Toast toast = Toast.makeText(MainActivity.this, R.string.text_copied_to_clipboard, Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restart() {
|
||||
Intent refresh = new Intent(MainActivity.this, MainActivity.class);
|
||||
|
@ -1041,19 +1041,8 @@ public class OfflineActivity extends CommonActivity implements
|
||||
}
|
||||
|
||||
if (article != null) {
|
||||
if (android.os.Build.VERSION.SDK_INT < 11) {
|
||||
@SuppressWarnings("deprecation")
|
||||
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
clipboard.setText(article.getString(article.getColumnIndex("link")));
|
||||
} else {
|
||||
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
clipboard.setText(article.getString(article.getColumnIndex("link")));
|
||||
}
|
||||
|
||||
copyToClipboard(article.getString(article.getColumnIndex("link")));
|
||||
article.close();
|
||||
|
||||
Toast toast = Toast.makeText(OfflineActivity.this, R.string.text_copied_to_clipboard, Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user