forked from hzuapps/android-labs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
a94ae99
commit 76dfc11
Showing
16 changed files
with
302 additions
and
53 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
app/src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901122/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.silenceburn" android:versionCode="1" android:versionName="1.0"> | ||
<application android:icon="@drawable/sketchy_paper_008" | ||
android:label="@string/app_name"> | ||
<receiver android:name=".MyNote"> | ||
<intent-filter> | ||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> | ||
</intent-filter> | ||
<meta-data android:name="android.appwidget.provider" | ||
android:resource="@xml/my_note_widget" /> | ||
</receiver> | ||
|
||
<activity android:name=".MyNoteConf"> | ||
<intent-filter> | ||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".MyNoteEdit"/> | ||
</application> | ||
</manifest> |
52 changes: 0 additions & 52 deletions
52
...in/java/edu/hzuapps/androidworks/homeworks/com1314080901122/Com1314080901122Activity.java
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
app/src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901122/MyNote.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package edu.hzuapps.androidworks.homeworks.com1314080901122; | ||
|
||
import android.appwidget.AppWidgetManager; | ||
import android.appwidget.AppWidgetProvider; | ||
import android.content.Context; | ||
import android.util.Log; | ||
|
||
public class MyNote extends AppWidgetProvider { | ||
/** Called when the activity is first created. */ | ||
|
||
final String mPerfName = "com.silenceburn.MyColorNoteConf"; | ||
|
||
@Override | ||
public void onUpdate(Context context, AppWidgetManager appWidgetManager, | ||
int[] appWidgetIds) { | ||
// TODO Auto-generated method stub | ||
final int N = appWidgetIds.length; | ||
for (int i = 0; i < N; i++) { | ||
int appWidgetId = appWidgetIds[i]; | ||
Log.i("myLog", "this is [" + appWidgetId + "] onUpdate!"); | ||
|
||
} | ||
} | ||
|
||
@Override | ||
public void onDeleted(Context context, int[] appWidgetIds) { | ||
// TODO Auto-generated method stub | ||
final int N = appWidgetIds.length; | ||
for (int i = 0; i < N; i++) { | ||
int appWidgetId = appWidgetIds[i]; | ||
Log.i("myLog", "this is [" + appWidgetId + "] onDelete!"); | ||
} | ||
} | ||
|
||
} |
108 changes: 108 additions & 0 deletions
108
app/src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901122/MyNoteConf.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package edu.hzuapps.androidworks.homeworks.com1314080901122; | ||
|
||
import android.app.Activity; | ||
import android.app.PendingIntent; | ||
import android.appwidget.AppWidgetManager; | ||
import android.content.Intent; | ||
import android.content.SharedPreferences; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.view.View.OnClickListener; | ||
import android.widget.ImageButton; | ||
import android.widget.RemoteViews; | ||
import android.widget.TextView; | ||
|
||
public class MyNoteConf extends Activity { | ||
|
||
int mAppWidgetId; | ||
ImageButton mImBtn1, mImBtn2, mImBtn3, mImBtn4; | ||
|
||
final String mPerfName = "com.silenceburn.MyNoteConf"; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
// TODO Auto-generated method stub | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_com1314080901122_my_note_conf); | ||
Log.i("myLog", " on WidgetConf ... "); | ||
|
||
setResult(RESULT_CANCELED); | ||
// Find the widget id from the intent. | ||
Intent intent = getIntent(); | ||
Bundle extras = intent.getExtras(); | ||
if (extras != null) { | ||
mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, | ||
AppWidgetManager.INVALID_APPWIDGET_ID); | ||
} | ||
|
||
// If they gave us an intent without the widget id, just bail. | ||
if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { | ||
finish(); | ||
} | ||
|
||
mImBtn1 = (ImageButton) findViewById(R.id.ImageButton01); | ||
mImBtn2 = (ImageButton) findViewById(R.id.ImageButton02); | ||
mImBtn3 = (ImageButton) findViewById(R.id.ImageButton03); | ||
mImBtn4 = (ImageButton) findViewById(R.id.ImageButton04); | ||
|
||
mImBtn1.setOnClickListener(mBtnClick); | ||
mImBtn2.setOnClickListener(mBtnClick); | ||
mImBtn3.setOnClickListener(mBtnClick); | ||
mImBtn4.setOnClickListener(mBtnClick); | ||
} | ||
|
||
OnClickListener mBtnClick = new OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
|
||
TextView mTextView = (TextView) MyNoteConf.this | ||
.findViewById(R.id.EditText02); | ||
SharedPreferences.Editor prefs = MyNoteConf.this | ||
.getSharedPreferences(mPerfName, 0).edit(); | ||
prefs.putString("DAT" + mAppWidgetId, mTextView.getText() | ||
.toString()); | ||
prefs.commit(); | ||
|
||
int srcId = R.drawable.com1314080901122_sketchy_paper_008; | ||
switch (v.getId()) { | ||
case R.id.ImageButton01: | ||
srcId = R.drawable.com1314080901122_sketchy_paper_003; | ||
break; | ||
case R.id.ImageButton02: | ||
srcId = R.drawable.com1314080901122_sketchy_paper_004; | ||
break; | ||
case R.id.ImageButton03: | ||
srcId = R.drawable.com1314080901122_sketchy_paper_007; | ||
break; | ||
case R.id.ImageButton04: | ||
srcId = R.drawable.com1314080901122_sketchy_paper_011; | ||
break; | ||
} | ||
Log.i("myLog", "mAppWidgetId is: " + mAppWidgetId); | ||
|
||
RemoteViews views = new RemoteViews(MyNoteConf.this | ||
.getPackageName(), R.layout.activity_com1314080901122_my_note_widget); | ||
views.setImageViewResource(R.id.my_widget_img, srcId); | ||
|
||
Intent intent = new Intent(MyNoteConf.this, MyNoteEdit.class); | ||
intent.setAction(mPerfName + mAppWidgetId); | ||
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,mAppWidgetId); | ||
PendingIntent pendingIntent = PendingIntent.getActivity(MyNoteConf.this, 0, | ||
intent, 0); | ||
views.setOnClickPendingIntent(R.id.my_widget_img, pendingIntent); | ||
|
||
AppWidgetManager appWidgetManager = AppWidgetManager | ||
.getInstance(MyNoteConf.this); | ||
appWidgetManager.updateAppWidget(mAppWidgetId, views); | ||
|
||
// return OK | ||
Intent resultValue = new Intent(); | ||
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, | ||
mAppWidgetId); | ||
|
||
setResult(RESULT_OK, resultValue); | ||
finish(); | ||
} | ||
}; | ||
} |
89 changes: 89 additions & 0 deletions
89
app/src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901122/MyNoteEdit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package edu.hzuapps.androidworks.homeworks.com1314080901122; | ||
|
||
import android.app.Activity; | ||
import android.appwidget.AppWidgetManager; | ||
import android.content.Intent; | ||
import android.content.SharedPreferences; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.view.View.OnClickListener; | ||
import android.widget.ImageButton; | ||
import android.widget.RemoteViews; | ||
import android.widget.TextView; | ||
|
||
public class MyNoteEdit extends Activity { | ||
int mAppWidgetId; | ||
TextView mTextView; | ||
ImageButton mImBtn1, mImBtn2, mImBtn3, mImBtn4; | ||
|
||
final String mPerfName = "com.silenceburn.MyNoteConf"; | ||
SharedPreferences mPref; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
// TODO Auto-generated method stub | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_com1314080901122_my_note_conf); | ||
|
||
Intent t = getIntent(); | ||
Log.i("myLog", t.getAction()); | ||
mAppWidgetId = t.getExtras().getInt( | ||
AppWidgetManager.EXTRA_APPWIDGET_ID, -1); | ||
Log.i("myLog", "it's [" + mAppWidgetId + "] editing!"); | ||
|
||
mPref = getSharedPreferences(mPerfName, 0); | ||
String noteContent = mPref.getString("DAT" + mAppWidgetId, ""); | ||
|
||
mTextView = (TextView) findViewById(R.id.EditText02); | ||
mTextView.setText(noteContent); | ||
mImBtn1 = (ImageButton) findViewById(R.id.ImageButton01); | ||
mImBtn2 = (ImageButton) findViewById(R.id.ImageButton02); | ||
mImBtn3 = (ImageButton) findViewById(R.id.ImageButton03); | ||
mImBtn4 = (ImageButton) findViewById(R.id.ImageButton04); | ||
|
||
mImBtn1.setOnClickListener(mBtnClick); | ||
mImBtn2.setOnClickListener(mBtnClick); | ||
mImBtn3.setOnClickListener(mBtnClick); | ||
mImBtn4.setOnClickListener(mBtnClick); | ||
|
||
} | ||
|
||
OnClickListener mBtnClick = new OnClickListener() { | ||
|
||
@Override | ||
public void onClick(View v) { | ||
|
||
SharedPreferences.Editor prefsEdit = mPref.edit(); | ||
prefsEdit.putString("DAT" + mAppWidgetId, mTextView.getText() | ||
.toString()); | ||
prefsEdit.commit(); | ||
|
||
int srcId = R.drawable.com1314080901122_sketchy_paper_008; | ||
switch (v.getId()) { | ||
case R.id.ImageButton01: | ||
srcId = R.drawable.com1314080901122_sketchy_paper_003; | ||
break; | ||
case R.id.ImageButton02: | ||
srcId = R.drawable.com1314080901122_sketchy_paper_004; | ||
break; | ||
case R.id.ImageButton03: | ||
srcId = R.drawable.com1314080901122_sketchy_paper_007; | ||
break; | ||
case R.id.ImageButton04: | ||
srcId = R.drawable.com1314080901122_sketchy_paper_011; | ||
break; | ||
} | ||
|
||
RemoteViews views = new RemoteViews(MyNoteEdit.this | ||
.getPackageName(), R.layout.activity_com1314080901122_my_note_widget); | ||
views.setImageViewResource(R.id.my_widget_img, srcId); | ||
|
||
AppWidgetManager appWidgetManager = AppWidgetManager | ||
.getInstance(MyNoteEdit.this); | ||
appWidgetManager.updateAppWidget(mAppWidgetId, views); | ||
|
||
MyNoteEdit.this.finish(); | ||
} | ||
}; | ||
} |
1 change: 0 additions & 1 deletion
1
app/src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901122/炸弹人.txt
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions
29
app/src/main/res/layout/activity_com1314080901122_my_note_conf.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout android:orientation="vertical" | ||
android:layout_width="fill_parent" android:layout_height="fill_parent" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<TextView android:layout_height="wrap_content" android:text="@string/note_title" | ||
android:layout_width="wrap_content" android:padding="10dp"></TextView> | ||
<LinearLayout android:layout_height="fill_parent" | ||
android:layout_width="fill_parent" android:layout_weight="1"> | ||
<EditText android:id="@+id/EditText02" android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" android:gravity="left" | ||
android:hint="@string/edithint"></EditText> | ||
</LinearLayout> | ||
<LinearLayout android:layout_height="fill_parent" | ||
android:layout_width="fill_parent" android:layout_weight="2" | ||
android:gravity="center"> | ||
<ImageButton android:id="@+id/ImageButton01" | ||
android:layout_width="72dp" android:layout_height="72dp" | ||
android:src="@drawable/com1314080901122_sketchy_paper_003" android:layout_margin="3dp"></ImageButton> | ||
<ImageButton android:id="@+id/ImageButton02" | ||
android:layout_width="72dp" android:layout_height="72dp" | ||
android:src="@drawable/com1314080901122_sketchy_paper_004" android:layout_margin="3dp"></ImageButton> | ||
<ImageButton android:id="@+id/ImageButton03" | ||
android:layout_width="72dp" android:layout_height="72dp" | ||
android:src="@drawable/com1314080901122_sketchy_paper_007" android:layout_margin="3dp"></ImageButton> | ||
<ImageButton android:id="@+id/ImageButton04" | ||
android:layout_width="72dp" android:layout_height="72dp" | ||
android:src="@drawable/com1314080901122_sketchy_paper_011" android:layout_margin="3dp"></ImageButton> | ||
</LinearLayout> | ||
</LinearLayout> |
7 changes: 7 additions & 0 deletions
7
app/src/main/res/layout/activity_com1314080901122_my_note_widget.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ImageView xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/my_widget_img" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:src="@drawable/com1314080901122_sketchy_paper_008" | ||
android:clickable="true"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="hello">Hello World, MyColorNote!</string> | ||
<string name="app_name">我的便签</string> | ||
<string name="widget_string"></string> | ||
<string name="note_title">请输入便签内容:</string> | ||
<string name="edithint">在这里输入内容...</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:minWidth="72dp" android:minHeight="72dp" | ||
android:updatePeriodMillis="86400000" android:initialLayout="@layout/my_note_widget" | ||
android:configure="com.silenceburn.MyNoteConf"> | ||
</appwidget-provider> |