diff --git a/Android/.gitignore b/Android/.gitignore new file mode 100644 index 0000000..39fb081 --- /dev/null +++ b/Android/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/Android/.idea/compiler.xml b/Android/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/Android/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Android/.idea/copyright/profiles_settings.xml b/Android/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/Android/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Android/.idea/encodings.xml b/Android/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/Android/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Android/.idea/gradle.xml b/Android/.idea/gradle.xml new file mode 100644 index 0000000..7ac24c7 --- /dev/null +++ b/Android/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/Android/.idea/misc.xml b/Android/.idea/misc.xml new file mode 100644 index 0000000..3be1ace --- /dev/null +++ b/Android/.idea/misc.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1.8 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Android/.idea/modules.xml b/Android/.idea/modules.xml new file mode 100644 index 0000000..aaad7e9 --- /dev/null +++ b/Android/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Android/.idea/runConfigurations.xml b/Android/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/Android/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/Android/.idea/vcs.xml b/Android/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/Android/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Android/README.md b/Android/README.md new file mode 100644 index 0000000..0d2b212 --- /dev/null +++ b/Android/README.md @@ -0,0 +1,25 @@ +## Android版本的项目框架 + +### 说明 +* 运行模式 + +> * ListView展示所有项目,点击选择进入对应的项目界面 + +> * 只需按照下面的步骤操作,即可自动完成耦合 + + +![](http://images2015.cnblogs.com/blog/951171/201609/951171-20160924003428121-1127574073.png) + +* 增加项目的方法 +* step 1:去values -> string -> Project,在Project中添加名称 +* step 2:新建一个独立的package,在该package里新建Activity用来展示功能,并设置隐式启动的action,同时在actionDocument类中添加对应的信息 +* step 3:在Activity中实现自己的项目功能 + +### 实现了的功能展示 +* 逆转字符串 + +![](http://images2015.cnblogs.com/blog/951171/201609/951171-20160924003440481-342957189.png) + +* 加密短信 + +![](http://images2015.cnblogs.com/blog/951171/201609/951171-20160924003435496-1603527109.png) diff --git a/Android/app/.gitignore b/Android/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/Android/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/Android/app/build.gradle b/Android/app/build.gradle new file mode 100644 index 0000000..1e0090d --- /dev/null +++ b/Android/app/build.gradle @@ -0,0 +1,25 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 24 + buildToolsVersion "24.0.0" + defaultConfig { + applicationId "andrew.com.android_ver" + minSdkVersion 17 + targetSdkVersion 24 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:24.2.1' + testCompile 'junit:junit:4.12' +} diff --git a/Android/app/proguard-rules.pro b/Android/app/proguard-rules.pro new file mode 100644 index 0000000..dd9245d --- /dev/null +++ b/Android/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:\Users\Andrew\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/Android/app/src/androidTest/java/andrew/com/android_ver/ExampleInstrumentedTest.java b/Android/app/src/androidTest/java/andrew/com/android_ver/ExampleInstrumentedTest.java new file mode 100644 index 0000000..a3a1e56 --- /dev/null +++ b/Android/app/src/androidTest/java/andrew/com/android_ver/ExampleInstrumentedTest.java @@ -0,0 +1,27 @@ +package andrew.com.android_ver; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.*; + +/** + * Instrumentation test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("andrew.com.android_ver", appContext.getPackageName()); + } +} diff --git a/Android/app/src/main/AndroidManifest.xml b/Android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..b6b8dd3 --- /dev/null +++ b/Android/app/src/main/AndroidManifest.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Android/app/src/main/java/andrew/com/android_ver/ListViewAdapter.java b/Android/app/src/main/java/andrew/com/android_ver/ListViewAdapter.java new file mode 100644 index 0000000..1a4f728 --- /dev/null +++ b/Android/app/src/main/java/andrew/com/android_ver/ListViewAdapter.java @@ -0,0 +1,87 @@ +package andrew.com.android_ver; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.Button; +import android.widget.ListAdapter; + +import static andrew.com.android_ver.actionDocument.project_activity; + +/** + * Created by Andrew on 2016/9/22. + */ + +public class ListViewAdapter extends BaseAdapter implements ListAdapter { + + private Context context; + private Activity activity; + private int attr; + private String[] data; + + public ListViewAdapter(Activity context, int attr, String[] data) { + this.context = context; + this.activity = context; + this.attr = attr; + this.data = data; + } + + @Override + public int getCount() { + return data.length; + } + + @Override + public Object getItem(int i) { + return null; + } + + @Override + public long getItemId(int i) { + return i; + } + + @Override + public View getView(int i, View view, ViewGroup viewGroup) { + final Button button; + if (view == null) { + LayoutInflater inflater = LayoutInflater.from(context); + view = inflater.inflate(attr, null); + button = (Button) view.findViewById(R.id.btn_Show); + + view.setTag(new ViewHolder(button)); + } else { + ViewHolder holder = (ViewHolder) view.getTag(); + button = holder.getButton(); + } + + button.setText(data[i]); + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + CharSequence activity = button.getText(); + Intent i = new Intent(); + String action = project_activity.get(activity); + i.setAction(action); + context.startActivity(i); + } + }); + return view; + } + + private class ViewHolder { + Button button; + + public ViewHolder(Button button) { + this.button = button; + } + + public Button getButton() { + return button; + } + } +} diff --git a/Android/app/src/main/java/andrew/com/android_ver/ProjectListView.java b/Android/app/src/main/java/andrew/com/android_ver/ProjectListView.java new file mode 100644 index 0000000..6e3cc98 --- /dev/null +++ b/Android/app/src/main/java/andrew/com/android_ver/ProjectListView.java @@ -0,0 +1,35 @@ +package andrew.com.android_ver; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.widget.ListView; + +import static andrew.com.android_ver.R.layout.item; + +public class ProjectListView extends AppCompatActivity { + + private ListView project_Document_ListView; + private String[] project_Document; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_project_list_view); + + //增加项目内容的方法: + //step 1:去values -> string -> Project,在Project中添加内容 + //step 2:新建一个独立的package,建立显示的Activity,设置启动的action,并在actionDocument类中添加对应的信息 + //step 3:实现自己的项目内容 + + + //在string文件中获取存在的项目内容 + project_Document = this.getResources().getStringArray(R.array.Project); + + //用来展示项目的ListView + project_Document_ListView = (ListView) findViewById(R.id.project_Document_ListView); + project_Document_ListView.setAdapter(new ListViewAdapter(this,item,project_Document)); + + } + + +} diff --git a/Android/app/src/main/java/andrew/com/android_ver/SecretMessage/SecretMessageView.java b/Android/app/src/main/java/andrew/com/android_ver/SecretMessage/SecretMessageView.java new file mode 100644 index 0000000..d31ea4c --- /dev/null +++ b/Android/app/src/main/java/andrew/com/android_ver/SecretMessage/SecretMessageView.java @@ -0,0 +1,81 @@ +package andrew.com.android_ver.SecretMessage; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import andrew.com.android_ver.R; + +public class SecretMessageView extends AppCompatActivity implements View.OnClickListener { + + private EditText et_Input; + private TextView tv_compile; + private TextView tv_parsing; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_secret_message_view); + + et_Input = (EditText) findViewById(R.id.et_Input); + tv_compile = (TextView) findViewById(R.id.tv_compile); + tv_parsing = (TextView) findViewById(R.id.tv_parsing); + + findViewById(R.id.btn_Compile).setOnClickListener(this); + findViewById(R.id.btn_parsing).setOnClickListener(this); + + } + + @Override + public void onClick(View view) { + switch (view.getId()) { + case R.id.btn_Compile: + String content = null; + try{ + content = et_Input.getText().toString(); + + //更换这里调用的加密方法即可改变加密的方式 + //假如你在某一个瞬间,看着这里,突然就杀气喷涌,抑制不住了, + String res = compiledByidiot(content); + + if (res != null) { + tv_compile.setText("加密后的内容为:" + res.toString()); + } else { + Toast.makeText(getApplicationContext(), "加密出错", Toast.LENGTH_SHORT).show(); + } + } catch (NullPointerException e){ + Toast.makeText(getApplicationContext(), "请先输入要加密的内容", Toast.LENGTH_SHORT).show(); + } + break; + case R.id.btn_parsing: + String parsingRes = et_Input.getText().toString(); + tv_parsing.setText("对加密内容解密为:" + parsingRes); + break; + } + } + + private String compiledByidiot(String content) { + char[] document = {'!','@','#','$','%','^','&','*','-','+',}; + int count = content.length(); + StringBuilder res = new StringBuilder(); + byte[] ch = null; + int value = -1; + while (count > 0) { + if (ch == null && value == -1){ + ch = content.substring(count-1,count).getBytes(); + value = Math.abs(ch[0]%10); + res.append(document[value]); + count--; + } + ch = null; + value = -1; + } + return res.toString(); + } + + +} diff --git a/Android/app/src/main/java/andrew/com/android_ver/TurnDownString/MainActivity.java b/Android/app/src/main/java/andrew/com/android_ver/TurnDownString/MainActivity.java new file mode 100644 index 0000000..c62a5e6 --- /dev/null +++ b/Android/app/src/main/java/andrew/com/android_ver/TurnDownString/MainActivity.java @@ -0,0 +1,47 @@ +package andrew.com.android_ver.TurnDownString; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.widget.EditText; +import android.widget.TextView; + +import andrew.com.android_ver.R; + +public class MainActivity extends AppCompatActivity { + + private EditText et_input; + private TextView tv_Result; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + et_input = (EditText) findViewById(R.id.et_input); + tv_Result = (TextView) findViewById(R.id.tv_Result); + + findViewById(R.id.btn_Turn).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + String before = et_input.getText().toString(); + String after = TurnDown(before); + + tv_Result.setText("颠倒顺序前为:"+before+"\n颠倒顺序后,结果为:"+after); + } + }); + + } + + private String TurnDown(String before) { + StringBuilder res = new StringBuilder(); + int count = before.length(); + while (count > 0){ + String change = before.substring(count-1,count); + res.append(change); + change = null; + count--; + } + return res.toString(); + } +} diff --git a/Android/app/src/main/java/andrew/com/android_ver/actionDocument.java b/Android/app/src/main/java/andrew/com/android_ver/actionDocument.java new file mode 100644 index 0000000..e990d1e --- /dev/null +++ b/Android/app/src/main/java/andrew/com/android_ver/actionDocument.java @@ -0,0 +1,28 @@ +package andrew.com.android_ver; + +import java.util.HashMap; + +/** + * Created by Andrew on 2016/9/23. + */ + +public class actionDocument { + + //用来储存Activity对应的Action + public static HashMap project_activity; + + public actionDocument() { + this.project_activity = new HashMap<>(); + init(); + } + + + private void init() { + //尝试通过string资源来存储信息,但是无法通过中文直接引用,只好使用hashmap + //这里是存储的对应项目的Activity的隐式启动action + project_activity.put("逆转字符串","Action_TurnDownString"); + project_activity.put("密码短信","Action_SecretMessage"); + } + + +} diff --git a/Android/app/src/main/java/andrew/com/android_ver/application.java b/Android/app/src/main/java/andrew/com/android_ver/application.java new file mode 100644 index 0000000..97803e4 --- /dev/null +++ b/Android/app/src/main/java/andrew/com/android_ver/application.java @@ -0,0 +1,23 @@ +package andrew.com.android_ver; + +import android.app.Application; + +/** + * Created by Andrew on 2016/9/23. + */ + +public class application extends Application { + + private actionDocument actionDocument; + + @Override + public void onCreate() { + super.onCreate(); + + //加载项目的ACTION信息 + actionDocument = new actionDocument(); + } + + + +} diff --git a/Android/app/src/main/res/layout/activity_main.xml b/Android/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..47fda36 --- /dev/null +++ b/Android/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,33 @@ + + + + + + +