Open license page in browser when tapping on license line

This commit is contained in:
Brion Vibber 2013-05-17 13:39:43 -07:00
parent eac7fdb575
commit 5b761ea132
2 changed files with 20 additions and 1 deletions

View file

@ -34,5 +34,5 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/share_license_summary" android:text="@string/share_license_summary"
android:id="@+id/textView" android:layout_gravity="center" android:layout_marginTop="16dp"/> android:id="@+id/licenseLabel" android:layout_gravity="center" android:layout_marginTop="16dp"/>
</LinearLayout> </LinearLayout>

View file

@ -8,10 +8,12 @@ import android.os.Bundle;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView;
import com.actionbarsherlock.app.SherlockFragment; import com.actionbarsherlock.app.SherlockFragment;
import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuInflater;
@ -27,6 +29,7 @@ public class SingleUploadFragment extends SherlockFragment {
private EditText titleEdit; private EditText titleEdit;
private EditText descEdit; private EditText descEdit;
private TextView licenseLabel;
private OnUploadActionInitiated uploadActionInitiatedHandler; private OnUploadActionInitiated uploadActionInitiatedHandler;
@ -55,6 +58,7 @@ public class SingleUploadFragment extends SherlockFragment {
titleEdit = (EditText)rootView.findViewById(R.id.titleEdit); titleEdit = (EditText)rootView.findViewById(R.id.titleEdit);
descEdit = (EditText)rootView.findViewById(R.id.descEdit); descEdit = (EditText)rootView.findViewById(R.id.descEdit);
licenseLabel = (TextView)rootView.findViewById(R.id.licenseLabel);
TextWatcher uploadEnabler = new TextWatcher() { TextWatcher uploadEnabler = new TextWatcher() {
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { }
@ -70,6 +74,21 @@ public class SingleUploadFragment extends SherlockFragment {
titleEdit.addTextChangedListener(uploadEnabler); titleEdit.addTextChangedListener(uploadEnabler);
// Open license page on touch
licenseLabel.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getActionMasked() == MotionEvent.ACTION_DOWN) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse("https://creativecommons.org/licenses/by-sa/3.0/"));
startActivity(intent);
return true;
} else {
return false;
}
}
});
return rootView; return rootView;
} }