Created
May 10, 2022 02:13
-
-
Save uta-water/da7d8c3911d11a425573804154b90274 to your computer and use it in GitHub Desktop.
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
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".KoumokuTouroku" | |
android:orientation="vertical"> | |
<Space | |
android:layout_width="wrap_content" | |
android:layout_height="20dp" /> | |
<TextView | |
android:id="@+id/koumokutouroku" | |
android:layout_width="250dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center" | |
android:gravity="center" | |
android:textSize="35dp" | |
android:text="項目登録画面" /> | |
<Space | |
android:layout_width="wrap_content" | |
android:layout_height="20dp" /> | |
<LinearLayout | |
android:layout_width="350dp" | |
android:layout_height="50dp" | |
android:layout_marginStart="10dp" | |
android:layout_marginEnd="10dp" | |
android:layout_gravity="center" | |
android:orientation="horizontal"> | |
<TextView | |
android:id="@+id/touroku1" | |
android:layout_width="140dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center_vertical" | |
android:gravity="center" | |
android:textSize="25dp" | |
android:text="項目1" /> | |
<EditText | |
android:id="@+id/editkoumoku1" | |
android:layout_width="210dp" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:ems="10" | |
android:maxLength="8" | |
android:inputType="textPersonName" | |
android:gravity="center" | |
android:text="" /> | |
</LinearLayout> | |
<LinearLayout | |
android:layout_width="350dp" | |
android:layout_height="50dp" | |
android:layout_marginStart="10dp" | |
android:layout_marginEnd="10dp" | |
android:layout_gravity="center" | |
android:orientation="horizontal"> | |
<TextView | |
android:id="@+id/touroku2" | |
android:layout_width="140dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center_vertical" | |
android:gravity="center" | |
android:textSize="25dp" | |
android:text="項目2" /> | |
<EditText | |
android:id="@+id/editkoumoku2" | |
android:layout_width="210dp" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:ems="10" | |
android:maxLength="8" | |
android:inputType="textPersonName" | |
android:gravity="center" | |
android:text="" /> | |
</LinearLayout> | |
<LinearLayout | |
android:layout_width="350dp" | |
android:layout_height="50dp" | |
android:layout_marginStart="10dp" | |
android:layout_marginEnd="10dp" | |
android:layout_gravity="center" | |
android:orientation="horizontal"> | |
<TextView | |
android:id="@+id/touroku3" | |
android:layout_width="140dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center_vertical" | |
android:gravity="center" | |
android:textSize="25dp" | |
android:text="項目3" /> | |
<EditText | |
android:id="@+id/editkoumoku3" | |
android:layout_width="210dp" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:ems="10" | |
android:maxLength="8" | |
android:inputType="textPersonName" | |
android:gravity="center" | |
android:text="" /> | |
</LinearLayout> | |
<LinearLayout | |
android:layout_width="350dp" | |
android:layout_height="50dp" | |
android:layout_marginStart="10dp" | |
android:layout_marginEnd="10dp" | |
android:layout_gravity="center" | |
android:orientation="horizontal"> | |
<TextView | |
android:id="@+id/touroku4" | |
android:layout_width="140dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center_vertical" | |
android:gravity="center" | |
android:textSize="25dp" | |
android:text="項目4" /> | |
<EditText | |
android:id="@+id/editkoumoku4" | |
android:layout_width="210dp" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:ems="10" | |
android:maxLength="8" | |
android:inputType="textPersonName" | |
android:gravity="center" | |
android:text="" /> | |
</LinearLayout> | |
<LinearLayout | |
android:layout_width="350dp" | |
android:layout_height="50dp" | |
android:layout_marginStart="10dp" | |
android:layout_marginEnd="10dp" | |
android:layout_gravity="center" | |
android:orientation="horizontal"> | |
<TextView | |
android:id="@+id/touroku5" | |
android:layout_width="140dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center_vertical" | |
android:gravity="center" | |
android:textSize="25dp" | |
android:text="項目5" /> | |
<EditText | |
android:id="@+id/editkoumoku5" | |
android:layout_width="210dp" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:ems="10" | |
android:maxLength="8" | |
android:inputType="textPersonName" | |
android:gravity="center" | |
android:text="" /> | |
</LinearLayout> | |
<TextView | |
android:id="@+id/checktext" | |
android:layout_width="250dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center" | |
android:gravity="center" | |
android:textSize="20dp" | |
android:text="" /> | |
<Button | |
android:id="@+id/tourokubtn" | |
android:layout_width="200dp" | |
android:layout_height="75dp" | |
android:backgroundTint="#444444" | |
android:layout_gravity="center" | |
android:textSize="25dp" | |
android:text="登録" /> | |
<Space | |
android:layout_width="wrap_content" | |
android:layout_height="20dp" /> | |
<Button | |
android:id="@+id/tourokuhome" | |
android:layout_width="100dp" | |
android:layout_height="wrap_content" | |
android:backgroundTint="#444444" | |
android:layout_gravity="center" | |
android:text="HOME" /> | |
</LinearLayout> |
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
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".MainActivity" | |
android:orientation="vertical" | |
> | |
<Space | |
android:layout_width="match_parent" | |
android:layout_height="10dp" /> | |
<Button | |
android:id="@+id/optionbtn" | |
android:layout_width="70dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="right" | |
android:layout_marginEnd="10dp" | |
android:backgroundTint="#444444" | |
android:text="設定" /> | |
<Space | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" /> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="50dp" | |
android:layout_marginStart="10dp" | |
android:layout_marginEnd="10dp" | |
android:orientation="horizontal"> | |
<Button | |
android:id="@+id/daybtn" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:backgroundTint="#444444" | |
android:text="日" /> | |
<Button | |
android:id="@+id/weekbtn" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:backgroundTint="#444444" | |
android:text="週" /> | |
<Button | |
android:id="@+id/monthbtn" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:backgroundTint="#444444" | |
android:text="月" /> | |
</LinearLayout> | |
<LinearLayout | |
android:layout_width="300dp" | |
android:layout_height="50dp" | |
android:layout_marginStart="10dp" | |
android:layout_marginEnd="10dp" | |
android:layout_gravity="center" | |
android:orientation="horizontal"> | |
<Button | |
android:id="@+id/leftbtn" | |
android:layout_width="50dp" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:backgroundTint="#444444" | |
android:text="←" /> | |
<TextView | |
android:id="@+id/daytext" | |
android:layout_width="200dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center_vertical" | |
android:gravity="center" | |
android:text="2022年4月30日" /> | |
<Button | |
android:id="@+id/rightbtn" | |
android:layout_width="50dp" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:backgroundTint="#444444" | |
android:text="→" /> | |
</LinearLayout> | |
<Space | |
android:layout_width="wrap_content" | |
android:layout_height="20dp" /> | |
<LinearLayout | |
android:layout_width="350dp" | |
android:layout_height="50dp" | |
android:layout_marginStart="10dp" | |
android:layout_marginEnd="10dp" | |
android:layout_gravity="center" | |
android:orientation="horizontal"> | |
<TextView | |
android:id="@+id/koumoku1" | |
android:layout_width="140dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center_vertical" | |
android:gravity="center" | |
android:text="項目名" /> | |
<Button | |
android:id="@+id/hand1" | |
android:layout_width="100dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="right" | |
android:backgroundTint="#444444" | |
android:text="手入力" /> | |
<Space | |
android:layout_width="10dp" | |
android:layout_height="wrap_content" /> | |
<Button | |
android:id="@+id/count1" | |
android:layout_width="100dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="right" | |
android:backgroundTint="#444444" | |
android:text="タイマー" /> | |
</LinearLayout> | |
<LinearLayout | |
android:layout_width="350dp" | |
android:layout_height="50dp" | |
android:layout_marginStart="10dp" | |
android:layout_marginEnd="10dp" | |
android:layout_gravity="center" | |
android:orientation="horizontal"> | |
<TextView | |
android:id="@+id/koumoku2" | |
android:layout_width="140dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center_vertical" | |
android:gravity="center" | |
android:text="項目名" /> | |
<Button | |
android:id="@+id/hand2" | |
android:layout_width="100dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="right" | |
android:backgroundTint="#444444" | |
android:text="手入力" /> | |
<Space | |
android:layout_width="10dp" | |
android:layout_height="wrap_content" /> | |
<Button | |
android:id="@+id/count2" | |
android:layout_width="100dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="right" | |
android:backgroundTint="#444444" | |
android:text="タイマー" /> | |
</LinearLayout> | |
<LinearLayout | |
android:layout_width="350dp" | |
android:layout_height="50dp" | |
android:layout_marginStart="10dp" | |
android:layout_marginEnd="10dp" | |
android:layout_gravity="center" | |
android:orientation="horizontal"> | |
<TextView | |
android:id="@+id/koumoku3" | |
android:layout_width="140dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center_vertical" | |
android:gravity="center" | |
android:text="項目名" /> | |
<Button | |
android:id="@+id/hand3" | |
android:layout_width="100dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="right" | |
android:backgroundTint="#444444" | |
android:text="手入力" /> | |
<Space | |
android:layout_width="10dp" | |
android:layout_height="wrap_content" /> | |
<Button | |
android:id="@+id/count3" | |
android:layout_width="100dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="right" | |
android:backgroundTint="#444444" | |
android:text="タイマー" /> | |
</LinearLayout> | |
<LinearLayout | |
android:layout_width="350dp" | |
android:layout_height="50dp" | |
android:layout_marginStart="10dp" | |
android:layout_marginEnd="10dp" | |
android:layout_gravity="center" | |
android:orientation="horizontal"> | |
<TextView | |
android:id="@+id/koumoku4" | |
android:layout_width="140dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center_vertical" | |
android:gravity="center" | |
android:text="項目名" /> | |
<Button | |
android:id="@+id/hand4" | |
android:layout_width="100dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="right" | |
android:backgroundTint="#444444" | |
android:text="手入力" /> | |
<Space | |
android:layout_width="10dp" | |
android:layout_height="wrap_content" /> | |
<Button | |
android:id="@+id/count4" | |
android:layout_width="100dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="right" | |
android:backgroundTint="#444444" | |
android:text="タイマー" /> | |
</LinearLayout> | |
<LinearLayout | |
android:layout_width="350dp" | |
android:layout_height="50dp" | |
android:layout_marginStart="10dp" | |
android:layout_marginEnd="10dp" | |
android:layout_gravity="center" | |
android:orientation="horizontal"> | |
<TextView | |
android:id="@+id/koumoku5" | |
android:layout_width="140dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center_vertical" | |
android:gravity="center" | |
android:text="項目名" /> | |
<Button | |
android:id="@+id/hand5" | |
android:layout_width="100dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="right" | |
android:backgroundTint="#444444" | |
android:text="手入力" /> | |
<Space | |
android:layout_width="10dp" | |
android:layout_height="wrap_content" /> | |
<Button | |
android:id="@+id/count5" | |
android:layout_width="100dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="right" | |
android:backgroundTint="#444444" | |
android:text="タイマー" /> | |
</LinearLayout> | |
</LinearLayout> |
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
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".TimeCount" | |
android:orientation="vertical"> | |
<Space | |
android:layout_width="match_parent" | |
android:layout_height="100dp" /> | |
<TextView | |
android:id="@+id/caltext" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center" | |
android:gravity="center" | |
android:textSize="30dp" | |
android:text="2022年4月30日12時30分30秒" /> | |
<Space | |
android:layout_width="match_parent" | |
android:layout_height="100dp" /> | |
<TextView | |
android:id="@+id/timetext" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center" | |
android:gravity="center" | |
android:textSize="50dp" | |
android:text="00:00:00" /> | |
<Space | |
android:layout_width="match_parent" | |
android:layout_height="100dp" /> | |
<LinearLayout | |
android:layout_width="300dp" | |
android:layout_height="50dp" | |
android:layout_gravity="center" | |
android:orientation="horizontal"> | |
<Button | |
android:id="@+id/startbtn" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:text="START" /> | |
<Button | |
android:id="@+id/stopbtn" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:text="STOP" /> | |
</LinearLayout> | |
</LinearLayout> |
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
package uta.utauta.tasktime; | |
import androidx.appcompat.app.AppCompatActivity; | |
import android.content.Intent; | |
import android.content.SharedPreferences; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.EditText; | |
import android.widget.TextView; | |
public class KoumokuTouroku extends AppCompatActivity implements View.OnClickListener { | |
private Button tourokuhome; | |
private Button tourokubtn; | |
private EditText editkoumoku1; | |
private EditText editkoumoku2; | |
private EditText editkoumoku3; | |
private EditText editkoumoku4; | |
private EditText editkoumoku5; | |
private TextView checktext; | |
private TextView touroku1; | |
private TextView touroku2; | |
private TextView touroku3; | |
private TextView touroku4; | |
private TextView touroku5; | |
public SharedPreferences pre; | |
private String koumokutext1; | |
private String koumokutext2; | |
private String koumokutext3; | |
private String koumokutext4; | |
private String koumokutext5; | |
private int tourokuphase = 0; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_koumoku_touroku); | |
pre = getSharedPreferences("pre",MODE_PRIVATE); | |
tourokuhome = findViewById(R.id.tourokuhome); | |
tourokuhome.setOnClickListener(this); | |
tourokubtn = findViewById(R.id.tourokubtn); | |
tourokubtn.setOnClickListener(this); | |
editkoumoku1 = findViewById(R.id.editkoumoku1); | |
editkoumoku2 = findViewById(R.id.editkoumoku2); | |
editkoumoku3 = findViewById(R.id.editkoumoku3); | |
editkoumoku4 = findViewById(R.id.editkoumoku4); | |
editkoumoku5 = findViewById(R.id.editkoumoku5); | |
checktext = findViewById(R.id.checktext); | |
touroku1 = findViewById(R.id.touroku1); | |
touroku2 = findViewById(R.id.touroku2); | |
touroku3 = findViewById(R.id.touroku3); | |
touroku4 = findViewById(R.id.touroku4); | |
touroku5 = findViewById(R.id.touroku5); | |
koumokutext1 = pre.getString("koumokutext1", ""); | |
if(koumokutext1.equals("")) { | |
editkoumoku2.setVisibility(View.INVISIBLE); | |
editkoumoku3.setVisibility(View.INVISIBLE); | |
editkoumoku4.setVisibility(View.INVISIBLE); | |
editkoumoku5.setVisibility(View.INVISIBLE); | |
touroku2.setVisibility(View.INVISIBLE); | |
touroku3.setVisibility(View.INVISIBLE); | |
touroku4.setVisibility(View.INVISIBLE); | |
touroku5.setVisibility(View.INVISIBLE); | |
tourokuphase = 1; | |
} else { | |
editkoumoku1.setText(koumokutext1); | |
koumokutext2 = pre.getString("koumokutext2", ""); | |
if(koumokutext2.equals("")) { | |
editkoumoku3.setVisibility(View.INVISIBLE); | |
editkoumoku4.setVisibility(View.INVISIBLE); | |
editkoumoku5.setVisibility(View.INVISIBLE); | |
touroku3.setVisibility(View.INVISIBLE); | |
touroku4.setVisibility(View.INVISIBLE); | |
touroku5.setVisibility(View.INVISIBLE); | |
tourokuphase = 2; | |
} else { | |
editkoumoku2.setText(koumokutext2); | |
koumokutext3 = pre.getString("koumokutext3", ""); | |
if(koumokutext3.equals("")) { | |
editkoumoku4.setVisibility(View.INVISIBLE); | |
editkoumoku5.setVisibility(View.INVISIBLE); | |
touroku4.setVisibility(View.INVISIBLE); | |
touroku5.setVisibility(View.INVISIBLE); | |
tourokuphase = 3; | |
} else { | |
editkoumoku3.setText(koumokutext3); | |
koumokutext4 = pre.getString("koumokutext4", ""); | |
if(koumokutext4.equals("")) { | |
editkoumoku5.setVisibility(View.INVISIBLE); | |
touroku5.setVisibility(View.INVISIBLE); | |
tourokuphase = 4; | |
} else { | |
editkoumoku4.setText(koumokutext4); | |
koumokutext5 = pre.getString("koumokutext5", ""); | |
if(koumokutext5.equals("")) { | |
tourokuphase = 5; | |
} else { | |
editkoumoku5.setText(koumokutext5); | |
tourokuphase = 6; | |
} | |
} | |
} | |
} | |
} | |
} | |
@Override | |
public void onClick(View v) { | |
switch (v.getId()) { | |
case(R.id.tourokuhome): | |
Intent home = new Intent(getApplication(),MainActivity.class); | |
startActivity(home); | |
break; | |
case(R.id.tourokubtn): | |
SharedPreferences.Editor edit = pre.edit(); | |
if(tourokuphase == 1) { | |
if(!editkoumoku1.getText().toString().equals("")) { | |
edit.putString("koumokutext1",editkoumoku1.getText().toString()); | |
} else { | |
tourokuphase = 0; | |
} | |
} else if(tourokuphase == 2) { | |
if(!editkoumoku1.getText().toString().equals("")) { | |
edit.putString("koumokutext1",editkoumoku1.getText().toString()); | |
} else { | |
tourokuphase = 0; | |
} | |
if(!editkoumoku2.getText().toString().equals("")) { | |
edit.putString("koumokutext2",editkoumoku2.getText().toString()); | |
} else { | |
tourokuphase = 0; | |
} | |
} else if(tourokuphase == 3) { | |
if(!editkoumoku1.getText().toString().equals("")) { | |
edit.putString("koumokutext1",editkoumoku1.getText().toString()); | |
} else { | |
tourokuphase = 0; | |
} | |
if(!editkoumoku2.getText().toString().equals("")) { | |
edit.putString("koumokutext2",editkoumoku2.getText().toString()); | |
} else { | |
tourokuphase = 0; | |
} | |
if(!editkoumoku3.getText().toString().equals("")) { | |
edit.putString("koumokutext3",editkoumoku3.getText().toString()); | |
} else { | |
tourokuphase = 0; | |
} | |
} else if(tourokuphase == 4) { | |
if(!editkoumoku1.getText().toString().equals("")) { | |
edit.putString("koumokutext1",editkoumoku1.getText().toString()); | |
} else { | |
tourokuphase = 0; | |
} | |
if(!editkoumoku2.getText().toString().equals("")) { | |
edit.putString("koumokutext2",editkoumoku2.getText().toString()); | |
} else { | |
tourokuphase = 0; | |
} | |
if(!editkoumoku3.getText().toString().equals("")) { | |
edit.putString("koumokutext3",editkoumoku3.getText().toString()); | |
} else { | |
tourokuphase = 0; | |
} | |
if(!editkoumoku4.getText().toString().equals("")) { | |
edit.putString("koumokutext4",editkoumoku4.getText().toString()); | |
} else { | |
tourokuphase = 0; | |
} | |
} else if(tourokuphase == 5 || tourokuphase == 6) { | |
if(!editkoumoku1.getText().toString().equals("")) { | |
edit.putString("koumokutext1",editkoumoku1.getText().toString()); | |
} else { | |
tourokuphase = 0; | |
} | |
if(!editkoumoku2.getText().toString().equals("")) { | |
edit.putString("koumokutext2",editkoumoku2.getText().toString()); | |
} else { | |
tourokuphase = 0; | |
} | |
if(!editkoumoku3.getText().toString().equals("")) { | |
edit.putString("koumokutext3",editkoumoku3.getText().toString()); | |
} else { | |
tourokuphase = 0; | |
} | |
if(!editkoumoku4.getText().toString().equals("")) { | |
edit.putString("koumokutext4",editkoumoku4.getText().toString()); | |
} else { | |
tourokuphase = 0; | |
} | |
if(!editkoumoku5.getText().toString().equals("")) { | |
edit.putString("koumokutext5",editkoumoku5.getText().toString()); | |
} else { | |
tourokuphase = 0; | |
} | |
} | |
if(tourokuphase != 0) { | |
if(tourokuphase != 6) { | |
tourokuphase += 1; | |
} | |
checktext.setText(""); | |
edit.commit(); | |
if(tourokuphase == 2) { | |
editkoumoku2.setVisibility(View.VISIBLE); | |
touroku2.setVisibility(View.VISIBLE); | |
} else if(tourokuphase == 3) { | |
touroku3.setVisibility(View.VISIBLE); | |
editkoumoku3.setVisibility(View.VISIBLE); | |
} else if(tourokuphase == 4) { | |
touroku4.setVisibility(View.VISIBLE); | |
editkoumoku4.setVisibility(View.VISIBLE); | |
} else if(tourokuphase == 5 || tourokuphase == 6) { | |
touroku5.setVisibility(View.VISIBLE); | |
editkoumoku5.setVisibility(View.VISIBLE); | |
} | |
} else { | |
checktext.setText("登録名を入力して下さい"); | |
} | |
break; | |
} | |
} | |
} |
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
package uta.utauta.tasktime; | |
import androidx.appcompat.app.AppCompatActivity; | |
import android.content.Intent; | |
import android.content.SharedPreferences; | |
import android.graphics.Color; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.TextView; | |
import java.util.Calendar; | |
public class MainActivity extends AppCompatActivity implements View.OnClickListener { | |
private Button count1; | |
private Button count2; | |
private Button count3; | |
private Button count4; | |
private Button count5; | |
private Button leftbtn; | |
private Button rightbtn; | |
private Button daybtn; | |
private Button weekbtn; | |
private Button monthbtn; | |
private Button optionbtn; | |
private Button hand1; | |
private Button hand2; | |
private Button hand3; | |
private Button hand4; | |
private Button hand5; | |
private TextView daytext; | |
private TextView koumoku1; | |
private TextView koumoku2; | |
private TextView koumoku3; | |
private TextView koumoku4; | |
private TextView koumoku5; | |
private int mainyear; | |
private int mainmonth; | |
private int mainday; | |
private int dayphase = 1; | |
private int maintourokuphase; | |
public SharedPreferences pre; | |
private String mainkoumoku1; | |
private String mainkoumoku2; | |
private String mainkoumoku3; | |
private String mainkoumoku4; | |
private String mainkoumoku5; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
pre = getSharedPreferences("pre",MODE_PRIVATE); | |
daytext = findViewById(R.id.daytext); | |
koumoku1 = findViewById(R.id.koumoku1); | |
koumoku2 = findViewById(R.id.koumoku2); | |
koumoku3 = findViewById(R.id.koumoku3); | |
koumoku4 = findViewById(R.id.koumoku4); | |
koumoku5 = findViewById(R.id.koumoku5); | |
daybtn = findViewById(R.id.daybtn); | |
daybtn.setOnClickListener(this); | |
weekbtn = findViewById(R.id.weekbtn); | |
weekbtn.setOnClickListener(this); | |
monthbtn = findViewById(R.id.monthbtn); | |
monthbtn.setOnClickListener(this); | |
daybtn.setBackgroundColor(Color.rgb(68, 68, 68)); | |
weekbtn.setBackgroundColor(Color.rgb(200, 200, 200)); | |
monthbtn.setBackgroundColor(Color.rgb(200, 200, 200)); | |
leftbtn = findViewById(R.id.leftbtn); | |
leftbtn.setOnClickListener(this); | |
rightbtn = findViewById(R.id.rightbtn); | |
rightbtn.setOnClickListener(this); | |
count1 = findViewById(R.id.count1); | |
count1.setOnClickListener(this); | |
count2 = findViewById(R.id.count2); | |
count2.setOnClickListener(this); | |
count3 = findViewById(R.id.count3); | |
count3.setOnClickListener(this); | |
count4 = findViewById(R.id.count4); | |
count4.setOnClickListener(this); | |
count5 = findViewById(R.id.count5); | |
count5.setOnClickListener(this); | |
optionbtn = findViewById(R.id.optionbtn); | |
optionbtn.setOnClickListener(this); | |
hand1 = findViewById(R.id.hand1); | |
hand1.setOnClickListener(this); | |
hand2 = findViewById(R.id.hand2); | |
hand2.setOnClickListener(this); | |
hand3 = findViewById(R.id.hand3); | |
hand3.setOnClickListener(this); | |
hand4 = findViewById(R.id.hand4); | |
hand4.setOnClickListener(this); | |
hand5 = findViewById(R.id.hand5); | |
hand5.setOnClickListener(this); | |
Calendar cal = Calendar.getInstance(); | |
mainyear = cal.get(Calendar.YEAR); | |
mainmonth = cal.get(Calendar.MONTH) + 1; | |
mainday = cal.get(Calendar.DAY_OF_MONTH); | |
daytext.setText(mainyear + "年" + mainmonth + "月" + mainday + "日"); | |
mainkoumoku1 = pre.getString("koumokutext1", ""); | |
if(mainkoumoku1.equals("")) { | |
koumoku1.setVisibility(View.INVISIBLE); | |
hand1.setVisibility(View.INVISIBLE); | |
count1.setVisibility(View.INVISIBLE); | |
koumoku2.setVisibility(View.INVISIBLE); | |
hand2.setVisibility(View.INVISIBLE); | |
count2.setVisibility(View.INVISIBLE); | |
koumoku3.setVisibility(View.INVISIBLE); | |
hand3.setVisibility(View.INVISIBLE); | |
count3.setVisibility(View.INVISIBLE); | |
koumoku4.setVisibility(View.INVISIBLE); | |
hand4.setVisibility(View.INVISIBLE); | |
count4.setVisibility(View.INVISIBLE); | |
koumoku5.setVisibility(View.INVISIBLE); | |
hand5.setVisibility(View.INVISIBLE); | |
count5.setVisibility(View.INVISIBLE); | |
maintourokuphase = 0; | |
Intent touroku = new Intent(getApplication(),KoumokuTouroku.class); | |
startActivity(touroku); | |
} else { | |
koumoku1.setText(mainkoumoku1); | |
mainkoumoku2 = pre.getString("koumokutext2", ""); | |
if(mainkoumoku2.equals("")) { | |
koumoku2.setVisibility(View.INVISIBLE); | |
hand2.setVisibility(View.INVISIBLE); | |
count2.setVisibility(View.INVISIBLE); | |
koumoku3.setVisibility(View.INVISIBLE); | |
hand3.setVisibility(View.INVISIBLE); | |
count3.setVisibility(View.INVISIBLE); | |
koumoku4.setVisibility(View.INVISIBLE); | |
hand4.setVisibility(View.INVISIBLE); | |
count4.setVisibility(View.INVISIBLE); | |
koumoku5.setVisibility(View.INVISIBLE); | |
hand5.setVisibility(View.INVISIBLE); | |
count5.setVisibility(View.INVISIBLE); | |
maintourokuphase = 1; | |
} else { | |
koumoku2.setText(mainkoumoku2); | |
mainkoumoku3 = pre.getString("koumokutext3", ""); | |
if(mainkoumoku3.equals("")) { | |
koumoku3.setVisibility(View.INVISIBLE); | |
hand3.setVisibility(View.INVISIBLE); | |
count3.setVisibility(View.INVISIBLE); | |
koumoku4.setVisibility(View.INVISIBLE); | |
hand4.setVisibility(View.INVISIBLE); | |
count4.setVisibility(View.INVISIBLE); | |
koumoku5.setVisibility(View.INVISIBLE); | |
hand5.setVisibility(View.INVISIBLE); | |
count5.setVisibility(View.INVISIBLE); | |
maintourokuphase = 2; | |
} else { | |
koumoku3.setText(mainkoumoku3); | |
mainkoumoku4 = pre.getString("koumokutext4", ""); | |
if(mainkoumoku4.equals("")) { | |
koumoku4.setVisibility(View.INVISIBLE); | |
hand4.setVisibility(View.INVISIBLE); | |
count4.setVisibility(View.INVISIBLE); | |
koumoku5.setVisibility(View.INVISIBLE); | |
hand5.setVisibility(View.INVISIBLE); | |
count5.setVisibility(View.INVISIBLE); | |
maintourokuphase = 3; | |
} else { | |
koumoku4.setText(mainkoumoku4); | |
mainkoumoku5 = pre.getString("koumokutext5", ""); | |
if(mainkoumoku5.equals("")) { | |
koumoku5.setVisibility(View.INVISIBLE); | |
hand5.setVisibility(View.INVISIBLE); | |
count5.setVisibility(View.INVISIBLE); | |
maintourokuphase = 4; | |
} else { | |
koumoku5.setText(mainkoumoku5); | |
maintourokuphase = 5; | |
} | |
} | |
} | |
} | |
} | |
} | |
@Override | |
public void onClick(View v) { | |
switch(v.getId()) { | |
case(R.id.optionbtn): | |
Intent touroku = new Intent(getApplication(),KoumokuTouroku.class); | |
startActivity(touroku); | |
break; | |
case(R.id.daybtn): | |
dayphase = 1; | |
daybtn.setBackgroundColor(Color.rgb(68, 68, 68)); | |
weekbtn.setBackgroundColor(Color.rgb(200, 200, 200)); | |
monthbtn.setBackgroundColor(Color.rgb(200, 200, 200)); | |
daytext.setText(mainyear + "年" + mainmonth + "月" + mainday + "日"); | |
break; | |
case(R.id.weekbtn): | |
dayphase = 2; | |
daybtn.setBackgroundColor(Color.rgb(200, 200, 200)); | |
weekbtn.setBackgroundColor(Color.rgb(68, 68, 68)); | |
monthbtn.setBackgroundColor(Color.rgb(200, 200, 200)); | |
daytext.setText(mainyear + "年" + mainmonth + "月"); | |
break; | |
case(R.id.monthbtn): | |
dayphase = 3; | |
daybtn.setBackgroundColor(Color.rgb(200, 200, 200)); | |
weekbtn.setBackgroundColor(Color.rgb(200, 200, 200)); | |
monthbtn.setBackgroundColor(Color.rgb(68, 68, 68)); | |
daytext.setText(mainyear + "年"); | |
break; | |
case(R.id.leftbtn): | |
if(dayphase == 1) { | |
mainday -= 1; | |
if(mainday == 0) { | |
mainmonth -= 1; | |
if(mainmonth == 0) { | |
mainday = 31; | |
mainyear -= 1; | |
} else if(mainmonth == 1 || mainmonth == 3 || mainmonth == 5 || mainmonth == 7 || mainmonth == 8 || mainmonth == 10) { | |
mainday = 31; | |
} else if(mainmonth == 2) { | |
if(mainyear % 4 == 0) { | |
mainday = 29; | |
} else { | |
mainday = 28; | |
} | |
} else { | |
mainday = 30; | |
} | |
} | |
daytext.setText(mainyear + "年" + mainmonth + "月" + mainday + "日"); | |
} else if(dayphase == 2) { | |
mainmonth -= 1; | |
if(mainmonth == 0) { | |
mainmonth = 12; | |
mainyear -= 1; | |
} | |
daytext.setText(mainyear + "年" + mainmonth + "月"); | |
} else if(dayphase == 3) { | |
mainyear -= 1; | |
daytext.setText(mainyear + "年"); | |
} | |
break; | |
case(R.id.rightbtn): | |
if(dayphase == 1) { | |
mainday += 1; | |
if(mainday == 29) { | |
if(mainmonth == 2) { | |
if(mainyear % 4 != 0) { | |
mainday = 1; | |
mainmonth = 3; | |
} | |
} | |
} else if(mainday == 30) { | |
if(mainmonth == 2) { | |
if (mainyear % 4 == 0) { | |
mainday = 1; | |
mainmonth = 3; | |
} | |
} | |
} else if(mainday == 31) { | |
if(mainmonth == 4 || mainmonth == 6 || mainmonth == 9 || mainmonth == 11) { | |
mainday = 1; | |
mainmonth += 1; | |
} | |
} else if(mainday == 32) { | |
if(mainmonth == 12) { | |
mainday = 1; | |
mainmonth += 1; | |
mainyear += 1; | |
} else { | |
mainday = 1; | |
mainmonth += 1; | |
} | |
} | |
daytext.setText(mainyear + "年" + mainmonth + "月" + mainday + "日"); | |
} else if(dayphase == 2) { | |
mainmonth += 1; | |
if(mainmonth == 13) { | |
mainmonth = 1; | |
mainyear += 1; | |
} | |
daytext.setText(mainyear + "年" + mainmonth + "月"); | |
} else if(dayphase == 3) { | |
mainyear += 1; | |
daytext.setText(mainyear + "年"); | |
} | |
break; | |
case(R.id.count1): | |
Intent intent = new Intent(getApplication(),TimeCount.class); | |
startActivity(intent); | |
break; | |
} | |
} | |
} |
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
package uta.utauta.tasktime; | |
import androidx.appcompat.app.AppCompatActivity; | |
import android.content.Intent; | |
import android.content.SharedPreferences; | |
import android.os.Bundle; | |
import android.os.Handler; | |
import android.os.Looper; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.TextView; | |
import java.text.SimpleDateFormat; | |
import java.util.Calendar; | |
import java.util.Locale; | |
public class TimeCount extends AppCompatActivity implements Runnable, View.OnClickListener { | |
private Button startbtn; | |
private Button stopbtn; | |
private TextView timetext; | |
private TextView caltext; | |
private final Handler handler = new Handler(Looper.getMainLooper()); | |
private final SimpleDateFormat date = new SimpleDateFormat("mm:ss:SS", Locale.JAPAN); | |
private volatile boolean timephase = true; | |
public SharedPreferences pre; | |
private int counthour = 0; | |
private int countminute = 0; | |
private int countsecond = 0; | |
private int year = 0; | |
private int month = 0; | |
private int day = 0; | |
private int hour = 0; | |
private int minute = 0; | |
private int second = 0; | |
private int nowyear = 0; | |
private int nowmonth = 0; | |
private int nowday = 0; | |
private int nowhour = 0; | |
private int nowminute = 0; | |
private int nowsecond = 0; | |
private boolean timecheckphase = true; | |
private String phasepre; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_time_count); | |
pre = getSharedPreferences("pre",MODE_PRIVATE); | |
timetext = findViewById(R.id.timetext); | |
caltext = findViewById(R.id.caltext); | |
startbtn = findViewById(R.id.startbtn); | |
startbtn.setOnClickListener(this); | |
stopbtn = findViewById(R.id.stopbtn); | |
stopbtn.setOnClickListener(this); | |
phasepre = pre.getString("quickphase", "true"); | |
if(phasepre.equals("false")) { | |
year = pre.getInt("quickyear",0); | |
month = pre.getInt("quickmonth",0); | |
day = pre.getInt("quickday",0); | |
hour = pre.getInt("quickhour",0); | |
minute = pre.getInt("quickminute",0); | |
second = pre.getInt("quicksecond",0); | |
Calendar cal = Calendar.getInstance(); | |
nowyear = cal.get(Calendar.YEAR); | |
nowmonth = cal.get(Calendar.MONTH) + 1; | |
nowday = cal.get(Calendar.DAY_OF_MONTH); | |
nowhour = cal.get(Calendar.HOUR_OF_DAY); | |
nowminute = cal.get(Calendar.MINUTE); | |
nowsecond = cal.get(Calendar.SECOND); | |
if((nowyear - year) == 1) { | |
nowmonth += 12; | |
} else if((nowyear - year) != 0) { | |
timecheckphase = false; | |
} | |
if((nowmonth - month) == 1) { | |
if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) { | |
nowday += 31; | |
} else if(month == 2) { | |
if(year % 4 == 0) { | |
nowday += 29; | |
} else { | |
nowday += 28; | |
} | |
} else { | |
nowday += 30; | |
} | |
} else if((nowmonth - month) != 0) { | |
timecheckphase = false; | |
} | |
if((nowday - day) == 1) { | |
nowhour += 24; | |
} else if((nowday - day) != 0) { | |
timecheckphase = false; | |
} | |
if(nowhour - hour >= 24) { | |
timecheckphase = false; | |
} | |
counthour = nowhour - hour; | |
if((nowminute - minute) < 0) { | |
nowminute += 60; | |
} | |
countminute = nowminute - minute; | |
if((nowsecond - second) < 0) { | |
nowsecond += 60; | |
} | |
countsecond = nowsecond - second; | |
caltext.setText(nowyear + "年" + nowmonth + "月" + nowday + "日" + nowhour + "時" + nowminute + "分" + nowsecond + "秒"); | |
if(timecheckphase == true) { | |
String hour; | |
String minute; | |
String second; | |
if(counthour < 10) { | |
hour = "0" + counthour; | |
} else { | |
hour = "" + counthour; | |
} | |
if(countminute < 10) { | |
minute = "0" + countminute; | |
} else { | |
minute = "" + countminute; | |
} | |
if(countsecond < 10) { | |
second = "0" + countsecond; | |
} else { | |
second = "" + countsecond; | |
} | |
timetext.setText(hour + ":" + minute + ":" + second); | |
Thread thread; | |
timephase = false; | |
thread = new Thread(this); | |
thread.start(); | |
startbtn.setEnabled(false); | |
} else { | |
timetext.setText("24hOver"); | |
} | |
} else { | |
stopbtn.setEnabled(false); | |
} | |
} | |
@Override | |
public void onClick(View v) { | |
switch(v.getId()) { | |
case (R.id.startbtn): | |
Thread thread; | |
timephase = false; | |
thread = new Thread(this); | |
thread.start(); | |
counthour = 0; | |
countminute = 0; | |
countsecond = 0; | |
startbtn.setEnabled(false); | |
timetext.setText("00:00:00"); | |
Calendar cal = Calendar.getInstance(); | |
year = cal.get(Calendar.YEAR); | |
month = cal.get(Calendar.MONTH) + 1; | |
day = cal.get(Calendar.DAY_OF_MONTH); | |
hour = cal.get(Calendar.HOUR_OF_DAY); | |
minute = cal.get(Calendar.MINUTE); | |
second = cal.get(Calendar.SECOND); | |
caltext.setText(year + "年" + month + "月" + day + "日" + hour + "時" + minute + "分" + second + "秒"); | |
SharedPreferences.Editor edit = pre.edit(); | |
edit.putInt("quickyear",year); | |
edit.putInt("quickmonth",month); | |
edit.putInt("quickday",day); | |
edit.putInt("quickhour",hour); | |
edit.putInt("quickminute",minute); | |
edit.putInt("quicksecond",second); | |
edit.putString("quickphase","false"); | |
edit.commit(); | |
break; | |
case (R.id.stopbtn): | |
SharedPreferences.Editor edit2 = pre.edit(); | |
timephase = true; | |
startbtn.setEnabled(true); | |
stopbtn.setEnabled(false); | |
edit2.putString("quickphase","true"); | |
edit2.commit(); | |
break; | |
} | |
} | |
@Override | |
public void run() { | |
int period = 1000; | |
while(!timephase) { | |
try { | |
Thread.sleep(period); | |
} catch(InterruptedException e) { | |
e.printStackTrace(); | |
timephase = true; | |
} | |
handler.post(new Runnable() { | |
@Override | |
public void run() { | |
if(countsecond == 0) { | |
if(countminute == 0) { | |
if(counthour == 0) { | |
stopbtn.setEnabled(true); | |
} | |
} | |
} | |
if (!timephase) { | |
countsecond += 1; | |
if(countsecond == 60) { | |
countminute += 1; | |
countsecond = 0; | |
if(countminute == 60) { | |
counthour += 1; | |
countminute = 0; | |
} | |
} | |
String hour; | |
String minute; | |
String second; | |
if(counthour < 10) { | |
hour = "0" + counthour; | |
} else { | |
hour = "" + counthour; | |
} | |
if(countminute < 10) { | |
minute = "0" + countminute; | |
} else { | |
minute = "" + countminute; | |
} | |
if(countsecond < 10) { | |
second = "0" + countsecond; | |
} else { | |
second = "" + countsecond; | |
} | |
timetext.setText(hour + ":" +minute + ":" + second); | |
} | |
} | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment