-
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.
- Loading branch information
Showing
27 changed files
with
1,062 additions
and
737 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,20 +1,30 @@ | ||
<?xml version="1.0" encoding="utf-8"?><!--Androidアプリを作る際のアプリに関する情報--> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.myapp.textcounter"> | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.myapp.textcounter"> | ||
|
||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:label="@string/app_name" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.TextCounter"> | ||
<activity android:name=".MainActivity" android:exported="true"> | ||
<activity | ||
android:name=".activity.ListActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".activity.MainActivity" | ||
android:exported="true"> | ||
|
||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
|
||
</activity> | ||
<activity android:name=".SubActivity"></activity> | ||
<activity android:name=".SubActivity" /> | ||
</application> | ||
|
||
</manifest> |
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 |
---|---|---|
@@ -1,49 +1,68 @@ | ||
package com.myapp.textcounter; | ||
|
||
import android.os.Build; | ||
import android.text.Editable; | ||
import android.content.ContentValues; | ||
import android.content.Context; | ||
import android.database.Cursor; | ||
import android.database.sqlite.SQLiteDatabase; | ||
import android.util.TypedValue; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.EditText; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
public class Buttons { | ||
|
||
//edittextのテキストの行数を取得するメソッド | ||
public String line(EditText text) {return format(text.getLineCount());} | ||
public class Buttons extends AppCompatActivity { | ||
//edittextの文字列の長さを取得するメソッド | ||
public String Count(Editable text) {return format(text.length ( ));} | ||
//SubActivity用 | ||
public String Count(String text) {return format(text.length ( ));} | ||
public String Count(Object text) {return intFormat(text.toString().length ( ));} | ||
//edittextのテキストの行数を取得するメソッド | ||
public String line(EditText text) {return text.length()==0 ? intFormat(text.getLineCount()-1) : intFormat(text.getLineCount());} | ||
//edittextの改行抜きでテキストの文字数を取得するメソッド | ||
public String BreakCnt(String letters,String lines) {return format((Integer.parseInt(letters) - Integer.parseInt(lines))+1);} | ||
public String BreakCnt(String letters,String lines) {return format2((Integer.parseInt(letters) - Integer.parseInt(lines)));} | ||
//空白抜きでテキストの文字数をカウント | ||
public String EmptyCnt(String letters) { | ||
//全角が含まれる場合半角に置き換え、その置き換えた半角を””に置き換えて、その際のdataの長さを返す | ||
if(letters.contains(" ")){ | ||
String data = letters.replaceAll(" ", " ");//全角=>半角 | ||
return format(data.replaceAll(" ","").length());//半角=>空 | ||
} | ||
//全角が含まれない場合 | ||
return format(letters.replaceAll(" ","").length()); | ||
//受けとった文章の中に改行が含まれていたら切り取るさらに全角及び半角が含まれていたら切り取る | ||
return intFormat(letters.replaceAll("\n","").replaceAll(" ","").replaceAll(" ","").replaceAll(" ","").length()); | ||
} | ||
//edittextの文字列の長さが空であるか判断するメソッド | ||
public boolean Judge(Object l) {return l.toString().isEmpty();}//空の場合だけtrueを返す | ||
// Editable、EditText、型をString型に変換するメソッド || Intをstring型に変換するメソッド | ||
public String format2(Object j){return String.valueOf(j);} | ||
public String intFormat(int lines) {return String.valueOf (lines);} | ||
|
||
|
||
//Intをstring型に変換するメソッド | ||
public String format(int lines) {return String.valueOf (lines);} | ||
//edittextの文字列の長さが0であるか判断するメソッド | ||
public boolean Judge(Editable l) {return Integer.parseInt (Count (l)) == 0;}//0の場合だけtrueを返す | ||
//OS Version Check | ||
public boolean ChkOS(int v) {return Build.VERSION.SDK_INT <= v;}//osが引数v以下の場合だけtrueを返す | ||
public static String getNowDate(){return new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date(System.currentTimeMillis()));} | ||
|
||
/**DB関係**/ | ||
public void textInsert(SQLiteDatabase db, String tableName, String[] values, String[] datas){ | ||
ContentValues value = new ContentValues(); | ||
for(int i =0 ; i<datas.length;i++){value.put(values[i], datas[i]);} | ||
db.insert(tableName, null, value);} | ||
public void textDelete(SQLiteDatabase db, String tableName){db.delete(tableName,null,null);} | ||
public void changeTheme(SQLiteDatabase db, Cursor cursor,String flag) { | ||
//一番先頭のレコードデータの有無を判別 | ||
if (cursor.moveToFirst()) {configUpdate(db, flag);} //ある場合はupdate | ||
else {configInsert(db, flag);}//データが空の場合insert | ||
} | ||
public void configInsert(SQLiteDatabase db, String mode) { | ||
ContentValues values = new ContentValues(); | ||
values.put("flag", mode); | ||
db.insert("themeModeData", null, values); | ||
} | ||
public void configUpdate(SQLiteDatabase db1,String mode) { | ||
ContentValues values = new ContentValues(); | ||
values.put("flag", mode); | ||
db1.update("themeModeData",values, null,null); | ||
} | ||
|
||
/*public boolean Judge(Editable l) { | ||
if (Integer.parseInt (Count (l)) == 0) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
/**view関係**/ | ||
public float dpToPx(Context context, float dp) {return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics());} | ||
public void setLayoutDp(Context context, View Item, float widthDp, float heightDp) { | ||
// LayoutParamsを取得して設定 | ||
ViewGroup.LayoutParams layoutParams = Item.getLayoutParams(); | ||
layoutParams.width = (int) dpToPx(context, widthDp);// dpからpxに変換 | ||
layoutParams.height = (int) dpToPx(context, heightDp); | ||
// LayoutParamsを引数のViewに設定する | ||
Item.setLayoutParams(layoutParams); | ||
} | ||
public boolean ChkOS(int v) { | ||
if (Build.VERSION.SDK_INT <= v) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
}*/ | ||
} |
Oops, something went wrong.