Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: webrtc/examples/androidapp/src/org/appspot/apprtc/ConnectActivity.java

Issue 2003983002: UI for AppRTC Android demo that doesn't require Design Support Library (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/examples/androidapp/res/menu/connect_menu.xml ('k') | webrtc/webrtc_examples.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2014 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 package org.appspot.apprtc; 11 package org.appspot.apprtc;
12 12
13 import android.app.Activity;
14 import android.app.AlertDialog;
13 import android.content.DialogInterface; 15 import android.content.DialogInterface;
14 import android.content.Intent; 16 import android.content.Intent;
15 import android.content.SharedPreferences; 17 import android.content.SharedPreferences;
16 import android.net.Uri; 18 import android.net.Uri;
17 import android.os.Bundle; 19 import android.os.Bundle;
18 import android.preference.PreferenceManager; 20 import android.preference.PreferenceManager;
19 import android.support.design.widget.FloatingActionButton;
20 import android.support.v7.app.AlertDialog;
21 import android.support.v7.app.AppCompatActivity;
22 import android.util.Log; 21 import android.util.Log;
23 import android.view.ContextMenu; 22 import android.view.ContextMenu;
24 import android.view.KeyEvent; 23 import android.view.KeyEvent;
25 import android.view.LayoutInflater;
26 import android.view.Menu; 24 import android.view.Menu;
27 import android.view.MenuItem; 25 import android.view.MenuItem;
28 import android.view.View; 26 import android.view.View;
29 import android.view.View.OnClickListener; 27 import android.view.View.OnClickListener;
30 import android.view.inputmethod.EditorInfo; 28 import android.view.inputmethod.EditorInfo;
31 import android.webkit.URLUtil; 29 import android.webkit.URLUtil;
32 import android.widget.AdapterView; 30 import android.widget.AdapterView;
33 import android.widget.ArrayAdapter; 31 import android.widget.ArrayAdapter;
34 import android.widget.EditText; 32 import android.widget.EditText;
35 import android.widget.ImageButton; 33 import android.widget.ImageButton;
36 import android.widget.ListView; 34 import android.widget.ListView;
37 import android.widget.TextView; 35 import android.widget.TextView;
38 36
39 import org.json.JSONArray; 37 import org.json.JSONArray;
40 import org.json.JSONException; 38 import org.json.JSONException;
41 39
42 import java.util.ArrayList; 40 import java.util.ArrayList;
43 import java.util.Random; 41 import java.util.Random;
44 42
45 /** 43 /**
46 * Handles the initial setup where the user selects which room to join. 44 * Handles the initial setup where the user selects which room to join.
47 */ 45 */
48 public class ConnectActivity extends AppCompatActivity { 46 public class ConnectActivity extends Activity {
49 private static final String TAG = "ConnectActivity"; 47 private static final String TAG = "ConnectActivity";
50 private static final int CONNECTION_REQUEST = 1; 48 private static final int CONNECTION_REQUEST = 1;
51 private static final int REMOVE_FAVORITE_INDEX = 0; 49 private static final int REMOVE_FAVORITE_INDEX = 0;
52 private static boolean commandLineRun = false; 50 private static boolean commandLineRun = false;
53 51
54 private ImageButton connectButton; 52 private ImageButton connectButton;
55 private FloatingActionButton addFavoriteButton; 53 private ImageButton addFavoriteButton;
56 private EditText roomEditText; 54 private EditText roomEditText;
57 private ListView roomListView; 55 private ListView roomListView;
58 private SharedPreferences sharedPref; 56 private SharedPreferences sharedPref;
59 private String keyprefVideoCallEnabled; 57 private String keyprefVideoCallEnabled;
60 private String keyprefResolution; 58 private String keyprefResolution;
61 private String keyprefFps; 59 private String keyprefFps;
62 private String keyprefCaptureQualitySlider; 60 private String keyprefCaptureQualitySlider;
63 private String keyprefVideoBitrateType; 61 private String keyprefVideoBitrateType;
64 private String keyprefVideoBitrateValue; 62 private String keyprefVideoBitrateValue;
65 private String keyprefVideoCodec; 63 private String keyprefVideoCodec;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 121 }
124 }); 122 });
125 roomEditText.requestFocus(); 123 roomEditText.requestFocus();
126 124
127 roomListView = (ListView) findViewById(R.id.room_listview); 125 roomListView = (ListView) findViewById(R.id.room_listview);
128 roomListView.setEmptyView(findViewById(android.R.id.empty)); 126 roomListView.setEmptyView(findViewById(android.R.id.empty));
129 roomListView.setOnItemClickListener(roomListClickListener); 127 roomListView.setOnItemClickListener(roomListClickListener);
130 registerForContextMenu(roomListView); 128 registerForContextMenu(roomListView);
131 connectButton = (ImageButton) findViewById(R.id.connect_button); 129 connectButton = (ImageButton) findViewById(R.id.connect_button);
132 connectButton.setOnClickListener(connectListener); 130 connectButton.setOnClickListener(connectListener);
131 addFavoriteButton = (ImageButton) findViewById(R.id.add_favorite_button);
132 addFavoriteButton.setOnClickListener(addFavoriteListener);
133 133
134 // If an implicit VIEW intent is launching the app, go directly to that URL. 134 // If an implicit VIEW intent is launching the app, go directly to that URL.
135 final Intent intent = getIntent(); 135 final Intent intent = getIntent();
136 if ("android.intent.action.VIEW".equals(intent.getAction()) 136 if ("android.intent.action.VIEW".equals(intent.getAction())
137 && !commandLineRun) { 137 && !commandLineRun) {
138 boolean loopback = intent.getBooleanExtra( 138 boolean loopback = intent.getBooleanExtra(
139 CallActivity.EXTRA_LOOPBACK, false); 139 CallActivity.EXTRA_LOOPBACK, false);
140 int runTimeMs = intent.getIntExtra( 140 int runTimeMs = intent.getIntExtra(
141 CallActivity.EXTRA_RUNTIME, 0); 141 CallActivity.EXTRA_RUNTIME, 0);
142 String room = sharedPref.getString(keyprefRoom, ""); 142 String room = sharedPref.getString(keyprefRoom, "");
143 connectToRoom(room, true, loopback, runTimeMs); 143 connectToRoom(room, true, loopback, runTimeMs);
144 return; 144 return;
145 } 145 }
146
147 addFavoriteButton = (FloatingActionButton) findViewById(R.id.add_favorite_bu tton);
148 addFavoriteButton.setOnClickListener(addFavoriteListener);
149 } 146 }
150 147
151 @Override 148 @Override
152 public boolean onCreateOptionsMenu(Menu menu) { 149 public boolean onCreateOptionsMenu(Menu menu) {
153 getMenuInflater().inflate(R.menu.connect_menu, menu); 150 getMenuInflater().inflate(R.menu.connect_menu, menu);
154 return true; 151 return true;
155 } 152 }
156 153
157 @Override 154 @Override
158 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextM enuInfo menuInfo) { 155 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextM enuInfo menuInfo) {
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 @Override 404 @Override
408 public void onItemClick(AdapterView<?> adapterView, View view, int i, long l ) { 405 public void onItemClick(AdapterView<?> adapterView, View view, int i, long l ) {
409 String roomId = ((TextView) view).getText().toString(); 406 String roomId = ((TextView) view).getText().toString();
410 connectToRoom(roomId, false, false, 0); 407 connectToRoom(roomId, false, false, 0);
411 } 408 }
412 }; 409 };
413 410
414 private final OnClickListener addFavoriteListener = new OnClickListener() { 411 private final OnClickListener addFavoriteListener = new OnClickListener() {
415 @Override 412 @Override
416 public void onClick(View view) { 413 public void onClick(View view) {
417 AlertDialog.Builder builder = new AlertDialog.Builder(ConnectActivity.this ); 414 String newRoom = roomEditText.getText().toString();
418 415 if (newRoom.length() > 0 && !roomList.contains(newRoom)) {
419 final View dialogView = LayoutInflater.from(ConnectActivity.this) 416 adapter.add(newRoom);
420 .inflate(R.layout.dialog_add_favorite, null); 417 adapter.notifyDataSetChanged();
421 final EditText favoriteEditText = (EditText) dialogView.findViewById(R.id. favorite_edittext); 418 }
422 favoriteEditText.append(roomEditText.getText());
423
424 builder.setTitle(R.string.add_favorite_title)
425 .setPositiveButton(R.string.add, new DialogInterface.OnClickListener() {
426 @Override
427 public void onClick(DialogInterface dialogInterface, int i) {
428 String newRoom = favoriteEditText.getText().toString();
429 if (newRoom.length() > 0 && !roomList.contains(newRoom)) {
430 adapter.add(newRoom);
431 adapter.notifyDataSetChanged();
432 }
433 }
434 })
435 .setView(dialogView)
436 .setNegativeButton(R.string.cancel, null);
437 builder.show();
438 } 419 }
439 }; 420 };
440 421
441 private final OnClickListener connectListener = new OnClickListener() { 422 private final OnClickListener connectListener = new OnClickListener() {
442 @Override 423 @Override
443 public void onClick(View view) { 424 public void onClick(View view) {
444 connectToRoom(roomEditText.getText().toString(), false, false, 0); 425 connectToRoom(roomEditText.getText().toString(), false, false, 0);
445 } 426 }
446 }; 427 };
447 } 428 }
OLDNEW
« no previous file with comments | « webrtc/examples/androidapp/res/menu/connect_menu.xml ('k') | webrtc/webrtc_examples.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698