Skip to content

Commit

Permalink
Counter_v1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
LaIixia committed Jan 21, 2025
1 parent 1621233 commit f672ba0
Show file tree
Hide file tree
Showing 27 changed files with 1,062 additions and 737 deletions.
6 changes: 6 additions & 0 deletions .idea/appInsightsSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/render.experimental.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 0 additions & 15 deletions README.md

This file was deleted.

8 changes: 3 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
minSdk 21
targetSdk 34
versionCode 1
versionName "1.5.5"
versionName "1.6"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -28,12 +28,10 @@ android {
}

dependencies {

implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.0'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'

}
20 changes: 15 additions & 5 deletions app/src/main/AndroidManifest.xml
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>
91 changes: 55 additions & 36 deletions app/src/main/java/com/myapp/textcounter/Buttons.java
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;
}
}*/
}
Loading

0 comments on commit f672ba0

Please sign in to comment.