<option value="$PROJECT_DIR$/wear" />
</set>
</option>
- <option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
<modules>
<module fileurl="file://$PROJECT_DIR$/JoggingTimer.iml" filepath="$PROJECT_DIR$/JoggingTimer.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/mobile/JoggingTimer.mobile.iml" filepath="$PROJECT_DIR$/.idea/modules/mobile/JoggingTimer.mobile.iml" />
+ <module fileurl="file://$PROJECT_DIR$/.idea/modules/mobile/JoggingTimer.mobile.androidTest.iml" filepath="$PROJECT_DIR$/.idea/modules/mobile/JoggingTimer.mobile.androidTest.iml" />
+ <module fileurl="file://$PROJECT_DIR$/.idea/modules/mobile/JoggingTimer.mobile.main.iml" filepath="$PROJECT_DIR$/.idea/modules/mobile/JoggingTimer.mobile.main.iml" />
+ <module fileurl="file://$PROJECT_DIR$/.idea/modules/mobile/JoggingTimer.mobile.unitTest.iml" filepath="$PROJECT_DIR$/.idea/modules/mobile/JoggingTimer.mobile.unitTest.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/wear/JoggingTimer.wear.iml" filepath="$PROJECT_DIR$/.idea/modules/wear/JoggingTimer.wear.iml" />
+ <module fileurl="file://$PROJECT_DIR$/.idea/modules/wear/JoggingTimer.wear.androidTest.iml" filepath="$PROJECT_DIR$/.idea/modules/wear/JoggingTimer.wear.androidTest.iml" />
+ <module fileurl="file://$PROJECT_DIR$/.idea/modules/wear/JoggingTimer.wear.main.iml" filepath="$PROJECT_DIR$/.idea/modules/wear/JoggingTimer.wear.main.iml" />
+ <module fileurl="file://$PROJECT_DIR$/.idea/modules/wear/JoggingTimer.wear.unitTest.iml" filepath="$PROJECT_DIR$/.idea/modules/wear/JoggingTimer.wear.unitTest.iml" />
</modules>
</component>
</project>
\ No newline at end of file
mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:7.1.3'
+ classpath 'com.android.tools.build:gradle:7.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
import android.app.FragmentManager;
import android.os.Bundle;
-import android.support.wearable.activity.WearableActivity;
import android.util.Log;
import android.view.MenuItem;
import android.widget.Toast;
import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DividerItemDecoration;
+import androidx.wear.ambient.AmbientModeSupport;
import androidx.wear.widget.WearableLinearLayoutManager;
import androidx.wear.widget.WearableRecyclerView;
import androidx.wear.widget.drawer.WearableActionDrawerView;
*
*
*/
-public class DetailActivity extends WearableActivity implements RecordDetailSetup.IDatabaseReadyNotify, MenuItem.OnMenuItemClickListener, DataEditDialog.Callback, CreateModelData.IEditedModelDataCallback, DetailSelectionMenuAdapter.ISelectedMenu
+public class DetailActivity extends AppCompatActivity implements RecordDetailSetup.IDatabaseReadyNotify, MenuItem.OnMenuItemClickListener, DataEditDialog.Callback, CreateModelData.IEditedModelDataCallback, DetailSelectionMenuAdapter.ISelectedMenu, AmbientModeSupport.AmbientCallbackProvider
{
private final String TAG = toString();
public static final String INTENT_EXTRA_DATA_ID = "Detail.dataId";
setContentView(R.layout.activity_detail);
// Enables Always-on
- setAmbientEnabled();
+ //setAmbientEnabled();
+ try
+ {
+ AmbientModeSupport.AmbientController ambientController = AmbientModeSupport.attach(this);
+ ambientController.setAutoResumeEnabled(true);
+ //boolean isAmbient = ambientController.isAmbient();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
try
{
System.gc();
}
- /**
- *
- *
- */
+/*
@Override
public void onEnterAmbient(Bundle ambientDetails)
{
Log.v(TAG, "onEnterAmbient()");
}
- /**
- *
- *
- */
@Override
public void onExitAmbient()
{
Log.v(TAG, "onExitAmbient()");
}
- /**
- *
- *
- */
@Override
public void onUpdateAmbient()
{
super.onUpdateAmbient();
Log.v(TAG, "onUpdateAmbient()");
}
+*/
/**
*
{
itemSelected(itemId);
}
+
+ @Override
+ public AmbientModeSupport.AmbientCallback getAmbientCallback()
+ {
+ return (new AmbientModeSupport.AmbientCallback() {
+ public void onEnterAmbient(Bundle ambientDetails)
+ {
+ Log.v(TAG, "onEnterAmbient()");
+ }
+ public void onExitAmbient(Bundle ambientDetails)
+ {
+ Log.v(TAG, "onExitAmbient()");
+ }
+ });
+ }
+
+ @Override
+ public void onPointerCaptureChanged(boolean hasCapture) {
+ super.onPointerCaptureChanged(hasCapture);
+ }
}
String getDetail()
{
- return (TimeStringConvert.getTimeString(overallTime).toString() + " (" + TimeStringConvert.getDiffTimeString(differenceTime).toString() +") ");
+ return (TimeStringConvert.getTimeString(overallTime) + " (" + TimeStringConvert.getDiffTimeString(differenceTime) +") ");
}
String getOverallTime()
import android.annotation.SuppressLint;
import android.content.Intent;
import android.database.Cursor;
-import android.support.wearable.activity.WearableActivity;
import android.util.Log;
import net.osdn.gokigen.joggingtimer.R;
import static net.osdn.gokigen.joggingtimer.storage.contract.TimeEntryIndex.EntryIndex.COLUMN_NAME_TITLE;
import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
/**
*
public class RecordDetailSetup implements ITimeEntryDatabaseCallback, IDetailEditor
{
private final String TAG = toString();
- private final WearableActivity activity;
+ private final AppCompatActivity activity;
private final long indexId;
private final IDatabaseReadyNotify callback;
private final IRecordOperation operation;
*
*
*/
- RecordDetailSetup(WearableActivity activity, long indexId, IDatabaseReadyNotify callback, IRecordOperation operation, CreateModelData.IEditedModelDataCallback editCallback)
+ RecordDetailSetup(AppCompatActivity activity, long indexId, IDatabaseReadyNotify callback, IRecordOperation operation, CreateModelData.IEditedModelDataCallback editCallback)
{
this.activity = activity;
this.indexId = indexId;
{
activity.runOnUiThread(() -> {
CreateModelDataDialog dialog2 = CreateModelDataDialog.newInstance(false, activity.getString(R.string.information_modify_time), count, new CreateModelData(database, editCallback, null, indexId, dataId), defaultMillis);
- dialog2.show(activity.getFragmentManager(), "dialog2");
+ dialog2.showNow(activity.getSupportFragmentManager(), "dialog2");
});
}
package net.osdn.gokigen.joggingtimer.recordlist;
-import android.app.FragmentManager;
import android.content.Intent;
import android.os.Bundle;
-import android.support.wearable.activity.WearableActivity;
import android.util.Log;
import android.widget.Toast;
import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DividerItemDecoration;
+import androidx.wear.ambient.AmbientModeSupport;
import androidx.wear.widget.WearableLinearLayoutManager;
import androidx.wear.widget.WearableRecyclerView;
import androidx.wear.widget.drawer.WearableNavigationDrawerView;
*
*
*/
-public class ListActivity extends WearableActivity implements IDetailLauncher, RecordSummarySetup.IDatabaseReadyNotify, CreateModelData.ICreatedModelDataCallback, ListSelectionMenuAdapter.ISelectedMenu
+public class ListActivity extends AppCompatActivity implements IDetailLauncher, RecordSummarySetup.IDatabaseReadyNotify, CreateModelData.ICreatedModelDataCallback, ListSelectionMenuAdapter.ISelectedMenu, AmbientModeSupport.AmbientCallbackProvider
{
private final String TAG = toString();
private RecordSummaryAdapter summaryAdapter = null;
setContentView(R.layout.activity_list);
// Enables Always-on
- setAmbientEnabled();
+ //setAmbientEnabled();
+ try
+ {
+ AmbientModeSupport.AmbientController ambientController = AmbientModeSupport.attach(this);
+ ambientController.setAutoResumeEnabled(true);
+ //boolean isAmbient = ambientController.isAmbient();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
try
{
Log.v(TAG, "onStop()");
}
- /**
- *
- *
- */
+/*
@Override
public void onEnterAmbient(Bundle ambientDetails)
{
Log.v(TAG, "onEnterAmbient()");
}
- /**
- *
- *
- */
@Override
public void onExitAmbient()
{
Log.v(TAG, "onExitAmbient()");
}
- /**
- *
- *
- */
@Override
public void onUpdateAmbient()
{
super.onUpdateAmbient();
Log.v(TAG, "onUpdateAmbient()");
}
+*/
/**
*
{
// モデルデータの作成
CreateModelDataDialog dialog2 = CreateModelDataDialog.newInstance(true, getString(R.string.information_time_picker), 0, setupper.getCreateModelDataCallback(ITimeEntryDatabase.DONT_USE_ID, ITimeEntryDatabase.DONT_USE_ID), 0);
- dialog2.show(getFragmentManager(), "dialog2");
+ dialog2.show(getSupportFragmentManager(), "dialog2");
}
/*
try
}
}
});
- FragmentManager manager = getFragmentManager();
- String tag = "dialog";
- if (manager != null)
- {
- dialog.show(manager, tag);
- }
+ dialog.show(getSupportFragmentManager(), "dialog");
}
catch (Exception e)
{
toast.show();
});
}
+
+ @Override
+ public AmbientModeSupport.AmbientCallback getAmbientCallback()
+ {
+ return (new AmbientModeSupport.AmbientCallback() {
+ public void onEnterAmbient(Bundle ambientDetails)
+ {
+ Log.v(TAG, "onEnterAmbient()");
+ }
+ public void onExitAmbient(Bundle ambientDetails)
+ {
+ Log.v(TAG, "onExitAmbient()");
+ //updateTimerLabel();
+ }
+ });
+ }
+
+ @Override
+ public void onPointerCaptureChanged(boolean hasCapture) {
+ super.onPointerCaptureChanged(hasCapture);
+ }
}
import android.annotation.SuppressLint;
import android.database.Cursor;
-import android.support.wearable.activity.WearableActivity;
import android.util.Log;
import net.osdn.gokigen.joggingtimer.storage.ITimeEntryDatabase;
import static net.osdn.gokigen.joggingtimer.storage.contract.TimeEntryIndex.EntryIndex.COLUMN_NAME_TIME_DURATION;
import static net.osdn.gokigen.joggingtimer.storage.contract.TimeEntryIndex.EntryIndex.COLUMN_NAME_TITLE;
+import androidx.appcompat.app.AppCompatActivity;
+
/**
*
*
class RecordSummarySetup implements ITimeEntryDatabaseCallback
{
private final String TAG = toString();
- private final WearableActivity activity;
+ private final AppCompatActivity activity;
private final IDatabaseReadyNotify callback;
private final IDetailLauncher detailLauncher;
private final IRecordOperation operation;
private ITimeEntryDatabase database = null;
- RecordSummarySetup(WearableActivity activity, IDatabaseReadyNotify callback, IDetailLauncher detailLauncher, IRecordOperation operation, CreateModelData.ICreatedModelDataCallback createCallback)
+ RecordSummarySetup(AppCompatActivity activity, IDatabaseReadyNotify callback, IDetailLauncher detailLauncher, IRecordOperation operation, CreateModelData.ICreatedModelDataCallback createCallback)
{
this.activity = activity;
this.callback = callback;
package net.osdn.gokigen.joggingtimer.stopwatch;
-import android.support.wearable.activity.WearableActivity;
+import androidx.appcompat.app.AppCompatActivity;
/**
*
*/
public interface IWearableActivityControl
{
- void setup(WearableActivity activity, IClickCallback callback, IDatabaseReloadCallback dbCallback);
- void setupDatabase(WearableActivity activity, boolean isReset);
- void exitApplication(WearableActivity activity);
+ void setup(AppCompatActivity activity, IClickCallback callback, IDatabaseReloadCallback dbCallback);
+ void setupDatabase(AppCompatActivity activity, boolean isReset);
+ void exitApplication(AppCompatActivity activity);
void vibrate(int duration);
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
-import android.support.wearable.activity.WearableActivity;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.wear.ambient.AmbientModeSupport;
import androidx.wear.widget.BoxInsetLayout;
import net.osdn.gokigen.joggingtimer.R;
*
*
*/
-public class MainActivity extends WearableActivity implements IClickCallback, MyTimerTrigger.ITimeoutReceiver, MyTimerCounter.ICounterStatusNotify
+public class MainActivity extends AppCompatActivity implements IClickCallback, MyTimerTrigger.ITimeoutReceiver, MyTimerCounter.ICounterStatusNotify, AmbientModeSupport.AmbientCallbackProvider
{
private final String TAG = toString();
private final IWearableActivityControl controller = new WearableActivityController();
controller.setup(this, this, counter);
// Enables Always-on
- setAmbientEnabled();
+ //getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+ //setAmbientEnabled();
+ try
+ {
+ AmbientModeSupport.AmbientController ambientController = AmbientModeSupport.attach(this);
+ ambientController.setAutoResumeEnabled(true);
+ //boolean isAmbient = ambientController.isAmbient();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
}
/**
controller.exitApplication(this);
}
- /**
- *
- *
- */
+/*
@Override
public void onEnterAmbient(Bundle ambientDetails)
{
Log.v(TAG, "onEnterAmbient()");
}
- /**
- *
- *
- */
@Override
public void onExitAmbient()
{
//updateTimerLabel();
}
- /**
- *
- *
- */
@Override
public void onUpdateAmbient()
{
super.onUpdateAmbient();
Log.v(TAG, "onUpdateAmbient()");
}
+*/
/**
*
return (super.dispatchKeyEvent(event));
}
+ @Override
+ public void onPointerCaptureChanged(boolean hasCapture) {
+ super.onPointerCaptureChanged(hasCapture);
+ }
+
/**
*
*
e.printStackTrace();
}
}
+
+ @Override
+ public AmbientModeSupport.AmbientCallback getAmbientCallback()
+ {
+ return (new AmbientModeSupport.AmbientCallback() {
+ public void onEnterAmbient(Bundle ambientDetails)
+ {
+ Log.v(TAG, "onEnterAmbient()");
+ }
+ public void onExitAmbient(Bundle ambientDetails)
+ {
+ Log.v(TAG, "onExitAmbient()");
+ //updateTimerLabel();
+ }
+ });
+ }
}
void startTimer()
{
- Thread thread = new Thread(new Runnable() {
- @Override
- public void run()
+ Thread thread = new Thread(() -> {
+ if (timerCounter != null)
{
- if (timerCounter != null)
- {
- do {
- try {
- Thread.sleep(duration);
- } catch (Exception e) {
- // timeout! (But, do nothing!)
- }
- if (triggerReceiver != null)
- {
- triggerReceiver.timeout();
- }
- } while ((timerCounter.isStarted())&&(!forceStop));
- }
- forceStop = false;
+ do {
+ try {
+ Thread.sleep(duration);
+ } catch (Exception e) {
+ // timeout! (But, do nothing!)
+ }
+ if (triggerReceiver != null)
+ {
+ triggerReceiver.timeout();
+ }
+ } while ((timerCounter.isStarted())&&(!forceStop));
}
+ forceStop = false;
});
try
{
import android.database.Cursor;
import android.os.Vibrator;
import android.preference.PreferenceManager;
-import android.support.wearable.activity.WearableActivity;
import android.util.Log;
import android.widget.ImageButton;
import android.widget.ListView;
import static android.content.Context.VIBRATOR_SERVICE;
+import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
}
@Override
- public void setup(WearableActivity activity, IClickCallback callback, IDatabaseReloadCallback dbCallback)
+ public void setup(AppCompatActivity activity, IClickCallback callback, IDatabaseReloadCallback dbCallback)
{
this.preferences = PreferenceManager.getDefaultSharedPreferences(activity);
this.dbCallback = dbCallback;
*
*
*/
- private void setupPermissions(WearableActivity activity)
+ private void setupPermissions(AppCompatActivity activity)
{
if ((ContextCompat.checkSelfPermission(activity, Manifest.permission.VIBRATE) != PackageManager.PERMISSION_GRANTED) ||
(ContextCompat.checkSelfPermission(activity, Manifest.permission.WAKE_LOCK) != PackageManager.PERMISSION_GRANTED)) {
*
*
*/
- private void setupHardwares(WearableActivity activity)
+ private void setupHardwares(AppCompatActivity activity)
{
// バイブレータをつかまえる
vibrator = (Vibrator) activity.getSystemService(VIBRATOR_SERVICE);
*
*
*/
- private void setupScreen(WearableActivity activity)
+ private void setupScreen(AppCompatActivity activity)
{
TextView mTextView = activity.findViewById(R.id.text);
if (mTextView != null)
* データベースのセットアップ
*/
@Override
- public void setupDatabase(final WearableActivity activity, final boolean isInitialize)
+ public void setupDatabase(final AppCompatActivity activity, final boolean isInitialize)
{
database = new TimeEntryDatabaseFactory(activity, this).getEntryDatabase();
Thread thread = new Thread(() -> {
/**
* リスナのセットアップ
*/
- private void setupListeners(WearableActivity activity, IClickCallback callback)
+ private void setupListeners(AppCompatActivity activity, IClickCallback callback)
{
try
{
*
*/
@Override
- public void exitApplication(WearableActivity activity)
+ public void exitApplication(AppCompatActivity activity)
{
Log.v(TAG, "exitApplication()");
closeDatabase();
long totalTime = curTimeList.get(lapCount - 1) - curTimeList.get(0);
currTime = curTimeList.get(lapCount - 1) - curTimeList.get(lapCount - 2);
//long currTime = (lapCount > 2) ? curTimeList.get(lapCount - 1) - curTimeList.get(lapCount - 2) : 0;
- if ((lapCount <= refCount)&&(refTimeList != null))
+ if (lapCount <= refCount)
{
diffTime = totalTime - (refTimeList.get(lapCount - 1) - refTimeList.get(0));
lapTime = currTime - (refTimeList.get(lapCount - 1) - refTimeList.get(lapCount - 2));
String textToDraw = "";
if ((lapTime == 0)&&(diffTime == 0)&&(lapCount > 1))
{
- textToDraw = "[" + (lapCount - 1) + "] " + TimeStringConvert.getTimeString(currTime).toString();
+ textToDraw = "[" + (lapCount - 1) + "] " + TimeStringConvert.getTimeString(currTime);
drawTextLeft = true;
}
else
if (diffTime != 0)
{
// 「前回ラップ時間の遅れ・進み / 全体時間の遅れ・進み」
- textToDraw = textToDraw + " / " + TimeStringConvert.getDiffTimeString(diffTime).toString();
+ textToDraw = textToDraw + " / " + TimeStringConvert.getDiffTimeString(diffTime);
}
}
{
private final String lapCount;
private final String mainText;
- private String subText;
+ private final String subText;
public LapTimeItems(long lapCount, long mainText, long subText)
{
this.lapCount = String.format(Locale.US,"%02d", lapCount);
this.mainText = TimeStringConvert.getTimeString(mainText).toString();
-
- this.subText = (subText != 0) ? this.subText = TimeStringConvert.getDiffTimeString(subText).toString() : "";
+ this.subText = (subText != 0) ? TimeStringConvert.getDiffTimeString(subText).toString() : "";
}
String getLapCount()