Skip to content

Commit aa3cc42

Browse files
author
Chris Bellew
committed
Rearranged main screen again.
1 parent bc1c504 commit aa3cc42

File tree

12 files changed

+222
-123
lines changed

12 files changed

+222
-123
lines changed

res/layout-land/main_with_server.xml

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:background="@color/black"
6+
android:orientation="vertical" >
7+
8+
<!--
9+
<TextView
10+
android:id="@+id/mainSettingItem1"
11+
android:layout_width="50%"
12+
android:layout_height="25dp"
13+
android:text="item1"
14+
android:textColor="@color/white"
15+
android:textSize="20sp" />
16+
17+
<TextView
18+
android:id="@+id/mainSettingItem2"
19+
android:layout_width="50%"
20+
android:layout_height="25dp"
21+
android:layout_toRightOf="@+id/mainSettingItem1"
22+
android:textColor="@color/white"
23+
android:text="item2"
24+
android:textSize="20sp" />
25+
-->
26+
27+
<TextView
28+
android:id="@+id/mainSettingItem1"
29+
android:layout_width="wrap_content"
30+
android:layout_height="wrap_content"
31+
android:layout_marginBottom="20dp"
32+
android:layout_alignParentLeft="true"
33+
android:layout_alignParentTop="true"
34+
android:textSize="20sp"
35+
android:text="item1" />
36+
37+
<TextView
38+
android:id="@+id/mainSettingItem2"
39+
android:layout_width="wrap_content"
40+
android:layout_height="wrap_content"
41+
android:layout_marginBottom="20dp"
42+
android:layout_alignParentRight="true"
43+
android:layout_alignParentTop="true"
44+
android:textSize="20sp"
45+
android:text="item2" />
46+
47+
</RelativeLayout>

res/layout/main_with_server.xml

Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,25 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="match_parent"
44
android:layout_height="match_parent"
55
android:background="@color/black"
6-
android:textColor="@color/white" >
7-
8-
<TextView
9-
android:id="@+id/textView7"
10-
android:layout_width="wrap_content"
11-
android:layout_height="wrap_content"
12-
android:layout_alignLeft="@+id/textView8"
13-
android:layout_alignParentTop="true"
14-
android:layout_marginTop="32dp"
15-
android:layout_marginBottom="15dp"
16-
android:layout_toLeftOf="@+id/serverSelectButton"
17-
android:text="@string/stream_video_from_server"
18-
android:textColor="@color/white"
19-
android:textSize="24sp" />
20-
21-
<Button
22-
android:id="@+id/serverSelectButton"
23-
android:layout_width="wrap_content"
24-
android:layout_height="wrap_content"
25-
android:layout_alignBottom="@+id/textView7"
26-
android:layout_alignParentRight="true"
27-
android:layout_marginRight="21dp"
28-
android:text="@string/search" />
6+
android:textColor="@color/white"
7+
android:orientation="vertical" >
298

30-
<TextView
31-
android:id="@+id/textView8"
32-
android:layout_width="wrap_content"
33-
android:layout_height="wrap_content"
34-
android:layout_alignBaseline="@+id/clientSelectButton"
35-
android:layout_alignBottom="@+id/clientSelectButton"
36-
android:layout_alignLeft="@+id/resumeCheckbox"
37-
android:layout_marginBottom="15dp"
38-
android:text="@string/to_the_client"
39-
android:textColor="@color/white"
40-
android:textSize="24sp" />
41-
42-
<Button
43-
android:id="@+id/clientSelectButton"
44-
android:layout_width="wrap_content"
45-
android:layout_height="wrap_content"
46-
android:layout_alignLeft="@+id/serverSelectButton"
47-
android:layout_below="@+id/textView7"
48-
android:layout_marginTop="14dp"
49-
android:layout_marginBottom="15dp"
50-
android:text="@string/search" />
9+
<ListView
10+
android:id="@+id/listView1"
11+
android:layout_height="wrap_content"
12+
android:layout_width="match_parent">
13+
</ListView>
5114

52-
<CheckBox
15+
<CheckBox
5316
android:id="@+id/resumeCheckbox"
5417
android:layout_width="wrap_content"
5518
android:layout_height="wrap_content"
56-
android:layout_below="@+id/textView8"
19+
android:onClick="resumeChecked"
5720
android:layout_marginBottom="30dp"
5821
android:text="@string/resume_if_in_progress"
5922
android:textColor="@color/white" />
60-
6123
<LinearLayout
6224
android:id="@+id/linearLayout1"
6325
android:layout_width="wrap_content"
@@ -114,4 +76,4 @@
11476
android:text="@string/help_text6"
11577
android:textColor="@color/white" />
11678
</LinearLayout>
117-
</RelativeLayout>
79+
</LinearLayout>

res/menu/main.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.

res/menu/menu_main.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
3+
<item android:id="@+id/menu_about"
4+
android:title="@string/menu_about">
5+
</item>
6+
<item android:id="@+id/menu_donate"
7+
android:title="@string/menu_donate">
8+
</item>
9+
10+
11+
</menu>

res/values-v11/styles.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Base application theme for API 11+. This theme completely replaces
55
AppBaseTheme from res/values/styles.xml on API 11+ devices.
66
-->
7-
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
7+
<style name="AppBaseTheme" parent="android:Theme.DeviceDefault">
88
<!-- API 11 theme customizations can go here. -->
99
</style>
1010

res/values-v14/styles.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
AppBaseTheme from BOTH res/values/styles.xml and
66
res/values-v11/styles.xml on API 14+ devices.
77
-->
8-
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
8+
<style name="AppBaseTheme" parent="android:Theme.DeviceDefault">
99
<!-- API 14 theme customizations can go here. -->
1010
</style>
1111

res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@
1515
<string name="help_text5">Watch episode Once More With Feeling of Buffy The Vampire Slayer</string>
1616
<string name="help_text6">Watch the latest episode of The Walking Dead</string>
1717
<string name="search">Search</string>
18+
<string name="menu_about">About</string>
19+
<string name="about_text">Voice Control for Plex Home Theater\n© 2013 Chris Bellew\nLicensed under GPLv3\n\nPlex Home Theater is copyright Plex, Inc.</string>
20+
<string name="menu_donate">Donate</string>
1821

1922
</resources>

res/values/styles.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Base application theme, dependent on API level. This theme is replaced
55
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
66
-->
7-
<style name="AppBaseTheme" parent="android:Theme.Light">
7+
<style name="AppBaseTheme" parent="android:Theme.DeviceDefault">
88
<!--
99
Theme customizations available in newer API levels can go in
1010
res/values-vXX/styles.xml, while customizations related to

src/com/atomjack/googlesearchplexcontrol/MainActivity.java

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,20 @@
1717
import android.content.IntentFilter;
1818
import android.content.SharedPreferences;
1919
import android.content.res.Resources.NotFoundException;
20+
import android.net.Uri;
2021
import android.os.Bundle;
2122
import android.support.v4.content.LocalBroadcastManager;
2223
import android.util.Log;
2324
import android.view.Menu;
25+
import android.view.MenuItem;
2426
import android.view.View;
2527
import android.view.View.OnClickListener;
2628
import android.widget.AdapterView;
2729
import android.widget.Button;
2830
import android.widget.CheckBox;
2931
import android.widget.ListView;
3032

33+
import com.atomjack.googlesearchplexcontrol.model.MainSetting;
3134
import com.atomjack.googlesearchplexcontrol.model.MediaContainer;
3235
import com.atomjack.googlesearchplexcontrol.model.PlexClient;
3336
import com.atomjack.googlesearchplexcontrol.model.PlexServer;
@@ -76,7 +79,6 @@ protected void onCreate(Bundle savedInstanceState) {
7679
serverSelectButton.setOnClickListener(new OnClickListener() {
7780
@Override
7881
public void onClick(View view) {
79-
// TODO Auto-generated method stub
8082
searchForPlexServers();
8183
}
8284
});
@@ -96,15 +98,68 @@ public void resumeChecked(View v) {
9698
mPrefsEditor.commit();
9799
}
98100

101+
@Override
102+
public boolean onOptionsItemSelected(MenuItem item) {
103+
switch (item.getItemId()) {
104+
case R.id.menu_about:
105+
return showAbout();
106+
case R.id.menu_donate:
107+
Intent intent = new Intent(Intent.ACTION_VIEW,
108+
Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=UJF9QY9QELERG"));
109+
startActivity(intent);
110+
return true;
111+
}
112+
113+
return super.onOptionsItemSelected(item);
114+
}
115+
116+
private boolean showAbout() {
117+
AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.this)
118+
.setTitle(R.string.app_name)
119+
.setMessage(R.string.about_text);
120+
121+
alertDialog.show();
122+
123+
return true;
124+
}
125+
99126
private void initMainWithServer() {
100127
setContentView(R.layout.main_with_server);
101128

129+
MainSetting setting_data[] = new MainSetting[] {
130+
new MainSetting("Stream from the server", this.server.getName()),
131+
new MainSetting("To the client", this.client.getName())
132+
};
133+
134+
MainListAdapter adapter = new MainListAdapter(this, R.layout.main_setting_item_row, setting_data);
135+
136+
ListView listView1 = (ListView)findViewById(R.id.listView1);
137+
138+
listView1.setAdapter(adapter);
139+
listView1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
140+
141+
@Override
142+
public void onItemClick(AdapterView<?> adapter, View view, int position,
143+
long arg3) {
144+
Log.v(TAG, "Clicked!");
145+
if(position == 0) {
146+
searchForPlexServers();
147+
} else if(position == 1) {
148+
getClients();
149+
}
150+
}
151+
152+
});
153+
154+
CheckBox resumeCheckbox = (CheckBox)findViewById(R.id.resumeCheckbox);
155+
Log.v(TAG, "checkbox: " + resumeCheckbox);
156+
resumeCheckbox.setChecked(mPrefs.getBoolean("resume", false));
157+
/*
102158
serverSelectButton = (Button)findViewById(R.id.serverSelectButton);
103159
serverSelectButton.setText(server.getName());
104160
serverSelectButton.setOnClickListener(new OnClickListener() {
105161
@Override
106162
public void onClick(View view) {
107-
// TODO Auto-generated method stub
108163
searchForPlexServers();
109164
}
110165
// foo
@@ -115,15 +170,13 @@ public void onClick(View view) {
115170
clientSelectButton.setOnClickListener(new OnClickListener() {
116171
@Override
117172
public void onClick(View view) {
118-
// TODO Auto-generated method stub
119173
getClients();
120174
}
121175
122176
});
123177
124-
CheckBox resumeCheckbox = (CheckBox)findViewById(R.id.resumeCheckbox);
125-
Log.v(TAG, "checkbox: " + resumeCheckbox);
126-
resumeCheckbox.setChecked(mPrefs.getBoolean("resume", false));
178+
179+
*/
127180
}
128181

129182
private void searchForPlexServers() {
@@ -351,7 +404,7 @@ public void setCurrentActivity(MainActivity mCurrentActivity){
351404
@Override
352405
public boolean onCreateOptionsMenu(Menu menu) {
353406
// Inflate the menu; this adds items to the action bar if it is present.
354-
getMenuInflater().inflate(R.menu.main, menu);
407+
getMenuInflater().inflate(R.menu.menu_main, menu);
355408
return true;
356409
}
357410

0 commit comments

Comments
 (0)