Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#90 #93 #94 #95 #363 已完成全部实验 #738

Merged
merged 4 commits into from
May 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="edu.hzuapps.androidworks.homeworks.com1314080901146"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/myicon" android:label="@string/app_name">
<activity android:name=".Com1314080901146Activity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>


</manifest>
Original file line number Diff line number Diff line change
@@ -1,41 +1,177 @@
package edu.hzuapps.androidworks.homeworks.com1314080901146;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.Button;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.Toast;

import edu.hzuapps.androidworks.R;
import edu.hzuapps.androidworks.homeworks.BackActivity;
import edu.hzuapps.androidworks.homeworks.com1314080901146.R;

public class Com1314080901146Activity extends BackActivity {
public class Com1314080901146Activity extends Activity {

private LinearLayout mylayout;
private Resources myColor;
private int li;
@Override
protected void onCreate(Bundle savedInstanceState) {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_com123456);
HideStatusBase();
setContentView(R.layout.main);


Button closeBtn = (Button) findViewById(R.id.button_close);
closeBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
mylayout=(LinearLayout)findViewById(R.id.mylayout);

SetColor(R.color.white);

li=0;
SetBright(1.0f);

}



@Override
protected void onStart() {
super.onStart();
public boolean onTouchEvent(MotionEvent event){

openOptionsMenu();
return false;
}

@Override
protected void onPause() {
super.onPause();
public boolean onCreateOptionsMenu(Menu menu){
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.menu, menu);

return true;
}


@Override
protected void onStop() {
super.onStop();
public boolean onOptionsItemSelected(MenuItem item){
switch(item.getItemId())
{

case R.id.setcolor:

selectColor();
return true;
case R.id.setbright:
selectBright();

return true;
case R.id.seteffer:

finish();
return true;

}
return false;
}

public void selectColor()
{
final String[] items = {"White", "Red", "Black","Yellow","Pink"};
new AlertDialog.Builder(this)
.setTitle("Select Color")
.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
switch (item) {
case 0:
SetColor(R.color.white);
break;
case 1:
SetColor(R.color.red);
break;
case 2:
SetColor(R.color.black);
break;
case 3:
SetColor(R.color.yellow);
break;
case 4:
SetColor(R.color.fs);
break;
default:
SetColor(R.color.white);
break;
}
}
}).show();
}


public void selectBright()
{
final String[] items = {"100%", "75%", "50%","25%","10%"};
new AlertDialog.Builder(this)
.setTitle("Select Brightness")
.setSingleChoiceItems(items, li, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(getApplicationContext(), items[item],Toast.LENGTH_SHORT).show();
li=item;
switch (item) {
case 0:
SetBright(1.0F);
break;
case 1:
SetBright(0.75F);
break;
case 2:
SetBright(0.5F);
break;
case 3:
SetBright(0.25F);
break;
case 4:
SetBright(0.1F);
break;
default:
SetBright(1.0F);
break;
}
dialog.cancel();
}
}).show();
}




private void HideStatusBase()
{
requestWindowFeature(Window.FEATURE_NO_TITLE);
int flag=WindowManager.LayoutParams.FLAG_FULLSCREEN;
Window myWindow=this.getWindow();
myWindow.setFlags(flag,flag);
}



private void SetColor(int color_1)
{
myColor = getBaseContext().getResources();
Drawable color_M = myColor.getDrawable(color_1);
mylayout.setBackgroundDrawable(color_M);

}


private void SetBright(float light)
{
WindowManager.LayoutParams lp=getWindow().getAttributes();
lp.screenBrightness=light;
getWindow().setAttributes(lp);

}
}
}
Binary file modified app/src/main/res/drawable/myicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions app/src/main/res/layout/Color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="white">#FFFFFF</color>
<color name="yellow">#FFD700</color>
<color name="red">#FF0000</color>
<color name="fs">#FF34B3</color>
<color name="black">#000000</color>
</resources>
14 changes: 14 additions & 0 deletions app/src/main/res/menu/menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/setcolor"
android:title="@string/setcolor"
/>
<item android:id="@+id/setbright"
android:title="@string/setbright"
/>
<item android:id="@+id/seteffer"
android:title="@string/seteffer"
/>

</menu>
8 changes: 8 additions & 0 deletions app/src/main/res/values/Color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="white">#FFFFFF</color>
<color name="yellow">#FFD700</color>
<color name="red">#FF0000</color>
<color name="fs">#FF34B3</color>
<color name="black">#000000</color>
</resources>
9 changes: 9 additions & 0 deletions app/src/main/res/values/com1314080901146strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">你好</string>
<string name="app_name">钟定钧的手电筒</string>
<string name="setcolor">Change Color</string>
<string name="setbright">Change Brightness</string>
<string name="seteffer">Quit</string>

</resources>
7 changes: 6 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<resources>
<resources>
<string name="app_name">Android开发</string>
<string name="action_settings">设置</string>

Expand Down Expand Up @@ -33,4 +33,9 @@
<string name="title_activity_file_select">FileSelectActivity</string>
<string name="title_activity_file_share">FileShareActivity</string>
<string name="title_activity_network">NetworkActivity</string>
<string name="startRecord_net1314080903144">开始录音</string>
<string name="startPlay_net1314080903144">结束录音</string>
<string name="stopRecord_net1314080903144">开始播放</string>
<string name="stopPlay_net1314080903144">结束播放</string>

</resources>