|
|
@@ -29,6 +29,7 @@ import android.support.v7.widget.RecyclerView; |
|
|
|
import android.support.v7.widget.Toolbar; |
|
|
|
import android.view.View; |
|
|
|
import android.widget.ImageButton; |
|
|
|
import android.widget.TextView; |
|
|
|
import android.widget.Toast; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
@@ -64,8 +65,17 @@ public class MultiLinkActivity extends AppCompatActivity { |
|
|
|
|
|
|
|
final Long[] ids = Arrays.copyOf(extra,extra.length,Long[].class); |
|
|
|
|
|
|
|
final MultiLinkAdapter.SelectionChangeListener selectionListener = new MultiLinkAdapter.SelectionChangeListener() { |
|
|
|
@Override |
|
|
|
public void onSelectionChanged() { |
|
|
|
String generatedSharedLink = generateShardedLink(); |
|
|
|
TextView tv = (TextView) findViewById(R.id.link); |
|
|
|
tv.setText(generatedSharedLink); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
//setup Adapter |
|
|
|
adapter = new MultiLinkAdapter(ids.length); |
|
|
|
adapter = new MultiLinkAdapter(ids.length,selectionListener); |
|
|
|
RecyclerView listView = (RecyclerView) findViewById(R.id.link_list); |
|
|
|
listView.setAdapter(adapter); |
|
|
|
|
|
|
@@ -120,6 +130,7 @@ public class MultiLinkActivity extends AppCompatActivity { |
|
|
|
shareButton.setEnabled(true); |
|
|
|
copyClipboardButton.setEnabled(true); |
|
|
|
deleteImageButton.setEnabled(true); |
|
|
|
selectionListener.onSelectionChanged(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
@@ -129,17 +140,14 @@ public class MultiLinkActivity extends AppCompatActivity { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//manage the sharing button |
|
|
|
shareButton.setOnClickListener(new View.OnClickListener() { |
|
|
|
@Override |
|
|
|
public void onClick(View v) { |
|
|
|
Intent sendIntent = new Intent(); |
|
|
|
sendIntent.setAction(Intent.ACTION_SEND_MULTIPLE); |
|
|
|
List<Integer> selected = adapter.getSelecteds(); |
|
|
|
String output = baseUrl; |
|
|
|
for(Integer index : selected) { |
|
|
|
output += sharedHashs.get(index)+","; |
|
|
|
} |
|
|
|
String output = generateShardedLink(); |
|
|
|
sendIntent.putExtra(Intent.EXTRA_TEXT, output); |
|
|
|
sendIntent.setType("text/plain"); |
|
|
|
startActivity(sendIntent); |
|
|
@@ -151,11 +159,7 @@ public class MultiLinkActivity extends AppCompatActivity { |
|
|
|
@Override |
|
|
|
public void onClick(View v) { |
|
|
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); |
|
|
|
List<Integer> selected = adapter.getSelecteds(); |
|
|
|
String output = baseUrl; |
|
|
|
for(Integer index : selected) { |
|
|
|
output += sharedHashs.get(index)+","; |
|
|
|
} |
|
|
|
String output = generateShardedLink(); |
|
|
|
android.content.ClipData clip = android.content.ClipData.newPlainText("Copied URL", output); |
|
|
|
clipboard.setPrimaryClip(clip); |
|
|
|
Toast.makeText(MultiLinkActivity.this,getString(R.string.copy_to_clipboard),Toast.LENGTH_SHORT).show(); |
|
|
@@ -221,4 +225,13 @@ public class MultiLinkActivity extends AppCompatActivity { |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private String generateShardedLink() { |
|
|
|
List<Integer> selected = adapter.getSelecteds(); |
|
|
|
String output = baseUrl; |
|
|
|
for(Integer index : selected) { |
|
|
|
output += sharedHashs.get(index)+","; |
|
|
|
} |
|
|
|
return output; |
|
|
|
} |
|
|
|
} |